Enable currencies if not enabled yet. #1952

This commit is contained in:
James Cole 2019-01-01 17:17:38 +01:00
parent d86383eba8
commit 99b0b24a89
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 12 additions and 0 deletions

View File

@ -114,6 +114,13 @@ class TransactionFactory
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
$currency = $currency ?? $defaultCurrency;
// enable currency:
if(false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}
// type of source account and destination account depends on journal type:
$sourceType = $this->accountType($journal, 'source');
$destinationType = $this->accountType($journal, 'destination');

View File

@ -217,6 +217,11 @@ trait TransactionServiceTrait
return;
}
// enable currency if not enabled:
if(false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}
$transaction->foreign_currency_id = $currency->id;
$transaction->save();