some more improvements
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
periodEnd,
|
||||
nextPaydayAfter,
|
||||
weekStart,
|
||||
weekdayInTz,
|
||||
bonusWindow,
|
||||
completionInWindow
|
||||
} from '@shared/timezone';
|
||||
@@ -47,7 +48,13 @@ function claimableStamp(cfg: any, payday: number, tz: string) {
|
||||
const now = todayInTz(resolveServerTz(tz));
|
||||
const start = cfg.period === 'monthly' ? `${now.slice(0, 7)}-01` : weekStart(payday, tz);
|
||||
const end = periodEnd(cfg.period, start);
|
||||
return { claimable: 'payday', settleDate: nextPaydayAfter(end, payday, tz) };
|
||||
// Weeks close on payday, so a weekly window's end IS the settle date —
|
||||
// nextPaydayAfter(end) would skip a whole extra week.
|
||||
const settle =
|
||||
weekdayInTz(new Date(end + 'T12:00:00Z'), tz) === payday
|
||||
? end
|
||||
: nextPaydayAfter(end, payday, tz);
|
||||
return { claimable: 'payday', settleDate: settle };
|
||||
}
|
||||
|
||||
function targetChoreFor(cfg: any, memberId: string): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user