From 7677cd07a4387f97bab64e76406211eea8ac437f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 19 Jan 2022 10:03:41 +1100 Subject: [PATCH] Fixes for reset counter --- app/Utils/Traits/GeneratesCounter.php | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index ecc16d9f6c8a..2feebd7888c0 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -532,42 +532,46 @@ trait GeneratesCounter switch ($reset_counter_frequency) { case RecurringInvoice::FREQUENCY_DAILY: - now()->addDay(); + $new_reset_date = now()->addDay(); break; case RecurringInvoice::FREQUENCY_WEEKLY: - now()->addWeek(); + $new_reset_date = now()->addWeek(); break; case RecurringInvoice::FREQUENCY_TWO_WEEKS: - now()->addWeeks(2); + $new_reset_date = now()->addWeeks(2); break; case RecurringInvoice::FREQUENCY_FOUR_WEEKS: - now()->addWeeks(4); + $new_reset_date = now()->addWeeks(4); break; case RecurringInvoice::FREQUENCY_MONTHLY: - now()->addMonth(); + $new_reset_date = now()->addMonth(); break; case RecurringInvoice::FREQUENCY_TWO_MONTHS: - now()->addMonths(2); + $new_reset_date = now()->addMonths(2); break; case RecurringInvoice::FREQUENCY_THREE_MONTHS: - now()->addMonths(3); + $new_reset_date = now()->addMonths(3); break; case RecurringInvoice::FREQUENCY_FOUR_MONTHS: - now()->addMonths(4); + $new_reset_date = now()->addMonths(4); break; case RecurringInvoice::FREQUENCY_SIX_MONTHS: - now()->addMonths(6); + $new_reset_date = now()->addMonths(6); break; case RecurringInvoice::FREQUENCY_ANNUALLY: - now()->addYear(); + $new_reset_date = now()->addYear(); break; case RecurringInvoice::FREQUENCY_TWO_YEARS: - now()->addYears(2); + $new_reset_date = now()->addYears(2); + break; + + default: + $new_reset_date = now()->addYear(); break; } $settings = $client->company->settings; - $settings->reset_counter_date = $reset_date->format('Y-m-d'); + $settings->reset_counter_date = $new_reset_date->format('Y-m-d'); $settings->invoice_number_counter = 1; $settings->quote_number_counter = 1; $settings->credit_number_counter = 1;