mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 11:04:34 -04:00
Pass references instead of full models into auto bill jobs
This commit is contained in:
parent
c05a0dd598
commit
08dbbade14
@ -56,10 +56,10 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping();
|
$schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping();
|
||||||
|
|
||||||
/* Checks for large companies and marked them as is_large */
|
/* 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 */
|
/* 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 */
|
/* Runs cleanup code for subscriptions */
|
||||||
$schedule->job(new SubscriptionCron)->daily()->withoutOverlapping();
|
$schedule->job(new SubscriptionCron)->daily()->withoutOverlapping();
|
||||||
|
@ -141,7 +141,7 @@ class SwissQrGenerator
|
|||||||
// Optionally, add some human-readable information about what the bill is for.
|
// Optionally, add some human-readable information about what the bill is for.
|
||||||
$qrBill->setAdditionalInformation(
|
$qrBill->setAdditionalInformation(
|
||||||
QrBill\DataGroup\Element\AdditionalInformation::create(
|
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.
|
// Now get the QR code image and save it as a file.
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, 'en');
|
$output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, $this->client->locale() ?: 'en');
|
||||||
|
|
||||||
$html = $output
|
$html = $output
|
||||||
->setPrintable(false)
|
->setPrintable(false)
|
||||||
|
@ -25,7 +25,7 @@ class AutoBill implements ShouldQueue
|
|||||||
|
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
|
|
||||||
public Invoice $invoice;
|
public int $invoice_id;
|
||||||
|
|
||||||
public string $db;
|
public string $db;
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ class AutoBill implements ShouldQueue
|
|||||||
*
|
*
|
||||||
* @return void
|
* @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;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +54,13 @@ class AutoBill implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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) {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,12 @@ class AutoBillCron
|
|||||||
->whereHas('company', function ($query) {
|
->whereHas('company', function ($query) {
|
||||||
$query->where('is_disabled', 0);
|
$query->where('is_disabled', 0);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC');
|
||||||
->with('company');
|
|
||||||
|
|
||||||
nlog($auto_bill_partial_invoices->count().' partial invoices to auto bill');
|
nlog($auto_bill_partial_invoices->count().' partial invoices to auto bill');
|
||||||
|
|
||||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice) {
|
$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())
|
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
|
||||||
@ -76,13 +75,12 @@ class AutoBillCron
|
|||||||
->whereHas('company', function ($query) {
|
->whereHas('company', function ($query) {
|
||||||
$query->where('is_disabled', 0);
|
$query->where('is_disabled', 0);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC');
|
||||||
->with('company');
|
|
||||||
|
|
||||||
nlog($auto_bill_invoices->count().' full invoices to auto bill');
|
nlog($auto_bill_invoices->count().' full invoices to auto bill');
|
||||||
|
|
||||||
$auto_bill_invoices->cursor()->each(function ($invoice) {
|
$auto_bill_invoices->cursor()->each(function ($invoice) {
|
||||||
AutoBill::dispatch($invoice, false);
|
AutoBill::dispatch($invoice->id, false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//multiDB environment, need to
|
//multiDB environment, need to
|
||||||
@ -98,13 +96,12 @@ class AutoBillCron
|
|||||||
->whereHas('company', function ($query) {
|
->whereHas('company', function ($query) {
|
||||||
$query->where('is_disabled', 0);
|
$query->where('is_disabled', 0);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC');
|
||||||
->with('company');
|
|
||||||
|
|
||||||
nlog($auto_bill_partial_invoices->count()." partial invoices to auto bill db = {$db}");
|
nlog($auto_bill_partial_invoices->count()." partial invoices to auto bill db = {$db}");
|
||||||
|
|
||||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice) use ($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())
|
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
|
||||||
@ -116,14 +113,13 @@ class AutoBillCron
|
|||||||
->whereHas('company', function ($query) {
|
->whereHas('company', function ($query) {
|
||||||
$query->where('is_disabled', 0);
|
$query->where('is_disabled', 0);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC');
|
||||||
->with('company');
|
|
||||||
|
|
||||||
nlog($auto_bill_invoices->count()." full invoices to auto bill db = {$db}");
|
nlog($auto_bill_invoices->count()." full invoices to auto bill db = {$db}");
|
||||||
|
|
||||||
$auto_bill_invoices->cursor()->each(function ($invoice) use ($db) {
|
$auto_bill_invoices->cursor()->each(function ($invoice) use ($db) {
|
||||||
nlog($this->counter);
|
nlog($this->counter);
|
||||||
AutoBill::dispatch($invoice, $db);
|
AutoBill::dispatch($invoice->id, $db);
|
||||||
$this->counter++;
|
$this->counter++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class SendRecurring implements ShouldQueue
|
|||||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||||
if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) {
|
if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) {
|
||||||
try {
|
try {
|
||||||
EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(10,20));
|
EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(1,2));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
nlog($e->getMessage());
|
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) {
|
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
|
||||||
nlog("attempting to autobill {$invoice->number}");
|
nlog("attempting to autobill {$invoice->number}");
|
||||||
// $invoice->service()->autoBill();
|
// $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) {
|
} 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())) {
|
if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) {
|
||||||
nlog("attempting to autobill {$invoice->number}");
|
nlog("attempting to autobill {$invoice->number}");
|
||||||
// $invoice->service()->autoBill();
|
// $invoice->service()->autoBill();
|
||||||
AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40));
|
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1,2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class ReminderJob implements ShouldQueue
|
|||||||
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) {
|
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) {
|
||||||
|
|
||||||
$invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
|
$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}");
|
nlog("Firing reminder email for invoice {$invoice->number} - {$reminder_template}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,6 +33,13 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#qr-bill {
|
||||||
|
width:100% !important;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-collapse: collapse;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
.header-container {
|
.header-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user