From 06d55098055229157a5d47e73c7fb4bc3f648f98 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 6 Jan 2017 12:36:27 +0200 Subject: [PATCH] Fix for client numbers --- app/Models/Traits/GeneratesNumbers.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Models/Traits/GeneratesNumbers.php b/app/Models/Traits/GeneratesNumbers.php index 418bc70265d5..ec4c832f5c92 100644 --- a/app/Models/Traits/GeneratesNumbers.php +++ b/app/Models/Traits/GeneratesNumbers.php @@ -43,13 +43,18 @@ trait GeneratesNumbers // update the counter to be caught up if ($counterOffset > 1) { - if ($entity->isType(INVOICE_TYPE_QUOTE) && !$this->share_counter) { + if ($entity->isEntityType(ENTITY_CLIENT)) { + if ($this->clientNumbersEnabled()) { + $this->client_number_counter += $counterOffset - 1; + $this->save(); + } + } elseif ($entity->isType(INVOICE_TYPE_QUOTE) && !$this->share_counter) { $this->quote_number_counter += $counterOffset - 1; + $this->save(); } else { - $this->{$entityType.'_number_counter'} += $counterOffset - 1; + $this->invoice_number_counter += $counterOffset - 1; + $this->save(); } - - $this->save(); } if ($entity->recurring_invoice_id) {