@managesome/eposmatic-toolkit 0.2.360 → 0.2.362

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.
@@ -183,7 +183,7 @@ function formatDateToDateTime(date, gmtOffset) {
183
183
  }
184
184
  // ==============================>><<==============================
185
185
  function localeAmount(currency, amount) {
186
- return `${currency ?? ''}${parseNum(amount).toLocaleString()}`;
186
+ return `${currency ?? ''}${parseNum(amount).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })}`;
187
187
  }
188
188
  let lastOfflineOrderNumber;
189
189
  const getOfflineOrderNumber = () => {
@@ -181,7 +181,7 @@ function getItemComparisonReportHtml(props) {
181
181
  cellData !== null &&
182
182
  selectedField in cellData
183
183
  ? cellData[selectedField] || 0
184
- : 0).toLocaleString()} (${typeof cellData === 'object' && cellData !== null && 'count' in cellData ? cellData.count : 0})`;
184
+ : 0).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} (${typeof cellData === 'object' && cellData !== null && 'count' in cellData ? cellData.count : 0})`;
185
185
  }
186
186
  rowHtml += `<td class="css-1itf2nwdsdsdd"><span class="css-l5zp2sfsdfsd">${displayValue}</span></td>`;
187
187
  }
@@ -232,7 +232,7 @@ function getItemComparisonReportHtml(props) {
232
232
  const count = typeof cellData === 'object' && cellData !== null && 'count' in cellData
233
233
  ? cellData.count
234
234
  : 0;
235
- displayValue = `${currency_symbol}${amount.toLocaleString()} (${count})`;
235
+ displayValue = `${currency_symbol}${amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} (${count})`;
236
236
  }
237
237
  rowHtml += `<td class="css-1itf2nwdsdsdd"><span class="css-l5zp2sfsdfsd">${displayValue}</span></td>`;
238
238
  }
@@ -842,7 +842,7 @@ function getItemComparisonReportReceiptHtml(props) {
842
842
  const count = typeof cellData === 'object' && cellData !== null && 'count' in cellData
843
843
  ? cellData.count
844
844
  : 0;
845
- displayValue = `${amount.toLocaleString()} (${count})`;
845
+ displayValue = `${amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} (${count})`;
846
846
  }
847
847
  content += `
848
848
  <div class="receipt-item-row">
@@ -890,7 +890,7 @@ function getItemComparisonReportReceiptHtml(props) {
890
890
  const count = typeof cellData === 'object' && cellData !== null && 'count' in cellData
891
891
  ? cellData.count
892
892
  : 0;
893
- displayValue = `${amount.toLocaleString()} (${count})`;
893
+ displayValue = `${amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} (${count})`;
894
894
  }
895
895
  content += `
896
896
  <div class="receipt-item-row">
@@ -48,6 +48,8 @@ function getReceiptTypes(value) {
48
48
  const validReceiptTypes = new Set(constants_1.ALL_RECEIPT_TYPES);
49
49
  if (!Array.isArray(value))
50
50
  return [...constants_1.ALL_RECEIPT_TYPES];
51
+ if (value.length === 0)
52
+ return [];
51
53
  const receiptTypes = Array.from(new Set(value.filter((receiptType) => typeof receiptType === 'string' && validReceiptTypes.has(receiptType))));
52
54
  return receiptTypes.length > 0 ? receiptTypes : [...constants_1.ALL_RECEIPT_TYPES];
53
55
  }
@@ -93,6 +95,8 @@ function getSelectedPlatforms(value) {
93
95
  const validPlatforms = new Set(constants_1.ALL_PLATFORMS);
94
96
  if (!Array.isArray(value))
95
97
  return [...constants_1.ALL_PLATFORMS];
98
+ if (value.length === 0)
99
+ return [];
96
100
  const selectedPlatforms = Array.from(new Set(value.filter((platform) => typeof platform === 'string' && validPlatforms.has(platform))));
97
101
  return selectedPlatforms.length > 0 ? selectedPlatforms : [...constants_1.ALL_PLATFORMS];
98
102
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const printer_helpers_1 = require("../helpers/utils/printer-helpers");
5
+ describe('syncPrinterSettingsFields receiptTypes', () => {
6
+ it('preserves explicit empty receiptTypes arrays', () => {
7
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
8
+ receiptTypes: [],
9
+ });
10
+ expect(result.receiptTypes).toEqual([]);
11
+ });
12
+ it('falls back to all receiptTypes when input is not an array', () => {
13
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
14
+ receiptTypes: 'invalid',
15
+ });
16
+ expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
17
+ });
18
+ it('falls back to all receiptTypes when array has only invalid values', () => {
19
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
20
+ receiptTypes: ['invalid'],
21
+ });
22
+ expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
23
+ });
24
+ it('keeps only valid deduplicated receiptTypes', () => {
25
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
26
+ receiptTypes: [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER, 'invalid', constants_1.RECEIPT_TYPE_ENUM.CUSTOMER],
27
+ });
28
+ expect(result.receiptTypes).toEqual([constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]);
29
+ });
30
+ });
31
+ describe('syncPrinterSettingsFields selectedPlatforms', () => {
32
+ it('preserves explicit empty selectedPlatforms arrays', () => {
33
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
34
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
35
+ selectedPlatforms: [],
36
+ },
37
+ [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
38
+ selectedPlatforms: [],
39
+ },
40
+ });
41
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([]);
42
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual([]);
43
+ });
44
+ it('falls back to all selectedPlatforms when array has only invalid values', () => {
45
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
46
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
47
+ selectedPlatforms: ['invalid'],
48
+ },
49
+ [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
50
+ selectedPlatforms: ['invalid'],
51
+ },
52
+ });
53
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
54
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
55
+ });
56
+ it('keeps only valid deduplicated selectedPlatforms', () => {
57
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
58
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
59
+ selectedPlatforms: [constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY, 'invalid', constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY],
60
+ },
61
+ });
62
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY]);
63
+ });
64
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.360",
3
+ "version": "0.2.362",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",