@fabriktor/fx 0.0.196 → 0.0.198

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.
@@ -11,7 +11,6 @@ export declare function timesheetPunchWindow(opts: {
11
11
  start: TimesheetDate;
12
12
  now: Date;
13
13
  minimum?: TimesheetDate;
14
- allow_equal?: boolean;
15
14
  }): {
16
15
  minimum: number;
17
16
  maximum: number;
@@ -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 + (opts.allow_equal ? 0 : minuteMS), opts.minimum ? timesheetDateTime(opts.minimum) : 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.action === PunchTypeOut
245
- ? timesheetDateTime(opts.date) >
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.length === 1 ? matches[0] : undefined;
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) > timesheetDateTime(opts.start), TimesheetsBlock.InvalidDay);
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)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.196",
3
+ "version": "0.0.198",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,9 +17,9 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "0.0.119",
20
+ "@fabriktor/client": "0.0.120",
21
21
  "@fabriktor/fx": "0.0.94",
22
- "@fabriktor/schema": "0.0.89",
22
+ "@fabriktor/schema": "0.0.90",
23
23
  "convert": "8.0.2"
24
24
  }
25
25
  }