diff --git a/app/Jobs/Cron/AutoBillCron.php b/app/Jobs/Cron/AutoBillCron.php index fcd6c3c876..99bcdbbf21 100644 --- a/app/Jobs/Cron/AutoBillCron.php +++ b/app/Jobs/Cron/AutoBillCron.php @@ -69,6 +69,7 @@ class AutoBillCron } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { + MultiDB::setDB($db); $auto_bill_partial_invoices = Invoice::whereDate('partial_due_date', '<=', now()) @@ -96,6 +97,12 @@ class AutoBillCron private function runAutoBiller(Invoice $invoice) { info("Firing autobill for {$invoice->company_id} - {$invoice->number}"); - $invoice->service()->autoBill()->save(); + + try{ + $invoice->service()->autoBill()->save(); + } + catch(\Exception $e) { + nlog("Failed to capture payment for {$invoice->company_id} - {$invoice->number} ->" . $e->getMessage()); + } } } diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index d19ebd3847..e13601219a 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -129,7 +129,7 @@ class SendRecurring implements ShouldQueue } }); - if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $this->recurring_invoice->auto_bill_enabled) { + if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) { nlog("attempting to autobill {$invoice->number}"); $invoice->service()->autoBill()->save(); }