mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for using credits in subscriptions
This commit is contained in:
parent
5e68199396
commit
079889a711
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -101,7 +101,7 @@
|
||||
<div class="mt-4">
|
||||
@foreach($subscription->service()->getPlans() as $_subscription)
|
||||
<button class="mt-8 mr-2">
|
||||
<a class="border mt-4 bg-white rounded py-2 px-4 hover:bg-gray-100 text-sm" target="_blank" href="{{ route('client.subscription.purchase', $_subscription->hashed_id) }}">{{ $_subscription->name }}</a>
|
||||
<a class="border mt-4 bg-white rounded py-2 px-4 hover:bg-gray-100 text-sm" href="{{ route('client.subscription.purchase', $_subscription->hashed_id) }}">{{ $_subscription->name }}</a>
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user