1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00
invoiceninja/app/Services/Bank/BankService.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2022-08-08 11:07:35 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2022-08-08 11:07:35 +02:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Bank;
2022-08-12 07:25:18 +02:00
use App\Models\BankTransaction;
2022-09-07 13:27:53 +02:00
use App\Models\Invoice;
2022-08-08 11:07:35 +02:00
2022-11-11 05:28:49 +01:00
class BankService
2022-08-08 11:07:35 +02:00
{
2023-02-16 02:36:09 +01:00
public function __construct(public BankTransaction $bank_transaction)
{
}
2022-08-12 05:41:55 +02:00
2022-11-11 05:28:49 +01:00
public function matchInvoiceNumber()
2022-08-08 11:07:35 +02:00
{
2023-02-16 02:36:09 +01:00
if (strlen($this->bank_transaction->description) > 1) {
2022-11-11 05:28:49 +01: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 05:41:55 +02:00
2022-11-11 05:28:49 +01:00
return $i ?: false;
}
2022-08-08 11:07:35 +02:00
2022-11-11 05:28:49 +01:00
return false;
2022-08-08 11:07:35 +02:00
}
2022-11-20 03:55:19 +01:00
public function processRules()
2022-08-08 11:07:35 +02:00
{
2022-11-20 03:55:19 +01:00
(new ProcessBankRules($this->bank_transaction))->run();
2022-08-12 06:23:23 +02:00
}
2023-02-16 02:36:09 +01:00
}