rerobe-js-orm 4.9.6 → 4.9.7
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.
|
@@ -693,11 +693,12 @@ class OrderHelpers {
|
|
|
693
693
|
}
|
|
694
694
|
let info = additionalInfo;
|
|
695
695
|
// Derive the return-policy line from the structured policy for the order's
|
|
696
|
-
// sales channel
|
|
697
|
-
// shown on refund receipts.
|
|
696
|
+
// sales channel, localized to the receipt's presentment locale (legacy
|
|
697
|
+
// free-text policies pass through unchanged). Never shown on refund receipts.
|
|
698
|
+
const returnPolicyTemplate = translations_1.returnPolicyReceiptTranslations[presentmentLocale] || translations_1.returnPolicyReceiptTranslations['en-US'];
|
|
698
699
|
const returnPolicyText = isRefund
|
|
699
700
|
? ''
|
|
700
|
-
: ReturnPolicyHelpers_1.default.returnPolicyReceiptText(returnPolicy, (_d = order.salesChannel) !== null && _d !== void 0 ? _d : undefined);
|
|
701
|
+
: ReturnPolicyHelpers_1.default.returnPolicyReceiptText(returnPolicy, (_d = order.salesChannel) !== null && _d !== void 0 ? _d : undefined, returnPolicyTemplate);
|
|
701
702
|
if (returnPolicyText) {
|
|
702
703
|
info = returnPolicyText;
|
|
703
704
|
if (additionalInfo) {
|
|
@@ -33,7 +33,7 @@ export default class ReturnPolicyHelpers {
|
|
|
33
33
|
soldAtMillis?: number;
|
|
34
34
|
nowMillis?: number;
|
|
35
35
|
}): ReturnEvaluation;
|
|
36
|
-
static returnPolicyReceiptText(raw: any, salesChannel?: string): string;
|
|
36
|
+
static returnPolicyReceiptText(raw: any, salesChannel?: string, template?: string): string;
|
|
37
37
|
static resolveEffectiveReturnPolicy({ ownPolicyRaw, marketplaceDefaultRaw, isManaged, }: {
|
|
38
38
|
ownPolicyRaw?: any;
|
|
39
39
|
marketplaceDefaultRaw?: any;
|
|
@@ -167,7 +167,12 @@ class ReturnPolicyHelpers {
|
|
|
167
167
|
// unchanged. For a structured policy, prefer the sale's channel; without a
|
|
168
168
|
// channel, summarize whichever channel(s) accept returns. Returns '' when
|
|
169
169
|
// there's nothing meaningful to print (no policy, or returns not accepted).
|
|
170
|
-
|
|
170
|
+
// `template` is a per-locale format string with a `{days}` placeholder, e.g.
|
|
171
|
+
// "{days} day return policy" / "{days} dagars öppet köp". Defaults to English
|
|
172
|
+
// so non-receipt callers (admin preview) need not pass one; the receipt
|
|
173
|
+
// builder passes the localized template. Legacy free-text policies pass
|
|
174
|
+
// through unchanged (can't be localized).
|
|
175
|
+
static returnPolicyReceiptText(raw, salesChannel, template = '{days} day return policy') {
|
|
171
176
|
if (typeof raw === 'string')
|
|
172
177
|
return raw.trim();
|
|
173
178
|
const policy = this.parse(raw);
|
|
@@ -176,7 +181,7 @@ class ReturnPolicyHelpers {
|
|
|
176
181
|
const lineFor = (ch) => {
|
|
177
182
|
if (!ch || !ch.allowed || ch.returnPeriodDays <= 0)
|
|
178
183
|
return '';
|
|
179
|
-
return
|
|
184
|
+
return template.replace('{days}', String(ch.returnPeriodDays));
|
|
180
185
|
};
|
|
181
186
|
if (salesChannel) {
|
|
182
187
|
const key = this.channelKeyForSalesChannel(salesChannel);
|
package/lib/translations.d.ts
CHANGED
package/lib/translations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.originalReceiptTranslations = exports.refundPurchaseTranslations = exports.refundReceiptTranslations = exports.referenceTranslations = exports.contactlessTranslations = exports.authorizationCodeTranslations = exports.mobilePaymentTranslations = exports.cardPaymentTranslations = exports.cashTranslations = exports.purchaseTranslations = exports.taxTranslations = exports.totalTranslations = exports.receiptTranslations = void 0;
|
|
3
|
+
exports.originalReceiptTranslations = exports.refundPurchaseTranslations = exports.refundReceiptTranslations = exports.referenceTranslations = exports.contactlessTranslations = exports.authorizationCodeTranslations = exports.mobilePaymentTranslations = exports.cardPaymentTranslations = exports.cashTranslations = exports.purchaseTranslations = exports.taxTranslations = exports.totalTranslations = exports.returnPolicyReceiptTranslations = exports.receiptTranslations = void 0;
|
|
4
4
|
exports.receiptTranslations = {
|
|
5
5
|
'sv-SE': 'Kvitto',
|
|
6
6
|
'nb-NO': 'Kvittering',
|
|
@@ -8,6 +8,16 @@ exports.receiptTranslations = {
|
|
|
8
8
|
'en-UK': 'Receipt',
|
|
9
9
|
'en-DE': 'Quittung',
|
|
10
10
|
};
|
|
11
|
+
// Return-policy line on the receipt. `{days}` is replaced with the channel's
|
|
12
|
+
// returnPeriodDays. Localized per presentment locale (en-DE renders German,
|
|
13
|
+
// matching the other dicts).
|
|
14
|
+
exports.returnPolicyReceiptTranslations = {
|
|
15
|
+
'sv-SE': '{days} dagars öppet köp',
|
|
16
|
+
'nb-NO': '{days} dagers åpent kjøp',
|
|
17
|
+
'en-US': '{days} day return policy',
|
|
18
|
+
'en-UK': '{days} day return policy',
|
|
19
|
+
'en-DE': '{days} Tage Rückgaberecht',
|
|
20
|
+
};
|
|
11
21
|
exports.totalTranslations = {
|
|
12
22
|
'sv-SE': 'Totalt',
|
|
13
23
|
'nb-NO': 'Total',
|