James Cole committed 2021-11-26 06:16:21 +01:00
1 parent 35bc92bb49
commit b85b32560c
3 files changed
+4 -2

No files matched your search

@@ -122,7 +122,7 @@ class EditController extends Controller
}
$request->session()->forget('accounts.edit.fromUpdate');
$openingBalanceAmount = app('steam')->positive((string)$repository->getOpeningBalanceAmount($account));
$openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
if ('0' === $openingBalanceAmount) {
$openingBalanceAmount = '';
}
@@ -530,6 +530,7 @@ trait AccountServiceTrait
if (null === $obGroup) {
return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);
}
Log::debug('Update OB group');
// if exists, update:
$currency = $this->accountRepository->getAccountCurrency($account);
@@ -547,6 +548,7 @@ trait AccountServiceTrait
// if amount is negative:
if (1 === bccomp('0', $openingBalance)) {
Log::debug('Amount is negative.');
// account transaction loses money:
$accountTransaction->amount = app('steam')->negative($openingBalance);
$accountTransaction->transaction_currency_id = $currency->id;
@@ -556,6 +558,7 @@ trait AccountServiceTrait
$obTransaction->transaction_currency_id = $currency->id;
}
if (-1 === bccomp('0', $openingBalance)) {
Log::debug('Amount is positive.');
// account gains money:
$accountTransaction->amount = app('steam')->positive($openingBalance);
$accountTransaction->transaction_currency_id = $currency->id;
@@ -292,7 +292,6 @@ class AccountUpdateService
*/
private function updateOpeningBalance(Account $account, array $data): void
{
// has valid initial balance (IB) data?
$type = $account->accountType;
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {