@pisell/pisellos 2.3.141 → 2.3.142
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/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +8 -0
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/server/index.js +118 -69
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.d.ts +2 -0
- package/dist/shared/receipt/small-ticket.js +188 -73
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/OrderInvoicePreview/index.js +2 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +8 -0
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/server/index.js +68 -28
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.d.ts +2 -0
- package/lib/shared/receipt/small-ticket.js +113 -22
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/OrderInvoicePreview/index.js +2 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ exports.hasSmallTicketData = hasSmallTicketData;
|
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
9
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
10
|
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
11
|
+
var _templateVisibility = require("./templateVisibility");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
const DEFAULT_LOCALES = ['en', 'zh_CN'];
|
|
13
14
|
|
|
@@ -291,12 +292,14 @@ function buildSmallTicketData(params) {
|
|
|
291
292
|
const shopInfo = params.shopInfo || {};
|
|
292
293
|
const locales = resolveLocales(shopInfo, params.locales);
|
|
293
294
|
const productMap = params.productMap || {};
|
|
295
|
+
const visibility = (0, _templateVisibility.resolveInvoiceDataVisibility)(params.templateSettings);
|
|
294
296
|
const result = locales.reduce((data, locale) => {
|
|
295
297
|
data[locale] = buildLocaleData({
|
|
296
298
|
order,
|
|
297
299
|
shopInfo,
|
|
298
300
|
locale,
|
|
299
|
-
productMap
|
|
301
|
+
productMap,
|
|
302
|
+
visibility
|
|
300
303
|
});
|
|
301
304
|
return data;
|
|
302
305
|
}, {});
|
|
@@ -311,13 +314,14 @@ function buildLocaleData(params) {
|
|
|
311
314
|
order,
|
|
312
315
|
shopInfo,
|
|
313
316
|
locale,
|
|
314
|
-
productMap
|
|
317
|
+
productMap,
|
|
318
|
+
visibility
|
|
315
319
|
} = params;
|
|
316
320
|
const products = buildProducts(order, locale, productMap);
|
|
317
321
|
const summary = getSummary(order);
|
|
318
322
|
const currencySymbol = getCurrencySymbol(order, shopInfo);
|
|
319
323
|
const financials = resolveReceiptFinancials(order, summary);
|
|
320
|
-
const delivery = buildDelivery(order, locale);
|
|
324
|
+
const delivery = buildDelivery(order, locale, visibility.handover);
|
|
321
325
|
return {
|
|
322
326
|
base_data: buildBaseData({
|
|
323
327
|
order,
|
|
@@ -336,7 +340,7 @@ function buildLocaleData(params) {
|
|
|
336
340
|
currencySymbol,
|
|
337
341
|
financials
|
|
338
342
|
}),
|
|
339
|
-
customer: buildCustomer(order, locale),
|
|
343
|
+
customer: buildCustomer(order, locale, visibility.customer),
|
|
340
344
|
appointment: buildAppointment(order, locale),
|
|
341
345
|
...(delivery.length ? {
|
|
342
346
|
delivery
|
|
@@ -347,12 +351,15 @@ function buildLocaleData(params) {
|
|
|
347
351
|
locale,
|
|
348
352
|
currencySymbol
|
|
349
353
|
}),
|
|
350
|
-
wallets: buildWallets({
|
|
354
|
+
wallets: visibility.card.show ? buildWallets({
|
|
351
355
|
order,
|
|
352
356
|
locale,
|
|
353
|
-
currencySymbol
|
|
354
|
-
|
|
355
|
-
|
|
357
|
+
currencySymbol,
|
|
358
|
+
passTypes: visibility.card.passTypes
|
|
359
|
+
}) : [],
|
|
360
|
+
// Native printers fall back to tickets when wallets is empty. Legacy rows
|
|
361
|
+
// have no trustworthy asset tags, so they cannot bypass a card whitelist.
|
|
362
|
+
tickets: visibility.card.show && visibility.card.passTypes === null && Array.isArray(order.tickets) ? order.tickets.map(group => Array.isArray(group) ? group.map(row => row && typeof row === 'object' ? {
|
|
356
363
|
...row,
|
|
357
364
|
...receiptKey(row, 'ticket')
|
|
358
365
|
} : row) : group) : [],
|
|
@@ -1240,7 +1247,9 @@ function calculateProductOriginalAmount(order) {
|
|
|
1240
1247
|
return total.plus(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity));
|
|
1241
1248
|
}, new _decimal.default(0));
|
|
1242
1249
|
}
|
|
1243
|
-
function buildCustomer(order, locale) {
|
|
1250
|
+
function buildCustomer(order, locale, visibility) {
|
|
1251
|
+
if (!visibility.show) return [];
|
|
1252
|
+
const fields = [visibility.name, visibility.phone, visibility.email];
|
|
1244
1253
|
return [{
|
|
1245
1254
|
...receiptKey(order, 'customer.contactName'),
|
|
1246
1255
|
item: label(locale, 'contactName'),
|
|
@@ -1253,7 +1262,7 @@ function buildCustomer(order, locale) {
|
|
|
1253
1262
|
...receiptKey(order, 'customer.email'),
|
|
1254
1263
|
item: label(locale, 'email'),
|
|
1255
1264
|
value: stringify(order.email || order.customer?.email)
|
|
1256
|
-
}];
|
|
1265
|
+
}].filter((_row, index) => fields[index]);
|
|
1257
1266
|
}
|
|
1258
1267
|
function normalizeCustomerDisplayValue(value) {
|
|
1259
1268
|
const text = stringify(value).trim();
|
|
@@ -1261,16 +1270,18 @@ function normalizeCustomerDisplayValue(value) {
|
|
|
1261
1270
|
if (text.toLowerCase() === 'select a customer') return 'Walk-In';
|
|
1262
1271
|
return text;
|
|
1263
1272
|
}
|
|
1264
|
-
function buildDelivery(order, locale) {
|
|
1273
|
+
function buildDelivery(order, locale, visibility) {
|
|
1274
|
+
if (!visibility.show) return [];
|
|
1265
1275
|
const serviceType = stringify(order.metadata?.shop_service_data?.service_type).trim();
|
|
1266
1276
|
const serviceTypeLabelKey = resolveServiceTypeLabelKey(serviceType);
|
|
1267
1277
|
if (!serviceTypeLabelKey) return [];
|
|
1268
|
-
const items = [{
|
|
1278
|
+
const items = visibility.method ? [{
|
|
1269
1279
|
...receiptKey(order, 'service-type'),
|
|
1270
1280
|
item: label(locale, serviceTypeLabelKey),
|
|
1271
1281
|
value: '',
|
|
1272
1282
|
size: 2
|
|
1273
|
-
}];
|
|
1283
|
+
}] : [];
|
|
1284
|
+
if (!visibility.fulfillmentTime) return items;
|
|
1274
1285
|
if (serviceType === 'pick_up') {
|
|
1275
1286
|
const pickupTime = formatPickupBookingStart(order.bookings, locale);
|
|
1276
1287
|
if (pickupTime) {
|
|
@@ -1563,9 +1574,77 @@ function resolveRefundPayment(refund, payments) {
|
|
|
1563
1574
|
const matchedPayment = payments.find(payment => isSameId(firstPresentValue(payment.order_payment_id, payment.id), orderPaymentId));
|
|
1564
1575
|
return matchedPayment || refund;
|
|
1565
1576
|
}
|
|
1577
|
+
function getPaymentWalletAssetIdentity(payment) {
|
|
1578
|
+
const record = getFundRecord(payment);
|
|
1579
|
+
return {
|
|
1580
|
+
id: firstNormalizedWalletAssetId(record?.voucher_id, payment.voucher_id),
|
|
1581
|
+
codes: normalizeWalletAssetCodes(record?.code, record?.encoded)
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function getProductWalletAssetTag(record) {
|
|
1585
|
+
// Rules normalizes product_discount_card to type=discount_card. That
|
|
1586
|
+
// ambiguous alias cannot establish the original asset tag for a whitelist.
|
|
1587
|
+
for (const tag of [record.tag, record.discount?.tag]) {
|
|
1588
|
+
if (typeof tag === 'string' && tag) return tag;
|
|
1589
|
+
}
|
|
1590
|
+
for (const type of [record.type, record.discount?.type]) {
|
|
1591
|
+
if (typeof type === 'string' && type !== 'discount_card' && PRODUCT_WALLET_DISCOUNT_TYPES.has(type)) return type;
|
|
1592
|
+
}
|
|
1593
|
+
return undefined;
|
|
1594
|
+
}
|
|
1595
|
+
function createWalletAssetFilter(order, passTypes) {
|
|
1596
|
+
if (passTypes === null) return () => true;
|
|
1597
|
+
const assets = [];
|
|
1598
|
+
const remember = (identity, tag) => {
|
|
1599
|
+
if (typeof tag === 'string' && tag && (identity.id || identity.codes.length)) assets.push({
|
|
1600
|
+
identity,
|
|
1601
|
+
tag
|
|
1602
|
+
});
|
|
1603
|
+
};
|
|
1604
|
+
for (const asset of [...normalizeArray(order.vouchers), ...normalizeArray(order.order_meta_list?.point_cards_snapshot), ...normalizeArray(order.order_meta_list?.virtual_currency_snapshot)]) {
|
|
1605
|
+
if (asset && typeof asset === 'object') remember(getVoucherAssetIdentity(asset), asset.tag);
|
|
1606
|
+
}
|
|
1607
|
+
// Some order snapshots retain the original selected assets at the root.
|
|
1608
|
+
// Only their explicit tag is authoritative; do not infer it from type.
|
|
1609
|
+
for (const record of normalizeArray(order.discount_list)) {
|
|
1610
|
+
if (!record || typeof record !== 'object') continue;
|
|
1611
|
+
remember({
|
|
1612
|
+
id: getProductWalletDiscountAssetId(record),
|
|
1613
|
+
codes: getProductWalletDiscountCodes(record)
|
|
1614
|
+
}, record.tag ?? record.discount?.tag);
|
|
1615
|
+
}
|
|
1616
|
+
const visit = product => {
|
|
1617
|
+
if (!product || typeof product !== 'object') return;
|
|
1618
|
+
for (const record of normalizeArray(product.discount_list)) {
|
|
1619
|
+
if (!record || typeof record !== 'object') continue;
|
|
1620
|
+
remember({
|
|
1621
|
+
id: getProductWalletDiscountAssetId(record),
|
|
1622
|
+
codes: getProductWalletDiscountCodes(record)
|
|
1623
|
+
}, getProductWalletAssetTag(record));
|
|
1624
|
+
}
|
|
1625
|
+
for (const key of ['combinations', 'product_bundle', 'bundle']) normalizeArray(product[key]).forEach(visit);
|
|
1626
|
+
};
|
|
1627
|
+
normalizeArray(order.products).forEach(product => {
|
|
1628
|
+
if (product && typeof product === 'object') visit(restoreReceiptDiscountHierarchy(product));
|
|
1629
|
+
});
|
|
1630
|
+
return (identity, tag, resolvePaymentSource = false) => {
|
|
1631
|
+
const directTag = typeof tag === 'string' && tag ? tag : undefined;
|
|
1632
|
+
if (directTag && !resolvePaymentSource) return passTypes.has(directTag);
|
|
1633
|
+
const exactMatches = identity.id ? assets.filter(asset => asset.identity.id === identity.id) : [];
|
|
1634
|
+
// A known asset ID is stronger than an unrelated code-only snapshot.
|
|
1635
|
+
const matches = exactMatches.length ? exactMatches : assets.filter(asset => isSameWalletAssetIdentity(asset.identity, identity));
|
|
1636
|
+
const tags = new Set(matches.map(asset => asset.tag));
|
|
1637
|
+
if (!tags.size) return !!directTag && passTypes.has(directTag);
|
|
1638
|
+
// A conflicting fund record is not reliable evidence for a payment's tag.
|
|
1639
|
+
// It must not claim the identity ahead of the original typed asset.
|
|
1640
|
+
if (tags.size !== 1 || directTag && !tags.has(directTag)) return false;
|
|
1641
|
+
return passTypes.has(matches[0].tag);
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1566
1644
|
function buildWallets(params) {
|
|
1567
|
-
const
|
|
1568
|
-
const
|
|
1645
|
+
const allowAsset = createWalletAssetFilter(params.order, params.passTypes);
|
|
1646
|
+
const virtualCurrencySnapshots = collectVirtualCurrencySnapshots(params.order, allowAsset);
|
|
1647
|
+
const displayedWalletPayments = normalizeArray(params.order.payments).filter(payment => isPrintablePayment(payment) && !!getFundRecord(payment) && allowAsset(getPaymentWalletAssetIdentity(payment), getFundRecord(payment)?.tag, true));
|
|
1569
1648
|
const paymentWallets = displayedWalletPayments.map(payment => {
|
|
1570
1649
|
const virtualCurrencySnapshot = findVirtualCurrencySnapshotForPayment(payment, virtualCurrencySnapshots.byId);
|
|
1571
1650
|
return buildPaymentItems({
|
|
@@ -1581,20 +1660,24 @@ function buildWallets(params) {
|
|
|
1581
1660
|
const displayedWalletAssetIdentities = collectDisplayedWalletAssetIdentities(displayedWalletPayments);
|
|
1582
1661
|
const voucherWallets = buildVoucherAssets({
|
|
1583
1662
|
...params,
|
|
1663
|
+
allowAsset,
|
|
1584
1664
|
displayedWalletAssetIdentities
|
|
1585
1665
|
});
|
|
1586
1666
|
const productDiscountWallets = buildProductDiscountAssets({
|
|
1587
1667
|
...params,
|
|
1668
|
+
allowAsset,
|
|
1588
1669
|
displayedWalletAssetIdentities
|
|
1589
1670
|
});
|
|
1590
1671
|
return [...paymentWallets, ...voucherWallets, ...productDiscountWallets, ...buildPointCardSnapshotAssets({
|
|
1591
1672
|
order: params.order,
|
|
1592
1673
|
locale: params.locale,
|
|
1674
|
+
allowAsset,
|
|
1593
1675
|
displayedWalletAssetIdentities
|
|
1594
1676
|
}), ...buildVirtualCurrencySnapshotAssets({
|
|
1595
1677
|
snapshots: virtualCurrencySnapshots.items,
|
|
1596
1678
|
order: params.order,
|
|
1597
1679
|
locale: params.locale,
|
|
1680
|
+
allowAsset,
|
|
1598
1681
|
displayedWalletAssetIdentities
|
|
1599
1682
|
})];
|
|
1600
1683
|
}
|
|
@@ -1623,7 +1706,7 @@ function collectDisplayedWalletAssetIdentities(payments) {
|
|
|
1623
1706
|
const PRODUCT_WALLET_DISCOUNT_TYPES = new Set(['good_pass', 'discount_card', 'product_discount_card', 'entitlement_pass']);
|
|
1624
1707
|
function buildProductDiscountAssets(params) {
|
|
1625
1708
|
const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1626
|
-
return collectProductWalletDiscountAssets(params.order).flatMap(asset => {
|
|
1709
|
+
return collectProductWalletDiscountAssets(params.order, params.allowAsset).flatMap(asset => {
|
|
1627
1710
|
if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1628
1711
|
id: asset.id,
|
|
1629
1712
|
codes: asset.codes
|
|
@@ -1667,16 +1750,16 @@ function buildProductDiscountAssets(params) {
|
|
|
1667
1750
|
}] : []), ...(timeRow ? [timeRow] : [])]];
|
|
1668
1751
|
});
|
|
1669
1752
|
}
|
|
1670
|
-
function collectProductWalletDiscountAssets(order) {
|
|
1753
|
+
function collectProductWalletDiscountAssets(order, allowAsset) {
|
|
1671
1754
|
const assets = [];
|
|
1672
1755
|
const assetsById = new Map();
|
|
1673
1756
|
normalizeArray(order.products).forEach(rawProduct => {
|
|
1674
1757
|
if (!rawProduct || typeof rawProduct !== 'object') return;
|
|
1675
|
-
visitProductWalletDiscounts(restoreReceiptDiscountHierarchy(rawProduct), assets, assetsById);
|
|
1758
|
+
visitProductWalletDiscounts(restoreReceiptDiscountHierarchy(rawProduct), assets, assetsById, allowAsset);
|
|
1676
1759
|
});
|
|
1677
1760
|
return assets;
|
|
1678
1761
|
}
|
|
1679
|
-
function visitProductWalletDiscounts(product, assets, assetsById) {
|
|
1762
|
+
function visitProductWalletDiscounts(product, assets, assetsById, allowAsset) {
|
|
1680
1763
|
normalizeArray(product.discount_list).forEach(record => {
|
|
1681
1764
|
if (!record || typeof record !== 'object' || Array.isArray(record)) return;
|
|
1682
1765
|
const type = getProductWalletDiscountType(record);
|
|
@@ -1684,6 +1767,10 @@ function visitProductWalletDiscounts(product, assets, assetsById) {
|
|
|
1684
1767
|
const id = getProductWalletDiscountAssetId(record);
|
|
1685
1768
|
if (!id) return;
|
|
1686
1769
|
const codes = getProductWalletDiscountCodes(record);
|
|
1770
|
+
if (allowAsset && !allowAsset({
|
|
1771
|
+
id,
|
|
1772
|
+
codes
|
|
1773
|
+
}, getProductWalletAssetTag(record))) return;
|
|
1687
1774
|
const existing = assetsById.get(id);
|
|
1688
1775
|
if (existing) {
|
|
1689
1776
|
existing.records.push(record);
|
|
@@ -1702,7 +1789,7 @@ function visitProductWalletDiscounts(product, assets, assetsById) {
|
|
|
1702
1789
|
for (const childKey of ['combinations', 'product_bundle', 'bundle']) {
|
|
1703
1790
|
normalizeArray(product[childKey]).forEach(child => {
|
|
1704
1791
|
if (!child || typeof child !== 'object' || Array.isArray(child)) return;
|
|
1705
|
-
visitProductWalletDiscounts(child, assets, assetsById);
|
|
1792
|
+
visitProductWalletDiscounts(child, assets, assetsById, allowAsset);
|
|
1706
1793
|
});
|
|
1707
1794
|
}
|
|
1708
1795
|
}
|
|
@@ -1818,6 +1905,7 @@ function buildPointCardSnapshotAssets(params) {
|
|
|
1818
1905
|
const pointCard = snapshot;
|
|
1819
1906
|
if (stringify(pointCard.tag).trim().toLowerCase() !== 'point_card') return [];
|
|
1820
1907
|
const assetId = normalizeWalletPassId(pointCard.id);
|
|
1908
|
+
if (!params.allowAsset(getVoucherAssetIdentity(pointCard), pointCard.tag)) return [];
|
|
1821
1909
|
if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1822
1910
|
id: assetId,
|
|
1823
1911
|
codes: []
|
|
@@ -1845,7 +1933,7 @@ function buildPointCardSnapshotAssets(params) {
|
|
|
1845
1933
|
return [rows];
|
|
1846
1934
|
});
|
|
1847
1935
|
}
|
|
1848
|
-
function collectVirtualCurrencySnapshots(order) {
|
|
1936
|
+
function collectVirtualCurrencySnapshots(order, allowAsset) {
|
|
1849
1937
|
const items = [];
|
|
1850
1938
|
const byId = new Map();
|
|
1851
1939
|
const snapshots = order.order_meta_list?.virtual_currency_snapshot;
|
|
@@ -1857,6 +1945,7 @@ function collectVirtualCurrencySnapshots(order) {
|
|
|
1857
1945
|
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) return;
|
|
1858
1946
|
const virtualCurrency = snapshot;
|
|
1859
1947
|
if (stringify(virtualCurrency.tag).trim().toLowerCase() !== 'virtual_currency') return;
|
|
1948
|
+
if (!allowAsset(getVoucherAssetIdentity(virtualCurrency), virtualCurrency.tag)) return;
|
|
1860
1949
|
const id = normalizeWalletPassId(virtualCurrency.id);
|
|
1861
1950
|
if (!id || byId.has(id)) return;
|
|
1862
1951
|
byId.set(id, virtualCurrency);
|
|
@@ -1881,13 +1970,14 @@ function buildVirtualCurrencySnapshotAssets(params) {
|
|
|
1881
1970
|
const snapshotTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1882
1971
|
return params.snapshots.flatMap(virtualCurrency => {
|
|
1883
1972
|
const assetId = normalizeWalletPassId(virtualCurrency.id);
|
|
1973
|
+
if (!params.allowAsset(getVoucherAssetIdentity(virtualCurrency), virtualCurrency.tag)) return [];
|
|
1884
1974
|
if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1885
1975
|
id: assetId,
|
|
1886
1976
|
codes: []
|
|
1887
1977
|
})) return [];
|
|
1888
1978
|
const rows = [{
|
|
1889
1979
|
...receiptKey(virtualCurrency, 'asset-name'),
|
|
1890
|
-
item: stringify(virtualCurrency.product_name).trim(),
|
|
1980
|
+
item: appendMaskedCardCode(stringify(virtualCurrency.product_name).trim(), virtualCurrency.code),
|
|
1891
1981
|
value: ''
|
|
1892
1982
|
}];
|
|
1893
1983
|
const balance = getVirtualCurrencySnapshotBalance(virtualCurrency);
|
|
@@ -1991,6 +2081,7 @@ function buildVoucherAssets(params) {
|
|
|
1991
2081
|
const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1992
2082
|
return normalizeArray(params.order.vouchers).flatMap(voucher => {
|
|
1993
2083
|
if (!voucher || typeof voucher !== 'object' || Array.isArray(voucher)) return [];
|
|
2084
|
+
if (!params.allowAsset(getVoucherAssetIdentity(voucher), voucher.tag)) return [];
|
|
1994
2085
|
if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, getVoucherAssetIdentity(voucher))) return [];
|
|
1995
2086
|
const name = getVoucherAssetName(voucher, params.locale);
|
|
1996
2087
|
const assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Template children are direct module members; legacy missing values stay visible. */
|
|
2
|
+
export interface InvoiceDataVisibility {
|
|
3
|
+
handover: {
|
|
4
|
+
show: boolean;
|
|
5
|
+
method: boolean;
|
|
6
|
+
fulfillmentTime: boolean;
|
|
7
|
+
};
|
|
8
|
+
customer: {
|
|
9
|
+
show: boolean;
|
|
10
|
+
name: boolean;
|
|
11
|
+
email: boolean;
|
|
12
|
+
phone: boolean;
|
|
13
|
+
};
|
|
14
|
+
card: {
|
|
15
|
+
show: boolean;
|
|
16
|
+
passTypes: ReadonlySet<string> | null;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare function invoiceSettingIsVisible(value: unknown): boolean;
|
|
20
|
+
export declare function getInvoiceTemplateModules(settings: unknown): Record<string, any>[];
|
|
21
|
+
export declare function resolveInvoiceDataVisibility(settings: unknown): InvoiceDataVisibility;
|
|
22
|
+
/** Whether an old unfiltered snapshot is unsafe for this template. */
|
|
23
|
+
export declare function requiresInvoiceDataFiltering(settings: unknown): boolean;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getInvoiceTemplateModules = getInvoiceTemplateModules;
|
|
7
|
+
exports.invoiceSettingIsVisible = invoiceSettingIsVisible;
|
|
8
|
+
exports.requiresInvoiceDataFiltering = requiresInvoiceDataFiltering;
|
|
9
|
+
exports.resolveInvoiceDataVisibility = resolveInvoiceDataVisibility;
|
|
10
|
+
/** Template children are direct module members; legacy missing values stay visible. */
|
|
11
|
+
|
|
12
|
+
function invoiceSettingIsVisible(value) {
|
|
13
|
+
return value !== 0 && value !== false;
|
|
14
|
+
}
|
|
15
|
+
function getInvoiceTemplateModules(settings) {
|
|
16
|
+
if (Array.isArray(settings)) return settings.filter(isRecord);
|
|
17
|
+
if (!isRecord(settings)) return [];
|
|
18
|
+
if (isRecord(settings.template_settings)) {
|
|
19
|
+
return getInvoiceTemplateModules(settings.template_settings);
|
|
20
|
+
}
|
|
21
|
+
const modules = settings.modules ?? settings.module;
|
|
22
|
+
return Array.isArray(modules) ? modules.filter(isRecord) : [];
|
|
23
|
+
}
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
function resolveInvoiceDataVisibility(settings) {
|
|
28
|
+
const modules = getInvoiceTemplateModules(settings);
|
|
29
|
+
// Native templates use the first occurrence of each module.
|
|
30
|
+
const module = key => modules.find(item => item.key === key);
|
|
31
|
+
const handover = module('handover');
|
|
32
|
+
const customer = module('customer');
|
|
33
|
+
const card = module('card');
|
|
34
|
+
const field = (config, key) => invoiceSettingIsVisible(config?.[key]?.is_show);
|
|
35
|
+
const passTypes = Array.isArray(card?.pass_type) && card.pass_type.length > 0 ? new Set(card.pass_type.filter(tag => typeof tag === 'string' && tag.length > 0)) : null;
|
|
36
|
+
return {
|
|
37
|
+
handover: {
|
|
38
|
+
show: invoiceSettingIsVisible(handover?.is_show),
|
|
39
|
+
method: field(handover, 'method'),
|
|
40
|
+
fulfillmentTime: field(handover, 'fulfillment_time')
|
|
41
|
+
},
|
|
42
|
+
customer: {
|
|
43
|
+
show: invoiceSettingIsVisible(customer?.is_show),
|
|
44
|
+
name: field(customer, 'name'),
|
|
45
|
+
email: field(customer, 'email'),
|
|
46
|
+
phone: field(customer, 'phone')
|
|
47
|
+
},
|
|
48
|
+
card: {
|
|
49
|
+
show: invoiceSettingIsVisible(card?.is_show),
|
|
50
|
+
passTypes
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Whether an old unfiltered snapshot is unsafe for this template. */
|
|
56
|
+
function requiresInvoiceDataFiltering(settings) {
|
|
57
|
+
const {
|
|
58
|
+
handover,
|
|
59
|
+
customer,
|
|
60
|
+
card
|
|
61
|
+
} = resolveInvoiceDataVisibility(settings);
|
|
62
|
+
return !handover.show || !handover.method || !handover.fulfillmentTime || !customer.show || !customer.name || !customer.email || !customer.phone || !card.show || card.passTypes !== null;
|
|
63
|
+
}
|
|
@@ -210,6 +210,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
210
210
|
* product: ProductData;
|
|
211
211
|
* date?: { startTime: string; endTime: string } | null;
|
|
212
212
|
* account?: Account | null;
|
|
213
|
+
* isLegacyOrder?: boolean;
|
|
213
214
|
* })} {
|
|
214
215
|
* product,
|
|
215
216
|
* date,
|
|
@@ -218,13 +219,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
218
219
|
* @return {*}
|
|
219
220
|
* @memberof BookingByStepImpl
|
|
220
221
|
*/
|
|
221
|
-
addProductToCart({ product, date, account, }: {
|
|
222
|
+
addProductToCart({ product, date, account, isLegacyOrder, }: {
|
|
222
223
|
product: ProductData;
|
|
223
224
|
date?: {
|
|
224
225
|
startTime: string;
|
|
225
226
|
endTime: string;
|
|
226
227
|
} | null;
|
|
227
228
|
account?: Account | null;
|
|
229
|
+
isLegacyOrder?: boolean;
|
|
228
230
|
}): {
|
|
229
231
|
success: boolean;
|
|
230
232
|
errorCode?: string;
|
|
@@ -326,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
328
|
date: string;
|
|
327
329
|
status: string;
|
|
328
330
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
330
332
|
}[]>;
|
|
331
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
334
|
private getScheduleDataByIds;
|
|
@@ -636,7 +636,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
636
636
|
// 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
|
|
637
637
|
return this.addProductToCart({
|
|
638
638
|
product: productData,
|
|
639
|
-
account: activeAccount
|
|
639
|
+
account: activeAccount,
|
|
640
|
+
isLegacyOrder: true
|
|
640
641
|
});
|
|
641
642
|
}
|
|
642
643
|
|
|
@@ -647,6 +648,7 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
647
648
|
* product: ProductData;
|
|
648
649
|
* date?: { startTime: string; endTime: string } | null;
|
|
649
650
|
* account?: Account | null;
|
|
651
|
+
* isLegacyOrder?: boolean;
|
|
650
652
|
* })} {
|
|
651
653
|
* product,
|
|
652
654
|
* date,
|
|
@@ -658,7 +660,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
658
660
|
addProductToCart({
|
|
659
661
|
product,
|
|
660
662
|
date,
|
|
661
|
-
account
|
|
663
|
+
account,
|
|
664
|
+
isLegacyOrder = false
|
|
662
665
|
}) {
|
|
663
666
|
const {
|
|
664
667
|
bundle,
|
|
@@ -725,7 +728,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
725
728
|
product: productData,
|
|
726
729
|
bundle,
|
|
727
730
|
options,
|
|
728
|
-
quantity
|
|
731
|
+
quantity,
|
|
732
|
+
isLegacyOrder
|
|
729
733
|
};
|
|
730
734
|
if (date) {
|
|
731
735
|
addItemParams.date = date;
|
|
@@ -165,7 +165,8 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
165
165
|
order: source,
|
|
166
166
|
shopInfo: shop,
|
|
167
167
|
locales: [...new Set(languageOptions.flatMap(option => option.locales))],
|
|
168
|
-
includeReceiptKeys: true
|
|
168
|
+
includeReceiptKeys: true,
|
|
169
|
+
templateSettings: template.layout
|
|
169
170
|
})
|
|
170
171
|
};
|
|
171
172
|
this.publish({
|