From c5b8c97b57bb2a6343e7c6e46d789a13f2414fe4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 19 Jul 2022 19:36:55 +1000 Subject: [PATCH] Fixes for invoice status if balance changes to negative --- app/Services/Invoice/InvoiceService.php | 3 +++ app/Utils/Traits/ClientGroupSettingsSaver.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 234392313b31..6da6423975b5 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -310,6 +310,9 @@ class InvoiceService elseif ($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) { $this->invoice->status_id = Invoice::STATUS_PARTIAL; } + elseif ($this->invoice->balance < 0) { + $this->invoice->status_id = Invoice::STATUS_SENT; + } return $this; } diff --git a/app/Utils/Traits/ClientGroupSettingsSaver.php b/app/Utils/Traits/ClientGroupSettingsSaver.php index 985e0b69b30c..7d819d754ef6 100644 --- a/app/Utils/Traits/ClientGroupSettingsSaver.php +++ b/app/Utils/Traits/ClientGroupSettingsSaver.php @@ -89,8 +89,9 @@ trait ClientGroupSettingsSaver if(property_exists($settings, 'translations')) unset($settings->translations); + //18-07-2022 removed || empty($settings->{$key}) from this check to allow "0" values to persist foreach ($settings as $key => $value) { - if (! isset($settings->{$key}) || empty($settings->{$key}) || (! is_object($settings->{$key}) && strlen($settings->{$key}) == 0)) { + if (! isset($settings->{$key}) || (! is_object($settings->{$key}) && strlen($settings->{$key}) == 0)) { unset($settings->{$key}); } }