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:
|
// 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()
|
||||||
|
|||||||
Reference in New Issue
Block a user