mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-03 20:14:31 +00:00
Make sure edit of liability always works.
This commit is contained in:
@@ -82,7 +82,8 @@ class AccountFormRequest extends FormRequest
|
||||
$data['account_type_name'] = null;
|
||||
$data['account_type_id'] = $this->convertInteger('liability_type_id');
|
||||
if ('' !== $data['opening_balance']) {
|
||||
$data['opening_balance'] = app('steam')->negative($data['opening_balance']);
|
||||
// opening balance is always positive for liabilities
|
||||
$data['opening_balance'] = app('steam')->positive($data['opening_balance']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,11 @@ class AccountUpdateService
|
||||
$openingBalance = $data['opening_balance'];
|
||||
$openingBalanceDate = $data['opening_balance_date'];
|
||||
|
||||
// if liability, make sure the amount is positive for a credit, and negative for a debit.
|
||||
if($this->isLiability($account)) {
|
||||
$openingBalance = 'credit' === $data['liability_direction'] ? app('steam')->positive($openingBalance) : app('steam')->negative($openingBalance);
|
||||
}
|
||||
|
||||
$this->updateOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user