@pisell/private-materials 6.12.306 → 6.12.308
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +12 -12
- package/build/lowcode/view.js +12 -12
- package/es/plus/invoice/ReceiptRenderer.js +17 -13
- package/es/plus/invoice/invoiceVisibility.js +21 -2
- package/es/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.js +5 -3
- package/lib/plus/invoice/ReceiptRenderer.js +16 -12
- package/lib/plus/invoice/invoiceVisibility.js +23 -1
- package/lib/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.js +4 -2
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
2
|
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
|
|
3
|
-
import { isInvoiceFieldVisible, isInvoiceModuleVisible } from "./invoiceVisibility.js";
|
|
3
|
+
import { isInvoiceFieldVisible, isInvoiceModuleVisible, isInvoicePaymentTimeRow } from "./invoiceVisibility.js";
|
|
4
4
|
import { getModuleImage, getModuleText, getReceiptBookingId, getReceiptLabel, getReceiptProductTotal, multiplyReceiptMoney, receiptMoneyValuesDiffer, subtractReceiptMoney, sumReceiptMoney } from "./receipt.js";
|
|
5
5
|
import { bilingualText, mergeTranslatedRows, receiptLabel, withReceiptTranslations } from "./receiptTranslations.js";
|
|
6
6
|
import dayjs from "dayjs";
|
|
@@ -372,23 +372,27 @@ const MODULE_RENDERERS = {
|
|
|
372
372
|
"settlement/original": "original_amount",
|
|
373
373
|
"settlement/item-discounts": "item_discounts"
|
|
374
374
|
});
|
|
375
|
-
|
|
375
|
+
const summaryRows = isInvoiceFieldVisible(config, "payment_summary") ? receipt.paymentSummaryRows : [];
|
|
376
|
+
return rows.length || summaryRows.length ? /* @__PURE__ */ React.createElement("section", null, /* @__PURE__ */ React.createElement(ReceiptRows, {
|
|
376
377
|
locale: receipt.locale,
|
|
377
378
|
rows
|
|
378
|
-
})) : null
|
|
379
|
+
}), summaryRows.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, rows.length ? /* @__PURE__ */ React.createElement(ReceiptSeparator, null) : null, /* @__PURE__ */ React.createElement(ReceiptSectionTitle, null, receiptLabel(receipt, "Payment summary")), /* @__PURE__ */ React.createElement(ReceiptRows, {
|
|
380
|
+
locale: receipt.locale,
|
|
381
|
+
rows: summaryRows
|
|
382
|
+
})) : null) : null;
|
|
379
383
|
},
|
|
380
384
|
custom_2: renderCustom,
|
|
381
385
|
customer_2: renderCustom,
|
|
382
|
-
payment: ({ receipt }) =>
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
386
|
+
payment: ({ config, receipt }) => {
|
|
387
|
+
const paymentRows = isInvoiceFieldVisible(config, "time") ? receipt.paymentRows : receipt.paymentRows.map((group) => group.filter((row) => !isInvoicePaymentTimeRow(row))).filter((group) => group.length > 0);
|
|
388
|
+
return paymentRows.length || receipt.refundRows.length ? /* @__PURE__ */ React.createElement("section", null, paymentRows.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ReceiptSectionTitle, null, receiptLabel(receipt, "Payment history")), /* @__PURE__ */ React.createElement(RecordGroups, {
|
|
389
|
+
groups: paymentRows,
|
|
390
|
+
locale: receipt.locale
|
|
391
|
+
})) : null, receipt.refundRows.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ReceiptSectionTitle, null, receiptLabel(receipt, "Refund history")), /* @__PURE__ */ React.createElement(RecordGroups, {
|
|
392
|
+
groups: receipt.refundRows,
|
|
393
|
+
locale: receipt.locale
|
|
394
|
+
})) : null) : null;
|
|
395
|
+
},
|
|
392
396
|
card: ({ receipt }) => receipt.walletRows.length ? /* @__PURE__ */ React.createElement("section", null, /* @__PURE__ */ React.createElement(ReceiptSectionTitle, null, receiptLabel(receipt, "Cards & Vouchers")), /* @__PURE__ */ React.createElement(RecordGroups, {
|
|
393
397
|
groups: receipt.walletRows,
|
|
394
398
|
locale: receipt.locale
|
|
@@ -58,7 +58,12 @@ const DETAIL_FIELDS = {
|
|
|
58
58
|
"allergies",
|
|
59
59
|
"base_price"
|
|
60
60
|
],
|
|
61
|
-
settlement: [
|
|
61
|
+
settlement: [
|
|
62
|
+
"original_amount",
|
|
63
|
+
"item_discounts",
|
|
64
|
+
"payment_summary"
|
|
65
|
+
],
|
|
66
|
+
payment: ["time"],
|
|
62
67
|
total_savings: ["description"]
|
|
63
68
|
};
|
|
64
69
|
/** Select the shared virtual-currency view only for the new detail protocol. */
|
|
@@ -68,6 +73,20 @@ function hasInvoiceDetailSettings(settings) {
|
|
|
68
73
|
return child && Object.prototype.hasOwnProperty.call(child, "is_show");
|
|
69
74
|
}));
|
|
70
75
|
}
|
|
76
|
+
function isInvoicePaymentTimeRow(row) {
|
|
77
|
+
return typeof row.receipt_key === "string" && /#payment-time\/history(?:\/secondary)?$/.test(row.receipt_key);
|
|
78
|
+
}
|
|
79
|
+
/** Hiding payment time requires identifiable rows, not a date-text heuristic. */
|
|
80
|
+
function requiresInvoicePaymentTimeKeys(settings) {
|
|
81
|
+
return invoiceModules(settings).some((module) => module.key === "payment" && isInvoiceModuleVisible(module) && !isInvoiceFieldVisible(module, "time"));
|
|
82
|
+
}
|
|
83
|
+
function hasInvoicePaymentTimeKeys(data) {
|
|
84
|
+
return Object.values(data).every((localeData) => {
|
|
85
|
+
const groups = localeData.payment_data;
|
|
86
|
+
if (groups === void 0 || groups === null) return true;
|
|
87
|
+
return Array.isArray(groups) && groups.every((group) => Array.isArray(group) && (!group.length || group.every((row) => typeof (row === null || row === void 0 ? void 0 : row.receipt_key) === "string" && row.receipt_key.length > 0) && group.some(isInvoicePaymentTimeRow)));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
71
90
|
function cardRequiresFiltering(config) {
|
|
72
91
|
return Boolean(config && (!isInvoiceModuleVisible(config) || Array.isArray(config.pass_type) && config.pass_type.length > 0));
|
|
73
92
|
}
|
|
@@ -91,4 +110,4 @@ function requiresInvoiceDataFiltering(settings) {
|
|
|
91
110
|
});
|
|
92
111
|
}
|
|
93
112
|
//#endregion
|
|
94
|
-
export { hasInvoiceDetailSettings, invoiceVisibility, isInvoiceFieldVisible, isInvoiceModuleVisible, permitsLegacyWalletFallback, requiresInvoiceDataFiltering };
|
|
113
|
+
export { hasInvoiceDetailSettings, hasInvoicePaymentTimeKeys, invoiceVisibility, isInvoiceFieldVisible, isInvoiceModuleVisible, isInvoicePaymentTimeRow, permitsLegacyWalletFallback, requiresInvoiceDataFiltering, requiresInvoicePaymentTimeKeys };
|
|
@@ -4,7 +4,7 @@ import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runt
|
|
|
4
4
|
import useLocale from "../../../../../../hooks/useLocale.js";
|
|
5
5
|
import { isVirtualSettlementTempOrder } from "../../../../../multiCurrencySettlement/index.js";
|
|
6
6
|
import { getLocalOrderReceiptSnapshot, getOrderSmallTicketData } from "../../../../serve.js";
|
|
7
|
-
import { hasInvoiceDetailSettings, requiresInvoiceDataFiltering } from "../../../../../invoice/invoiceVisibility.js";
|
|
7
|
+
import { hasInvoiceDetailSettings, hasInvoicePaymentTimeKeys, requiresInvoiceDataFiltering, requiresInvoicePaymentTimeKeys } from "../../../../../invoice/invoiceVisibility.js";
|
|
8
8
|
import { buildInvoiceReceiptViewModel, formatReceiptPreviewTime, isSmallTicketData, resolveInvoiceLayoutConfig, resolveSmallTicketData, selectSmallTicketLocale } from "../../../../../invoice/receipt.js";
|
|
9
9
|
import { useEffect, useMemo, useState } from "react";
|
|
10
10
|
//#region src/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.ts
|
|
@@ -77,6 +77,7 @@ function useInvoiceReceiptPreview(context) {
|
|
|
77
77
|
const layout = yield resolveInvoiceLayoutConfig(salesModule);
|
|
78
78
|
if (cancelled) return null;
|
|
79
79
|
const mustFilter = requiresInvoiceDataFiltering(layout);
|
|
80
|
+
const needsPaymentTimeKeys = requiresInvoicePaymentTimeKeys(layout);
|
|
80
81
|
const useSharedConfig = hasInvoiceDetailSettings(layout) || mustFilter;
|
|
81
82
|
const isVirtualOrder = isVirtualSettlementTempOrder(tempOrder) || isVirtualSettlementTempOrder(salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.raw);
|
|
82
83
|
const legacyVirtualResult = {
|
|
@@ -94,16 +95,17 @@ function useInvoiceReceiptPreview(context) {
|
|
|
94
95
|
const freshSnapshot = yield getLocalOrderReceiptSnapshot(orderId, [appLocale], layout);
|
|
95
96
|
if (!freshSnapshot || !isSmallTicketData(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot is unavailable");
|
|
96
97
|
if (mustFilter && freshSnapshot.template_visibility_applied !== true) throw new Error("Receipt snapshot does not support template filtering");
|
|
98
|
+
if (needsPaymentTimeKeys && !hasInvoicePaymentTimeKeys(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot does not identify payment history times");
|
|
97
99
|
if (requiresSource && !freshSnapshot.source) throw new Error("Virtual currency receipt source is unavailable");
|
|
98
100
|
return {
|
|
99
101
|
snapshot: freshSnapshot.small_ticket_data,
|
|
100
102
|
source: freshSnapshot.source || null
|
|
101
103
|
};
|
|
102
104
|
} catch (error) {
|
|
103
|
-
if (mustFilter || requiresSource) throw error;
|
|
105
|
+
if (mustFilter || needsPaymentTimeKeys || requiresSource) throw error;
|
|
104
106
|
console.warn("[SaleDetail.Invoice] Failed to rebuild local receipt snapshot", error);
|
|
105
107
|
}
|
|
106
|
-
if (mustFilter || requiresSource) throw new Error("A template-aware local receipt snapshot is required");
|
|
108
|
+
if (mustFilter || needsPaymentTimeKeys || requiresSource) throw new Error("A template-aware local receipt snapshot is required");
|
|
107
109
|
return {
|
|
108
110
|
snapshot: embeddedSnapshot || (orderId !== null && orderId !== void 0 ? yield getOrderSmallTicketData(orderId) : null),
|
|
109
111
|
source: null
|
|
@@ -375,23 +375,27 @@ const MODULE_RENDERERS = {
|
|
|
375
375
|
"settlement/original": "original_amount",
|
|
376
376
|
"settlement/item-discounts": "item_discounts"
|
|
377
377
|
});
|
|
378
|
-
|
|
378
|
+
const summaryRows = require_invoiceVisibility.isInvoiceFieldVisible(config, "payment_summary") ? receipt.paymentSummaryRows : [];
|
|
379
|
+
return rows.length || summaryRows.length ? /* @__PURE__ */ react.default.createElement("section", null, /* @__PURE__ */ react.default.createElement(ReceiptRows, {
|
|
379
380
|
locale: receipt.locale,
|
|
380
381
|
rows
|
|
381
|
-
})) : null
|
|
382
|
+
}), summaryRows.length ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, rows.length ? /* @__PURE__ */ react.default.createElement(ReceiptSeparator, null) : null, /* @__PURE__ */ react.default.createElement(ReceiptSectionTitle, null, require_receiptTranslations.receiptLabel(receipt, "Payment summary")), /* @__PURE__ */ react.default.createElement(ReceiptRows, {
|
|
383
|
+
locale: receipt.locale,
|
|
384
|
+
rows: summaryRows
|
|
385
|
+
})) : null) : null;
|
|
382
386
|
},
|
|
383
387
|
custom_2: renderCustom,
|
|
384
388
|
customer_2: renderCustom,
|
|
385
|
-
payment: ({ receipt }) =>
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
389
|
+
payment: ({ config, receipt }) => {
|
|
390
|
+
const paymentRows = require_invoiceVisibility.isInvoiceFieldVisible(config, "time") ? receipt.paymentRows : receipt.paymentRows.map((group) => group.filter((row) => !require_invoiceVisibility.isInvoicePaymentTimeRow(row))).filter((group) => group.length > 0);
|
|
391
|
+
return paymentRows.length || receipt.refundRows.length ? /* @__PURE__ */ react.default.createElement("section", null, paymentRows.length ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(ReceiptSectionTitle, null, require_receiptTranslations.receiptLabel(receipt, "Payment history")), /* @__PURE__ */ react.default.createElement(RecordGroups, {
|
|
392
|
+
groups: paymentRows,
|
|
393
|
+
locale: receipt.locale
|
|
394
|
+
})) : null, receipt.refundRows.length ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(ReceiptSectionTitle, null, require_receiptTranslations.receiptLabel(receipt, "Refund history")), /* @__PURE__ */ react.default.createElement(RecordGroups, {
|
|
395
|
+
groups: receipt.refundRows,
|
|
396
|
+
locale: receipt.locale
|
|
397
|
+
})) : null) : null;
|
|
398
|
+
},
|
|
395
399
|
card: ({ receipt }) => receipt.walletRows.length ? /* @__PURE__ */ react.default.createElement("section", null, /* @__PURE__ */ react.default.createElement(ReceiptSectionTitle, null, require_receiptTranslations.receiptLabel(receipt, "Cards & Vouchers")), /* @__PURE__ */ react.default.createElement(RecordGroups, {
|
|
396
400
|
groups: receipt.walletRows,
|
|
397
401
|
locale: receipt.locale
|
|
@@ -58,7 +58,12 @@ const DETAIL_FIELDS = {
|
|
|
58
58
|
"allergies",
|
|
59
59
|
"base_price"
|
|
60
60
|
],
|
|
61
|
-
settlement: [
|
|
61
|
+
settlement: [
|
|
62
|
+
"original_amount",
|
|
63
|
+
"item_discounts",
|
|
64
|
+
"payment_summary"
|
|
65
|
+
],
|
|
66
|
+
payment: ["time"],
|
|
62
67
|
total_savings: ["description"]
|
|
63
68
|
};
|
|
64
69
|
/** Select the shared virtual-currency view only for the new detail protocol. */
|
|
@@ -68,6 +73,20 @@ function hasInvoiceDetailSettings(settings) {
|
|
|
68
73
|
return child && Object.prototype.hasOwnProperty.call(child, "is_show");
|
|
69
74
|
}));
|
|
70
75
|
}
|
|
76
|
+
function isInvoicePaymentTimeRow(row) {
|
|
77
|
+
return typeof row.receipt_key === "string" && /#payment-time\/history(?:\/secondary)?$/.test(row.receipt_key);
|
|
78
|
+
}
|
|
79
|
+
/** Hiding payment time requires identifiable rows, not a date-text heuristic. */
|
|
80
|
+
function requiresInvoicePaymentTimeKeys(settings) {
|
|
81
|
+
return invoiceModules(settings).some((module) => module.key === "payment" && isInvoiceModuleVisible(module) && !isInvoiceFieldVisible(module, "time"));
|
|
82
|
+
}
|
|
83
|
+
function hasInvoicePaymentTimeKeys(data) {
|
|
84
|
+
return Object.values(data).every((localeData) => {
|
|
85
|
+
const groups = localeData.payment_data;
|
|
86
|
+
if (groups === void 0 || groups === null) return true;
|
|
87
|
+
return Array.isArray(groups) && groups.every((group) => Array.isArray(group) && (!group.length || group.every((row) => typeof (row === null || row === void 0 ? void 0 : row.receipt_key) === "string" && row.receipt_key.length > 0) && group.some(isInvoicePaymentTimeRow)));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
71
90
|
function cardRequiresFiltering(config) {
|
|
72
91
|
return Boolean(config && (!isInvoiceModuleVisible(config) || Array.isArray(config.pass_type) && config.pass_type.length > 0));
|
|
73
92
|
}
|
|
@@ -92,8 +111,11 @@ function requiresInvoiceDataFiltering(settings) {
|
|
|
92
111
|
}
|
|
93
112
|
//#endregion
|
|
94
113
|
exports.hasInvoiceDetailSettings = hasInvoiceDetailSettings;
|
|
114
|
+
exports.hasInvoicePaymentTimeKeys = hasInvoicePaymentTimeKeys;
|
|
95
115
|
exports.invoiceVisibility = invoiceVisibility;
|
|
96
116
|
exports.isInvoiceFieldVisible = isInvoiceFieldVisible;
|
|
97
117
|
exports.isInvoiceModuleVisible = isInvoiceModuleVisible;
|
|
118
|
+
exports.isInvoicePaymentTimeRow = isInvoicePaymentTimeRow;
|
|
98
119
|
exports.permitsLegacyWalletFallback = permitsLegacyWalletFallback;
|
|
99
120
|
exports.requiresInvoiceDataFiltering = requiresInvoiceDataFiltering;
|
|
121
|
+
exports.requiresInvoicePaymentTimeKeys = requiresInvoicePaymentTimeKeys;
|
|
@@ -78,6 +78,7 @@ function useInvoiceReceiptPreview(context) {
|
|
|
78
78
|
const layout = yield require_receipt.resolveInvoiceLayoutConfig(salesModule);
|
|
79
79
|
if (cancelled) return null;
|
|
80
80
|
const mustFilter = require_invoiceVisibility.requiresInvoiceDataFiltering(layout);
|
|
81
|
+
const needsPaymentTimeKeys = require_invoiceVisibility.requiresInvoicePaymentTimeKeys(layout);
|
|
81
82
|
const useSharedConfig = require_invoiceVisibility.hasInvoiceDetailSettings(layout) || mustFilter;
|
|
82
83
|
const isVirtualOrder = require_index.isVirtualSettlementTempOrder(tempOrder) || require_index.isVirtualSettlementTempOrder(salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.raw);
|
|
83
84
|
const legacyVirtualResult = {
|
|
@@ -95,16 +96,17 @@ function useInvoiceReceiptPreview(context) {
|
|
|
95
96
|
const freshSnapshot = yield require_serve.getLocalOrderReceiptSnapshot(orderId, [appLocale], layout);
|
|
96
97
|
if (!freshSnapshot || !require_receipt.isSmallTicketData(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot is unavailable");
|
|
97
98
|
if (mustFilter && freshSnapshot.template_visibility_applied !== true) throw new Error("Receipt snapshot does not support template filtering");
|
|
99
|
+
if (needsPaymentTimeKeys && !require_invoiceVisibility.hasInvoicePaymentTimeKeys(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot does not identify payment history times");
|
|
98
100
|
if (requiresSource && !freshSnapshot.source) throw new Error("Virtual currency receipt source is unavailable");
|
|
99
101
|
return {
|
|
100
102
|
snapshot: freshSnapshot.small_ticket_data,
|
|
101
103
|
source: freshSnapshot.source || null
|
|
102
104
|
};
|
|
103
105
|
} catch (error) {
|
|
104
|
-
if (mustFilter || requiresSource) throw error;
|
|
106
|
+
if (mustFilter || needsPaymentTimeKeys || requiresSource) throw error;
|
|
105
107
|
console.warn("[SaleDetail.Invoice] Failed to rebuild local receipt snapshot", error);
|
|
106
108
|
}
|
|
107
|
-
if (mustFilter || requiresSource) throw new Error("A template-aware local receipt snapshot is required");
|
|
109
|
+
if (mustFilter || needsPaymentTimeKeys || requiresSource) throw new Error("A template-aware local receipt snapshot is required");
|
|
108
110
|
return {
|
|
109
111
|
snapshot: embeddedSnapshot || (orderId !== null && orderId !== void 0 ? yield require_serve.getOrderSmallTicketData(orderId) : null),
|
|
110
112
|
source: null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.308",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"styled-components": "^6.0.0-rc.3",
|
|
73
73
|
"use-sync-external-store": "^1.6.0",
|
|
74
74
|
"@pisell/pi-payment-sdk": "0.0.3",
|
|
75
|
-
"@pisell/utils": "3.0.7",
|
|
76
75
|
"@pisell/icon": "0.0.11",
|
|
77
|
-
"@pisell/
|
|
78
|
-
"@pisell/date-picker": "3.0.12"
|
|
76
|
+
"@pisell/utils": "3.0.7",
|
|
77
|
+
"@pisell/date-picker": "3.0.12",
|
|
78
|
+
"@pisell/materials": "6.12.78"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"react": "^18.0.0",
|