mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Scan transaction journals for recurring transactions on store.
This commit is contained in:
parent
0c2f9d22b9
commit
d7a4bf22c6
38
app/lib/FireflyIII/Event/TransactionJournal.php
Normal file
38
app/lib/FireflyIII/Event/TransactionJournal.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 19/11/14
|
||||
* Time: 21:11
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Event;
|
||||
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
class TransactionJournal
|
||||
{
|
||||
|
||||
public function store(\TransactionJournal $journal, $id = 0)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Recurring $repository */
|
||||
$repository = \App::make('FireflyIII\Database\Recurring');
|
||||
$set = $repository->get();
|
||||
|
||||
/** @var \RecurringTransaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$repository->scan($entry, $journal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
// triggers when others are updated.
|
||||
$events->listen('transactionJournal.store', 'FireflyIII\Event\TransactionJournal@store');
|
||||
$events->listen('transactionJournal.update', 'FireflyIII\Event\TransactionJournal@update');
|
||||
}
|
||||
}
|
@ -90,6 +90,7 @@ require $framework . '/Illuminate/Foundation/start.php';
|
||||
//Event::subscribe('Firefly\Trigger\Journals\EloquentJournalTrigger');
|
||||
Event::subscribe('FireflyIII\Event\Piggybank');
|
||||
Event::subscribe('FireflyIII\Event\Budget');
|
||||
Event::subscribe('FireflyIII\Event\TransactionJournal');
|
||||
|
||||
// TODO event that creates a relationship between transaction journals and recurring events when created.
|
||||
// TODO event that updates the relationship between transaction journals and recurring events when edited.
|
||||
|
Loading…
Reference in New Issue
Block a user