From d3a7596be2d7c06694e8a6c7ee782ba7a4f1a7f2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 20 Nov 2014 07:12:41 +0100 Subject: [PATCH] A fix for a bug that would prevent both the category and the budget to be updated. --- app/lib/FireflyIII/Database/TransactionJournal.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/lib/FireflyIII/Database/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal.php index ab007317ed..040ee14989 100644 --- a/app/lib/FireflyIII/Database/TransactionJournal.php +++ b/app/lib/FireflyIII/Database/TransactionJournal.php @@ -221,17 +221,15 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData } /* - * Store the budget. + * Update the budget and the category. */ - \Log::info('Before budget id.'); + $components = []; if (isset($data['budget_id']) && intval($data['budget_id']) > 0) { /** @var \FireflyIII\Database\Budget $budgetRepository */ $budgetRepository = \App::make('FireflyIII\Database\Budget'); $budget = $budgetRepository->find(intval($data['budget_id'])); - \Log::info('Isset budget id!'); if ($budget) { - \Log::info('Sync!'); - $model->budgets()->sync([$budget->id]); + $components[] = $budget->id; } } if (strlen($data['category']) > 0) { @@ -239,9 +237,10 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData $categoryRepository = \App::make('FireflyIII\Database\Category'); $category = $categoryRepository->firstOrCreate($data['category']); if ($category) { - $model->categories()->sync([$category->id]); + $components[] = $category->id; } } + $model->components()->sync($components); /* * Now we can update the transactions related to this journal.