fix: fixed supressed payady overlay in dashboard get response
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user