From 99b0b24a895fde172b71b54e8f611d53d6c4362d Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 1 Jan 2019 17:17:38 +0100 Subject: [PATCH] Enable currencies if not enabled yet. #1952 --- app/Factory/TransactionFactory.php | 7 +++++++ app/Services/Internal/Support/TransactionServiceTrait.php | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index 1da058eec9..e94a0da9c3 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -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'); diff --git a/app/Services/Internal/Support/TransactionServiceTrait.php b/app/Services/Internal/Support/TransactionServiceTrait.php index 207ef8da81..0f76b5dd1b 100644 --- a/app/Services/Internal/Support/TransactionServiceTrait.php +++ b/app/Services/Internal/Support/TransactionServiceTrait.php @@ -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();