@open-tender/store 0.3.59 → 0.3.61

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.
@@ -24,6 +24,16 @@ export interface PunchProcessed extends Punch {
24
24
  date: Date;
25
25
  }
26
26
  export declare type PunchesProcessed = PunchProcessed[];
27
+ export interface Shift {
28
+ department: string;
29
+ punchIn?: PunchProcessed;
30
+ punchOut?: PunchProcessed;
31
+ breaks: PunchesProcessed;
32
+ breakOut: PunchProcessed | null;
33
+ breakSeconds: number;
34
+ netSeconds: number;
35
+ }
36
+ export declare type Shifts = Shift[];
27
37
  export declare type Role = 'Manager' | 'Cashier' | 'Employee';
28
38
  export interface Employee {
29
39
  employee_id: number;
@@ -54,6 +54,7 @@ export interface StoreMessage {
54
54
  message_url: string | null;
55
55
  is_active: boolean;
56
56
  }
57
+ export declare type StorePunchType = 'PIN' | 'CARD';
57
58
  export interface Store {
58
59
  address: StoreAddress;
59
60
  auth_type: 'PIN' | 'CARD';
@@ -89,7 +90,7 @@ export interface Store {
89
90
  pickup_minutes: number;
90
91
  prep_minutes: number;
91
92
  print_on_completed: boolean;
92
- punch_type: 'PIN' | 'CARD';
93
+ punch_type: StorePunchType;
93
94
  receipt_footer: string;
94
95
  receipt_header: string;
95
96
  receipt_phone: boolean;
@@ -1,4 +1,4 @@
1
- import { Employee, PunchesProcessed, PunchType, Timezone } from '../types';
1
+ import { Employee, PunchesProcessed, PunchType, Shift, Shifts, Timezone } from '../types';
2
2
  export declare const punchTypes: {
3
3
  PUNCH_IN: string;
4
4
  BREAK_IN: string;
@@ -7,13 +7,5 @@ export declare const punchTypes: {
7
7
  };
8
8
  export declare const makePunchMessage: (employee: Employee, punch_type: PunchType) => string;
9
9
  export declare const calcBreakSeconds: (breaks: PunchesProcessed) => number;
10
- export declare const processPunchees: (employee: Employee, tz: Timezone) => {
11
- department: string;
12
- punchIn: import("../types").PunchProcessed | undefined;
13
- punchOut: import("../types").PunchProcessed | undefined;
14
- breaks: import("../types").PunchProcessed[];
15
- breakOut: import("../types").PunchProcessed | null;
16
- totalSeconds: number;
17
- breakSeconds: number;
18
- netSeconds: number;
19
- }[] | null;
10
+ export declare const makeShifts: (employee: Employee, tz: Timezone) => Shifts | null;
11
+ export declare const processShift: (shift: Shift) => string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processPunchees = exports.calcBreakSeconds = exports.makePunchMessage = exports.punchTypes = void 0;
3
+ exports.processShift = exports.makeShifts = exports.calcBreakSeconds = exports.makePunchMessage = exports.punchTypes = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var date_fns_1 = require("date-fns");
6
6
  var datetimes_1 = require("./datetimes");
@@ -40,7 +40,7 @@ var calcBreakSeconds = function (breaks) {
40
40
  }, 0);
41
41
  };
42
42
  exports.calcBreakSeconds = calcBreakSeconds;
43
- var processPunchees = function (employee, tz) {
43
+ var makeShifts = function (employee, tz) {
44
44
  var departments = employee.departments, punches = employee.punches;
45
45
  if (!punches)
46
46
  return null;
@@ -94,4 +94,22 @@ var processPunchees = function (employee, tz) {
94
94
  };
95
95
  });
96
96
  };
97
- exports.processPunchees = processPunchees;
97
+ exports.makeShifts = makeShifts;
98
+ var makeShiftTime = function (seconds) {
99
+ var hours = Math.floor(seconds / 3600);
100
+ var minutes = ((seconds % 3600) / 60).toFixed(0).padStart(2, '0');
101
+ return "".concat(hours, ":").concat(minutes);
102
+ };
103
+ var processShift = function (shift) {
104
+ var department = shift.department, punchIn = shift.punchIn, punchOut = shift.punchOut, breakOut = shift.breakOut, netSeconds = shift.netSeconds, breakSeconds = shift.breakSeconds;
105
+ var inTime = punchIn ? (0, datetimes_1.formatDate)(punchIn.date, 'h:mma', true) : 'n/a';
106
+ var outTime = punchOut
107
+ ? (0, datetimes_1.formatDate)(punchOut.date, 'h:mma', true)
108
+ : breakOut
109
+ ? 'On Break'
110
+ : 'On Clock';
111
+ var onClock = makeShiftTime(netSeconds);
112
+ var onBreak = makeShiftTime(breakSeconds);
113
+ return [department, inTime, outTime, onClock, onBreak];
114
+ };
115
+ exports.processShift = processShift;
@@ -24,6 +24,16 @@ export interface PunchProcessed extends Punch {
24
24
  date: Date;
25
25
  }
26
26
  export declare type PunchesProcessed = PunchProcessed[];
27
+ export interface Shift {
28
+ department: string;
29
+ punchIn?: PunchProcessed;
30
+ punchOut?: PunchProcessed;
31
+ breaks: PunchesProcessed;
32
+ breakOut: PunchProcessed | null;
33
+ breakSeconds: number;
34
+ netSeconds: number;
35
+ }
36
+ export declare type Shifts = Shift[];
27
37
  export declare type Role = 'Manager' | 'Cashier' | 'Employee';
28
38
  export interface Employee {
29
39
  employee_id: number;
@@ -54,6 +54,7 @@ export interface StoreMessage {
54
54
  message_url: string | null;
55
55
  is_active: boolean;
56
56
  }
57
+ export declare type StorePunchType = 'PIN' | 'CARD';
57
58
  export interface Store {
58
59
  address: StoreAddress;
59
60
  auth_type: 'PIN' | 'CARD';
@@ -89,7 +90,7 @@ export interface Store {
89
90
  pickup_minutes: number;
90
91
  prep_minutes: number;
91
92
  print_on_completed: boolean;
92
- punch_type: 'PIN' | 'CARD';
93
+ punch_type: StorePunchType;
93
94
  receipt_footer: string;
94
95
  receipt_header: string;
95
96
  receipt_phone: boolean;
@@ -1,4 +1,4 @@
1
- import { Employee, PunchesProcessed, PunchType, Timezone } from '../types';
1
+ import { Employee, PunchesProcessed, PunchType, Shift, Shifts, Timezone } from '../types';
2
2
  export declare const punchTypes: {
3
3
  PUNCH_IN: string;
4
4
  BREAK_IN: string;
@@ -7,13 +7,5 @@ export declare const punchTypes: {
7
7
  };
8
8
  export declare const makePunchMessage: (employee: Employee, punch_type: PunchType) => string;
9
9
  export declare const calcBreakSeconds: (breaks: PunchesProcessed) => number;
10
- export declare const processPunchees: (employee: Employee, tz: Timezone) => {
11
- department: string;
12
- punchIn: import("../types").PunchProcessed | undefined;
13
- punchOut: import("../types").PunchProcessed | undefined;
14
- breaks: import("../types").PunchProcessed[];
15
- breakOut: import("../types").PunchProcessed | null;
16
- totalSeconds: number;
17
- breakSeconds: number;
18
- netSeconds: number;
19
- }[] | null;
10
+ export declare const makeShifts: (employee: Employee, tz: Timezone) => Shifts | null;
11
+ export declare const processShift: (shift: Shift) => string[];
@@ -1,6 +1,6 @@
1
1
  import { __assign, __spreadArray } from "tslib";
2
2
  import { differenceInSeconds } from 'date-fns';
3
- import { currentLocalDate, isoToDate } from './datetimes';
3
+ import { currentLocalDate, formatDate, isoToDate } from './datetimes';
4
4
  export var punchTypes = {
5
5
  PUNCH_IN: 'PUNCH_IN',
6
6
  BREAK_IN: 'BREAK_IN',
@@ -35,7 +35,7 @@ export var calcBreakSeconds = function (breaks) {
35
35
  : 0;
36
36
  }, 0);
37
37
  };
38
- export var processPunchees = function (employee, tz) {
38
+ export var makeShifts = function (employee, tz) {
39
39
  var departments = employee.departments, punches = employee.punches;
40
40
  if (!punches)
41
41
  return null;
@@ -89,3 +89,20 @@ export var processPunchees = function (employee, tz) {
89
89
  };
90
90
  });
91
91
  };
92
+ var makeShiftTime = function (seconds) {
93
+ var hours = Math.floor(seconds / 3600);
94
+ var minutes = ((seconds % 3600) / 60).toFixed(0).padStart(2, '0');
95
+ return "".concat(hours, ":").concat(minutes);
96
+ };
97
+ export var processShift = function (shift) {
98
+ var department = shift.department, punchIn = shift.punchIn, punchOut = shift.punchOut, breakOut = shift.breakOut, netSeconds = shift.netSeconds, breakSeconds = shift.breakSeconds;
99
+ var inTime = punchIn ? formatDate(punchIn.date, 'h:mma', true) : 'n/a';
100
+ var outTime = punchOut
101
+ ? formatDate(punchOut.date, 'h:mma', true)
102
+ : breakOut
103
+ ? 'On Break'
104
+ : 'On Clock';
105
+ var onClock = makeShiftTime(netSeconds);
106
+ var onBreak = makeShiftTime(breakSeconds);
107
+ return [department, inTime, outTime, onClock, onBreak];
108
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.3.59",
3
+ "version": "0.3.61",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",