@fabriktor/fx 0.0.195 → 0.0.196
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.
|
@@ -39,7 +39,7 @@ export class RouteArrivalCue {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
export function routeHasActiveTransport(actor, route, vehicle_id, state, location_id) {
|
|
42
|
-
// A prior-day start
|
|
42
|
+
// A prior-day start still belongs to the same active transport.
|
|
43
43
|
// Keep the cue tied to stored state; the punch workflow validates its finish.
|
|
44
44
|
return (actor.active_mode === UserTypeEmployee &&
|
|
45
45
|
routeCanTrack(actor, route, vehicle_id, actor.owner_id) &&
|
|
@@ -6,6 +6,7 @@ export declare function timesheetDateChoices(value: InDate): SchemaDate[];
|
|
|
6
6
|
export declare function timesheetDate(value: TimesheetDate): SchemaDate;
|
|
7
7
|
export declare function timesheetDateTime(value: TimesheetDate): number;
|
|
8
8
|
export declare function timesheetPunchDeadline(start: TimesheetDate): number;
|
|
9
|
+
export declare function timesheetPunchExpired(start: TimesheetDate, now: Date): boolean;
|
|
9
10
|
export declare function timesheetPunchWindow(opts: {
|
|
10
11
|
start: TimesheetDate;
|
|
11
12
|
now: Date;
|
|
@@ -40,6 +40,9 @@ export function timesheetDateTime(value) {
|
|
|
40
40
|
export function timesheetPunchDeadline(start) {
|
|
41
41
|
return timesheetDateTime(start) + TimesheetMaxPunchHours * hourMS;
|
|
42
42
|
}
|
|
43
|
+
export function timesheetPunchExpired(start, now) {
|
|
44
|
+
return now.getTime() > timesheetPunchDeadline(start);
|
|
45
|
+
}
|
|
43
46
|
export function timesheetPunchWindow(opts) {
|
|
44
47
|
const start = timesheetDateTime(opts.start);
|
|
45
48
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeQueryOptions, queryNestedParam, queryParams, } from "@fabriktor/client";
|
|
2
2
|
import { PunchStatusApproved, PunchStatusPending, PunchStatusWorking, PunchTypeIn, PunchTypeOut, PunchTypeRideIn, PunchTypeRideOut, } from "@fabriktor/schema";
|
|
3
3
|
import { inDateAtTimestamp } from "../core/date.js";
|
|
4
|
-
import { timesheetDate, timesheetDateTime, timesheetPunchDeadline, } from "./time.js";
|
|
4
|
+
import { timesheetDate, timesheetDateTime, timesheetPunchDeadline, timesheetPunchExpired, } from "./time.js";
|
|
5
5
|
import { errRequired } from "../core/err.js";
|
|
6
6
|
import { PreActionBlocked } from "../core/pre-action.js";
|
|
7
7
|
import { queryRecordParams, runOwnerScopeQuery, } from "../core/query.js";
|
|
@@ -222,7 +222,9 @@ export class TimesheetsWorkspace {
|
|
|
222
222
|
: undefined,
|
|
223
223
|
});
|
|
224
224
|
requireState(timesheetStateKey(current) === timesheetStateKey(opts.expected), TimesheetsBlock.Changed);
|
|
225
|
-
requireState(
|
|
225
|
+
requireState(!!opts.date ||
|
|
226
|
+
!current.punch ||
|
|
227
|
+
!timesheetPunchExpired(current.punch.punch_in_time, await this.now()), TimesheetsBlock.FinishRequired);
|
|
226
228
|
requireState(opts.action === PunchTypeOut || (current.open_punches?.length ?? 0) <= 1, TimesheetsBlock.Active);
|
|
227
229
|
requireState(!current.week_sheet || timesheetIsMutable(current.week_sheet), TimesheetsBlock.Locked);
|
|
228
230
|
const controls = this.actions.punchControls(current);
|