Make sure edit of liability always works.

This commit is contained in:
James Cole
2023-01-15 07:20:58 +01:00
parent 1f9e0b48c9
commit 7111aec101
5 changed files with 31 additions and 3 deletions

View File

@@ -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);
}