diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index bf5306005061..bd41bcd8af0e 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -138,7 +138,7 @@ class DeletePayment private function updateCreditables() { if ($this->payment->credits()->exists()) { - $this->payment->credits()->each(function ($paymentable_credit) { + $this->payment->credits()->where('is_deleted',0)->each(function ($paymentable_credit) { $multiplier = 1; if ($paymentable_credit->pivot->amount < 0) { diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 940a3231e270..c9862683f843 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -540,7 +540,12 @@ class SubscriptionService $last_invoice->payments->each(function ($payment){ - $this->credit_payments += $payment->credits->sum('amount'); + $payment->credits()->where('is_deleted', 0)->each(function ($credit){ + + $this->credit_payments += $credit->pivot->sum('amount'); + + }); + }); @@ -556,7 +561,7 @@ class SubscriptionService } - + //if there are existing credit payments, then we refund directly to the credit. if($this->calculateProRataRefundForSubscription($last_invoice) > 0 && $this->credit_payments == 0) $credit = $this->createCredit($last_invoice, $target_subscription, false); diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php index 3c88dbd7bc72..446bb79a74c8 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php @@ -101,7 +101,7 @@
@foreach($subscription->service()->getPlans() as $_subscription) @endforeach