added pointer interfaces for jobs

This commit is contained in:
Denis Duliçi
2021-09-06 11:53:57 +03:00
parent abd55133f1
commit c08a8cfc4e
63 changed files with 635 additions and 1524 deletions

View File

@@ -3,35 +3,19 @@
namespace App\Jobs\Banking;
use App\Abstracts\Job;
use App\Interfaces\Job\ShouldDelete;
use App\Models\Banking\Transaction;
class DeleteReconciliation extends Job
class DeleteReconciliation extends Job implements ShouldDelete
{
protected $reconciliation;
/**
* Create a new job instance.
*
* @param $reconciliation
*/
public function __construct($reconciliation)
{
$this->reconciliation = $reconciliation;
}
/**
* Execute the job.
*
* @return boolean|Exception
*/
public function handle()
public function handle(): bool
{
\DB::transaction(function () {
$this->reconciliation->delete();
$this->model->delete();
Transaction::where('account_id', $this->reconciliation->account_id)
Transaction::where('account_id', $this->model->account_id)
->isReconciled()
->whereBetween('paid_at', [$this->reconciliation->started_at, $this->reconciliation->ended_at])->each(function ($transaction) {
->whereBetween('paid_at', [$this->model->started_at, $this->model->ended_at])->each(function ($transaction) {
$transaction->reconciled = 0;
$transaction->save();
});