From 0885b2a7c1c3e95fbc27e84dae978e0be52a998d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 12 Jan 2023 12:22:32 +1100 Subject: [PATCH 1/3] Minor fixes for create test data --- app/Console/Commands/CreateSingleAccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 2d6c983ae043..fb7e9b575dce 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -306,7 +306,7 @@ class CreateSingleAccount extends Command $webhook_config = [ 'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan', - 'post_purchase_rest_method' => 'POST', + 'post_purchase_rest_method' => 'post', 'post_purchase_headers' => [config('ninja.ninja_hosted_header') => config('ninja.ninja_hosted_secret')], ]; From 5320b953db6e160c595d4a7790f5af37a4bb2451 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 12 Jan 2023 13:40:26 +1100 Subject: [PATCH 2/3] Fix for data leak on products route when using the ?with filter --- app/Filters/QueryFilters.php | 3 ++- app/Services/Subscription/SubscriptionService.php | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index 91752e747360..a735d70ffdca 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -251,6 +251,7 @@ abstract class QueryFilters { return $this->builder ->orWhere($this->with_property, $value) - ->orderByRaw("{$this->with_property} = ? DESC", [$value]); + ->orderByRaw("{$this->with_property} = ? DESC", [$value]) + ->company(); } } diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index f4439c922e59..ba5fe331a5ad 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -239,11 +239,6 @@ class SubscriptionService ->where('status_id', Invoice::STATUS_PAID) ->first(); -if($last_invoice) - nlog($last_invoice->toArray()); -else - nlog("no invoice found"); - $refund = $this->calculateProRataRefundForSubscription($last_invoice); if($use_credit_setting != 'off') @@ -340,7 +335,7 @@ else */ private function calculateProRataRefundForSubscription($invoice) :float { - if(!$invoice || !$invoice->date) + if(!$invoice || !$invoice->date || $invoice->status_id != Invoice::STATUS_PAID) return 0; $start_date = Carbon::parse($invoice->date); @@ -486,7 +481,7 @@ else ->where('client_id', $recurring_invoice->client_id) ->where('is_proforma',0) ->where('is_deleted', 0) - ->where('status_id', Invoice::STATUS_PAID) + ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID]) ->withTrashed() ->orderBy('id', 'desc') ->first(); @@ -626,6 +621,7 @@ else $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id) ->where('client_id', $recurring_invoice->client_id) + ->where('is_proforma',0) ->where('is_deleted', 0) ->withTrashed() ->orderBy('id', 'desc') @@ -673,6 +669,7 @@ else $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id) ->where('client_id', $recurring_invoice->client_id) ->where('is_deleted', 0) + ->where('is_proforma',0) ->withTrashed() ->orderBy('id', 'desc') ->first(); From 320142876e887e3fe87d6966ef7d166fa11a35c1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 12 Jan 2023 13:40:48 +1100 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 f28700914655..d26b31b06358 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.53 \ No newline at end of file +5.5.54 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 90f276a72430..b1eac14e8c27 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.5.53', - 'app_tag' => '5.5.53', + 'app_version' => '5.5.54', + 'app_tag' => '5.5.54', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),