mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Added some correcting methods. [skip ci]
This commit is contained in:
@@ -99,15 +99,22 @@ class TransactionJournal extends Model
|
||||
/** @var Tag $tag */
|
||||
$tag = $this->tags()->where('tagMode', 'advancePayment')->first();
|
||||
if ($tag && $this->transactionType->type == 'Withdrawal') {
|
||||
|
||||
// loop other deposits, remove from our amount.
|
||||
$others = $tag->transactionJournals()->transactionTypes(['Deposit'])->get();
|
||||
foreach ($others as $other) {
|
||||
$amount -= $other->amount;
|
||||
$amount -= $other->actualAmount;
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
// if this journal is part of an advancePayment AND the journal is a deposit,
|
||||
// then the journal amount is correcting a withdrawal, and the amount is zero:
|
||||
if ($tag && $this->transactionType->type == 'Deposit') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user