@managesome/eposmatic-toolkit 0.2.581 → 0.2.583
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/lib/constants/SOCKET.d.ts +0 -2
- package/lib/constants/SOCKET.js +2 -4
- package/lib/constants/WEBVIEW.d.ts +0 -2
- package/lib/constants/WEBVIEW.js +1 -3
- package/lib/constants/types.d.ts +4 -23
- package/lib/helpers/utils/printer-helpers.js +1 -2
- package/lib/helpers/utils/time-helpers.d.ts +18 -0
- package/lib/helpers/utils/time-helpers.js +56 -19
- package/lib/schemas/models/printer_settings.d.ts +3 -6
- package/lib/schemas/models/printer_settings.js +1 -5
- package/lib/schemas/types/printer_settings.d.ts +1 -2
- package/lib/tests/time-helpers.test.d.ts +1 -0
- package/lib/tests/time-helpers.test.js +98 -0
- package/package.json +1 -1
|
@@ -88,8 +88,6 @@ export declare const SOCKET_EMIT_PATCH_PRINTERS = "SOCKET_EMIT_PATCH_PRINTERS";
|
|
|
88
88
|
export declare const SOCKET_EMIT_PRINT_ORDER = "SOCKET_EMIT_PRINT_ORDER";
|
|
89
89
|
export declare const SOCKET_EMIT_PRINT_IMAGE = "SOCKET_EMIT_PRINT_IMAGE";
|
|
90
90
|
export declare const SOCKET_EMIT_OPEN_DRAWER = "SOCKET_EMIT_OPEN_DRAWER";
|
|
91
|
-
export declare const SOCKET_EMIT_CONNECT_DRAWER = "SOCKET_EMIT_CONNECT_DRAWER";
|
|
92
|
-
export declare const SOCKET_EMIT_DISCONNECT_DRAWER = "SOCKET_EMIT_DISCONNECT_DRAWER";
|
|
93
91
|
export declare const SOCKET_EMIT_ATTACH_PRINTERS_TO_ACCOUNT = "SOCKET_EMIT_ATTACH_PRINTERS_TO_ACCOUNT";
|
|
94
92
|
export declare const SOCKET_EMIT_PRINTER_EVENT = "SOCKET_EMIT_PRINTER_EVENT";
|
|
95
93
|
export declare const SOCKET_EMIT_SET_ALL_PRINTER_SETTINGS = "SOCKET_EMIT_SET_ALL_PRINTER_SETTINGS";
|
package/lib/constants/SOCKET.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SOCKET_EMIT_CREATED_TENANT_INSTORE_SHIFT = exports.SOCKET_EMIT_UPDATED_STAFF = exports.SOCKET_EMIT_UPDATED_DINEIN_TABLE = exports.SOCKET_EMIT_UPDATED_DINEIN_LAYOUT = exports.SOCKET_EMIT_UPDATED_TENANT = exports.SOCKET_EMIT_UPDATED_BRAND = exports.SOCKET_EMIT_DELETED_RESERVATION = exports.SOCKET_EMIT_UPDATED_RESERVATION = exports.SOCKET_EMIT_CREATED_RESERVATION = exports.SOCKET_SEND_ORDER_TO_CONNECTED_PEERS = exports.SOCKET_EMIT_SYNC_OFFLINE_ORDERS_SUCCESS = exports.SOCKET_EMIT_CREATED_MULTIPLE_OFFLINE_ORDERS = exports.SOCKET_EMIT_UPDATED_OFFLINE_ORDER = exports.SOCKET_EMIT_CREATED_OFFLINE_ORDER = exports.SOCKET_EMIT_DELETED_TRANSFERRED_ORDER = exports.SOCKET_EMIT_UPDATED_TRANSFERRED_ORDER = exports.SOCKET_EMIT_CREATED_TRANSFERRED_ORDER = exports.SOCKET_EMIT_CREATED_MULTIPLE_ORDERS = exports.SOCKET_EMIT_DELETED_ORDER = exports.SOCKET_EMIT_UPDATED_ORDER = exports.SOCKET_EMIT_CREATED_ORDER = exports.SOCKET_EMIT_SOLD_OUT_MODIFIERS = exports.SOCKET_EMIT_DELETED_CATEGORY = exports.SOCKET_EMIT_UPDATED_CATEGORY = exports.SOCKET_EMIT_CREATED_CATEGORY = exports.SOCKET_EMIT_BULK_UPDATE_CATEGORIES = exports.SOCKET_EMIT_BULK_UPDATE_SPECIAL_ITEMS = exports.SOCKET_EMIT_DELETED_SPECIAL_ITEM = exports.SOCKET_EMIT_UPDATED_SPECIAL_ITEM = exports.SOCKET_EMIT_CREATED_SPECIAL_ITEM = exports.SOCKET_EMIT_DELETED_HALFHALF_ITEM = exports.SOCKET_EMIT_UPDATED_HALFHALF_ITEM = exports.SOCKET_EMIT_CREATED_HALFHALF_ITEM = exports.SOCKET_EMIT_DELETED_GIFT_CARD = exports.SOCKET_EMIT_UPDATED_GIFT_CARD = exports.SOCKET_EMIT_CREATED_GIFT_CARD = exports.SOCKET_EMIT_DELETED_VOUCHER = exports.SOCKET_EMIT_UPDATED_VOUCHER = exports.SOCKET_EMIT_CREATED_VOUCHER = exports.SOCKET_EMIT_DELETED_OFFER = exports.SOCKET_EMIT_BULK_UPDATE_OFFER = exports.SOCKET_EMIT_UPDATED_OFFER = exports.SOCKET_EMIT_CREATED_OFFER = exports.SOCKET_EMIT_DELETED_ITEM = exports.SOCKET_EMIT_BULK_UPDATE_ITEMS = exports.SOCKET_EMIT_UPDATED_ITEM = exports.SOCKET_EMIT_CREATED_ITEM = exports.SOCKET_INITIATE_CATALOG = exports.SOCKET_INITIATE_ON_CONNECTION = exports.SOCKET_ON_CONNECTION = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.SOCKET_EMIT_DIALER_INCOMING = exports.SOCKET_EMIT_RIDER_ON_MOVE = exports.SOCKET_EMIT_RIDER_RECEIVED_ORDER_ASSIGN_REQUEST = exports.SOCKET_EMIT_UPDATED_DELIVERY_ORDER =
|
|
4
|
+
exports.SOCKET_EMIT_RECEIVED_ASSIGN_ORDER_REQUEST = exports.SOCKET_EMIT_ACTIVE_PLATFORM_SESSIONS = exports.SOCKET_EMIT_SEND_CUSTOMER_INFO = exports.SOCKET_EMIT_PRINT_TEXT = exports.SOCKET_EMIT_COMMIT_SYNC_PRINTERS_SETTINGS = exports.SOCKET_EMIT_SYNC_PRINTERS_SETTINGS = exports.SOCKET_EMIT_SET_PRINTER_SETTINGS = exports.SOCKET_EMIT_SET_ALL_PRINTER_SETTINGS = exports.SOCKET_EMIT_PRINTER_EVENT = exports.SOCKET_EMIT_ATTACH_PRINTERS_TO_ACCOUNT = exports.SOCKET_EMIT_OPEN_DRAWER = exports.SOCKET_EMIT_PRINT_IMAGE = exports.SOCKET_EMIT_PRINT_ORDER = exports.SOCKET_EMIT_PATCH_PRINTERS = exports.SOCKET_EMIT_CONNECT_PRINTERS = exports.SOCKET_EMIT_POSTED_REVIEW = exports.SOCKET_EMIT_BULK_UPDATE_DISCOUNTS = exports.SOCKET_EMIT_DELETED_DISCOUNT = exports.SOCKET_EMIT_UPDATED_DISCOUNT = exports.SOCKET_EMIT_CREATED_DISCOUNT = exports.SOCKET_EMIT_DELETED_PUBLIC_HOLIDAY = exports.SOCKET_EMIT_UPDATED_PUBLIC_HOLIDAY = exports.SOCKET_EMIT_CREATED_PUBLIC_HOLIDAY = exports.SOCKET_EMIT_DELETED_CLOSED_DATE = exports.SOCKET_EMIT_UPDATED_CLOSED_DATE = exports.SOCKET_EMIT_CREATED_CLOSED_DATE = exports.SOCKET_EMIT_DELETED_DELIVERY_AREA = exports.SOCKET_EMIT_UPDATED_DELIVERY_AREA = exports.SOCKET_EMIT_CREATED_DELIVERY_AREA = exports.SOCKET_EMIT_DELETED_MENU = exports.SOCKET_EMIT_BULK_UPDATE_MENU = exports.SOCKET_EMIT_UPDATED_MENU = exports.SOCKET_EMIT_CREATED_MENU = exports.SOCKET_EMIT_UPDATED_TENANT_INSTORE_SHIFT_SESSION = exports.SOCKET_EMIT_CREATED_TENANT_INSTORE_SHIFT_SESSION = exports.SOCKET_EMIT_UPDATED_TENANT_DAY_SESSION = exports.SOCKET_EMIT_CREATED_TENANT_DAY_SESSION = exports.SOCKET_EMIT_UPDATED_CASH_DRAWER_SESSION = exports.SOCKET_EMIT_CREATED_CASH_DRAWER_SESSION = exports.SOCKET_EMIT_DELETED_CASH_DRAWER = exports.SOCKET_EMIT_UPDATED_CASH_DRAWER = exports.SOCKET_EMIT_CREATED_CASH_DRAWER = exports.SOCKET_EMIT_DELETED_COURSE = exports.SOCKET_EMIT_BULK_UPDATE_COURSES = exports.SOCKET_EMIT_UPDATED_COURSE = exports.SOCKET_EMIT_CREATED_COURSE = exports.SOCKET_EMIT_UPDATED_CONFIG_V1 = exports.SOCKET_EMIT_UPDATED_OPERATIONAL_ROLES = exports.SOCKET_EMIT_DELETED_TENANT_INSTORE_SHIFT = exports.SOCKET_EMIT_UPDATED_TENANT_INSTORE_SHIFT = void 0;
|
|
5
|
+
exports.SOCKET_EMIT_DIALER_INCOMING = exports.SOCKET_EMIT_RIDER_ON_MOVE = exports.SOCKET_EMIT_RIDER_RECEIVED_ORDER_ASSIGN_REQUEST = exports.SOCKET_EMIT_UPDATED_DELIVERY_ORDER = void 0;
|
|
6
6
|
exports.SOCKET_ON_CONNECTION = 'connection';
|
|
7
7
|
exports.SOCKET_INITIATE_ON_CONNECTION = 'SOCKET_INITIATE_ON_CONNECTION';
|
|
8
8
|
exports.SOCKET_INITIATE_CATALOG = 'SOCKET_INITIATE_CATALOG';
|
|
@@ -124,8 +124,6 @@ exports.SOCKET_EMIT_PATCH_PRINTERS = 'SOCKET_EMIT_PATCH_PRINTERS';
|
|
|
124
124
|
exports.SOCKET_EMIT_PRINT_ORDER = 'SOCKET_EMIT_PRINT_ORDER';
|
|
125
125
|
exports.SOCKET_EMIT_PRINT_IMAGE = 'SOCKET_EMIT_PRINT_IMAGE';
|
|
126
126
|
exports.SOCKET_EMIT_OPEN_DRAWER = 'SOCKET_EMIT_OPEN_DRAWER';
|
|
127
|
-
exports.SOCKET_EMIT_CONNECT_DRAWER = 'SOCKET_EMIT_CONNECT_DRAWER';
|
|
128
|
-
exports.SOCKET_EMIT_DISCONNECT_DRAWER = 'SOCKET_EMIT_DISCONNECT_DRAWER';
|
|
129
127
|
exports.SOCKET_EMIT_ATTACH_PRINTERS_TO_ACCOUNT = 'SOCKET_EMIT_ATTACH_PRINTERS_TO_ACCOUNT';
|
|
130
128
|
exports.SOCKET_EMIT_PRINTER_EVENT = 'SOCKET_EMIT_PRINTER_EVENT';
|
|
131
129
|
exports.SOCKET_EMIT_SET_ALL_PRINTER_SETTINGS = 'SOCKET_EMIT_SET_ALL_PRINTER_SETTINGS';
|
|
@@ -4,8 +4,6 @@ export declare const WEBVIEW_PRINT_ORDER_FROM_ALL_PRINTERS = "WEBVIEW_PRINT_ORDE
|
|
|
4
4
|
export declare const WEBVIEW_PRINT_ORDER = "WEBVIEW_PRINT_ORDER";
|
|
5
5
|
export declare const WEBVIEW_OPEN_ALL_CASH_DRAWERS = "WEBVIEW_OPEN_ALL_CASH_DRAWERS";
|
|
6
6
|
export declare const WEBVIEW_OPEN_CASH_DRAWER = "WEBVIEW_OPEN_CASH_DRAWER";
|
|
7
|
-
export declare const WEBVIEW_CONNECT_CASH_DRAWER = "WEBVIEW_CONNECT_CASH_DRAWER";
|
|
8
|
-
export declare const WEBVIEW_DISCONNECT_CASH_DRAWER = "WEBVIEW_DISCONNECT_CASH_DRAWER";
|
|
9
7
|
export declare const WEBVIEW_SET_SETTINGS = "WEBVIEW_SET_SETTINGS";
|
|
10
8
|
export declare const WEBVIEW_SET_INITIATE_STATE = "WEBVIEW_SET_INITIATE_STATE";
|
|
11
9
|
export declare const WEBVIEW_UPDATE_SETTINGS = "WEBVIEW_UPDATE_SETTINGS";
|
package/lib/constants/WEBVIEW.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WEBVIEW_OO_PLACED_REVIEW = exports.WEBVIEW_OO_PLACED_ORDER = exports.WEBVIEW_OO_ADD_TO_CART = exports.WEBVIEW_OO_VIEWED_ITEM = exports.WEBVIEW_OO_SENT_CATALOG = exports.WEBVIEW_OO_SET_STORE_SETTINGS = exports.WEBVIEW_OO_SET_LOADING = exports.WEBVIEW_REGISTER_USER_DETAILS = exports.WEBVIEW_GET_IMAGE_DATA_LOGO_FROM_BASE64 = exports.WEBVIEW_GET_IMAGE_DATA_FROM_BASE64 = exports.WEBVIEW_GET_BINARY_LOGO_FROM_BASE64 = exports.WEBVIEW_GET_BINARY_IMAGE_FROM_BASE64 = exports.WEBVIEW_UPDATE_PRINTER_SETTINGS = exports.WEBVIEW_PRINTER_EVENT = exports.WEBVIEW_SET_PRINTERS = exports.WEBVIEW_RENDER_BACK_PRESS = exports.WEBVIEW_RETRY_PRINT = exports.WEBVIEW_ENABLE_DARK_MODE = exports.WEBVIEW_SET_IMAGE_DATA_LOGO = exports.WEBVIEW_PRINT_IMAGE_DATA = exports.WEBVIEW_SET_BINARY_LOGO = exports.WEBVIEW_PRINT_BINARY_IMAGE = exports.WEBVIEW_PRINT_TEXT = exports.WEBVIEW_DOWNLOAD_FILE = exports.WEBVIEW_COMMIT_SYNC_PRINTERS_SETTINGS = exports.WEBVIEW_SYNC_PRINTERS_SETTINGS = exports.WEBVIEW_SET_ALL_PRINTER_SETTINGS = exports.WEBVIEW_SET_PRINTER_SETTINGS = exports.WEBVIEW_ATTACH_PRINTERS_TO_ACCOUNT = exports.WEBVIEW_PRINT_IMAGE_FROM_ALL_PRINTERS = exports.WEBVIEW_PRINT_IMAGE = exports.WEBVIEW_GET_PRINTERS = exports.WEBVIEW_LOGOUT = exports.WEBVIEW_UPDATE_SETTINGS = exports.WEBVIEW_SET_INITIATE_STATE = exports.WEBVIEW_SET_SETTINGS = exports.
|
|
3
|
+
exports.WEBVIEW_OO_PLACED_REVIEW = exports.WEBVIEW_OO_PLACED_ORDER = exports.WEBVIEW_OO_ADD_TO_CART = exports.WEBVIEW_OO_VIEWED_ITEM = exports.WEBVIEW_OO_SENT_CATALOG = exports.WEBVIEW_OO_SET_STORE_SETTINGS = exports.WEBVIEW_OO_SET_LOADING = exports.WEBVIEW_REGISTER_USER_DETAILS = exports.WEBVIEW_GET_IMAGE_DATA_LOGO_FROM_BASE64 = exports.WEBVIEW_GET_IMAGE_DATA_FROM_BASE64 = exports.WEBVIEW_GET_BINARY_LOGO_FROM_BASE64 = exports.WEBVIEW_GET_BINARY_IMAGE_FROM_BASE64 = exports.WEBVIEW_UPDATE_PRINTER_SETTINGS = exports.WEBVIEW_PRINTER_EVENT = exports.WEBVIEW_SET_PRINTERS = exports.WEBVIEW_RENDER_BACK_PRESS = exports.WEBVIEW_RETRY_PRINT = exports.WEBVIEW_ENABLE_DARK_MODE = exports.WEBVIEW_SET_IMAGE_DATA_LOGO = exports.WEBVIEW_PRINT_IMAGE_DATA = exports.WEBVIEW_SET_BINARY_LOGO = exports.WEBVIEW_PRINT_BINARY_IMAGE = exports.WEBVIEW_PRINT_TEXT = exports.WEBVIEW_DOWNLOAD_FILE = exports.WEBVIEW_COMMIT_SYNC_PRINTERS_SETTINGS = exports.WEBVIEW_SYNC_PRINTERS_SETTINGS = exports.WEBVIEW_SET_ALL_PRINTER_SETTINGS = exports.WEBVIEW_SET_PRINTER_SETTINGS = exports.WEBVIEW_ATTACH_PRINTERS_TO_ACCOUNT = exports.WEBVIEW_PRINT_IMAGE_FROM_ALL_PRINTERS = exports.WEBVIEW_PRINT_IMAGE = exports.WEBVIEW_GET_PRINTERS = exports.WEBVIEW_LOGOUT = exports.WEBVIEW_UPDATE_SETTINGS = exports.WEBVIEW_SET_INITIATE_STATE = exports.WEBVIEW_SET_SETTINGS = exports.WEBVIEW_OPEN_CASH_DRAWER = exports.WEBVIEW_OPEN_ALL_CASH_DRAWERS = exports.WEBVIEW_PRINT_ORDER = exports.WEBVIEW_PRINT_ORDER_FROM_ALL_PRINTERS = exports.WEBVIEW_SET_ROUTE_TO_PRINTER_SETTINGS = exports.WEBVIEW_OPEN_LINK = void 0;
|
|
4
4
|
exports.WEBVIEW_OPEN_LINK = 'WEBVIEW_OPEN_LINK';
|
|
5
5
|
exports.WEBVIEW_SET_ROUTE_TO_PRINTER_SETTINGS = 'WEBVIEW_SET_ROUTE_TO_PRINTER_SETTINGS';
|
|
6
6
|
exports.WEBVIEW_PRINT_ORDER_FROM_ALL_PRINTERS = 'WEBVIEW_PRINT_ORDER_FROM_ALL_PRINTERS';
|
|
7
7
|
exports.WEBVIEW_PRINT_ORDER = 'WEBVIEW_PRINT_ORDER';
|
|
8
8
|
exports.WEBVIEW_OPEN_ALL_CASH_DRAWERS = 'WEBVIEW_OPEN_ALL_CASH_DRAWERS';
|
|
9
9
|
exports.WEBVIEW_OPEN_CASH_DRAWER = 'WEBVIEW_OPEN_CASH_DRAWER';
|
|
10
|
-
exports.WEBVIEW_CONNECT_CASH_DRAWER = 'WEBVIEW_CONNECT_CASH_DRAWER';
|
|
11
|
-
exports.WEBVIEW_DISCONNECT_CASH_DRAWER = 'WEBVIEW_DISCONNECT_CASH_DRAWER';
|
|
12
10
|
exports.WEBVIEW_SET_SETTINGS = 'WEBVIEW_SET_SETTINGS';
|
|
13
11
|
exports.WEBVIEW_SET_INITIATE_STATE = 'WEBVIEW_SET_INITIATE_STATE';
|
|
14
12
|
exports.WEBVIEW_UPDATE_SETTINGS = 'WEBVIEW_UPDATE_SETTINGS';
|
package/lib/constants/types.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ export interface ISocketPrinter {
|
|
|
11
11
|
custom_name: string;
|
|
12
12
|
series_name: string;
|
|
13
13
|
connected: boolean;
|
|
14
|
-
|
|
15
|
-
staff_id: string;
|
|
14
|
+
pos_id: string;
|
|
16
15
|
}
|
|
17
16
|
export interface ISocketConnectPrinters {
|
|
18
17
|
request_id: string;
|
|
@@ -31,22 +30,13 @@ export interface ISocketPrintOrder {
|
|
|
31
30
|
}
|
|
32
31
|
export interface ISocketPatchPrinters {
|
|
33
32
|
request_id: string;
|
|
34
|
-
|
|
33
|
+
pos_id: string;
|
|
35
34
|
printers: ISocketPrinter[];
|
|
36
35
|
}
|
|
37
36
|
export interface ISocketOpenDrawer {
|
|
38
37
|
request_id: string;
|
|
39
38
|
target: string;
|
|
40
39
|
}
|
|
41
|
-
export interface ISocketConnectDrawer {
|
|
42
|
-
request_id: string;
|
|
43
|
-
target: string;
|
|
44
|
-
staff_id: string;
|
|
45
|
-
}
|
|
46
|
-
export interface ISocketDisconnectDrawer {
|
|
47
|
-
request_id: string;
|
|
48
|
-
target: string;
|
|
49
|
-
}
|
|
50
40
|
export interface ISocketPrinterPrintOrderSuccess {
|
|
51
41
|
request_id: string;
|
|
52
42
|
target: string | null;
|
|
@@ -77,7 +67,7 @@ export interface ISocketPrintText {
|
|
|
77
67
|
}
|
|
78
68
|
export interface ISocketAttachPrinterToAccount {
|
|
79
69
|
target: string;
|
|
80
|
-
|
|
70
|
+
pos_id: string;
|
|
81
71
|
}
|
|
82
72
|
export interface ISocketAttachPrinters {
|
|
83
73
|
request_id: string;
|
|
@@ -188,22 +178,13 @@ export interface IWebviewOpenDrawer {
|
|
|
188
178
|
target: string;
|
|
189
179
|
request_id: string;
|
|
190
180
|
}
|
|
191
|
-
export interface IWebviewConnectDrawer {
|
|
192
|
-
target: string;
|
|
193
|
-
staff_id: string;
|
|
194
|
-
request_id: string;
|
|
195
|
-
}
|
|
196
|
-
export interface IWebviewDisconnectDrawer {
|
|
197
|
-
target: string;
|
|
198
|
-
request_id: string;
|
|
199
|
-
}
|
|
200
181
|
export interface IWebviewPatchPrinters {
|
|
201
182
|
printers: ISocketPrinter[];
|
|
202
183
|
request_id: string;
|
|
203
184
|
}
|
|
204
185
|
export interface IWebviewAttachPrinterToAccount {
|
|
205
186
|
target: string;
|
|
206
|
-
|
|
187
|
+
pos_id: string;
|
|
207
188
|
}
|
|
208
189
|
export interface IWebviewPrinterEvent {
|
|
209
190
|
type: PRINTER_EVENT_TYPE_ENUM;
|
|
@@ -231,8 +231,7 @@ function syncPrinterSettingsFields(printerSettings) {
|
|
|
231
231
|
brand_type: getBrandType(settings.brand_type),
|
|
232
232
|
interface_type: getInterfaceType(settings.interface_type),
|
|
233
233
|
name: getStringValue(settings.name, ''),
|
|
234
|
-
|
|
235
|
-
drawer_connected: getBooleanValue(settings.drawer_connected, false),
|
|
234
|
+
pos_id: getStringValue(settings.pos_id, ''),
|
|
236
235
|
backup_printer_target: getNullableStringValue(settings.backup_printer_target, null),
|
|
237
236
|
num_of_columns: getNumberValue(settings.num_of_columns, 48),
|
|
238
237
|
receiptTypes: getReceiptTypes(settings.receiptTypes),
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { ILocalTimeFields } from '../types/common';
|
|
2
2
|
export declare function getTenantTime(desiredGMTOffset: number, date?: Date): Date;
|
|
3
3
|
export declare function getDaysDifference(date1: Date, date2: Date, gmtOffset: number): number;
|
|
4
|
+
/**
|
|
5
|
+
* ISO 8601 week number (1-53) for a calendar date: weeks start on Monday, and
|
|
6
|
+
* week 1 is the week containing the year's first Thursday. Every week is
|
|
7
|
+
* exactly 7 days and the number can never exceed 53, so no clamp is needed.
|
|
8
|
+
*
|
|
9
|
+
* Pure UTC calendar math — independent of the runtime server's timezone.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getIsoWeekOfYear(localYear: number, localMonth: number, localDay: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the start date ("YYYY-MM-DD") of the calendar week containing the
|
|
14
|
+
* given localDate. `weekStart` selects the first day of the week:
|
|
15
|
+
* 0 = Sunday, 1 = Monday (default, ISO-aligned).
|
|
16
|
+
*
|
|
17
|
+
* Every resulting week is exactly 7 days regardless of month/year boundaries —
|
|
18
|
+
* the recommended bucket for weekly analytics (same as GA's weekly granularity,
|
|
19
|
+
* and it never mixes partial weeks).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCalendarWeekStart(localDate: string, weekStart?: number): string;
|
|
4
22
|
export declare function getLocalDocumentFields(gmtOffset: number, date: Date): {
|
|
5
23
|
localSecond: number;
|
|
6
24
|
localMinute: number;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTenantTime = getTenantTime;
|
|
4
4
|
exports.getDaysDifference = getDaysDifference;
|
|
5
|
+
exports.getIsoWeekOfYear = getIsoWeekOfYear;
|
|
6
|
+
exports.getCalendarWeekStart = getCalendarWeekStart;
|
|
5
7
|
exports.getLocalDocumentFields = getLocalDocumentFields;
|
|
6
8
|
exports.getLocalFieldsFromLocalDate = getLocalFieldsFromLocalDate;
|
|
7
9
|
const constants_1 = require("../../constants");
|
|
@@ -21,6 +23,39 @@ function getDaysDifference(date1, date2, gmtOffset) {
|
|
|
21
23
|
const millisecondsInADay = 24 * 60 * 60 * 1000;
|
|
22
24
|
return Math.floor((date1Time - date2Time) / millisecondsInADay);
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* ISO 8601 week number (1-53) for a calendar date: weeks start on Monday, and
|
|
28
|
+
* week 1 is the week containing the year's first Thursday. Every week is
|
|
29
|
+
* exactly 7 days and the number can never exceed 53, so no clamp is needed.
|
|
30
|
+
*
|
|
31
|
+
* Pure UTC calendar math — independent of the runtime server's timezone.
|
|
32
|
+
*/
|
|
33
|
+
function getIsoWeekOfYear(localYear, localMonth, localDay) {
|
|
34
|
+
const date = new Date(Date.UTC(localYear, localMonth - 1, localDay));
|
|
35
|
+
const dayNum = date.getUTCDay() || 7; // Monday = 1 ... Sunday = 7
|
|
36
|
+
// Move to the Thursday of the current ISO week.
|
|
37
|
+
date.setUTCDate(date.getUTCDate() + 4 - dayNum);
|
|
38
|
+
const isoYearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1));
|
|
39
|
+
const diffInDays = (date.getTime() - isoYearStart.getTime()) / (24 * 60 * 60 * 1000);
|
|
40
|
+
return Math.ceil((diffInDays + 1) / 7);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the start date ("YYYY-MM-DD") of the calendar week containing the
|
|
44
|
+
* given localDate. `weekStart` selects the first day of the week:
|
|
45
|
+
* 0 = Sunday, 1 = Monday (default, ISO-aligned).
|
|
46
|
+
*
|
|
47
|
+
* Every resulting week is exactly 7 days regardless of month/year boundaries —
|
|
48
|
+
* the recommended bucket for weekly analytics (same as GA's weekly granularity,
|
|
49
|
+
* and it never mixes partial weeks).
|
|
50
|
+
*/
|
|
51
|
+
function getCalendarWeekStart(localDate, weekStart = 1) {
|
|
52
|
+
const [localYear, localMonth, localDay] = localDate.split('-').map(Number);
|
|
53
|
+
const date = new Date(Date.UTC(localYear, localMonth - 1, localDay));
|
|
54
|
+
const weekday = date.getUTCDay(); // 0 (Sun) - 6 (Sat)
|
|
55
|
+
const diff = (weekday - weekStart + 7) % 7;
|
|
56
|
+
date.setUTCDate(date.getUTCDate() - diff);
|
|
57
|
+
return date.toISOString().slice(0, 10);
|
|
58
|
+
}
|
|
24
59
|
function getLocalDocumentFields(gmtOffset, date) {
|
|
25
60
|
const tenantDate = getTenantTime(gmtOffset, date);
|
|
26
61
|
const localSecond = tenantDate.getSeconds(); // 0 - 59
|
|
@@ -30,15 +65,18 @@ function getLocalDocumentFields(gmtOffset, date) {
|
|
|
30
65
|
const localDate = tenantDate.getDate(); // 1 - 31
|
|
31
66
|
const localMonth = tenantDate.getMonth() + 1; // 1 - 12
|
|
32
67
|
const localYear = tenantDate.getFullYear(); // YYYY
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
const localWeek = Math.
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
// Week of month (1-5): day-of-month blocks 1-7 → 1, 8-14 → 2, ..., 29-31 → 5.
|
|
69
|
+
// Every block is exactly 7 days except the final one, and the value can never
|
|
70
|
+
// exceed 5 — no clamp is required (schema caps at 5).
|
|
71
|
+
const localWeek = Math.ceil(localDate / 7);
|
|
72
|
+
// Day of year (1-366) — pure calendar math (no server timezone dependence),
|
|
73
|
+
// so localDayOfYear can never contradict localDate/localMonth/localYear.
|
|
74
|
+
const localDayOfYear = Math.floor((Date.UTC(localYear, localMonth - 1, localDate) - Date.UTC(localYear, 0, 1)) / (24 * 60 * 60 * 1000)) +
|
|
75
|
+
1;
|
|
76
|
+
// Week of year (1-53) — ISO 8601 (Monday start, week 1 contains the first
|
|
77
|
+
// Thursday). ISO weeks never exceed 53, so no clamp is required (schema caps
|
|
78
|
+
// at 53).
|
|
79
|
+
const localWeekOfYear = getIsoWeekOfYear(localYear, localMonth, localDate);
|
|
42
80
|
// Calculate quarter (1-4)
|
|
43
81
|
const localQuarter = Math.ceil(localMonth / 3);
|
|
44
82
|
// Calculate semester (1-2)
|
|
@@ -59,7 +97,7 @@ function getLocalDocumentFields(gmtOffset, date) {
|
|
|
59
97
|
localYear,
|
|
60
98
|
localDate: localDateString,
|
|
61
99
|
localTime: localTimeString,
|
|
62
|
-
localDayOfYear
|
|
100
|
+
localDayOfYear,
|
|
63
101
|
};
|
|
64
102
|
}
|
|
65
103
|
/**
|
|
@@ -82,14 +120,13 @@ function getLocalFieldsFromLocalDate(localDate, operational_time_zone_offset_gmt
|
|
|
82
120
|
// component is derived directly from the string using pure calendar math
|
|
83
121
|
// (no dependence on the server's timezone).
|
|
84
122
|
const weekday = new Date(Date.UTC(localYear, localMonth - 1, localDay)).getUTCDay();
|
|
85
|
-
// Week of month (1-5) —
|
|
86
|
-
|
|
87
|
-
const localWeek = Math.
|
|
88
|
-
// Day of year (1-366) and week of year (1-53)
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const localWeekOfYear = Math.min(Math.ceil((dayOfYear + startOfYearDow) / 7), 53);
|
|
123
|
+
// Week of month (1-5) — day-of-month blocks (1-7 → 1 ... 29-31 → 5). Same
|
|
124
|
+
// semantics as getLocalDocumentFields; never exceeds 5, no clamp required.
|
|
125
|
+
const localWeek = Math.ceil(localDay / 7);
|
|
126
|
+
// Day of year (1-366) and ISO week of year (1-53) — pure calendar math
|
|
127
|
+
// (no dependence on the server's timezone).
|
|
128
|
+
const localDayOfYear = Math.floor((Date.UTC(localYear, localMonth - 1, localDay) - Date.UTC(localYear, 0, 1)) / (24 * 60 * 60 * 1000)) + 1;
|
|
129
|
+
const localWeekOfYear = getIsoWeekOfYear(localYear, localMonth, localDay);
|
|
93
130
|
// Time components come from the actual settle timestamp in the tenant's
|
|
94
131
|
// timezone. The timestamp is normalized with new Date() since callers pass
|
|
95
132
|
// the field straight from the order (which may be a Date or an ISO string).
|
|
@@ -108,6 +145,6 @@ function getLocalFieldsFromLocalDate(localDate, operational_time_zone_offset_gmt
|
|
|
108
145
|
localQuarter: Math.ceil(localMonth / 3),
|
|
109
146
|
localSemester: Math.ceil(localMonth / 6),
|
|
110
147
|
localYear,
|
|
111
|
-
localDayOfYear
|
|
148
|
+
localDayOfYear,
|
|
112
149
|
};
|
|
113
150
|
}
|
|
@@ -11,12 +11,11 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
|
|
|
11
11
|
_id: import("mongoose").Types.ObjectId;
|
|
12
12
|
name: string;
|
|
13
13
|
tenant_id: string;
|
|
14
|
-
staff_id: string;
|
|
15
14
|
createdAt: NativeDate;
|
|
16
15
|
updatedAt: NativeDate;
|
|
17
16
|
target: string;
|
|
18
17
|
interface_type: PRINTER_INTERFACE_ENUM;
|
|
19
|
-
|
|
18
|
+
pos_id: string;
|
|
20
19
|
num_of_columns: number;
|
|
21
20
|
receiptTypes: {
|
|
22
21
|
default: unknown[] | unknown[];
|
|
@@ -81,12 +80,11 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
|
|
|
81
80
|
_id: import("mongoose").Types.ObjectId;
|
|
82
81
|
name: string;
|
|
83
82
|
tenant_id: string;
|
|
84
|
-
staff_id: string;
|
|
85
83
|
createdAt: NativeDate;
|
|
86
84
|
updatedAt: NativeDate;
|
|
87
85
|
target: string;
|
|
88
86
|
interface_type: PRINTER_INTERFACE_ENUM;
|
|
89
|
-
|
|
87
|
+
pos_id: string;
|
|
90
88
|
num_of_columns: number;
|
|
91
89
|
receiptTypes: {
|
|
92
90
|
default: unknown[] | unknown[];
|
|
@@ -151,12 +149,11 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
|
|
|
151
149
|
_id: import("mongoose").Types.ObjectId;
|
|
152
150
|
name: string;
|
|
153
151
|
tenant_id: string;
|
|
154
|
-
staff_id: string;
|
|
155
152
|
createdAt: NativeDate;
|
|
156
153
|
updatedAt: NativeDate;
|
|
157
154
|
target: string;
|
|
158
155
|
interface_type: PRINTER_INTERFACE_ENUM;
|
|
159
|
-
|
|
156
|
+
pos_id: string;
|
|
160
157
|
num_of_columns: number;
|
|
161
158
|
receiptTypes: {
|
|
162
159
|
default: unknown[] | unknown[];
|
|
@@ -37,14 +37,10 @@ exports.PrinterSettingsSchema = new mongoose_1.Schema({
|
|
|
37
37
|
type: String,
|
|
38
38
|
default: '',
|
|
39
39
|
},
|
|
40
|
-
|
|
40
|
+
pos_id: {
|
|
41
41
|
type: String,
|
|
42
42
|
default: '',
|
|
43
43
|
},
|
|
44
|
-
drawer_connected: {
|
|
45
|
-
type: Boolean,
|
|
46
|
-
default: false,
|
|
47
|
-
},
|
|
48
44
|
backup_printer_target: {
|
|
49
45
|
type: String,
|
|
50
46
|
required: false,
|
|
@@ -56,8 +56,7 @@ export interface IPrinterSettings {
|
|
|
56
56
|
brand_type?: PRINTER_BRAND_TYPE_ENUM | null;
|
|
57
57
|
interface_type: PRINTER_INTERFACE_ENUM;
|
|
58
58
|
name: string;
|
|
59
|
-
|
|
60
|
-
drawer_connected: boolean;
|
|
59
|
+
pos_id: string;
|
|
61
60
|
backup_printer_target: string | null;
|
|
62
61
|
num_of_columns: number;
|
|
63
62
|
receiptTypes: RECEIPT_TYPE_ENUM[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const time_helpers_1 = require("../helpers/utils/time-helpers");
|
|
4
|
+
const addDays = (iso, days) => {
|
|
5
|
+
const [y, m, d] = iso.split('-').map(Number);
|
|
6
|
+
const dt = new Date(Date.UTC(y, m - 1, d));
|
|
7
|
+
dt.setUTCDate(dt.getUTCDate() + days);
|
|
8
|
+
return dt.toISOString().slice(0, 10);
|
|
9
|
+
};
|
|
10
|
+
describe('getIsoWeekOfYear', () => {
|
|
11
|
+
it('returns correct ISO 8601 week numbers (Monday start)', () => {
|
|
12
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2026, 8, 23)).toBe(34); // was 35 under the old Sunday-based formula
|
|
13
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2026, 8, 30)).toBe(35);
|
|
14
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2026, 9, 1)).toBe(36);
|
|
15
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2026, 1, 1)).toBe(1);
|
|
16
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2026, 12, 31)).toBe(53);
|
|
17
|
+
});
|
|
18
|
+
it('handles year-boundary weeks (ISO week belongs to the year of its Thursday)', () => {
|
|
19
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2027, 1, 1)).toBe(53); // Jan 1 2027 falls in week 53 of 2026
|
|
20
|
+
expect((0, time_helpers_1.getIsoWeekOfYear)(2028, 1, 1)).toBe(52); // Jan 1 2028 falls in week 52 of 2027
|
|
21
|
+
});
|
|
22
|
+
it('never exceeds 53, even for leap years starting on a Saturday', () => {
|
|
23
|
+
for (const week of [
|
|
24
|
+
(0, time_helpers_1.getIsoWeekOfYear)(2026, 12, 31),
|
|
25
|
+
(0, time_helpers_1.getIsoWeekOfYear)(2028, 12, 31),
|
|
26
|
+
(0, time_helpers_1.getIsoWeekOfYear)(2024, 12, 29),
|
|
27
|
+
]) {
|
|
28
|
+
expect(week).toBeLessThanOrEqual(53);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('getCalendarWeekStart', () => {
|
|
33
|
+
it('returns the Monday (ISO) week start by default', () => {
|
|
34
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-08-23')).toBe('2026-08-17');
|
|
35
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-08-17')).toBe('2026-08-17');
|
|
36
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-01-01')).toBe('2025-12-29');
|
|
37
|
+
});
|
|
38
|
+
it('returns the Sunday week start when weekStart = 0', () => {
|
|
39
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-08-23', 0)).toBe('2026-08-23');
|
|
40
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-08-24', 0)).toBe('2026-08-23');
|
|
41
|
+
expect((0, time_helpers_1.getCalendarWeekStart)('2026-01-01', 0)).toBe('2025-12-28');
|
|
42
|
+
});
|
|
43
|
+
it('every calendar week in 2026 is exactly 7 days for both week starts', () => {
|
|
44
|
+
let day = '2026-01-01';
|
|
45
|
+
for (let i = 0; i < 365; i++) {
|
|
46
|
+
for (const weekStart of [0, 1]) {
|
|
47
|
+
const w = (0, time_helpers_1.getCalendarWeekStart)(day, weekStart);
|
|
48
|
+
expect((0, time_helpers_1.getCalendarWeekStart)(w, weekStart)).toBe(w);
|
|
49
|
+
expect((0, time_helpers_1.getCalendarWeekStart)(addDays(w, 6), weekStart)).toBe(w);
|
|
50
|
+
expect((0, time_helpers_1.getCalendarWeekStart)(addDays(w, 7), weekStart)).not.toBe(w);
|
|
51
|
+
}
|
|
52
|
+
day = addDays(day, 1);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('getLocalDocumentFields', () => {
|
|
57
|
+
it('computes week/day fields consistently with the tenant local date (server TZ independent)', () => {
|
|
58
|
+
const fields = (0, time_helpers_1.getLocalDocumentFields)(5, new Date('2026-08-23T09:26:42.353Z'));
|
|
59
|
+
expect(fields.localDate).toBe('2026-08-23');
|
|
60
|
+
expect(fields.localTime).toBe('14:26:42');
|
|
61
|
+
expect(fields.localDay).toBe(0); // Sunday
|
|
62
|
+
expect(fields.localWeek).toBe(4); // month-aligned: Aug 23 is in days 22-28
|
|
63
|
+
expect(fields.localWeekOfYear).toBe(34); // ISO 8601
|
|
64
|
+
expect(fields.localDayOfYear).toBe(235);
|
|
65
|
+
expect(fields.localMonth).toBe(8);
|
|
66
|
+
expect(fields.localYear).toBe(2026);
|
|
67
|
+
});
|
|
68
|
+
it('never produces an internal contradiction at early tenant-morning hours', () => {
|
|
69
|
+
// 02:00 tenant time (+5) = 21:00Z previous day; old code gave localDayOfYear 234.
|
|
70
|
+
const fields = (0, time_helpers_1.getLocalDocumentFields)(5, new Date('2026-08-22T21:00:00.000Z'));
|
|
71
|
+
expect(fields.localDate).toBe('2026-08-23');
|
|
72
|
+
expect(fields.localDayOfYear).toBe(235);
|
|
73
|
+
expect(fields.localWeekOfYear).toBe(34);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('getLocalFieldsFromLocalDate', () => {
|
|
77
|
+
it('uses month-aligned localWeek (never a 9-day week)', () => {
|
|
78
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-01', 5, new Date('2026-08-01T12:00:00Z')).localWeek).toBe(1);
|
|
79
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-07', 5, new Date('2026-08-07T12:00:00Z')).localWeek).toBe(1);
|
|
80
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-08', 5, new Date('2026-08-08T12:00:00Z')).localWeek).toBe(2);
|
|
81
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-23', 5, new Date('2026-08-23T12:00:00Z')).localWeek).toBe(4);
|
|
82
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-29', 5, new Date('2026-08-29T12:00:00Z')).localWeek).toBe(5);
|
|
83
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-30', 5, new Date('2026-08-30T12:00:00Z')).localWeek).toBe(5);
|
|
84
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-31', 5, new Date('2026-08-31T12:00:00Z')).localWeek).toBe(5);
|
|
85
|
+
});
|
|
86
|
+
it('matches getLocalDocumentFields for the same date (no week-5 clamp distortion)', () => {
|
|
87
|
+
const fromDate = (0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-08-23', 5, new Date('2026-08-23T09:26:42.353Z'));
|
|
88
|
+
const fromDoc = (0, time_helpers_1.getLocalDocumentFields)(5, new Date('2026-08-23T09:26:42.353Z'));
|
|
89
|
+
expect(fromDate.localWeek).toBe(fromDoc.localWeek);
|
|
90
|
+
expect(fromDate.localWeekOfYear).toBe(fromDoc.localWeekOfYear);
|
|
91
|
+
expect(fromDate.localDayOfYear).toBe(fromDoc.localDayOfYear);
|
|
92
|
+
expect(fromDate.localDay).toBe(fromDoc.localDay);
|
|
93
|
+
});
|
|
94
|
+
it('opens with the full month-aligned week semantics for 28-day February', () => {
|
|
95
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-02-01', 5, new Date('2026-02-01T12:00:00Z')).localWeek).toBe(1);
|
|
96
|
+
expect((0, time_helpers_1.getLocalFieldsFromLocalDate)('2026-02-28', 5, new Date('2026-02-28T12:00:00Z')).localWeek).toBe(4);
|
|
97
|
+
});
|
|
98
|
+
});
|