@fabriktor/fx 0.0.196 → 0.0.197
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.
|
@@ -46,7 +46,7 @@ export function timesheetPunchExpired(start, now) {
|
|
|
46
46
|
export function timesheetPunchWindow(opts) {
|
|
47
47
|
const start = timesheetDateTime(opts.start);
|
|
48
48
|
return {
|
|
49
|
-
minimum: Math.max(start
|
|
49
|
+
minimum: Math.max(start, opts.minimum ? timesheetDateTime(opts.minimum) : start),
|
|
50
50
|
maximum: Math.min(opts.now.getTime(), timesheetPunchDeadline(opts.start)),
|
|
51
51
|
};
|
|
52
52
|
}
|
|
@@ -241,11 +241,8 @@ export class TimesheetsWorkspace {
|
|
|
241
241
|
current.punch.timezone === opts.timezone, TimesheetsBlock.Changed);
|
|
242
242
|
}
|
|
243
243
|
if (opts.date && current.punch && opts.action !== PunchTypeIn) {
|
|
244
|
-
requireState(opts.
|
|
245
|
-
|
|
246
|
-
timesheetDateTime(current.punch.punch_in_time)
|
|
247
|
-
: timesheetDateTime(opts.date) >=
|
|
248
|
-
timesheetDateTime(current.punch.punch_in_time), TimesheetsBlock.InvalidDay);
|
|
244
|
+
requireState(timesheetDateTime(opts.date) >=
|
|
245
|
+
timesheetDateTime(current.punch.punch_in_time), TimesheetsBlock.InvalidDay);
|
|
249
246
|
requireState(timesheetDateTime(opts.date) <=
|
|
250
247
|
timesheetPunchDeadline(current.punch.punch_in_time), TimesheetsBlock.Duration);
|
|
251
248
|
}
|
|
@@ -280,8 +277,10 @@ export class TimesheetsWorkspace {
|
|
|
280
277
|
: !!current.punch &&
|
|
281
278
|
timesheetDateTime(p.punch_in_time) ===
|
|
282
279
|
timesheetDateTime(current.punch.punch_in_time)));
|
|
283
|
-
const last = matches.
|
|
280
|
+
const last = matches.at(-1);
|
|
284
281
|
requireState(!!last &&
|
|
282
|
+
matches.filter((p) => p.punch_status === PunchStatusWorking).length ===
|
|
283
|
+
(opts.action === PunchTypeOut ? 0 : 1) &&
|
|
285
284
|
last.location_id === opts.location_id &&
|
|
286
285
|
!sheet.is_archived &&
|
|
287
286
|
(opts.action === PunchTypeOut
|
|
@@ -296,7 +295,7 @@ export class TimesheetsWorkspace {
|
|
|
296
295
|
async saveDay(opts) {
|
|
297
296
|
await this.validateDay(opts.start, opts.timezone);
|
|
298
297
|
await this.validateDay(opts.end, opts.timezone);
|
|
299
|
-
requireState(timesheetDateTime(opts.end)
|
|
298
|
+
requireState(timesheetDateTime(opts.end) >= timesheetDateTime(opts.start), TimesheetsBlock.InvalidDay);
|
|
300
299
|
requireState(timesheetDateTime(opts.end) <= timesheetPunchDeadline(opts.start), TimesheetsBlock.Duration);
|
|
301
300
|
const matches = opts.replace
|
|
302
301
|
? [await this.week(opts.replace.id)]
|