2022-08-11 08:26:47 +02:00
|
|
|
<?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\Repositories;
|
|
|
|
|
|
|
|
use App\Models\BankTransaction;
|
|
|
|
use App\Models\Task;
|
|
|
|
use App\Models\TaskStatus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for bank transaction repository.
|
|
|
|
*/
|
|
|
|
class BankTransactionRepository extends BaseRepository
|
|
|
|
{
|
|
|
|
|
2022-09-14 07:35:51 +02:00
|
|
|
public function save($data, BankTransaction $bank_transaction)
|
2022-08-11 08:26:47 +02:00
|
|
|
{
|
|
|
|
|
2022-10-25 04:58:44 +02:00
|
|
|
if(!isset($bank_transaction->bank_integration_id) && array_key_exists('bank_integration_id', $data))
|
2022-10-24 00:14:42 +02:00
|
|
|
$bank_transaction->bank_integration_id = $data['bank_integration_id'];
|
|
|
|
|
2022-09-21 07:30:57 +02:00
|
|
|
$bank_transaction->fill($data);
|
2022-08-11 08:26:47 +02:00
|
|
|
|
2022-09-21 07:30:57 +02:00
|
|
|
$bank_transaction->save();
|
2022-08-11 08:26:47 +02:00
|
|
|
|
2022-11-11 05:28:49 +01:00
|
|
|
if($bank_transaction->base_type == 'CREDIT' && $invoice = $bank_transaction->service()->matchInvoiceNumber())
|
2022-11-10 11:57:55 +01:00
|
|
|
{
|
|
|
|
$bank_transaction->invoice_ids = $invoice->hashed_id;
|
|
|
|
$bank_transaction->status_id = BankTransaction::STATUS_MATCHED;
|
|
|
|
$bank_transaction->save();
|
|
|
|
}
|
|
|
|
|
2022-09-21 07:30:57 +02:00
|
|
|
return $bank_transaction;
|
2022-08-11 08:26:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|