1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Bank/BankService.php
2022-08-08 19:07:35 +10:00

62 lines
1.3 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Bank;
use App\Models\Company;
class BankService
{
public Company $company;
private $invoices;
public function __construct(Company $company)
{
$this->company = $company;
$this->invoices = $this->company->invoices()->whereIn('status_id', [1,2,3])
->where('is_deleted', 0)
->get();
}
public function match($transactions): array
{
foreach($transactions as $transaction)
{
$this->matchIncome($transaction);
}
return $transactions;
}
private function matchExpense()
{
}
private function matchIncome($transaction)
{
$description = str_replace(" ", "", $transaction->description);
$invoice = $this->invoices->where('number', $description)->first();
if($invoice)
$transaction['invocie_id'] = $invoice->hashed_id;
return $transaction;
}
}