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:
// - on payday: cycle starts today
// - after payday: cycle starts on the last expected payday
const lookbackDaysByFrequency = {
weekly: 14,
biweekly: 28,
monthly: 62,
// - after payday: cycle starts on the immediately prior expected payday
const oneCycleLookbackDaysByFrequency = {
weekly: 7,
biweekly: 14,
monthly: 32,
} as const;
const lookbackAnchor = new Date(
now.getTime() - lookbackDaysByFrequency[user.incomeFrequency] * DAY_MS
const previousPaydayAnchor = new Date(
nextPayday.getTime() - oneCycleLookbackDaysByFrequency[user.incomeFrequency] * DAY_MS
);
const currentCycleStart = calculateNextPayday(
const previousExpectedPayday = calculateNextPayday(
user.firstIncomeDate,
user.incomeFrequency,
lookbackAnchor,
previousPaydayAnchor,
userTimezone
);
const currentCycleStart = isPayday ? nextPayday : previousExpectedPayday;
const isCycleDue = now.getTime() >= currentCycleStart.getTime();
const currentCycleEnd =
currentCycleStart.getTime() === nextPayday.getTime()