mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 19:53:44 +00:00
This commit is contained in:
@@ -122,7 +122,7 @@ class EditController extends Controller
|
|||||||
}
|
}
|
||||||
$request->session()->forget('accounts.edit.fromUpdate');
|
$request->session()->forget('accounts.edit.fromUpdate');
|
||||||
|
|
||||||
$openingBalanceAmount = app('steam')->positive((string)$repository->getOpeningBalanceAmount($account));
|
$openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
|
||||||
if ('0' === $openingBalanceAmount) {
|
if ('0' === $openingBalanceAmount) {
|
||||||
$openingBalanceAmount = '';
|
$openingBalanceAmount = '';
|
||||||
}
|
}
|
||||||
|
@@ -530,6 +530,7 @@ trait AccountServiceTrait
|
|||||||
if (null === $obGroup) {
|
if (null === $obGroup) {
|
||||||
return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||||
}
|
}
|
||||||
|
Log::debug('Update OB group');
|
||||||
|
|
||||||
// if exists, update:
|
// if exists, update:
|
||||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||||
@@ -547,6 +548,7 @@ trait AccountServiceTrait
|
|||||||
|
|
||||||
// if amount is negative:
|
// if amount is negative:
|
||||||
if (1 === bccomp('0', $openingBalance)) {
|
if (1 === bccomp('0', $openingBalance)) {
|
||||||
|
Log::debug('Amount is negative.');
|
||||||
// account transaction loses money:
|
// account transaction loses money:
|
||||||
$accountTransaction->amount = app('steam')->negative($openingBalance);
|
$accountTransaction->amount = app('steam')->negative($openingBalance);
|
||||||
$accountTransaction->transaction_currency_id = $currency->id;
|
$accountTransaction->transaction_currency_id = $currency->id;
|
||||||
@@ -556,6 +558,7 @@ trait AccountServiceTrait
|
|||||||
$obTransaction->transaction_currency_id = $currency->id;
|
$obTransaction->transaction_currency_id = $currency->id;
|
||||||
}
|
}
|
||||||
if (-1 === bccomp('0', $openingBalance)) {
|
if (-1 === bccomp('0', $openingBalance)) {
|
||||||
|
Log::debug('Amount is positive.');
|
||||||
// account gains money:
|
// account gains money:
|
||||||
$accountTransaction->amount = app('steam')->positive($openingBalance);
|
$accountTransaction->amount = app('steam')->positive($openingBalance);
|
||||||
$accountTransaction->transaction_currency_id = $currency->id;
|
$accountTransaction->transaction_currency_id = $currency->id;
|
||||||
|
@@ -292,7 +292,6 @@ class AccountUpdateService
|
|||||||
*/
|
*/
|
||||||
private function updateOpeningBalance(Account $account, array $data): void
|
private function updateOpeningBalance(Account $account, array $data): void
|
||||||
{
|
{
|
||||||
|
|
||||||
// has valid initial balance (IB) data?
|
// has valid initial balance (IB) data?
|
||||||
$type = $account->accountType;
|
$type = $account->accountType;
|
||||||
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {
|
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {
|
||||||
|
Reference in New Issue
Block a user