mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 00:54:29 -04:00
Handle archived user in cron
This commit is contained in:
parent
fd29b623ca
commit
b118052d7c
@ -111,7 +111,7 @@ class SendRecurringInvoices extends Command
|
||||
|
||||
$account = $recurInvoice->account;
|
||||
$account->loadLocalizationSettings($recurInvoice->client);
|
||||
Auth::loginUsingId($recurInvoice->user_id);
|
||||
Auth::loginUsingId($recurInvoice->activeUser()->id);
|
||||
|
||||
try {
|
||||
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
|
||||
@ -150,7 +150,7 @@ class SendRecurringInvoices extends Command
|
||||
|
||||
if ($invoice->getAutoBillEnabled() && $invoice->client->autoBillLater()) {
|
||||
$this->info('Processing Autobill-delayed Invoice: ' . $invoice->id);
|
||||
Auth::loginUsingId($invoice->user_id);
|
||||
Auth::loginUsingId($invoice->activeUser()->id);
|
||||
$this->paymentService->autoBillInvoice($invoice);
|
||||
Auth::logout();
|
||||
}
|
||||
|
@ -690,6 +690,15 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
}
|
||||
}
|
||||
|
||||
public function activeUser()
|
||||
{
|
||||
if (! $this->user->trashed()) {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
return $this->account->users->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user