Wind back Middleware for Bank Service Matching

This commit is contained in:
David Bomba 2022-11-27 19:03:28 +11:00
parent b138630d39
commit 8b3c579f7b

View File

@ -31,32 +31,16 @@ use Illuminate\Support\Facades\Cache;
class BankMatchingService implements ShouldQueue class BankMatchingService implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, GeneratesCounter; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private Company $company;
private $invoices;
public $deleteWhenMissingModels = true;
public function __construct(private int $company_id, private string $db){} public function __construct(private int $company_id, private string $db){}
public function handle() public function handle() :void
{ {
MultiDB::setDb($this->db); MultiDB::setDb($this->db);
$this->company = Company::find($this->company_id); BankTransaction::where('company_id', $this->company_id)
$this->matchTransactions();
}
private function matchTransactions()
{
BankTransaction::where('company_id', $this->company->id)
->where('status_id', BankTransaction::STATUS_UNMATCHED) ->where('status_id', BankTransaction::STATUS_UNMATCHED)
->cursor() ->cursor()
->each(function ($bt){ ->each(function ($bt){
@ -64,11 +48,11 @@ class BankMatchingService implements ShouldQueue
(new BankService($bt))->processRules(); (new BankService($bt))->processRules();
}); });
} }
public function middleware() // public function middleware()
{ // {
return [new WithoutOverlapping($this->company_id)]; // return [new WithoutOverlapping($this->company_id)];
} // }
} }