Skip to content

Firefly III: a personal finances manager

A temporary fix for the problem that storing a transaction journal doesn't return the actual journal when successful.

Sander Dorigo1fbdb3d0ae05
diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php
index bd73089784..a2b385c330 100644
--- a/app/controllers/TransactionController.php
+++ b/app/controllers/TransactionController.php
@@ -268,7 +268,10 @@ class TransactionController extends BaseController
/*
* Try to store:
*/
- $messageBag = $this->_helper->store($data);
+ $data['return_journal'] = true;
+ $set = $this->_helper->store($data);
+ $journal = $set['journal'];
+ $messageBag = $set['messagebag'];
/*
* Failure!
@@ -283,6 +286,13 @@ class TransactionController extends BaseController
*/
Session::flash('success', 'Transaction "' . e(Input::get('description')) . '" saved!');
+ /*
+ * Trigger something that will search for possibly matching recurring transactions.
+ * This only works for expenses. However, at this point we have no idea what the latest
+ * transaction is. We'll have to find it, and when the user creates a lot of them it might
+ * get lost somewhere.
+ */
+
/*
* Redirect to original location or back to the form.
*/
diff --git a/app/lib/Firefly/Helper/Controllers/Transaction.php b/app/lib/Firefly/Helper/Controllers/Transaction.php
index 4222342da2..181f0681f3 100644
--- a/app/lib/Firefly/Helper/Controllers/Transaction.php
+++ b/app/lib/Firefly/Helper/Controllers/Transaction.php
@@ -469,7 +469,7 @@ class Transaction implements TransactionInterface
$journal->completed = true;
$journal->save();
if (isset($data['return_journal']) && $data['return_journal'] == true) {
- return $journal;
+ return ['journal' => $journal, 'messagebag' => $journal->errors()];
}
return $journal->errors();
}
diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php
index 57eb80aed7..6814003f1a 100644
--- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php
+++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php
@@ -106,7 +106,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
'what' => 'transfer',
'return_journal' => true
];
- $journal = $transactions->store($set);
+ $returnSet = $transactions->store($set);
+ $journal = $returnSet['journal'];
/*
* Validate the store action:
@@ -333,7 +334,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
/*
* Import it:
*/
- $journal = $transactions->store($set);
+ $returnSet = $transactions->store($set);
+ $journal = $returnSet['journal'];
/*
* Validate the store action: