From 4555859936f7588f92e19f3857299767e6ec5ba5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 16 Jul 2021 23:10:27 +1000 Subject: [PATCH 1/2] Fixes for shared counterS --- app/Utils/Traits/GeneratesCounter.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 4a2f9ba2cffc..fcd7d10e8aff 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -126,7 +126,7 @@ trait GeneratesCounter break; case Quote::class: - if ($this->hasSharedCounter($client)) + if ($this->hasSharedCounter($client, 'quote')) return 'invoice_number_counter'; return 'quote_number_counter'; @@ -138,7 +138,7 @@ trait GeneratesCounter return 'payment_number_counter'; break; case Credit::class: - if ($this->hasSharedCounter($client)) + if ($this->hasSharedCounter($client, 'credit')) return 'invoice_number_counter'; return 'credit_number_counter'; @@ -318,9 +318,13 @@ trait GeneratesCounter * * @return bool True if has shared counter, False otherwise. */ - public function hasSharedCounter(Client $client) : bool + public function hasSharedCounter(Client $client, string $type) : bool { - return (bool) $client->getSetting('shared_invoice_quote_counter') || (bool) $client->getSetting('shared_invoice_credit_counter'); + if($type == 'quote') + return (bool) $client->getSetting('shared_invoice_quote_counter'); + + if($type == 'credit') + return (bool) $client->getSetting('shared_invoice_credit_counter'); } /** From a4c1829257d154484afd4e70171ace28567673ba Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 16 Jul 2021 23:33:53 +1000 Subject: [PATCH 2/2] Fixes for shared counterS --- app/Utils/Traits/GeneratesCounter.php | 2 +- tests/Unit/GeneratesCounterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index fcd7d10e8aff..97810afd67e3 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -318,7 +318,7 @@ trait GeneratesCounter * * @return bool True if has shared counter, False otherwise. */ - public function hasSharedCounter(Client $client, string $type) : bool + public function hasSharedCounter(Client $client, string $type = 'quote') : bool { if($type == 'quote') return (bool) $client->getSetting('shared_invoice_quote_counter'); diff --git a/tests/Unit/GeneratesCounterTest.php b/tests/Unit/GeneratesCounterTest.php index 6fb5bbe8872c..ead294b9425b 100644 --- a/tests/Unit/GeneratesCounterTest.php +++ b/tests/Unit/GeneratesCounterTest.php @@ -108,7 +108,7 @@ class GeneratesCounterTest extends TestCase public function testHasSharedCounter() { - $this->assertFalse($this->hasSharedCounter($this->client)); + $this->assertFalse($this->hasSharedCounter($this->client,)); } public function testHasTrueSharedCounter()