mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Working on actions when a subscription invoice is paid
This commit is contained in:
parent
539c8646e9
commit
ecf7f66cfe
@ -51,6 +51,11 @@ class InvoicePaidActivity implements ShouldQueue
|
||||
|
||||
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);
|
||||
|
||||
if($event->invoice->subscription()->exists())
|
||||
{
|
||||
$event->invoice->subscription->service()->planPaid($event->invoice);
|
||||
}
|
||||
|
||||
try {
|
||||
$event->invoice->service()->touchPdf();
|
||||
} catch (\Exception $e) {
|
||||
|
@ -165,7 +165,7 @@ class Invoice extends BaseModel
|
||||
|
||||
public function recurring_invoice()
|
||||
{
|
||||
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
||||
return $this->belongsTo(RecurringInvoice::class, 'recurring_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function assigned_user()
|
||||
|
@ -906,4 +906,17 @@ nlog("handle plan change");
|
||||
|
||||
return redirect($default_redirect);
|
||||
}
|
||||
|
||||
public function planPaid($invoice)
|
||||
{
|
||||
$context = [
|
||||
'context' => 'plan_paid',
|
||||
'subscription' => $this->subscription->hashed_id,
|
||||
'recurring_invoice' => $invoice->recurring_invoice->hashed_id,
|
||||
'client' => $invoice->client->hashed_id,
|
||||
'contact' => $invoice->client->primary_contact()->first()->hashed_id,
|
||||
];
|
||||
|
||||
$this->triggerWebhook($context);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user