Data matching

This commit is contained in:
David Bomba 2022-08-09 12:21:06 +10:00
parent 72b86cd25b
commit 957cc727f1
2 changed files with 12 additions and 8 deletions

View File

@ -50,7 +50,11 @@ class BankService
{ {
$description = str_replace(" ", "", $transaction->description); $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) if($invoice)
$transaction['invocie_id'] = $invoice->hashed_id; $transaction['invocie_id'] = $invoice->hashed_id;

View File

@ -33,13 +33,13 @@ class YodleeApiTest extends TestCase
{ {
$transaction = collect([ $transaction = collect([
(object)[ (object)[
'description' => 'tinkertonkton' 'description' => 'tinkertonkton'
], ],
(object)[ (object)[
'description' => 'spud' 'description' => 'spud'
], ],
]); ]);
$this->assertEquals(2, $transaction->count()); $this->assertEquals(2, $transaction->count());