Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Improve transaction linking [skip ci]
James Coleb2aa73b31e5f
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 49e8a68e84..d8f501f922 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -28,7 +28,6 @@ use FireflyIII\Factory\BillFactory;use FireflyIII\Models\Bill;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;-use FireflyIII\Models\TransactionType;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\Services\Internal\Destroy\BillDestroyService;use FireflyIII\Services\Internal\Update\BillUpdateService;@@ -427,11 +426,12 @@ class BillRepository implements BillRepositoryInterface*/public function linkCollectionToBill(Bill $bill, Collection $journals): void{- $ids = $journals->pluck('id')->toArray();- DB::table('transaction_journals')- ->where('user_id', $this->user->id)- ->whereIn('id', $ids)- ->update(['bill_id' => $bill->id]);+ /** @var TransactionJournal $journal */+ foreach ($journals as $journal) {+ $journal->bill_id = $bill->id;+ $journal->save();+ Log::debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));+ }}/**