From 90bf2e58b2b31fe973ea77913f242627f4497a50 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 18 Aug 2018 14:12:39 +0200 Subject: [PATCH] Fixes #1620 --- app/Factory/BillFactory.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php index a3de276298..c08cea5a8d 100644 --- a/app/Factory/BillFactory.php +++ b/app/Factory/BillFactory.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace FireflyIII\Factory; use FireflyIII\Models\Bill; +use FireflyIII\Models\TransactionCurrency; use FireflyIII\Services\Internal\Support\BillServiceTrait; use FireflyIII\User; use Illuminate\Support\Collection; @@ -46,6 +47,10 @@ class BillFactory */ public function create(array $data): ?Bill { + /** @var TransactionCurrencyFactory $factory */ + $factory = app(TransactionCurrencyFactory::class); + /** @var TransactionCurrency $currency */ + $currency = $factory->find((int)$data['currency_id'], (string)$data['currency_code']); /** @var Bill $bill */ $bill = Bill::create( [ @@ -53,7 +58,7 @@ class BillFactory 'match' => 'MIGRATED_TO_RULES', 'amount_min' => $data['amount_min'], 'user_id' => $this->user->id, - 'transaction_currency_id' => $data['transaction_currency_id'], + 'transaction_currency_id' => $currency->id, 'amount_max' => $data['amount_max'], 'date' => $data['date'], 'repeat_freq' => $data['repeat_freq'],