From bd94f7bb65330b48910933444c4314b9814846f3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 19 Jun 2024 18:18:05 +1000 Subject: [PATCH] Working on credit rules for bank transactions --- app/Services/Bank/ProcessBankRules.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Services/Bank/ProcessBankRules.php b/app/Services/Bank/ProcessBankRules.php index d0f207f9f4c5..4a4becf4d443 100644 --- a/app/Services/Bank/ProcessBankRules.php +++ b/app/Services/Bank/ProcessBankRules.php @@ -50,6 +50,13 @@ class ProcessBankRules extends AbstractService } } + // $payment.amount => "Payment Amount", float + // $payment.transaction_reference => "Payment Transaction Reference", string + // $invoice.amount => "Invoice Amount", float + // $invoice.number => "Invoice Number", string + // $client.id_number => "Client ID Number", string + // $client.email => "Client Email", string + // $invoice.po_number => "Invoice Purchase Order Number", string private function matchCredit() { $this->invoices = Invoice::query()->where('company_id', $this->bank_transaction->company_id) @@ -97,6 +104,20 @@ class ProcessBankRules extends AbstractService } + if ($rule['search_key'] == '$invoice.po_number') { + + $invoicePONumbers = Invoice::query()->where('company_id', $this->bank_transaction->company_id) + ->whereIn('status_id', [1,2,3]) + ->where('is_deleted', 0) + ->where('po_number', $this->bank_transaction->description) + ->get(); + + if($invoicePONumbers->count() > 0) { + $matches++; + } + + } + if ($rule['search_key'] == '$invoice.amount') { $this->invoices = Invoice::query()->where('company_id', $this->bank_transaction->company_id)