James Cole
2025-01-29 08:40:16 +01:00
parent 22081d3f0a
commit 60354c0202
8 changed files with 132 additions and 77 deletions

View File

@@ -308,6 +308,23 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return $sum;
}
/**
* Get current amount saved in piggy bank.
*/
public function getCurrentNativeAmount(PiggyBank $piggyBank, ?Account $account = null): string
{
$sum = '0';
foreach ($piggyBank->accounts as $current) {
if (null !== $account && $account->id !== $current->id) {
continue;
}
$amount = (string) $current->pivot->native_current_amount;
$amount = '' === $amount ? '0' : $amount;
$sum = bcadd($sum, $amount);
}
return $sum;
}
public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition
{
if (false === $overrule) {