Improve refunding from subscription upgrades

This commit is contained in:
David Bomba 2022-02-28 14:44:06 +11:00
parent 32596b4287
commit de8ee988b7

View File

@ -228,10 +228,14 @@ class SubscriptionService
->where('is_deleted', 0) ->where('is_deleted', 0)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->first(); ->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 //nothing outstanding
return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice); return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice);
} }