phpvms/app/Cron/Monthly/ApplyExpenses.php

43 lines
1.0 KiB
PHP
Raw Normal View History

<?php
2018-04-07 06:14:01 +08:00
namespace App\Cron\Monthly;
use App\Contracts\Listener;
2019-07-16 03:51:35 +08:00
use App\Events\CronMonthly;
use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService;
use Illuminate\Support\Facades\Log;
/**
* Go through and apply any finances that are daily
*/
class ApplyExpenses extends Listener
{
private RecurringFinanceService $financeSvc;
/**
* ApplyExpenses constructor.
2018-08-27 00:40:04 +08:00
*
* @param RecurringFinanceService $financeSvc
*/
public function __construct(RecurringFinanceService $financeSvc)
{
$this->financeSvc = $financeSvc;
}
/**
* Apply all of the expenses for a month
2018-08-27 00:40:04 +08:00
*
* @param CronMonthly $event
2018-08-27 00:40:04 +08:00
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function handle(CronMonthly $event): void
{
Log::info('Monthly: Applying monthly expenses');
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
}
}