From de8ee988b77af712e8e638e46e8730a7152d77fc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 14:44:06 +1100 Subject: [PATCH] Improve refunding from subscription upgrades --- app/Services/Subscription/SubscriptionService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 2cf99ad5b410..b4c2c2187eeb 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -228,10 +228,14 @@ class SubscriptionService ->where('is_deleted', 0) ->orderBy('id', 'desc') ->first(); - } - if ($outstanding->count() == 0){ + //need to ensure at this point that a refund is appropriate!! + //28-02-2022 + if($recurring_invoice->invoices()->count() == 0){ + return $target->price; + } + elseif ($outstanding->count() == 0){ //nothing outstanding return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice); }