From b3f753cbf3c73e7dc230a0d53cd0555b9f0cf323 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 19:57:14 +1100 Subject: [PATCH] Fixes for tests --- app/Services/Invoice/MarkSent.php | 12 ++++++------ tests/Integration/CompanyLedgerTest.php | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 5c7c53200665..292521ea5a7f 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -47,12 +47,6 @@ class MarkSent extends AbstractService ->updateBalance($adjustment, true) ->save(); - /*Adjust client balance*/ - $this->client - ->service() - ->updateBalance($adjustment) - ->save(); - /*Update ledger*/ $this->invoice ->ledger() @@ -68,6 +62,12 @@ class MarkSent extends AbstractService ->setReminder() ->save(); + /*Adjust client balance*/ + $this->client->fresh(); + $this->client->balance += $adjustment; + $this->client->save(); + + $this->invoice->markInvitationsSent(); event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); diff --git a/tests/Integration/CompanyLedgerTest.php b/tests/Integration/CompanyLedgerTest.php index c5ece3e949f6..01d87f9fce9c 100644 --- a/tests/Integration/CompanyLedgerTest.php +++ b/tests/Integration/CompanyLedgerTest.php @@ -182,7 +182,8 @@ class CompanyLedgerTest extends TestCase //client->balance should = 10 $invoice->service()->markSent()->save(); - $this->assertEquals($invoice->client->balance, 10); + $this->client = Client::find($this->client->id); + $this->assertEquals($this->client->balance, 10); $invoice_ledger = $invoice->company_ledger->sortByDesc('id')->first();