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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user