Fixes for recurring due dates

This commit is contained in:
David Bomba 2025-02-01 14:38:14 +11:00
parent de65dbd086
commit 50a1a746f3
2 changed files with 6 additions and 7 deletions

View File

@ -380,16 +380,16 @@ class Task extends BaseModel
if ($this->company->invoice_task_datelog) {
$date_time[] = Carbon::createFromTimestamp((int)$log[0])
->setTimeZone($this->company->timezone()->name)
// ->setTimeZone($this->company->timezone()->name)
->format($parent_entity->date_format());
}
if ($this->company->invoice_task_timelog) {
$date_time[] = Carbon::createFromTimestamp((int)$log[0])
->setTimeZone($this->company->timezone()->name)
// ->setTimeZone($this->company->timezone()->name)
->format($time_format) . " - " .
Carbon::createFromTimestamp((int)$log[1])
->setTimeZone($this->company->timezone()->name)
// ->setTimeZone($this->company->timezone()->name)
->format($time_format);
}

View File

@ -114,17 +114,16 @@ class RecurringDatesTest extends TestCase
$recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
$recurring_invoice->remaining_cycles = 5;
$recurring_invoice->due_date_days = '1';
$recurring_invoice->next_send_date = now()->format('Y-m-d');
$recurring_invoice->next_send_date = now()->setTimezone($this->client->timezone()->name)->format('Y-m-d');
$recurring_invoice->save();
$recurring_invoice = $recurring_invoice->calc()->getInvoice();
$recurring_invoice->service()->sendNow();
$r = $recurring_invoice->fresh();
$invoice = $recurring_invoice->invoices()->latest()->first();
$this->assertGreaterThan(0, $recurring_invoice->invoices()->count());
$expected_due_date = now()->startOfDay()->addMonthWithoutOverflow()->startOfMonth()->format('Y-m-d');
$expected_due_date = now()->setTimezone($this->client->timezone()->name)->startOfDay()->addMonthWithoutOverflow()->startOfMonth()->format('Y-m-d');
$this->assertEquals($expected_due_date, $invoice->due_date);
}