@managesome/eposmatic-toolkit 0.2.790 → 0.2.792
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/ENUMS.d.ts +6 -0
- package/lib/constants/ENUMS.js +18 -6
- package/lib/helpers/store/catalog-actions.js +43 -5
- package/lib/helpers/utils/index.d.ts +1 -0
- package/lib/helpers/utils/index.js +1 -0
- package/lib/helpers/utils/scan-code-helpers.d.ts +20 -0
- package/lib/helpers/utils/scan-code-helpers.js +35 -0
- package/lib/tests/scan-code-helpers.test.d.ts +1 -0
- package/lib/tests/scan-code-helpers.test.js +52 -0
- package/package.json +1 -1
package/lib/constants/ENUMS.d.ts
CHANGED
|
@@ -154,6 +154,12 @@ export declare enum ASAANBILL_DQRC_PURPOSE_ENUM {
|
|
|
154
154
|
}
|
|
155
155
|
export declare const ASAANBILL_DQRC_PURPOSES: ASAANBILL_DQRC_PURPOSE_ENUM[];
|
|
156
156
|
export declare const ASAANBILL_DQRC_IDENTIFIER_SEPARATOR: ":";
|
|
157
|
+
export declare enum SCAN_CODE_TYPE_ENUM {
|
|
158
|
+
POS_ITEM = "POS_ITEM",
|
|
159
|
+
INVENTORY_CODE = "INVENTORY_CODE"
|
|
160
|
+
}
|
|
161
|
+
export declare const ALL_SCAN_CODE_TYPES: SCAN_CODE_TYPE_ENUM[];
|
|
162
|
+
export declare const SCAN_CODE_IDENTIFIER_SEPARATOR: ":";
|
|
157
163
|
export declare enum TERMINAL_PROVIDER_ENUM {
|
|
158
164
|
SMARTPAY = "SMARTPAY",
|
|
159
165
|
ASAAN_BILL = "ASAAN_BILL"
|
package/lib/constants/ENUMS.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.ALL_PRINTER_COMMAND_LANGUAGES = exports.PRINTER_COMMAND_LANGUAGE = exports.ALL_HR_REVIEW_TYPE_NAMES = exports.HR_REVIEW_TYPE_ENUM = exports.DEFAULT_HR_LEAVE_ALLOWANCE = exports.ALL_HR_LEAVE_STATUS_NAMES = exports.HR_LEAVE_STATUS_ENUM = exports.ALL_HR_LEAVE_TYPE_NAMES = exports.HR_LEAVE_TYPE_ENUM = exports.ALL_HR_POLICY_STATUS_NAMES = exports.HR_POLICY_STATUS_ENUM = exports.ALL_HR_DOCUMENT_STATUS_NAMES = exports.HR_DOCUMENT_STATUS_ENUM = exports.ALL_HR_DOCUMENT_TYPE_NAMES = exports.HR_DOCUMENT_TYPE_ENUM = exports.ALL_HR_PAYMENT_METHOD_NAMES = exports.HR_PAYMENT_METHOD_ENUM = exports.ALL_HR_PAYROLL_STATUS_NAMES = exports.HR_PAYROLL_STATUS_ENUM = exports.ALL_HR_PAY_TYPE_NAMES = exports.HR_PAY_TYPE_ENUM = exports.ALL_HR_EMPLOYEE_DOCUMENT_TYPES = exports.HR_EMPLOYEE_DOCUMENT_TYPE_ENUM = exports.ALL_HR_SHIFT_STATUS_NAMES = exports.HR_SHIFT_STATUS_ENUM = exports.ALL_HR_SHIFT_TYPE_NAMES = exports.HR_SHIFT_TYPE_ENUM = exports.ALL_HR_BIOMETRIC_ENROLLMENT_TYPE_NAMES = exports.HR_BIOMETRIC_ENROLLMENT_TYPE_ENUM = void 0;
|
|
3
|
+
exports.COUNTRY_CODE_ENUM = exports.ALL_CURRENCY_SYMBOLS = exports.CURRENCY_SYMBOL_ENUM = exports.ALL_CURRENCY_NAMES = exports.CURRENCY_NAME_ENUM = exports.ALL_CURRENCY_CODES = exports.CURRENCY_CODE_ENUM = exports.ALL_DAY_INDEX = exports.DAY_INDEX_ENUM = exports.ALL_INVENTORY_UNIT_TYPES = exports.INVENTORY_ITEM_UNIT_ENUM = exports.ALL_DIETARY_PREFERENCES = exports.ITEM_DIETARY_PREFERENCE_ENUM = exports.ALL_CAVEATS = exports.ITEM_CAVEATS_ENUM = exports.ALL_PAYMENT_STATUS = exports.PAYMENT_STATUS_ENUM = exports.ALL_ORDER_STATUS_NAMES = exports.ORDER_STATUS_ENUM = exports.TRANSACTION_TYPE_ENUM = exports.ALL_CARD_PROCESSING_PROVIDERS = exports.CARD_PROCESSING_PROVIDERS_ENUM = exports.ALL_TERMINAL_PROVIDER_NAMES = exports.TERMINAL_PROVIDER_ENUM = exports.SCAN_CODE_IDENTIFIER_SEPARATOR = exports.ALL_SCAN_CODE_TYPES = exports.SCAN_CODE_TYPE_ENUM = exports.ASAANBILL_DQRC_IDENTIFIER_SEPARATOR = exports.ASAANBILL_DQRC_PURPOSES = exports.ASAANBILL_DQRC_PURPOSE_ENUM = exports.ALL_PAYMENT_PROVIDERS = exports.PAYMENT_PROVIDERS_ENUM = exports.ALL_TERMINAL_PAYMENT_TYPE_NAMES = exports.TERMINAL_PAYMENT_TYPE_ENUM = exports.PaymentTypeDescriptions = exports.ALL_PAYMENT_TYPE_NAMES = exports.PAYMENT_TYPE_ENUM = exports.ALL_API_STATUS_NAMES = exports.API_STATUS_ENUM = exports.ALL_INTEGRATIONS = exports.INTEGRATIONS_ENUM = exports.PLATFORM_NAMES = exports.PLATFORMS_BY_ORDER_FROM = exports.PLATFORMS_BY_ORDER_TYPE = exports.ALL_PLATFORMS = exports.PLATFORMS_ENUM = exports.ALL_ORDER_TYPE_NAMES = exports.ORDER_TYPE_ENUM = exports.ALL_ORDER_FROM_NAMES = exports.ORDER_FROM_ENUM = void 0;
|
|
4
|
+
exports.EMAIL_PROCESSING_PROVIDERS_ENUM = exports.ALL_SMS_PROCESSING_PROVIDERS = exports.SMS_PROCESSING_PROVIDERS_ENUM = exports.ALL_SUPPORT_SPECIALIST_PERMISSIONS = exports.ALL_MODERATOR_PERMISSIONS = exports.ALL_USER_PERMISSIONS = exports.USER_PERMISSIONS_ENUM = exports.ALL_REWARDS_USAGE_REF_TYPES = exports.REWARDS_USAGE_REF_TYPE_ENUM = exports.ALL_PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPES = exports.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM = exports.ALL_PATHWAY_TO_UNLOCK_TYPES = exports.PATHWAY_TO_UNLOCK_TYPE_ENUM = exports.ALL_MYSTERY_GIFT_POPUP_TYPES = exports.MYSTERY_GIFT_POPUP_TYPE_ENUM = exports.ALL_MYSTERY_GIFT_TYPES = exports.MYSTERY_GIFT_TYPE_ENUM = exports.ALL_GIFT_CARD_REWARD_TYPES = exports.GIFT_CARD_REWARD_TYPE_ENUM = exports.ALL_CUSTOMER_REDEMPTION_TYPES = exports.CUSTOMER_REDEMPTION_TYPE_ENUM = exports.ALL_CUSTOMER_REDEMPTION_SOURCE_TYPES = exports.CUSTOMER_REDEMPTION_SOURCE_ENUM = exports.ALL_OFFER_REWARD_TYPES = exports.OFFER_REWARD_TYPE_ENUM = exports.ALL_USER_ROLES = exports.USER_ROLES_ENUM = exports.ALL_PLATFORM_TYPES = exports.PLATFORM_TYPE_ENUM = exports.ALL_ORDER_NUMBER_GROUPING_TYPES = exports.ORDER_NUMBER_GROUPING_TYPE_ENUM = exports.ALL_TRACK_ORDER_NUMBER_TYPES = exports.TRACK_ORDER_NUMBER_ENUM = exports.ALL_TABLE_TYPES = exports.TABLE_TYPE_ENUM = exports.ALL_CATEGORY_DISPLAY_TYPES = exports.CATEGORY_DISPLAY_TYPE_ENUM = exports.ALL_PAYMENT_METHOD_EXPECTED = exports.PAYMENT_METHOD_EXPECTED_ENUM = exports.ALL_WEB_UNPAID_PAYMENT_TYPES = exports.WEB_UNPAID_PAYMENT_TYPE_ENUM = exports.ALL_COUNTRY_FLAG_TYPES = exports.COUNTRY_FLAG_ENUM = exports.ALL_COUNTRY_NAME_TYPES = exports.COUNTRY_NAME_ENUM = exports.ALL_COUNTRY_ALPHA_3_TYPES = exports.COUNTRY_ALPHA_3_ENUM = exports.ALL_COUNTRY_ALPHA_2_TYPES = exports.COUNTRY_ALPHA_2_ENUM = exports.ALL_COUNTRY_CODES = void 0;
|
|
5
|
+
exports.NUM_OF_COLUMNS_ENUM = exports.SPLIT_SYNC_SOURCE_ENUM = exports.ALL_SPLIT_BILL_TYPES = exports.SPLIT_BILL_TYPE_ENUM = exports.ALL_RIDER_FEE_TYPES = exports.RIDER_FEE_TYPE_ENUM = exports.ALL_DELIVERY_AREAS_SEARCH_TYPES = exports.DELIVERY_AREAS_SEARCH_TYPE_ENUM = exports.ALL_WEB_AUTH_TYPES = exports.WEB_AUTH_TYPE_ENUM = exports.KITCHEN_RECEIPT_TYPE_ENUM = exports.PRINTER_EVENT_TYPE_ENUM = exports.SORT_TYPE_ENUM = exports.WHITELISTED_API_SMS_COUNTRY_CODES = exports.BLACKLISTED_SMS_COUNTRY_CODES = exports.ALL_OTP_TYPES = exports.OTP_TYPE_ENUM = exports.ALL_TAX_INVOICE_PROVIDERS = exports.TAX_INVOICE_PROVIDER_ENUM = exports.ALL_RESERVATION_STATUS_TYPES = exports.RESERVATION_STATUS_ENUM = exports.TENANT_AMOUNT_DUE_TYPE_ENUM = exports.ALL_KITCHEN_DOCKET_FONT_TYPES = exports.KITCHEN_DOCKET_FONT_TYPE_ENUM = exports.ALL_SORT_ORDER_BY_TYPES = exports.SORT_ORDER_BY_ENUM = exports.RECEIPT_IMAGE_TYPE_ENUM = exports.ALL_RECEIPT_TYPES = exports.RECEIPT_TYPE_ENUM = exports.ALL_PRINTING_PREFERENCES = exports.PRINTING_PREFERENCE_ENUM = exports.ALL_PRINTER_BRAND_TYPES = exports.PRINTER_BRAND_TYPE_ENUM = exports.ALL_ORDER_ITEM_TYPES = exports.ORDER_ITEM_TYPE_ENUM = exports.ALL_PLATFORM_PROVIDER_IDS = exports.PLATFORM_PROVIDER_IDS_ENUM = exports.ALL_MARKETING_RECEIPIENT_TYPES = exports.MARKETING_RECEIPIENT_ENUM = exports.ALL_MARKETING_TYPES = exports.MARKETING_TYPE_ENUM = exports.ALL_TOKEN_TYPES = exports.TOKEN_TYPE_ENUM = exports.ALL_EMAIL_STATUS = exports.EMAIL_STATUS_ENUM = exports.ALL_COMMUNICATION_CHANNELS = exports.COMMUNICATION_CHANNEL_ENUM = exports.ALL_EMAIL_DOCUMENT_KINDS = exports.EMAIL_DOCUMENT_KIND_ENUM = exports.ALL_EMAIL_PROCESSING_PROVIDERS = void 0;
|
|
6
|
+
exports.NOTIFICATION_PROVIDER_ENUM = exports.ALL_ORDER_COMPLETION_TYPES = exports.ORDER_COMPLETION_TYPE_ENUM = exports.ITEM_COMPARISON_FIELD_ENUM = exports.VOID_ITEM_STAFF_REPORT_ENUM = exports.ALL_DISCOUNT_APPLICABILITY_TYPES = exports.DISCOUNT_APPLICABILITY_ENUM = exports.ALL_DISCOUNT_TYPES = exports.DISCOUNT_TYPE_ENUM = exports.EMAIL_TEMPLATES_TYPE_ENUM = exports.ALL_ALERT_NOTIFICATIONS_TYPES = exports.ALERT_NOTIFICATIONS_TYPE_ENUM = exports.ALL_WALLET_TRANSACTION_STATUS = exports.WALLET_TRANSACTION_STATUS_ENUM = exports.ALL_WALLET_TRANSACTION_CATEGORIES = exports.WALLET_TRANSACTION_CATEGORY_ENUM = exports.ALL_WALLET_TRANSACTION_TYPES = exports.WALLET_TRANSACTION_TYPE_ENUM = exports.ALL_DELIVERY_STATUS = exports.DELIVERY_STATUS_ENUM = exports.ALL_INVENTORY_ITEM_TYPES = exports.INVENTORY_ITEM_TYPE_ENUM = exports.ALL_RATING_TYPES = exports.RATING_TYPE_ENUM = exports.ALL_SUBSCRIPTION_STATUS = exports.SUBSCRIPTION_STATUS_ENUM = exports.ALL_VOID_PURCHASE_ORDER_ITEM_TYPES = exports.VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM = exports.ALL_VOID_ORDER_ITEM_TYPES = exports.VOID_ORDER_ITEM_TYPE_ENUM = exports.COMPARISON_REPORT_TYPE_ENUM = exports.ALL_MULTI_TENANT_WEBSITE_TYPES = exports.MULTI_TENANT_WEBSITE_TYPE_ENUM = exports.ALL_ITEM_TRANSACTION_TYPES = exports.ITEM_TRANSACTION_TYPE_ENUM = exports.INVENTORY_OUTBOUND_TRANSACTIONS = exports.INVENTORY_INBOUND_TRANSACTIONS = exports.ALL_INVENTORY_TRANSACTION_CATEGORIES = exports.INVENTORY_TRANSACTION_CATEGORY_ENUM = exports.ALL_INVENTORY_TRANSACTION_TYPES = exports.INVENTORY_TRANSACTION_TYPE_ENUM = exports.ALL_GST_TYPES = exports.GST_TYPE_ENUM = exports.ALL_EXPENSE_REACCURING_TYPES = exports.EXPENSE_REACCURING_TYPE_ENUM = exports.PAYMENT_EXTENSION_ENUM = exports.ALL_PRINTER_INTERFACES = exports.PRINTER_INTERFACE_ENUM = exports.RECEIPT_WIDTHS = exports.ALL_NUM_OF_COLUMNS = void 0;
|
|
7
|
+
exports.HR_ATTENDANCE_STATUS_ENUM = exports.ALL_HR_EMPLOYMENT_STATUS_NAMES = exports.HR_EMPLOYMENT_STATUS_ENUM = exports.ALL_INTERNAL_CUSTOMER_PAYMENT_METHOD_NAMES = exports.INTERNAL_CUSTOMER_PAYMENT_METHOD_ENUM = exports.ALL_INTERNAL_CUSTOMER_SUBSCRIPTION_SERVICE_NAMES = exports.INTERNAL_CUSTOMER_SUBSCRIPTION_SERVICE_ENUM = exports.ALL_INTERNAL_CUSTOMER_SUBSCRIPTION_PLAN_NAMES = exports.INTERNAL_CUSTOMER_SUBSCRIPTION_PLAN_ENUM = exports.ALL_INTERNAL_CUSTOMER_BILLING_CYCLE_NAMES = exports.INTERNAL_CUSTOMER_BILLING_CYCLE_ENUM = exports.ALL_INTERNAL_CUSTOMER_TYPE_NAMES = exports.INTERNAL_CUSTOMER_TYPE_ENUM = exports.ALL_INTERNAL_INVOICE_TYPE_NAMES = exports.INTERNAL_INVOICE_TYPE_ENUM = exports.ALL_INTERNAL_INVOICE_STATUS_NAMES = exports.INTERNAL_INVOICE_STATUS_ENUM = exports.ALL_SUBSCRIPTION_HARDWARE_NAMES = exports.SUBSCRIPTION_HARDWARE_ENUM = exports.ALL_CUSTOMER_TARGET_MODES = exports.CUSTOMER_TARGET_MODE_ENUM = exports.ALL_WALLET_ASSIGNMENT_BEHAVIORS = exports.WALLET_ASSIGNMENT_BEHAVIOR_ENUM = exports.ALL_WALLET_ASSET_TYPES = exports.WALLET_ASSET_TYPE_ENUM = exports.ALL_RECEIPT_QR_CODE_TYPES = exports.RECEIPT_QR_CODE_TYPE_ENUM = exports.ALL_INTERNAL_LEAD_STATUS = exports.INTERNAL_LEAD_STATUS_ENUM = exports.ALL_INTERNAL_LEAD_SOURCES = exports.INTERNAL_LEAD_SOURCE_ENUM = exports.ALL_CASH_DRAWER_STATUS = exports.CASH_DRAWER_STATUS_ENUM = exports.ALL_CASH_IN_HAND_TRANSACTION_CATEGORIES = exports.CASH_IN_HAND_TRANSACTION_CATEGORY_ENUM = exports.ALL_CASH_IN_HAND_TRANSACTION_TYPES = exports.CASH_IN_HAND_TRANSACTION_TYPE_ENUM = exports.ALL_CASH_IN_OUT_REFS = exports.CASH_IN_OUT_REF_ENUM = exports.ALL_CASH_IN_OUT_TYPES = exports.CASH_IN_OUT_TYPE_ENUM = exports.ALL_POS_SHIFT_STATUS = exports.POS_SHIFT_STATUS_ENUM = exports.ALL_POS_DAY_STATUS = exports.POS_DAY_STATUS_ENUM = exports.ALL_MODIFIER_OPTION_REF_TYPES = exports.MODIFIER_OPTION_REF_TYPE_ENUM = exports.ALL_ONLINE_ORDERING_DESIGN_TYPES = exports.ONLINE_ORDERING_DESIGN_TYPE_ENUM = exports.ALL_NOTIFICATION_PROVIDERS = void 0;
|
|
8
|
+
exports.ALL_PRINTER_COMMAND_LANGUAGES = exports.PRINTER_COMMAND_LANGUAGE = exports.ALL_HR_REVIEW_TYPE_NAMES = exports.HR_REVIEW_TYPE_ENUM = exports.DEFAULT_HR_LEAVE_ALLOWANCE = exports.ALL_HR_LEAVE_STATUS_NAMES = exports.HR_LEAVE_STATUS_ENUM = exports.ALL_HR_LEAVE_TYPE_NAMES = exports.HR_LEAVE_TYPE_ENUM = exports.ALL_HR_POLICY_STATUS_NAMES = exports.HR_POLICY_STATUS_ENUM = exports.ALL_HR_DOCUMENT_STATUS_NAMES = exports.HR_DOCUMENT_STATUS_ENUM = exports.ALL_HR_DOCUMENT_TYPE_NAMES = exports.HR_DOCUMENT_TYPE_ENUM = exports.ALL_HR_PAYMENT_METHOD_NAMES = exports.HR_PAYMENT_METHOD_ENUM = exports.ALL_HR_PAYROLL_STATUS_NAMES = exports.HR_PAYROLL_STATUS_ENUM = exports.ALL_HR_PAY_TYPE_NAMES = exports.HR_PAY_TYPE_ENUM = exports.ALL_HR_EMPLOYEE_DOCUMENT_TYPES = exports.HR_EMPLOYEE_DOCUMENT_TYPE_ENUM = exports.ALL_HR_SHIFT_STATUS_NAMES = exports.HR_SHIFT_STATUS_ENUM = exports.ALL_HR_SHIFT_TYPE_NAMES = exports.HR_SHIFT_TYPE_ENUM = exports.ALL_HR_BIOMETRIC_ENROLLMENT_TYPE_NAMES = exports.HR_BIOMETRIC_ENROLLMENT_TYPE_ENUM = exports.ALL_HR_CHECK_IN_METHOD_NAMES = exports.HR_CHECK_IN_METHOD_ENUM = exports.ALL_HR_ATTENDANCE_STATUS_NAMES = void 0;
|
|
9
9
|
var ORDER_FROM_ENUM;
|
|
10
10
|
(function (ORDER_FROM_ENUM) {
|
|
11
11
|
ORDER_FROM_ENUM["WEB"] = "WEB";
|
|
@@ -297,6 +297,18 @@ var ASAANBILL_DQRC_PURPOSE_ENUM;
|
|
|
297
297
|
exports.ASAANBILL_DQRC_PURPOSES = Object.values(ASAANBILL_DQRC_PURPOSE_ENUM);
|
|
298
298
|
exports.ASAANBILL_DQRC_IDENTIFIER_SEPARATOR = ':';
|
|
299
299
|
// ======================>> <<====================== //
|
|
300
|
+
// Scannable barcode/QR code identifier type + separator. Printed codes encode
|
|
301
|
+
// `<type>:<entity id>` (e.g. `POS_ITEM:<item._id>`); scanners decode with the
|
|
302
|
+
// shared `buildScanCode` / `parseScanCode` helpers so encoding and decoding
|
|
303
|
+
// never drift apart across apps and services.
|
|
304
|
+
var SCAN_CODE_TYPE_ENUM;
|
|
305
|
+
(function (SCAN_CODE_TYPE_ENUM) {
|
|
306
|
+
SCAN_CODE_TYPE_ENUM["POS_ITEM"] = "POS_ITEM";
|
|
307
|
+
SCAN_CODE_TYPE_ENUM["INVENTORY_CODE"] = "INVENTORY_CODE";
|
|
308
|
+
})(SCAN_CODE_TYPE_ENUM || (exports.SCAN_CODE_TYPE_ENUM = SCAN_CODE_TYPE_ENUM = {}));
|
|
309
|
+
exports.ALL_SCAN_CODE_TYPES = Object.values(SCAN_CODE_TYPE_ENUM);
|
|
310
|
+
exports.SCAN_CODE_IDENTIFIER_SEPARATOR = ':';
|
|
311
|
+
// ======================>> <<====================== //
|
|
300
312
|
var TERMINAL_PROVIDER_ENUM;
|
|
301
313
|
(function (TERMINAL_PROVIDER_ENUM) {
|
|
302
314
|
TERMINAL_PROVIDER_ENUM["SMARTPAY"] = "SMARTPAY";
|
|
@@ -281,11 +281,35 @@ function getSelectedVendorInventoryItems(mappedInventory, includedCategories, ca
|
|
|
281
281
|
refToId.set(c.ref_id, c._id);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
|
|
284
|
+
// A vendor can hold BOTH a legacy ref_id-keyed entry and a synced
|
|
285
|
+
// _id-keyed entry for one category (the drawer appends the synced entry
|
|
286
|
+
// without recognizing the legacy one). Merge them by canonical category id
|
|
287
|
+
// first — otherwise the legacy entry (typically excluded_items: [])
|
|
288
|
+
// re-includes every item the synced entry excluded, leaking them into the
|
|
289
|
+
// catalog. The `_id`-keyed entry reflects the newest form save, so it wins.
|
|
290
|
+
const mergedCategories = [];
|
|
291
|
+
const mergedIndexByCanonicalId = new Map();
|
|
285
292
|
for (let i = 0; i < includedCategories.length; i++) {
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
293
|
+
const entry = includedCategories[i];
|
|
294
|
+
const rawCategoryId = entry.category_id ?? '';
|
|
295
|
+
const canonicalCategoryId = refToId.get(rawCategoryId) ?? rawCategoryId;
|
|
296
|
+
const mergedIndex = mergedIndexByCanonicalId.get(canonicalCategoryId);
|
|
297
|
+
const mergedEntry = {
|
|
298
|
+
category_id: canonicalCategoryId,
|
|
299
|
+
excluded_items: entry.excluded_items ?? [],
|
|
300
|
+
};
|
|
301
|
+
if (mergedIndex === undefined) {
|
|
302
|
+
mergedIndexByCanonicalId.set(canonicalCategoryId, mergedCategories.length);
|
|
303
|
+
mergedCategories.push(mergedEntry);
|
|
304
|
+
}
|
|
305
|
+
else if (rawCategoryId === canonicalCategoryId) {
|
|
306
|
+
mergedCategories[mergedIndex] = mergedEntry;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const result = [];
|
|
310
|
+
for (let i = 0; i < mergedCategories.length; i++) {
|
|
311
|
+
const { category_id, excluded_items } = mergedCategories[i];
|
|
312
|
+
const items = mappedInventory[category_id ?? ''];
|
|
289
313
|
if (!items)
|
|
290
314
|
continue;
|
|
291
315
|
if (excluded_items.length === 0) {
|
|
@@ -334,9 +358,23 @@ function getGroupedInventoryCategories(categories, items) {
|
|
|
334
358
|
// would omit those items from the group.
|
|
335
359
|
const sortedCategories = [...categories].sort((a, b) => a.sort_id - b.sort_id);
|
|
336
360
|
for (const cat of sortedCategories) {
|
|
361
|
+
// Items can be stored under BOTH keys when legacy (ref_id) and synced
|
|
362
|
+
// (_id) data coexist — merge the two sets instead of the old `||` fallback,
|
|
363
|
+
// which silently dropped one of them. The PO container merges both, so
|
|
364
|
+
// dropped items leaked into the PO without ever being visible/selectable
|
|
365
|
+
// here. De-dupe for the legacy case ref_id === _id.
|
|
366
|
+
const refItems = cat.ref_id ? (itemsByCategory[cat.ref_id] ?? []) : [];
|
|
367
|
+
const idItems = cat._id ? (itemsByCategory[cat._id] ?? []) : [];
|
|
368
|
+
const seenItemIds = new Set();
|
|
369
|
+
const items = [...refItems, ...idItems].filter((item) => {
|
|
370
|
+
if (seenItemIds.has(item._id))
|
|
371
|
+
return false;
|
|
372
|
+
seenItemIds.add(item._id);
|
|
373
|
+
return true;
|
|
374
|
+
});
|
|
337
375
|
result.push({
|
|
338
376
|
category: cat,
|
|
339
|
-
items
|
|
377
|
+
items,
|
|
340
378
|
});
|
|
341
379
|
}
|
|
342
380
|
// Append uncategorized items as a synthetic category (ref_id: null so the API receives null, not a fake string)
|
|
@@ -57,6 +57,7 @@ export * from './sales-comparison-report-helpers';
|
|
|
57
57
|
export * from './sales-comparitive-report-helpers';
|
|
58
58
|
export * from './sales-overview-report-helpers';
|
|
59
59
|
export * from './sales-summary-report-helpers';
|
|
60
|
+
export * from './scan-code-helpers';
|
|
60
61
|
export * from './shift-window-helpers';
|
|
61
62
|
export * from './simplified-catalog';
|
|
62
63
|
export * from './simplified-halfhalf';
|
|
@@ -73,6 +73,7 @@ __exportStar(require("./sales-comparison-report-helpers"), exports);
|
|
|
73
73
|
__exportStar(require("./sales-comparitive-report-helpers"), exports);
|
|
74
74
|
__exportStar(require("./sales-overview-report-helpers"), exports);
|
|
75
75
|
__exportStar(require("./sales-summary-report-helpers"), exports);
|
|
76
|
+
__exportStar(require("./scan-code-helpers"), exports);
|
|
76
77
|
__exportStar(require("./shift-window-helpers"), exports);
|
|
77
78
|
__exportStar(require("./simplified-catalog"), exports);
|
|
78
79
|
__exportStar(require("./simplified-halfhalf"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SCAN_CODE_TYPE_ENUM } from '../../constants';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a scannable barcode/QR identifier: `<type>:<entity id>`
|
|
4
|
+
* (e.g. `POS_ITEM:<item._id>`, `INVENTORY_CODE:<inventory entry _id>`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildScanCode(type: SCAN_CODE_TYPE_ENUM, id: string): string;
|
|
7
|
+
export interface IParsedScanCode {
|
|
8
|
+
type: SCAN_CODE_TYPE_ENUM;
|
|
9
|
+
/** The scanned entity id — everything after the first separator, as-is. */
|
|
10
|
+
code: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parses a scanned barcode/QR payload back into its parts, or null when the
|
|
14
|
+
* payload does not follow the `<type>:<entity id>` format. Callers ignore
|
|
15
|
+
* null — only supported enum types are ever returned.
|
|
16
|
+
*
|
|
17
|
+
* Only the FIRST separator is structural: the type must be one of
|
|
18
|
+
* `ALL_SCAN_CODE_TYPES` and the remaining string is the code untouched.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseScanCode(raw: string | null | undefined): IParsedScanCode | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildScanCode = buildScanCode;
|
|
4
|
+
exports.parseScanCode = parseScanCode;
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
// =======================>>><<<=======================
|
|
7
|
+
/**
|
|
8
|
+
* Builds a scannable barcode/QR identifier: `<type>:<entity id>`
|
|
9
|
+
* (e.g. `POS_ITEM:<item._id>`, `INVENTORY_CODE:<inventory entry _id>`).
|
|
10
|
+
*/
|
|
11
|
+
function buildScanCode(type, id) {
|
|
12
|
+
return `${type}${constants_1.SCAN_CODE_IDENTIFIER_SEPARATOR}${id}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parses a scanned barcode/QR payload back into its parts, or null when the
|
|
16
|
+
* payload does not follow the `<type>:<entity id>` format. Callers ignore
|
|
17
|
+
* null — only supported enum types are ever returned.
|
|
18
|
+
*
|
|
19
|
+
* Only the FIRST separator is structural: the type must be one of
|
|
20
|
+
* `ALL_SCAN_CODE_TYPES` and the remaining string is the code untouched.
|
|
21
|
+
*/
|
|
22
|
+
function parseScanCode(raw) {
|
|
23
|
+
if (!raw)
|
|
24
|
+
return null;
|
|
25
|
+
const separatorIndex = raw.indexOf(constants_1.SCAN_CODE_IDENTIFIER_SEPARATOR);
|
|
26
|
+
if (separatorIndex <= 0)
|
|
27
|
+
return null; // no separator, or empty type
|
|
28
|
+
const type = raw.slice(0, separatorIndex);
|
|
29
|
+
if (!constants_1.ALL_SCAN_CODE_TYPES.includes(type))
|
|
30
|
+
return null;
|
|
31
|
+
const code = raw.slice(separatorIndex + 1);
|
|
32
|
+
if (!code)
|
|
33
|
+
return null; // missing entity id
|
|
34
|
+
return { type, code };
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const scan_code_helpers_1 = require("../helpers/utils/scan-code-helpers");
|
|
5
|
+
describe('scan code constants', () => {
|
|
6
|
+
it('supports POS_ITEM and INVENTORY_CODE with ":" as the separator', () => {
|
|
7
|
+
expect(constants_1.SCAN_CODE_TYPE_ENUM.POS_ITEM).toBe('POS_ITEM');
|
|
8
|
+
expect(constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE).toBe('INVENTORY_CODE');
|
|
9
|
+
expect(constants_1.ALL_SCAN_CODE_TYPES).toEqual([constants_1.SCAN_CODE_TYPE_ENUM.POS_ITEM, constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE]);
|
|
10
|
+
expect(constants_1.SCAN_CODE_IDENTIFIER_SEPARATOR).toBe(':');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe('buildScanCode', () => {
|
|
14
|
+
it('joins the type and entity id with a single separator', () => {
|
|
15
|
+
expect((0, scan_code_helpers_1.buildScanCode)(constants_1.SCAN_CODE_TYPE_ENUM.POS_ITEM, '66f1a2b3c4d5e6f7a8b9c0d1')).toBe('POS_ITEM:66f1a2b3c4d5e6f7a8b9c0d1');
|
|
16
|
+
expect((0, scan_code_helpers_1.buildScanCode)(constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE, 'INV-42')).toBe('INVENTORY_CODE:INV-42');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('parseScanCode', () => {
|
|
20
|
+
it('parses supported payloads into type + code', () => {
|
|
21
|
+
expect((0, scan_code_helpers_1.parseScanCode)('POS_ITEM:66f1a2b3c4d5e6f7a8b9c0d1')).toEqual({
|
|
22
|
+
type: constants_1.SCAN_CODE_TYPE_ENUM.POS_ITEM,
|
|
23
|
+
code: '66f1a2b3c4d5e6f7a8b9c0d1',
|
|
24
|
+
});
|
|
25
|
+
expect((0, scan_code_helpers_1.parseScanCode)('INVENTORY_CODE:INV-42')).toEqual({
|
|
26
|
+
type: constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE,
|
|
27
|
+
code: 'INV-42',
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
it('splits on the FIRST separator only (rest stays in code)', () => {
|
|
31
|
+
expect((0, scan_code_helpers_1.parseScanCode)('POS_ITEM:a:b:c')).toEqual({ type: constants_1.SCAN_CODE_TYPE_ENUM.POS_ITEM, code: 'a:b:c' });
|
|
32
|
+
});
|
|
33
|
+
it('ignores payloads without a type', () => {
|
|
34
|
+
expect((0, scan_code_helpers_1.parseScanCode)('just-some-text')).toBeNull();
|
|
35
|
+
expect((0, scan_code_helpers_1.parseScanCode)(':abc123')).toBeNull();
|
|
36
|
+
expect((0, scan_code_helpers_1.parseScanCode)('')).toBeNull();
|
|
37
|
+
expect((0, scan_code_helpers_1.parseScanCode)(undefined)).toBeNull();
|
|
38
|
+
expect((0, scan_code_helpers_1.parseScanCode)(null)).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
it('ignores unsupported or mis-cased types (e.g. order links)', () => {
|
|
41
|
+
expect((0, scan_code_helpers_1.parseScanCode)('ORDER:abc123')).toBeNull();
|
|
42
|
+
expect((0, scan_code_helpers_1.parseScanCode)('pos_item:abc123')).toBeNull();
|
|
43
|
+
expect((0, scan_code_helpers_1.parseScanCode)('https://thailemon-uk.onlineordering.pk/orders/6ab685e8bf7ea5a01cf6d3aa')).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
it('ignores a missing entity id', () => {
|
|
46
|
+
expect((0, scan_code_helpers_1.parseScanCode)('POS_ITEM:')).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
it('round-trips build -> parse', () => {
|
|
49
|
+
const code = (0, scan_code_helpers_1.buildScanCode)(constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE, 'entry_9');
|
|
50
|
+
expect((0, scan_code_helpers_1.parseScanCode)(code)).toEqual({ type: constants_1.SCAN_CODE_TYPE_ENUM.INVENTORY_CODE, code: 'entry_9' });
|
|
51
|
+
});
|
|
52
|
+
});
|