mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for reminders
This commit is contained in:
parent
63e2280228
commit
fb24255813
@ -168,46 +168,51 @@ class ReminderJob implements ShouldQueue
|
||||
$amount = $fees[0];
|
||||
$percent = $fees[1];
|
||||
|
||||
$temp_invoice_balance = $over_due_invoice->balance;
|
||||
$invoice = false;
|
||||
|
||||
if ($amount <= 0 && $percent <= 0) {
|
||||
return;
|
||||
//2024-06-07 this early return prevented any reminders from sending for users who enabled lock_invoices.
|
||||
if ($amount > 0 || $percent > 0) {
|
||||
// return;
|
||||
|
||||
$fee = $amount;
|
||||
|
||||
if ($over_due_invoice->partial > 0) {
|
||||
$fee += round($over_due_invoice->partial * $percent / 100, 2);
|
||||
} else {
|
||||
$fee += round($over_due_invoice->balance * $percent / 100, 2);
|
||||
}
|
||||
|
||||
/** @var \App\Models\Invoice $invoice */
|
||||
$invoice = InvoiceFactory::create($over_due_invoice->company_id, $over_due_invoice->user_id);
|
||||
$invoice->client_id = $over_due_invoice->client_id;
|
||||
$invoice->date = now()->format('Y-m-d');
|
||||
$invoice->due_date = now()->format('Y-m-d');
|
||||
|
||||
$invoice_item = new InvoiceItem();
|
||||
$invoice_item->type_id = '5';
|
||||
$invoice_item->product_key = trans('texts.fee');
|
||||
$invoice_item->notes = ctrans('texts.late_fee_added_locked_invoice', ['invoice' => $over_due_invoice->number, 'date' => $this->translateDate(now()->startOfDay(), $over_due_invoice->client->date_format(), $over_due_invoice->client->locale())]);
|
||||
$invoice_item->quantity = 1;
|
||||
$invoice_item->cost = $fee;
|
||||
|
||||
$invoice_items = [];
|
||||
$invoice_items[] = $invoice_item;
|
||||
|
||||
$invoice->line_items = $invoice_items;
|
||||
|
||||
/**Refresh Invoice values*/
|
||||
$invoice = $invoice->calc()->getInvoice();
|
||||
$invoice->service()
|
||||
->createInvitations()
|
||||
->applyNumber()
|
||||
->markSent()
|
||||
->save();
|
||||
}
|
||||
|
||||
$fee = $amount;
|
||||
|
||||
if ($over_due_invoice->partial > 0) {
|
||||
$fee += round($over_due_invoice->partial * $percent / 100, 2);
|
||||
} else {
|
||||
$fee += round($over_due_invoice->balance * $percent / 100, 2);
|
||||
if(!$invoice){
|
||||
$invoice = $over_due_invoice;
|
||||
}
|
||||
|
||||
/** @var \App\Models\Invoice $invoice */
|
||||
$invoice = InvoiceFactory::create($over_due_invoice->company_id, $over_due_invoice->user_id);
|
||||
$invoice->client_id = $over_due_invoice->client_id;
|
||||
$invoice->date = now()->format('Y-m-d');
|
||||
$invoice->due_date = now()->format('Y-m-d');
|
||||
|
||||
$invoice_item = new InvoiceItem();
|
||||
$invoice_item->type_id = '5';
|
||||
$invoice_item->product_key = trans('texts.fee');
|
||||
$invoice_item->notes = ctrans('texts.late_fee_added_locked_invoice', ['invoice' => $over_due_invoice->number, 'date' => $this->translateDate(now()->startOfDay(), $over_due_invoice->client->date_format(), $over_due_invoice->client->locale())]);
|
||||
$invoice_item->quantity = 1;
|
||||
$invoice_item->cost = $fee;
|
||||
|
||||
$invoice_items = [];
|
||||
$invoice_items[] = $invoice_item;
|
||||
|
||||
$invoice->line_items = $invoice_items;
|
||||
|
||||
/**Refresh Invoice values*/
|
||||
$invoice = $invoice->calc()->getInvoice();
|
||||
$invoice->service()
|
||||
->createInvitations()
|
||||
->applyNumber()
|
||||
->markSent()
|
||||
->save();
|
||||
|
||||
$enabled_reminder = 'enable_'.$reminder_template;
|
||||
if ($reminder_template == 'endless_reminder') {
|
||||
$enabled_reminder = 'enable_reminder_endless';
|
||||
|
@ -184,7 +184,7 @@ class ReminderTest extends TestCase
|
||||
$settings->schedule_reminder1 = 'after_invoice_date';
|
||||
$settings->schedule_reminder2 = 'after_invoice_date';
|
||||
$settings->schedule_reminder3 = 'after_invoice_date';
|
||||
|
||||
$settings->lock_invoices = true;
|
||||
$settings->num_days_reminder1 = 5;
|
||||
$settings->num_days_reminder2 = 10;
|
||||
$settings->num_days_reminder3 = 15;
|
||||
@ -231,7 +231,6 @@ class ReminderTest extends TestCase
|
||||
}
|
||||
while($x === false);
|
||||
|
||||
|
||||
$this->assertNotNull($invoice->reminder_last_sent);
|
||||
|
||||
//check next send date is on day "10"
|
||||
|
Loading…
x
Reference in New Issue
Block a user