Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

fix: update invoice generation hour to 15:00 Warsaw time and adjust related tests

VladSez3c3778230176
diff --git a/src/trigger/__tests__/monthly-recurring-invoice.test.ts b/src/trigger/__tests__/monthly-recurring-invoice.test.ts
index 0f9c99f..ed6a673 100644
--- a/src/trigger/__tests__/monthly-recurring-invoice.test.ts
+++ b/src/trigger/__tests__/monthly-recurring-invoice.test.ts
@@ -40,11 +40,15 @@ vi.mock("@trigger.dev/sdk", () => ({
},
}));
-// 13:00 on the 10th, Warsaw wall time (same instants as warsaw-time.test.ts).
+// Saturday/Sunday on the 10th, Warsaw wall time (weekday checks only; hour matches warsaw-time.test.ts payloads).
const SATURDAY_JAN_10_2026 = new Date("2026-01-10T12:00:00Z");
const SUNDAY_MAY_10_2026 = new Date("2026-05-10T11:00:00Z");
const FRIDAY_JUL_10_2026 = new Date("2026-07-10T11:00:00Z");
+// Resume-at instants: 15:00 Warsaw on the following Monday (matches INVOICE_GENERATION_HOUR).
+const MONDAY_JAN_12_2026_15_WARSAW = new Date("2026-01-12T14:00:00.000Z");
+const MONDAY_MAY_11_2026_15_WARSAW = new Date("2026-05-11T13:00:00.000Z");
+
function createPayload(timestamp: Date): ScheduledTaskPayload {
return {
timestamp,
@@ -126,13 +130,13 @@ describe("monthlyRecurringInvoice", () => {
await runMonthlyRecurringInvoice!(createPayload(SATURDAY_JAN_10_2026));
expect(mockWaitUntil).toHaveBeenCalledWith({
- date: new Date("2026-01-12T12:00:00.000Z"),
+ date: MONDAY_JAN_12_2026_15_WARSAW,
});
expect(mockLoggerLog).toHaveBeenCalledWith(
"The 10th falls on a weekend, waiting until Monday to generate the invoice",
{
scheduledAt: SATURDAY_JAN_10_2026,
- resumeAt: new Date("2026-01-12T12:00:00.000Z"),
+ resumeAt: MONDAY_JAN_12_2026_15_WARSAW,
},
);
expect(fetch).toHaveBeenCalledOnce();
@@ -142,7 +146,7 @@ describe("monthlyRecurringInvoice", () => {
await runMonthlyRecurringInvoice!(createPayload(SUNDAY_MAY_10_2026));
expect(mockWaitUntil).toHaveBeenCalledWith({
- date: new Date("2026-05-11T11:00:00.000Z"),
+ date: MONDAY_MAY_11_2026_15_WARSAW,
});
expect(fetch).toHaveBeenCalledOnce();
});
diff --git a/src/trigger/monthly-recurring-invoice.ts b/src/trigger/monthly-recurring-invoice.ts
index c247ec1..00c1ced 100644
--- a/src/trigger/monthly-recurring-invoice.ts
+++ b/src/trigger/monthly-recurring-invoice.ts
@@ -11,7 +11,7 @@ const APP_URL = process.env.APP_URL ?? `http://localhost:3000`;
const INVOICE_API_URL = `${APP_URL}/api/generate-invoice` as const;
// Hour of the day (Warsaw wall time) at which the invoice is generated.
-const INVOICE_GENERATION_HOUR = 13;
+const INVOICE_GENERATION_HOUR = 15;
/**
* Generates the monthly recurring invoice on the 10th of every month
@@ -30,7 +30,7 @@ export const monthlyRecurringInvoice = schedules.task({
maxAttempts: 1,
},
cron: {
- // 13:00 on the 10th of every month, Warsaw wall time (DST-adjusted automatically)
+ // 15:00 on the 10th of every month, Warsaw wall time (DST-adjusted automatically)
pattern: `0 ${INVOICE_GENERATION_HOUR} 27 * *`, // IMPORTANT: we use the 27th only for TESTING. RETURN BACK TO 10TH AFTER TESTING!!!
timezone: WARSAW_TIME_ZONE,
environments: ["PRODUCTION"],