fix: fixed supressed payady overlay in dashboard get response
All checks were successful
Deploy / deploy (push) Successful in 1m29s
Security Tests / security-non-db (push) Successful in 20s
Security Tests / security-db (push) Successful in 26s

This commit is contained in:
2026-03-28 21:45:31 -05:00
parent 339ab559d1
commit 6f27f9117a

View File

@@ -105,21 +105,22 @@ const paydayRoutes: FastifyPluginAsync<PaydayRoutesOptions> = async (app, opts)
// Determine the currently due pay cycle: // Determine the currently due pay cycle:
// - on payday: cycle starts today // - on payday: cycle starts today
// - after payday: cycle starts on the last expected payday // - after payday: cycle starts on the immediately prior expected payday
const lookbackDaysByFrequency = { const oneCycleLookbackDaysByFrequency = {
weekly: 14, weekly: 7,
biweekly: 28, biweekly: 14,
monthly: 62, monthly: 32,
} as const; } as const;
const lookbackAnchor = new Date( const previousPaydayAnchor = new Date(
now.getTime() - lookbackDaysByFrequency[user.incomeFrequency] * DAY_MS nextPayday.getTime() - oneCycleLookbackDaysByFrequency[user.incomeFrequency] * DAY_MS
); );
const currentCycleStart = calculateNextPayday( const previousExpectedPayday = calculateNextPayday(
user.firstIncomeDate, user.firstIncomeDate,
user.incomeFrequency, user.incomeFrequency,
lookbackAnchor, previousPaydayAnchor,
userTimezone userTimezone
); );
const currentCycleStart = isPayday ? nextPayday : previousExpectedPayday;
const isCycleDue = now.getTime() >= currentCycleStart.getTime(); const isCycleDue = now.getTime() >= currentCycleStart.getTime();
const currentCycleEnd = const currentCycleEnd =
currentCycleStart.getTime() === nextPayday.getTime() currentCycleStart.getTime() === nextPayday.getTime()