mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Added the ability to manually add or remove money from piggy banks (issue #6) [skip ci]
This commit is contained in:
@@ -52,12 +52,15 @@ class EloquentPiggybankTrigger
|
||||
$reps = $piggy->piggybankrepetitions()->get();
|
||||
/** @var \PiggybankRepetition $rep */
|
||||
foreach ($reps as $rep) {
|
||||
$sum = \Transaction::where('piggybank_id', $piggy->id)->leftJoin(
|
||||
if ($rep->currentamount == 0) {
|
||||
$sum = \Transaction::where('piggybank_id', $piggy->id)->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '>=', $rep->startdate->format('Y-m-d'))->where(
|
||||
'transaction_journals.date', '<=', $rep->targetdate->format('Y-m-d')
|
||||
)->sum('transactions.amount');
|
||||
$rep->currentamount = floatval($sum);
|
||||
'transaction_journals.date', '<=', $rep->targetdate->format('Y-m-d')
|
||||
)->sum('transactions.amount');
|
||||
|
||||
$rep->currentamount = floatval($sum);
|
||||
}
|
||||
$rep->save();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user