@burdenoff/microfe-timecampus 2026.1107.5 → 2026.1107.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/wspace-operations.d.ts +45 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +715 -680
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/timecampus/analytics/timecampusAnalytics.d.ts +7 -1
- package/dist/timecampus/analytics/timecampusAnalytics.d.ts.map +1 -1
- package/dist/timecampus/analytics/timecampusAnalytics.js +12 -0
- package/dist/timecampus/analytics/timecampusAnalytics.js.map +1 -1
- package/dist/timecampus/analytics/useTimeCampusAnalytics.d.ts.map +1 -1
- package/dist/timecampus/analytics/useTimeCampusAnalytics.js +1 -0
- package/dist/timecampus/analytics/useTimeCampusAnalytics.js.map +1 -1
- package/dist/timecampus/index.js +7 -7
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.d.ts +14 -0
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.d.ts.map +1 -0
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js +238 -0
- package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js.map +1 -0
- package/dist/timecampus/pages/time-approval/TimeApprovalPage.d.ts.map +1 -1
- package/dist/timecampus/pages/time-approval/TimeApprovalPage.js +122 -87
- package/dist/timecampus/pages/time-approval/TimeApprovalPage.js.map +1 -1
- package/dist/timecampus/pages/time-approval/timesheetPeriod.d.ts +80 -0
- package/dist/timecampus/pages/time-approval/timesheetPeriod.d.ts.map +1 -0
- package/dist/timecampus/pages/time-approval/timesheetPeriod.js +103 -0
- package/dist/timecampus/pages/time-approval/timesheetPeriod.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timesheet period rules for "Submit for approval" (BOFF-10584).
|
|
3
|
+
*
|
|
4
|
+
* Pure functions so the period maths, the hour totals and the duplicate guard
|
|
5
|
+
* are unit-tested in one place. The backend collects a request's entries by
|
|
6
|
+
* `createdBy` and `startTime` within `[startDate, endDate]`, so the range built
|
|
7
|
+
* here and the totals summed here must follow the same rule: an entry belongs
|
|
8
|
+
* to the period its start time falls in.
|
|
9
|
+
*/
|
|
10
|
+
/** Which period the submitter picked. */
|
|
11
|
+
export type TimesheetPeriodKind = "this_week" | "last_week" | "custom";
|
|
12
|
+
export interface TimesheetPeriod {
|
|
13
|
+
kind: TimesheetPeriodKind;
|
|
14
|
+
/** Local midnight at the start of the first day. */
|
|
15
|
+
start: Date;
|
|
16
|
+
/** The last millisecond of the last day, local time. */
|
|
17
|
+
end: Date;
|
|
18
|
+
/** Human label stored as the request's `period`, e.g. "Week of Nov 2, 2026". */
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
/** The fields of a time entry the totals need. */
|
|
22
|
+
export interface TimesheetEntryLike {
|
|
23
|
+
duration?: number | null;
|
|
24
|
+
billable: boolean;
|
|
25
|
+
isRunning: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface TimesheetTotals {
|
|
28
|
+
/** Hours from finished entries, rounded to two decimals. */
|
|
29
|
+
totalHours: number;
|
|
30
|
+
/** Billable share of `totalHours`, rounded to two decimals. */
|
|
31
|
+
billableHours: number;
|
|
32
|
+
/** Finished entries counted in the totals. */
|
|
33
|
+
entryCount: number;
|
|
34
|
+
/** Timers still running in the period; they are not counted yet. */
|
|
35
|
+
runningCount: number;
|
|
36
|
+
}
|
|
37
|
+
/** The fields of an existing request the duplicate guard needs. */
|
|
38
|
+
export interface ApprovalRequestLike {
|
|
39
|
+
id: string;
|
|
40
|
+
status: string;
|
|
41
|
+
period: string;
|
|
42
|
+
startDate: string | Date;
|
|
43
|
+
endDate: string | Date;
|
|
44
|
+
}
|
|
45
|
+
/** Longest custom range a single submission may cover, in days. */
|
|
46
|
+
export declare const MAX_CUSTOM_RANGE_DAYS = 31;
|
|
47
|
+
/** Monday of the ISO week that contains `date`, at local midnight. */
|
|
48
|
+
export declare function startOfWeek(date: Date): Date;
|
|
49
|
+
/** "Nov 2 – Nov 8, 2026", or "Dec 28, 2026 – Jan 3, 2027" across a year. */
|
|
50
|
+
export declare function formatRangeLabel(start: Date, end: Date): string;
|
|
51
|
+
/** The Monday-to-Sunday week containing `reference` (this week) or the one before it. */
|
|
52
|
+
export declare function weekPeriod(reference: Date, which?: "this_week" | "last_week"): TimesheetPeriod;
|
|
53
|
+
/** Parse an `<input type="date">` value (`YYYY-MM-DD`) as a local calendar day. */
|
|
54
|
+
export declare function parseDateInput(value: string): Date | null;
|
|
55
|
+
/** Format a date as an `<input type="date">` value in local time. */
|
|
56
|
+
export declare function toDateInputValue(date: Date): string;
|
|
57
|
+
export type CustomPeriodResult = {
|
|
58
|
+
ok: true;
|
|
59
|
+
period: TimesheetPeriod;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
error: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Build a custom range from two date-input values. Both days are inclusive.
|
|
66
|
+
* The range may not end after today, run backwards, or exceed
|
|
67
|
+
* {@link MAX_CUSTOM_RANGE_DAYS} days.
|
|
68
|
+
*/
|
|
69
|
+
export declare function customPeriod(fromValue: string, toValue: string, now?: Date): CustomPeriodResult;
|
|
70
|
+
/**
|
|
71
|
+
* Sum finished entries into hours. Running timers have no final duration, so
|
|
72
|
+
* they are counted separately and left out of the totals.
|
|
73
|
+
*/
|
|
74
|
+
export declare function summarizeEntries(entries: readonly TimesheetEntryLike[]): TimesheetTotals;
|
|
75
|
+
/**
|
|
76
|
+
* The submitter's pending or approved request that overlaps the period, if
|
|
77
|
+
* any. Submitting the same hours twice would double-count them for payroll.
|
|
78
|
+
*/
|
|
79
|
+
export declare function findOverlappingRequest<T extends ApprovalRequestLike>(requests: readonly T[], period: Pick<TimesheetPeriod, "start" | "end">): T | undefined;
|
|
80
|
+
//# sourceMappingURL=timesheetPeriod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timesheetPeriod.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/time-approval/timesheetPeriod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,yCAAyC;AACzC,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,oDAAoD;IACpD,KAAK,EAAE,IAAI,CAAC;IACZ,wDAAwD;IACxD,GAAG,EAAE,IAAI,CAAC;IACV,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AA2BxC,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAI5C;AAUD,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAK/D;AAED,yFAAyF;AACzF,wBAAgB,UAAU,CACxB,SAAS,EAAE,IAAI,EACf,KAAK,GAAE,WAAW,GAAG,WAAyB,GAC7C,eAAe,CASjB;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAgBzD;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKnD;AAED,MAAM,MAAM,kBAAkB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,IAAiB,GACrB,kBAAkB,CA8BpB;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,eAAe,CA0BjB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,mBAAmB,EAClE,QAAQ,EAAE,SAAS,CAAC,EAAE,EACtB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,KAAK,CAAC,GAC7C,CAAC,GAAG,SAAS,CAYf"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var e = /* @__PURE__ */ new Set(["PENDING", "APPROVED"]), t = 864e5;
|
|
2
|
+
function n(e) {
|
|
3
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
4
|
+
}
|
|
5
|
+
function r(e) {
|
|
6
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999);
|
|
7
|
+
}
|
|
8
|
+
function i(e, t) {
|
|
9
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t);
|
|
10
|
+
}
|
|
11
|
+
function a(e) {
|
|
12
|
+
let t = n(e);
|
|
13
|
+
return i(t, -((t.getDay() + 6) % 7));
|
|
14
|
+
}
|
|
15
|
+
function o(e, t) {
|
|
16
|
+
return e.toLocaleDateString("en-US", {
|
|
17
|
+
month: "short",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
...t ? { year: "numeric" } : {}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function s(e, t) {
|
|
23
|
+
return e.getFullYear() === t.getFullYear() ? `${o(e, !1)} – ${o(t, !0)}` : `${o(e, !0)} – ${o(t, !0)}`;
|
|
24
|
+
}
|
|
25
|
+
function c(e, t = "this_week") {
|
|
26
|
+
let n = i(a(e), t === "last_week" ? -7 : 0);
|
|
27
|
+
return {
|
|
28
|
+
kind: t,
|
|
29
|
+
start: n,
|
|
30
|
+
end: r(i(n, 6)),
|
|
31
|
+
label: `Week of ${o(n, !0)}`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function l(e) {
|
|
35
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());
|
|
36
|
+
if (!t) return null;
|
|
37
|
+
let n = Number(t[1]), r = Number(t[2]) - 1, i = Number(t[3]), a = new Date(n, r, i);
|
|
38
|
+
return a.getFullYear() !== n || a.getMonth() !== r || a.getDate() !== i ? null : a;
|
|
39
|
+
}
|
|
40
|
+
function u(e) {
|
|
41
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
42
|
+
}
|
|
43
|
+
function d(e, i, a = /* @__PURE__ */ new Date()) {
|
|
44
|
+
let o = l(e), c = l(i);
|
|
45
|
+
if (!o || !c) return {
|
|
46
|
+
ok: !1,
|
|
47
|
+
error: "Pick a start and an end date."
|
|
48
|
+
};
|
|
49
|
+
if (c.getTime() < o.getTime()) return {
|
|
50
|
+
ok: !1,
|
|
51
|
+
error: "The end date must be on or after the start date."
|
|
52
|
+
};
|
|
53
|
+
if (c.getTime() > n(a).getTime()) return {
|
|
54
|
+
ok: !1,
|
|
55
|
+
error: "The period cannot end in the future."
|
|
56
|
+
};
|
|
57
|
+
if (Math.round((c.getTime() - o.getTime()) / t) + 1 > 31) return {
|
|
58
|
+
ok: !1,
|
|
59
|
+
error: "A timesheet can cover at most 31 days."
|
|
60
|
+
};
|
|
61
|
+
let u = n(o), d = r(c);
|
|
62
|
+
return {
|
|
63
|
+
ok: !0,
|
|
64
|
+
period: {
|
|
65
|
+
kind: "custom",
|
|
66
|
+
start: u,
|
|
67
|
+
end: d,
|
|
68
|
+
label: s(u, d)
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function f(e) {
|
|
73
|
+
return Math.round(e / 3600 * 100) / 100;
|
|
74
|
+
}
|
|
75
|
+
function p(e) {
|
|
76
|
+
let t = 0, n = 0, r = 0, i = 0;
|
|
77
|
+
for (let a of e) {
|
|
78
|
+
if (a.isRunning) {
|
|
79
|
+
i += 1;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
let e = typeof a.duration == "number" && Number.isFinite(a.duration) && a.duration > 0 ? a.duration : 0;
|
|
83
|
+
t += e, a.billable && (n += e), r += 1;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
totalHours: f(t),
|
|
87
|
+
billableHours: f(n),
|
|
88
|
+
entryCount: r,
|
|
89
|
+
runningCount: i
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function m(t, n) {
|
|
93
|
+
let r = n.start.getTime(), i = n.end.getTime();
|
|
94
|
+
return t.find((t) => {
|
|
95
|
+
if (!e.has(t.status)) return !1;
|
|
96
|
+
let n = new Date(t.startDate).getTime(), a = new Date(t.endDate).getTime();
|
|
97
|
+
return !Number.isFinite(n) || !Number.isFinite(a) ? !1 : n <= i && a >= r;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { d as customPeriod, m as findOverlappingRequest, s as formatRangeLabel, l as parseDateInput, a as startOfWeek, p as summarizeEntries, u as toDateInputValue, c as weekPeriod };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=timesheetPeriod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timesheetPeriod.js","names":[],"sources":["../../../../src/timecampus/pages/time-approval/timesheetPeriod.ts"],"sourcesContent":["/**\n * Timesheet period rules for \"Submit for approval\" (BOFF-10584).\n *\n * Pure functions so the period maths, the hour totals and the duplicate guard\n * are unit-tested in one place. The backend collects a request's entries by\n * `createdBy` and `startTime` within `[startDate, endDate]`, so the range built\n * here and the totals summed here must follow the same rule: an entry belongs\n * to the period its start time falls in.\n */\n\n/** Which period the submitter picked. */\nexport type TimesheetPeriodKind = \"this_week\" | \"last_week\" | \"custom\";\n\nexport interface TimesheetPeriod {\n kind: TimesheetPeriodKind;\n /** Local midnight at the start of the first day. */\n start: Date;\n /** The last millisecond of the last day, local time. */\n end: Date;\n /** Human label stored as the request's `period`, e.g. \"Week of Nov 2, 2026\". */\n label: string;\n}\n\n/** The fields of a time entry the totals need. */\nexport interface TimesheetEntryLike {\n duration?: number | null;\n billable: boolean;\n isRunning: boolean;\n}\n\nexport interface TimesheetTotals {\n /** Hours from finished entries, rounded to two decimals. */\n totalHours: number;\n /** Billable share of `totalHours`, rounded to two decimals. */\n billableHours: number;\n /** Finished entries counted in the totals. */\n entryCount: number;\n /** Timers still running in the period; they are not counted yet. */\n runningCount: number;\n}\n\n/** The fields of an existing request the duplicate guard needs. */\nexport interface ApprovalRequestLike {\n id: string;\n status: string;\n period: string;\n startDate: string | Date;\n endDate: string | Date;\n}\n\n/** Longest custom range a single submission may cover, in days. */\nexport const MAX_CUSTOM_RANGE_DAYS = 31;\n\n/** Statuses that still hold a period; rejected or revision-requested ones can be resubmitted. */\nconst ACTIVE_STATUSES = new Set([\"PENDING\", \"APPROVED\"]);\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\nfunction startOfDay(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n}\n\nfunction endOfDay(date: Date): Date {\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n 23,\n 59,\n 59,\n 999,\n );\n}\n\nfunction addDays(date: Date, days: number): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);\n}\n\n/** Monday of the ISO week that contains `date`, at local midnight. */\nexport function startOfWeek(date: Date): Date {\n const day = startOfDay(date);\n const offset = (day.getDay() + 6) % 7; // Monday = 0 … Sunday = 6\n return addDays(day, -offset);\n}\n\nfunction formatDay(date: Date, withYear: boolean): string {\n return date.toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n ...(withYear ? { year: \"numeric\" } : {}),\n });\n}\n\n/** \"Nov 2 – Nov 8, 2026\", or \"Dec 28, 2026 – Jan 3, 2027\" across a year. */\nexport function formatRangeLabel(start: Date, end: Date): string {\n if (start.getFullYear() === end.getFullYear()) {\n return `${formatDay(start, false)} – ${formatDay(end, true)}`;\n }\n return `${formatDay(start, true)} – ${formatDay(end, true)}`;\n}\n\n/** The Monday-to-Sunday week containing `reference` (this week) or the one before it. */\nexport function weekPeriod(\n reference: Date,\n which: \"this_week\" | \"last_week\" = \"this_week\",\n): TimesheetPeriod {\n const start = addDays(startOfWeek(reference), which === \"last_week\" ? -7 : 0);\n const end = endOfDay(addDays(start, 6));\n return {\n kind: which,\n start,\n end,\n label: `Week of ${formatDay(start, true)}`,\n };\n}\n\n/** Parse an `<input type=\"date\">` value (`YYYY-MM-DD`) as a local calendar day. */\nexport function parseDateInput(value: string): Date | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value.trim());\n if (!match) return null;\n const year = Number(match[1]);\n const month = Number(match[2]) - 1;\n const day = Number(match[3]);\n const date = new Date(year, month, day);\n // Reject roll-overs such as 2026-02-31.\n if (\n date.getFullYear() !== year ||\n date.getMonth() !== month ||\n date.getDate() !== day\n ) {\n return null;\n }\n return date;\n}\n\n/** Format a date as an `<input type=\"date\">` value in local time. */\nexport function toDateInputValue(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nexport type CustomPeriodResult =\n { ok: true; period: TimesheetPeriod } | { ok: false; error: string };\n\n/**\n * Build a custom range from two date-input values. Both days are inclusive.\n * The range may not end after today, run backwards, or exceed\n * {@link MAX_CUSTOM_RANGE_DAYS} days.\n */\nexport function customPeriod(\n fromValue: string,\n toValue: string,\n now: Date = new Date(),\n): CustomPeriodResult {\n const from = parseDateInput(fromValue);\n const to = parseDateInput(toValue);\n if (!from || !to) {\n return { ok: false, error: \"Pick a start and an end date.\" };\n }\n if (to.getTime() < from.getTime()) {\n return {\n ok: false,\n error: \"The end date must be on or after the start date.\",\n };\n }\n // Only days that have happened can be signed off; the week presets are the\n // one place a period may include the rest of the current week.\n if (to.getTime() > startOfDay(now).getTime()) {\n return { ok: false, error: \"The period cannot end in the future.\" };\n }\n const days = Math.round((to.getTime() - from.getTime()) / DAY_MS) + 1;\n if (days > MAX_CUSTOM_RANGE_DAYS) {\n return {\n ok: false,\n error: `A timesheet can cover at most ${MAX_CUSTOM_RANGE_DAYS} days.`,\n };\n }\n const start = startOfDay(from);\n const end = endOfDay(to);\n return {\n ok: true,\n period: { kind: \"custom\", start, end, label: formatRangeLabel(start, end) },\n };\n}\n\nfunction roundHours(seconds: number): number {\n return Math.round((seconds / 3600) * 100) / 100;\n}\n\n/**\n * Sum finished entries into hours. Running timers have no final duration, so\n * they are counted separately and left out of the totals.\n */\nexport function summarizeEntries(\n entries: readonly TimesheetEntryLike[],\n): TimesheetTotals {\n let totalSeconds = 0;\n let billableSeconds = 0;\n let entryCount = 0;\n let runningCount = 0;\n for (const entry of entries) {\n if (entry.isRunning) {\n runningCount += 1;\n continue;\n }\n const seconds =\n typeof entry.duration === \"number\" &&\n Number.isFinite(entry.duration) &&\n entry.duration > 0\n ? entry.duration\n : 0;\n totalSeconds += seconds;\n if (entry.billable) billableSeconds += seconds;\n entryCount += 1;\n }\n return {\n totalHours: roundHours(totalSeconds),\n billableHours: roundHours(billableSeconds),\n entryCount,\n runningCount,\n };\n}\n\n/**\n * The submitter's pending or approved request that overlaps the period, if\n * any. Submitting the same hours twice would double-count them for payroll.\n */\nexport function findOverlappingRequest<T extends ApprovalRequestLike>(\n requests: readonly T[],\n period: Pick<TimesheetPeriod, \"start\" | \"end\">,\n): T | undefined {\n const start = period.start.getTime();\n const end = period.end.getTime();\n return requests.find((request) => {\n if (!ACTIVE_STATUSES.has(request.status)) return false;\n const requestStart = new Date(request.startDate).getTime();\n const requestEnd = new Date(request.endDate).getTime();\n if (!Number.isFinite(requestStart) || !Number.isFinite(requestEnd)) {\n return false;\n }\n return requestStart <= end && requestEnd >= start;\n });\n}\n"],"mappings":"AAsDA,IAAM,oBAAkB,IAAI,IAAI,CAAC,WAAW,UAAU,CAAC,GAEjD,IAAS;AAEf,SAAS,EAAW,GAAkB;CACpC,OAAO,IAAI,KAAK,EAAK,YAAY,GAAG,EAAK,SAAS,GAAG,EAAK,QAAQ,CAAC;AACrE;AAEA,SAAS,EAAS,GAAkB;CAClC,OAAO,IAAI,KACT,EAAK,YAAY,GACjB,EAAK,SAAS,GACd,EAAK,QAAQ,GACb,IACA,IACA,IACA,GACF;AACF;AAEA,SAAS,EAAQ,GAAY,GAAoB;CAC/C,OAAO,IAAI,KAAK,EAAK,YAAY,GAAG,EAAK,SAAS,GAAG,EAAK,QAAQ,IAAI,CAAI;AAC5E;AAGA,SAAgB,EAAY,GAAkB;CAC5C,IAAM,IAAM,EAAW,CAAI;CAE3B,OAAO,EAAQ,GAAK,GADJ,EAAI,OAAO,IAAI,KAAK,EACT;AAC7B;AAEA,SAAS,EAAU,GAAY,GAA2B;CACxD,OAAO,EAAK,mBAAmB,SAAS;EACtC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