2016-01-29 00:29:21 -06:00
|
|
|
<?php
|
2016-02-05 05:08:25 -06:00
|
|
|
declare(strict_types = 1);
|
2016-01-29 00:29:21 -06:00
|
|
|
/**
|
|
|
|
* BillScanner.php
|
2016-04-01 09:44:46 -05:00
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
2016-01-29 00:29:21 -06:00
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace FireflyIII\Support\Events;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2016-05-02 13:49:19 -05:00
|
|
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
2016-01-29 00:29:21 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BillScanner
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Support\Events
|
|
|
|
*/
|
|
|
|
class BillScanner
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*/
|
2016-02-06 13:19:28 -06:00
|
|
|
public static function scan(TransactionJournal $journal)
|
2016-01-29 00:29:21 -06:00
|
|
|
{
|
2016-05-02 13:49:19 -05:00
|
|
|
/** @var BillRepositoryInterface $repository */
|
|
|
|
$repository = app(BillRepositoryInterface::class);
|
2016-01-29 00:29:21 -06:00
|
|
|
$list = $journal->user->bills()->where('active', 1)->where('automatch', 1)->get();
|
|
|
|
|
|
|
|
/** @var \FireflyIII\Models\Bill $bill */
|
|
|
|
foreach ($list as $bill) {
|
|
|
|
$repository->scan($bill, $journal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-30 01:42:04 -06:00
|
|
|
}
|