From 71b243bace9a4fefdcc6f1bbbc3322a55ac77569 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 21 Aug 2021 14:01:32 +1000 Subject: [PATCH] Fixes for client balances --- app/Jobs/Util/ReminderJob.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index e4240b49ac..b468fb097c 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -184,8 +184,12 @@ class ReminderJob implements ShouldQueue $invoice->fresh(); $invoice->service()->deletePdf(); + /* Refresh the client here to ensure the balance is fresh */ + $client = $invoice->client; + $client = $client->fresh(); + nlog("adjusting client balance and invoice balance by ". ($invoice->balance - $temp_invoice_balance)); - $invoice->client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); + $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); return $invoice;