From 5aaa5cfed87c92c35bc8b673e38d3b7d325a5456 Mon Sep 17 00:00:00 2001 From: Christian Hood Date: Thu, 19 Mar 2026 20:39:47 -0400 Subject: [PATCH] Fix timezone hazard in financing start_date guard Replace new Date(date_string) + getFullYear/getMonth with direct string parsing (split('-').map(Number)) so month comparisons are never shifted by UTC offset. Affects both buildVirtualPaychecks and generatePaychecks. Co-Authored-By: Claude Sonnet 4.6 --- server/src/routes/paychecks.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/server/src/routes/paychecks.js b/server/src/routes/paychecks.js index 88711e9..ccd9472 100644 --- a/server/src/routes/paychecks.js +++ b/server/src/routes/paychecks.js @@ -97,9 +97,7 @@ async function buildVirtualPaychecks(year, month) { try { for (const plan of activePlans.rows) { // Skip plans that haven't started yet for this period - const start = new Date(plan.start_date); - const planStartYear = start.getFullYear(); - const planStartMonth = start.getMonth() + 1; + const [planStartYear, planStartMonth] = plan.start_date.split('-').map(Number); if (year * 12 + month < planStartYear * 12 + planStartMonth) continue; const amount = await calcPaymentAmount(client, plan, year, month); @@ -202,9 +200,7 @@ async function generatePaychecks(year, month) { ); for (const plan of activePlans.rows) { // Skip plans that haven't started yet for this period - const start = new Date(plan.start_date); - const planStartYear = start.getFullYear(); - const planStartMonth = start.getMonth() + 1; + const [planStartYear, planStartMonth] = plan.start_date.split('-').map(Number); if (year * 12 + month < planStartYear * 12 + planStartMonth) continue; // Determine which paycheck(s) this plan applies to