invoiceninja/app/Services/Bank/BankService.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2022-08-08 19:07:35 +10:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-29 09:21:40 +11:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2022-08-08 19:07:35 +10:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Bank;
2022-08-12 15:25:18 +10:00
use App\Models\BankTransaction;
2022-09-07 21:27:53 +10:00
use App\Models\Invoice;
2022-08-08 19:07:35 +10:00
2022-11-11 15:28:49 +11:00
class BankService
2022-08-08 19:07:35 +10:00
{
2023-02-16 12:36:09 +11:00
public function __construct(public BankTransaction $bank_transaction)
{
}
2022-08-12 13:41:55 +10:00
2022-11-11 15:28:49 +11:00
public function matchInvoiceNumber()
2022-08-08 19:07:35 +10:00
{
2023-02-16 12:36:09 +11:00
if (strlen($this->bank_transaction->description) > 1) {
2022-11-11 15:28:49 +11:00
$i = Invoice::where('company_id', $this->bank_transaction->company_id)
->whereIn('status_id', [1,2,3])
->where('is_deleted', 0)
->where('number', 'LIKE', '%'.$this->bank_transaction->description.'%')
->first();
2022-08-12 13:41:55 +10:00
2022-11-11 15:28:49 +11:00
return $i ?: false;
}
2022-08-08 19:07:35 +10:00
2022-11-11 15:28:49 +11:00
return false;
2022-08-08 19:07:35 +10:00
}
2022-11-20 13:55:19 +11:00
public function processRules()
2022-08-08 19:07:35 +10:00
{
2022-11-20 13:55:19 +11:00
(new ProcessBankRules($this->bank_transaction))->run();
2022-08-12 14:23:23 +10:00
}
2023-02-16 12:36:09 +11:00
}