From 957cc727f192055274e3c77ed63132d2dd22b540 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 9 Aug 2022 12:21:06 +1000 Subject: [PATCH] Data matching --- app/Services/Bank/BankService.php | 6 +++++- tests/Feature/Bank/YodleeApiTest.php | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Services/Bank/BankService.php b/app/Services/Bank/BankService.php index f22946b87e8d..9514a0c14c85 100644 --- a/app/Services/Bank/BankService.php +++ b/app/Services/Bank/BankService.php @@ -50,7 +50,11 @@ class BankService { $description = str_replace(" ", "", $transaction->description); - $invoice = $this->invoices->where('number', $description)->first(); + $invoice = $this->invoices->first(function ($value, $key) use ($description){ + + return str_contains($value->number, $description); + + }); if($invoice) $transaction['invocie_id'] = $invoice->hashed_id; diff --git a/tests/Feature/Bank/YodleeApiTest.php b/tests/Feature/Bank/YodleeApiTest.php index 29aff207bc53..91fcc9e3f633 100644 --- a/tests/Feature/Bank/YodleeApiTest.php +++ b/tests/Feature/Bank/YodleeApiTest.php @@ -33,13 +33,13 @@ class YodleeApiTest extends TestCase { $transaction = collect([ - (object)[ - 'description' => 'tinkertonkton' - ], - (object)[ - 'description' => 'spud' - ], - ]); + (object)[ + 'description' => 'tinkertonkton' + ], + (object)[ + 'description' => 'spud' + ], + ]); $this->assertEquals(2, $transaction->count());