2018-03-17 09:12:56 +08:00
|
|
|
<?php
|
|
|
|
|
2018-04-07 06:14:01 +08:00
|
|
|
namespace App\Cron\Monthly;
|
2018-03-17 09:12:56 +08:00
|
|
|
|
|
|
|
use App\Events\CronMonthly;
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Listener;
|
2018-03-17 09:12:56 +08:00
|
|
|
use App\Models\Enums\ExpenseType;
|
|
|
|
use App\Services\Finance\RecurringFinanceService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go through and apply any finances that are daily
|
|
|
|
* @package App\Listeners\Cron\Nightly
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class ApplyExpenses extends Listener
|
2018-03-17 09:12:56 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
private $financeSvc;
|
2018-03-17 09:12:56 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* ApplyExpenses constructor.
|
|
|
|
* @param RecurringFinanceService $financeSvc
|
|
|
|
*/
|
|
|
|
public function __construct(RecurringFinanceService $financeSvc)
|
2018-03-17 09:12:56 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
$this->financeSvc = $financeSvc;
|
2018-03-17 09:12:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply all of the expenses for a month
|
|
|
|
* @param CronMonthly $event
|
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function handle(CronMonthly $event): void
|
2018-03-17 09:12:56 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
|
2018-03-17 09:12:56 +08:00
|
|
|
}
|
|
|
|
}
|