diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 23a824d22505..6510aa0ef8d3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -56,10 +56,10 @@ class Kernel extends ConsoleKernel $schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping(); /* Checks for large companies and marked them as is_large */ - $schedule->job(new CompanySizeCheck)->daily()->withoutOverlapping(); + $schedule->job(new CompanySizeCheck)->dailyAt('23:20')->withoutOverlapping(); /* Pulls in the latest exchange rates */ - $schedule->job(new UpdateExchangeRates)->daily()->withoutOverlapping(); + $schedule->job(new UpdateExchangeRates)->dailyAt('23:30')->withoutOverlapping(); /* Runs cleanup code for subscriptions */ $schedule->job(new SubscriptionCron)->daily()->withoutOverlapping(); diff --git a/app/Helpers/SwissQr/SwissQrGenerator.php b/app/Helpers/SwissQr/SwissQrGenerator.php index b824ed7a5e33..f2d1fc1c8adb 100644 --- a/app/Helpers/SwissQr/SwissQrGenerator.php +++ b/app/Helpers/SwissQr/SwissQrGenerator.php @@ -141,7 +141,7 @@ class SwissQrGenerator // Optionally, add some human-readable information about what the bill is for. $qrBill->setAdditionalInformation( QrBill\DataGroup\Element\AdditionalInformation::create( - $this->invoice->public_notes ?: '' + $this->invoice->public_notes ?: ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice_number]) ) ); @@ -149,7 +149,7 @@ class SwissQrGenerator // Now get the QR code image and save it as a file. try { - $output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, 'en'); + $output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, $this->client->locale() ?: 'en'); $html = $output ->setPrintable(false) diff --git a/app/Jobs/Cron/AutoBill.php b/app/Jobs/Cron/AutoBill.php index 464ab62f3f54..a16cdad0d8ae 100644 --- a/app/Jobs/Cron/AutoBill.php +++ b/app/Jobs/Cron/AutoBill.php @@ -25,7 +25,7 @@ class AutoBill implements ShouldQueue public $tries = 1; - public Invoice $invoice; + public int $invoice_id; public string $db; @@ -34,9 +34,9 @@ class AutoBill implements ShouldQueue * * @return void */ - public function __construct(Invoice $invoice, ?string $db) + public function __construct(int $invoice_id, ?string $db) { - $this->invoice = $invoice; + $this->invoice_id = $invoice_id; $this->db = $db; } @@ -54,11 +54,13 @@ class AutoBill implements ShouldQueue } try { - nlog("autobill {$this->invoice->id}"); + nlog("autobill {$this->invoice_id}"); + + $invoice = Invoice::withTrashed()->find($this->invoice_id); - $this->invoice->service()->autoBill(); + $invoice->service()->autoBill(); } catch (\Exception $e) { - nlog("Failed to capture payment for {$this->invoice->company_id} - {$this->invoice->number} ->".$e->getMessage()); + nlog("Failed to capture payment for {$this->invoice_id} ->".$e->getMessage()); } } } diff --git a/app/Jobs/Cron/AutoBillCron.php b/app/Jobs/Cron/AutoBillCron.php index 16d7ba752777..c291c5bca7ef 100644 --- a/app/Jobs/Cron/AutoBillCron.php +++ b/app/Jobs/Cron/AutoBillCron.php @@ -58,13 +58,12 @@ class AutoBillCron ->whereHas('company', function ($query) { $query->where('is_disabled', 0); }) - ->orderBy('id', 'DESC') - ->with('company'); + ->orderBy('id', 'DESC'); nlog($auto_bill_partial_invoices->count().' partial invoices to auto bill'); $auto_bill_partial_invoices->cursor()->each(function ($invoice) { - AutoBill::dispatch($invoice, false); + AutoBill::dispatch($invoice->id, false); }); $auto_bill_invoices = Invoice::whereDate('due_date', '<=', now()) @@ -76,13 +75,12 @@ class AutoBillCron ->whereHas('company', function ($query) { $query->where('is_disabled', 0); }) - ->orderBy('id', 'DESC') - ->with('company'); + ->orderBy('id', 'DESC'); nlog($auto_bill_invoices->count().' full invoices to auto bill'); $auto_bill_invoices->cursor()->each(function ($invoice) { - AutoBill::dispatch($invoice, false); + AutoBill::dispatch($invoice->id, false); }); } else { //multiDB environment, need to @@ -98,13 +96,12 @@ class AutoBillCron ->whereHas('company', function ($query) { $query->where('is_disabled', 0); }) - ->orderBy('id', 'DESC') - ->with('company'); + ->orderBy('id', 'DESC'); nlog($auto_bill_partial_invoices->count()." partial invoices to auto bill db = {$db}"); $auto_bill_partial_invoices->cursor()->each(function ($invoice) use ($db) { - AutoBill::dispatch($invoice, $db); + AutoBill::dispatch($invoice->id, $db); }); $auto_bill_invoices = Invoice::whereDate('due_date', '<=', now()) @@ -116,14 +113,13 @@ class AutoBillCron ->whereHas('company', function ($query) { $query->where('is_disabled', 0); }) - ->orderBy('id', 'DESC') - ->with('company'); + ->orderBy('id', 'DESC'); nlog($auto_bill_invoices->count()." full invoices to auto bill db = {$db}"); $auto_bill_invoices->cursor()->each(function ($invoice) use ($db) { nlog($this->counter); - AutoBill::dispatch($invoice, $db); + AutoBill::dispatch($invoice->id, $db); $this->counter++; }); } diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 529ed3df5dd5..41f0cfa864d6 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -130,7 +130,7 @@ class SendRecurring implements ShouldQueue $invoice->invitations->each(function ($invitation) use ($invoice) { if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) { try { - EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(10,20)); + EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(1,2)); } catch (\Exception $e) { nlog($e->getMessage()); } @@ -143,13 +143,13 @@ class SendRecurring implements ShouldQueue if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) { nlog("attempting to autobill {$invoice->number}"); // $invoice->service()->autoBill(); - AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40)); + AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1,2)); } elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) { if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) { nlog("attempting to autobill {$invoice->number}"); // $invoice->service()->autoBill(); - AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40)); + AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1,2)); } } } diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 97a038a8ffc5..90995cab13db 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -99,7 +99,7 @@ class ReminderJob implements ShouldQueue (Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) { $invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) { - EmailEntity::dispatch($invitation, $invitation->company, $reminder_template); + EmailEntity::dispatchSync($invitation, $invitation->company, $reminder_template); nlog("Firing reminder email for invoice {$invoice->number} - {$reminder_template}"); }); diff --git a/resources/views/pdf-designs/clean.html b/resources/views/pdf-designs/clean.html index 9230bf86aa44..ea6de792c9b9 100644 --- a/resources/views/pdf-designs/clean.html +++ b/resources/views/pdf-designs/clean.html @@ -33,6 +33,13 @@ margin: 0; padding: 0; } + + #qr-bill { + width:100% !important; + box-sizing: border-box; + border-collapse: collapse; + color: #000; + } .header-container { display: grid;