1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Clean up subscription service

This commit is contained in:
David Bomba 2022-11-27 08:12:37 +11:00
parent bb4687f18d
commit ecfd306fd7

View File

@ -901,6 +901,8 @@ class SubscriptionService
*/
public function handleCancellation(RecurringInvoice $recurring_invoice)
{
$invoice_start_date = false;
$refund_end_date = false;
//only refund if they are in the refund window.
$outstanding_invoice = Invoice::where('subscription_id', $this->subscription->id)
@ -909,8 +911,11 @@ class SubscriptionService
->orderBy('id', 'desc')
->first();
$invoice_start_date = Carbon::parse($outstanding_invoice->date);
$refund_end_date = $invoice_start_date->addSeconds($this->subscription->refund_period);
if($outstanding_invoice)
{
$invoice_start_date = Carbon::parse($outstanding_invoice->date);
$refund_end_date = $invoice_start_date->addSeconds($this->subscription->refund_period);
}
/* Stop the recurring invoice and archive */
$recurring_invoice->service()->stop()->save();