1
0
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:
= 2021-07-14 21:20:41 +10:00
parent 539c8646e9
commit ecf7f66cfe
3 changed files with 19 additions and 1 deletions

View File

@ -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) {

View File

@ -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()

View File

@ -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);
}
}