2016-01-29 07:29:21 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* BillScanner.php
|
2016-04-01 16:44:46 +02:00
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
2016-01-29 07:29:21 +01:00
|
|
|
*
|
2016-10-05 06:52:15 +02:00
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
2016-01-29 07:29:21 +01:00
|
|
|
*/
|
|
|
|
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2016-05-20 12:41:23 +02:00
|
|
|
|
2016-01-29 07:29:21 +01:00
|
|
|
namespace FireflyIII\Support\Events;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2016-05-02 20:49:19 +02:00
|
|
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
2016-01-29 07:29:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BillScanner
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Support\Events
|
|
|
|
*/
|
|
|
|
class BillScanner
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*/
|
2016-02-06 20:19:28 +01:00
|
|
|
public static function scan(TransactionJournal $journal)
|
2016-01-29 07:29:21 +01:00
|
|
|
{
|
2016-05-02 20:49:19 +02:00
|
|
|
/** @var BillRepositoryInterface $repository */
|
|
|
|
$repository = app(BillRepositoryInterface::class);
|
2016-01-29 07:29:21 +01: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 08:42:04 +01:00
|
|
|
}
|