mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
Fixed a bug where deposits and withdrawals might show the wrong accounts when editing.
This commit is contained in:
@@ -196,18 +196,38 @@ class TransactionController extends BaseController
|
||||
*/
|
||||
switch ($what) {
|
||||
case 'withdrawal':
|
||||
if (floatval($journal->transactions[0]->amount) < 0) {
|
||||
// transactions[0] is the asset account that paid for the withdrawal.
|
||||
$prefilled['account_id'] = $journal->transactions[0]->account->id;
|
||||
$prefilled['expense_account'] = $journal->transactions[1]->account->name;
|
||||
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
||||
} else {
|
||||
// transactions[1] is the asset account that paid for the withdrawal.
|
||||
$prefilled['account_id'] = $journal->transactions[1]->account->id;
|
||||
$prefilled['expense_account'] = $journal->transactions[0]->account->name;
|
||||
$prefilled['amount'] = floatval($journal->transactions[0]->amount);
|
||||
}
|
||||
|
||||
|
||||
$budget = $journal->budgets()->first();
|
||||
if (!is_null($budget)) {
|
||||
$prefilled['budget_id'] = $budget->id;
|
||||
}
|
||||
break;
|
||||
case 'deposit':
|
||||
if (floatval($journal->transactions[0]->amount) < 0) {
|
||||
// transactions[0] contains the account the money came from.
|
||||
$prefilled['account_id'] = $journal->transactions[1]->account->id;
|
||||
$prefilled['revenue_account'] = $journal->transactions[0]->account->name;
|
||||
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
||||
} else {
|
||||
// transactions[1] contains the account the money came from.
|
||||
$prefilled['account_id'] = $journal->transactions[0]->account->id;
|
||||
$prefilled['revenue_account'] = $journal->transactions[1]->account->name;
|
||||
$prefilled['amount'] = floatval($journal->transactions[0]->amount);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case 'transfer':
|
||||
if (floatval($journal->transactions[0]->amount) < 0) {
|
||||
@@ -295,7 +315,6 @@ class TransactionController extends BaseController
|
||||
);
|
||||
|
||||
|
||||
|
||||
return View::make('transactions.show')->with('journal', $journal)->with(
|
||||
'subTitle', $journal->transactionType->type . ' "' . $journal->description . '"'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user