mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
Fix #1893
This commit is contained in:
parent
297e12f6e4
commit
b6c23b8eb3
@ -26,7 +26,9 @@ namespace FireflyIII\Jobs;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Events\RequestedReportOnJournals;
|
use FireflyIII\Events\RequestedReportOnJournals;
|
||||||
|
use FireflyIII\Events\StoredTransactionJournal;
|
||||||
use FireflyIII\Models\Recurrence;
|
use FireflyIII\Models\Recurrence;
|
||||||
|
use FireflyIII\Models\RecurrenceMeta;
|
||||||
use FireflyIII\Models\RecurrenceRepetition;
|
use FireflyIII\Models\RecurrenceRepetition;
|
||||||
use FireflyIII\Models\RecurrenceTransaction;
|
use FireflyIII\Models\RecurrenceTransaction;
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
@ -188,6 +190,24 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Recurrence $recurrence
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getPiggyId(Recurrence $recurrence): int
|
||||||
|
{
|
||||||
|
$meta = $recurrence->recurrenceMeta;
|
||||||
|
/** @var RecurrenceMeta $metaEntry */
|
||||||
|
foreach ($meta as $metaEntry) {
|
||||||
|
if ('piggy_bank_id' === $metaEntry->name) {
|
||||||
|
return (int)$metaEntry->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the users rules.
|
* Get the users rules.
|
||||||
*
|
*
|
||||||
@ -313,6 +333,12 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
$journal = $this->journalRepository->store($array);
|
$journal = $this->journalRepository->store($array);
|
||||||
Log::info(sprintf('Created new journal #%d', $journal->id));
|
Log::info(sprintf('Created new journal #%d', $journal->id));
|
||||||
|
|
||||||
|
// get piggy bank ID from meta data:
|
||||||
|
$piggyBankId = $this->getPiggyId($recurrence);
|
||||||
|
|
||||||
|
// trigger event:
|
||||||
|
event(new StoredTransactionJournal($journal, $piggyBankId));
|
||||||
|
|
||||||
$collection->push($journal);
|
$collection->push($journal);
|
||||||
// update recurring thing:
|
// update recurring thing:
|
||||||
$recurrence->latest_date = $date;
|
$recurrence->latest_date = $date;
|
||||||
|
Loading…
Reference in New Issue
Block a user