1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/app/Services/Bank/BankMatchingService.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2022-11-11 05:28:49 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
2022-11-11 05:28:49 +01:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Bank;
use App\Libraries\MultiDB;
use App\Models\BankTransaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
2022-11-20 03:12:33 +01:00
use Illuminate\Queue\Middleware\WithoutOverlapping;
2022-11-11 05:28:49 +01:00
use Illuminate\Queue\SerializesModels;
class BankMatchingService implements ShouldQueue
2022-11-11 05:28:49 +01:00
{
2024-01-14 05:05:00 +01:00
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
2023-02-16 02:36:09 +01:00
public function __construct(public $company_id, public $db)
{
}
2022-11-11 05:28:49 +01:00
2024-01-14 05:05:00 +01:00
public function handle(): void
2022-11-11 05:28:49 +01:00
{
MultiDB::setDb($this->db);
2023-08-06 09:35:19 +02:00
BankTransaction::query()->where('company_id', $this->company_id)
2022-11-20 03:12:33 +01:00
->where('status_id', BankTransaction::STATUS_UNMATCHED)
->cursor()
2023-02-16 02:36:09 +01:00
->each(function ($bt) {
2022-11-20 03:55:19 +01:00
(new BankService($bt))->processRules();
2022-11-20 03:12:33 +01:00
});
2022-11-11 05:28:49 +01:00
}
2023-02-09 02:10:08 +01:00
public function middleware()
2023-02-16 02:36:09 +01:00
{
2023-02-09 02:10:08 +01:00
return [(new WithoutOverlapping($this->company_id))];
}
2022-11-11 05:28:49 +01:00
}