20 lines
722 B
JavaScript
20 lines
722 B
JavaScript
// Generated, do not edit. sha256:dee49c9ff6e746770628ebfbeb55d9732c23407998d26306fb4c07dd8cc4e1ec
|
|||
|
|
export const dueKey = d => `${d.scheduleId}|${d.periodEnd}`;
|
||
|
|
|
||
|
|
export function byPeriod(due) {
|
||
|
|
return [...due].sort((a, b) =>
|
||
|
|
a.periodEnd.localeCompare(b.periodEnd)
|
||
|
|
|| a.periodStart.localeCompare(b.periodStart)
|
||
|
|
|| a.scheduleId - b.scheduleId);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function bookableDues(due) {
|
||
|
|
const oudstePerAccount = new Map();
|
||
|
|
for (const d of due) {
|
||
|
|
const huidig = oudstePerAccount.get(d.accountId);
|
||
|
|
if (huidig == null || d.periodEnd < huidig) oudstePerAccount.set(d.accountId, d.periodEnd);
|
||
|
|
}
|
||
|
|
return new Set(due
|
||
|
|
.filter(d => d.periodEnd === oudstePerAccount.get(d.accountId))
|
||
|
|
.map(dueKey));
|
||
|
|
}
|