Tests for bank transaction matching

This commit is contained in:
David Bomba 2022-08-18 09:27:28 +10:00
parent c9f50608f2
commit 45d658cf47
3 changed files with 11 additions and 3 deletions

View File

@ -239,7 +239,7 @@ class Yodlee
} }
private function bankFormRequest(string $uri, string $verb, array $data = [], array $headers) private function bankFormRequest(string $uri, string $verb, array $data, array $headers)
{ {
$response = Http::withHeaders($this->getFormHeaders($headers))->asForm()->{$verb}($this->getEndpoint() . $uri, $this->buildBody()); $response = Http::withHeaders($this->getFormHeaders($headers))->asForm()->{$verb}($this->getEndpoint() . $uri, $this->buildBody());

View File

@ -54,6 +54,7 @@ class BankService implements ShouldQueue
private function match() private function match()
{ {
BankTransaction::where('company_id', $this->company->id) BankTransaction::where('company_id', $this->company->id)
->where('is_matched', false) ->where('is_matched', false)
->where('provisional_match', false) ->where('provisional_match', false)
@ -62,7 +63,7 @@ class BankService implements ShouldQueue
$invoice = $this->invoices->first(function ($value, $key) use ($bt){ $invoice = $this->invoices->first(function ($value, $key) use ($bt){
return str_contains($value->number, $bt->description); return str_contains($bt->description, $value->number);
}); });

View File

@ -74,9 +74,16 @@ class YodleeApiTest extends TestCase
$this->assertGreaterThan(1, BankIntegration::count()); $this->assertGreaterThan(1, BankIntegration::count());
$this->assertGreaterThan(1, BankTransaction::count()); $this->assertGreaterThan(1, BankTransaction::count());
$this->invoice->number = "XXXXXX8501";
$this->invoice->save();
BankService::dispatchSync($this->company->id, $this->company->db); BankService::dispatchSync($this->company->id, $this->company->db);
// $transactions = $yodlee->getTransactions(); $bt = BankTransaction::where('invoice_id', $this->invoice->id)->first();
$this->assertNotNull($bt);
$this->assertEquals(1, $bt->provisional_match);
} }