mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add another case for deposits.
This commit is contained in:
parent
7e6ce7c3e8
commit
3c0b23aaed
@ -313,14 +313,29 @@ class CreditRecalculateService
|
|||||||
return $newLeftOfDebt;
|
return $newLeftOfDebt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in any other case, remove amount from left of debt.
|
// case 4
|
||||||
if (in_array($type, [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER], true)) {
|
// it's a deposit into this liability (from revenue account).
|
||||||
$newLeftOfDebt = bcadd($leftOfDebt, bcmul($usedAmount, '-1'));
|
// if it's a credit ("I am owed") this increases the amount due.
|
||||||
Log::debug(sprintf('[4] transaction is withdrawal/deposit/transfer, remove amount %s from left of debt, = %s.', $usedAmount, $newLeftOfDebt));
|
// because the person is having to pay more money.
|
||||||
|
if (
|
||||||
|
$type === TransactionType::DEPOSIT
|
||||||
|
&& (int)$account->id === (int)$destTransaction->account_id
|
||||||
|
&& 1 === bccomp($usedAmount, '0')
|
||||||
|
&& 'credit' === $direction
|
||||||
|
) {
|
||||||
|
$newLeftOfDebt = bcadd($leftOfDebt, app('steam')->positive($usedAmount));
|
||||||
|
Log::debug(sprintf('[4] Is deposit (%s) into liability, left of debt = %s.', $usedAmount, $newLeftOfDebt));
|
||||||
return $newLeftOfDebt;
|
return $newLeftOfDebt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::warning(sprintf('[5] Catch-all, should not happen. Left of debt = %s', $leftOfDebt));
|
// in any other case, remove amount from left of debt.
|
||||||
|
if (in_array($type, [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER], true)) {
|
||||||
|
$newLeftOfDebt = bcadd($leftOfDebt, bcmul($usedAmount, '-1'));
|
||||||
|
Log::debug(sprintf('[5] Fallback: transaction is withdrawal/deposit/transfer, remove amount %s from left of debt, = %s.', $usedAmount, $newLeftOfDebt));
|
||||||
|
return $newLeftOfDebt;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::warning(sprintf('[6] Catch-all, should not happen. Left of debt = %s', $leftOfDebt));
|
||||||
|
|
||||||
return $leftOfDebt;
|
return $leftOfDebt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user