From 7e5c0374c165773cd19e6804c3b43df2c883d1b2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 17 Sep 2021 19:13:15 +1000 Subject: [PATCH 1/3] Clean up --- .../views/portal/ninja2020/subscriptions/ninja_plan.blade.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/resources/views/portal/ninja2020/subscriptions/ninja_plan.blade.php b/resources/views/portal/ninja2020/subscriptions/ninja_plan.blade.php index dce7dc0c53..2cb559453f 100644 --- a/resources/views/portal/ninja2020/subscriptions/ninja_plan.blade.php +++ b/resources/views/portal/ninja2020/subscriptions/ninja_plan.blade.php @@ -107,8 +107,6 @@ input:checked ~ .dot {
Branded client portal: "https://billing.yourcompany.com"

-
Custom background for invoices & quotes
-
Priority support

+ Much more!
@@ -192,8 +190,6 @@ input:checked ~ .dot {
Branded client portal: "https://billing.yourcompany.com"

-
Custom background for invoices & quotes
-
Priority support

+ Much more!
From 13f4ce365fbd0b24c2444df35f14238dc47ca067 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 17 Sep 2021 19:32:44 +1000 Subject: [PATCH 2/3] update crons --- app/Jobs/Cron/RecurringExpensesCron.php | 13 ++++--- app/Models/RecurringExpense.php | 50 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/app/Jobs/Cron/RecurringExpensesCron.php b/app/Jobs/Cron/RecurringExpensesCron.php index a08f4eeedb..78a59aec6b 100644 --- a/app/Jobs/Cron/RecurringExpensesCron.php +++ b/app/Jobs/Cron/RecurringExpensesCron.php @@ -12,9 +12,9 @@ namespace App\Jobs\Cron; use App\Factory\RecurringExpenseToExpenseFactory; -use App\Jobs\RecurringInvoice\SendRecurring; use App\Libraries\MultiDB; use App\Models\RecurringExpense; +use App\Models\RecurringInvoice; use App\Utils\Traits\GeneratesCounter; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Carbon; @@ -64,11 +64,8 @@ class RecurringExpensesCron $recurring_expenses = RecurringExpense::where('next_send_date', '<=', now()->toDateTimeString()) ->whereNotNull('next_send_date') ->whereNull('deleted_at') + ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('remaining_cycles', '!=', '0') - // ->whereHas('client', function ($query) { - // $query->where('is_deleted',0) - // ->where('deleted_at', NULL); - // }) ->with('company') ->cursor(); @@ -80,6 +77,8 @@ class RecurringExpensesCron if (!$recurring_expense->company->is_disabled) { $this->generateExpense($recurring_expense); } + + }); } @@ -90,6 +89,10 @@ class RecurringExpensesCron $expense->number = $this->getNextExpenseNumber($expense); $expense->save(); + + $recurring_expense->next_send_date = $recurring_expense->nextSendDate(); + $recurring_expense->remaining_cycles = $recurring_expense->remainingCycles(); + $recurring_expense->save(); } } diff --git a/app/Models/RecurringExpense.php b/app/Models/RecurringExpense.php index 35cc6ecd05..8682c0568f 100644 --- a/app/Models/RecurringExpense.php +++ b/app/Models/RecurringExpense.php @@ -11,8 +11,10 @@ namespace App\Models; +use App\Models\RecurringInvoice; use App\Services\Recurring\RecurringService; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Carbon; class RecurringExpense extends BaseModel { @@ -114,4 +116,52 @@ class RecurringExpense extends BaseModel { return new RecurringService($this); } + + public function nextSendDate() :?Carbon + { + if (!$this->next_send_date) { + return null; + } + + switch ($this->frequency_id) { + case RecurringInvoice::FREQUENCY_DAILY: + return Carbon::parse($this->next_send_date)->startOfDay()->addDay(); + case RecurringInvoice::FREQUENCY_WEEKLY: + return Carbon::parse($this->next_send_date)->startOfDay()->addWeek(); + case RecurringInvoice::FREQUENCY_TWO_WEEKS: + return Carbon::parse($this->next_send_date)->startOfDay()->addWeeks(2); + case RecurringInvoice::FREQUENCY_FOUR_WEEKS: + return Carbon::parse($this->next_send_date)->startOfDay()->addWeeks(4); + case RecurringInvoice::FREQUENCY_MONTHLY: + return Carbon::parse($this->next_send_date)->startOfDay()->addMonthNoOverflow(); + case RecurringInvoice::FREQUENCY_TWO_MONTHS: + return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(2); + case RecurringInvoice::FREQUENCY_THREE_MONTHS: + return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(3); + case RecurringInvoice::FREQUENCY_FOUR_MONTHS: + return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(4); + case RecurringInvoice::FREQUENCY_SIX_MONTHS: + return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(6); + case RecurringInvoice::FREQUENCY_ANNUALLY: + return Carbon::parse($this->next_send_date)->startOfDay()->addYear(); + case RecurringInvoice::FREQUENCY_TWO_YEARS: + return Carbon::parse($this->next_send_date)->startOfDay()->addYears(2); + case RecurringInvoice::FREQUENCY_THREE_YEARS: + return Carbon::parse($this->next_send_date)->startOfDay()->addYears(3); + default: + return null; + } + } + + public function remainingCycles() : int + { + if ($this->remaining_cycles == 0) { + return 0; + } elseif ($this->remaining_cycles == -1) { + return -1; + } else { + return $this->remaining_cycles - 1; + } + } + } From 7d31272354b88f830c956a06fad954de744ea1fa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 17 Sep 2021 19:34:00 +1000 Subject: [PATCH 3/3] version bump --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 8b23bc9172..1cb2aaa839 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.13 \ No newline at end of file +5.3.14 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 2918d961f8..960a4f2b50 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.13', - 'app_tag' => '5.3.13', + 'app_version' => '5.3.14', + 'app_tag' => '5.3.14', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),