From 468aec6bc1edcdb0d9dd944c8a88e6c0402d2d11 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Sun, 4 Aug 2024 19:45:08 +0200 Subject: [PATCH] Fix partially paid status appearing after invoice update --- app/Models/Invoice.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 7bcc754f..4764c502 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -407,13 +407,13 @@ class Invoice extends Model implements HasMedia $data['base_due_amount'] = $data['due_amount'] * $data['exchange_rate']; $data['customer_sequence_number'] = $serial->nextCustomerSequenceNumber; + $this->update($data); + $statusData = $this->getInvoiceStatusByAmount($data['due_amount']); if (! empty($statusData)) { - $data = array_merge($data, $statusData); + $this->update($statusData); } - $this->update($data); - $company_currency = CompanySetting::getSetting('currency', $request->header('company')); if ((string) $data['currency_id'] !== $company_currency) { @@ -711,6 +711,10 @@ class Invoice extends Model implements HasMedia return []; } + \Log::error(print_r($amount, true)); + \Log::error(print_r($this->due_amount, true)); + \Log::error($this->total); + if ($amount == 0) { $data = [ 'status' => Invoice::STATUS_COMPLETED,