rerobe-js-orm 4.8.1 → 4.8.3
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/product-constants.d.ts +11 -0
- package/lib/constants/product-constants.js +20 -1
- package/lib/factories/Product/ProductFromFormState.js +1 -0
- package/lib/form-states/Product/ProductFormState.d.ts +3 -0
- package/lib/form-states/Product/ProductFormState.js +25 -13
- package/lib/form-states/Product/options.d.ts +4 -0
- package/lib/form-states/Product/options.js +8 -1
- package/lib/helpers/OrderHelpers.d.ts +4 -1
- package/lib/helpers/OrderHelpers.js +29 -11
- package/lib/models/Product.js +1 -0
- package/lib/translations.d.ts +9 -0
- package/lib/translations.js +22 -1
- package/lib/types/rerobe-order-types.d.ts +3 -0
- package/lib/types/rerobe-product-types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function getDefaultTaxCategory(isConsignment: any, countryCode: any): any;
|
|
1
2
|
export namespace SELLER_DRIVEN_STATES {
|
|
2
3
|
let sellerDonated: string;
|
|
3
4
|
let sellRequestReview: string;
|
|
@@ -327,6 +328,16 @@ export namespace PAYOUT_SYSTEM {
|
|
|
327
328
|
export { RIBBN_CREDITS_1 as RIBBN_CREDITS };
|
|
328
329
|
}
|
|
329
330
|
export const ADMIN_STATES: {};
|
|
331
|
+
export namespace TAX_CATEGORIES {
|
|
332
|
+
let STANDARD: string;
|
|
333
|
+
let FOOD: string;
|
|
334
|
+
let CULTURE: string;
|
|
335
|
+
let EXEMPT: string;
|
|
336
|
+
}
|
|
337
|
+
export namespace CONSIGNMENT_TAX_DEFAULTS {
|
|
338
|
+
let SE: string;
|
|
339
|
+
let _default: string;
|
|
340
|
+
}
|
|
330
341
|
export namespace PRODUCT_CLASS_VALUES {
|
|
331
342
|
let UNIQUE: string;
|
|
332
343
|
let MULTIVARIANT: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PRODUCT_CLASS_VALUES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
|
|
3
|
+
exports.PRODUCT_CLASS_VALUES = exports.CONSIGNMENT_TAX_DEFAULTS = exports.TAX_CATEGORIES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
|
|
4
|
+
exports.getDefaultTaxCategory = getDefaultTaxCategory;
|
|
4
5
|
exports.SELLER_DRIVEN_STATES = {
|
|
5
6
|
sellerDonated: 'SELLER_DONATED',
|
|
6
7
|
sellRequestReview: 'SELL_REQUEST_REVIEW',
|
|
@@ -234,6 +235,24 @@ exports.ADMIN_STATES = Object.entries(exports.PRODUCT_STATES)
|
|
|
234
235
|
acc[key] = value;
|
|
235
236
|
return acc;
|
|
236
237
|
}, {});
|
|
238
|
+
exports.TAX_CATEGORIES = {
|
|
239
|
+
STANDARD: 'STANDARD',
|
|
240
|
+
FOOD: 'FOOD',
|
|
241
|
+
CULTURE: 'CULTURE',
|
|
242
|
+
EXEMPT: 'EXEMPT',
|
|
243
|
+
};
|
|
244
|
+
exports.CONSIGNMENT_TAX_DEFAULTS = {
|
|
245
|
+
SE: 'EXEMPT',
|
|
246
|
+
_default: 'EXEMPT',
|
|
247
|
+
};
|
|
248
|
+
function getDefaultTaxCategory(isConsignment, countryCode) {
|
|
249
|
+
if (!isConsignment)
|
|
250
|
+
return exports.TAX_CATEGORIES.STANDARD;
|
|
251
|
+
const map = exports.CONSIGNMENT_TAX_DEFAULTS;
|
|
252
|
+
if (countryCode && map[countryCode] !== undefined)
|
|
253
|
+
return map[countryCode];
|
|
254
|
+
return map._default;
|
|
255
|
+
}
|
|
237
256
|
exports.PRODUCT_CLASS_VALUES = {
|
|
238
257
|
UNIQUE: 'UNIQUE',
|
|
239
258
|
MULTIVARIANT: 'MULTIVARIANT',
|
|
@@ -17,6 +17,7 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
17
17
|
imageUrlsForAI: ((_e = props.props) === null || _e === void 0 ? void 0 : _e.imageUrlsForAI) || [],
|
|
18
18
|
price: props.fields.price.inputValue,
|
|
19
19
|
isTaxable: props.fields.isTaxable.selectedValue,
|
|
20
|
+
taxCategory: props.fields.taxCategory.selectedValue,
|
|
20
21
|
productClass: props.fields.productClass.selectedValue,
|
|
21
22
|
createdAt: ((_f = props.props) === null || _f === void 0 ? void 0 : _f.createdAt) || new Date().toUTCString(), // ToDo look into different timestamp
|
|
22
23
|
updatedAt: ((_g = props.props) === null || _g === void 0 ? void 0 : _g.updatedAt) || new Date().toUTCString(), // ToDo look into different timestamp
|
|
@@ -31,7 +31,10 @@ export default class ProductFormState extends FormState {
|
|
|
31
31
|
majorDefects: string[];
|
|
32
32
|
minorDefects: string[];
|
|
33
33
|
primaryAgeCategories: string[];
|
|
34
|
+
countryCode?: string;
|
|
35
|
+
isConsignment?: boolean;
|
|
34
36
|
};
|
|
37
|
+
private _rawProps?;
|
|
35
38
|
constructor(props?: any, opts?: any);
|
|
36
39
|
autoCreateTitle(): string;
|
|
37
40
|
autoCreateDescription(): string;
|
|
@@ -15,9 +15,11 @@ const FormState_1 = require("../FormState");
|
|
|
15
15
|
const options_1 = require("./options");
|
|
16
16
|
const Product_1 = require("../../models/Product");
|
|
17
17
|
const ProductFromFormState_1 = require("../../factories/Product/ProductFromFormState");
|
|
18
|
+
const product_constants_1 = require("../../constants/product-constants");
|
|
18
19
|
class ProductFormState extends FormState_1.default {
|
|
19
20
|
constructor(props, opts) {
|
|
20
21
|
super();
|
|
22
|
+
this._rawProps = props;
|
|
21
23
|
this.props = new Product_1.default(props).toObj();
|
|
22
24
|
this.opts = opts;
|
|
23
25
|
// ProductAttributesFormFields
|
|
@@ -26,6 +28,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
26
28
|
this.fields.title = this.fieldFactory('textInput', 'title');
|
|
27
29
|
this.fields.price = this.fieldFactory('textInput', 'price');
|
|
28
30
|
this.fields.isTaxable = this.fieldFactory('singleSelect', 'isTaxable', options_1.productYesNoOptions);
|
|
31
|
+
this.fields.taxCategory = this.fieldFactory('singleSelect', 'taxCategory', options_1.taxCategoryOptions);
|
|
29
32
|
this.fields.weight = this.fieldFactory('textInput', 'weight');
|
|
30
33
|
this.fields.weightRange = this.fieldFactory('singleSelect', 'weightRange', options_1.productWeightRanges);
|
|
31
34
|
this.fields.weightUnit = this.fieldFactory('singleSelect', 'weightUnit', options_1.weightUnits);
|
|
@@ -1042,7 +1045,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1042
1045
|
this.fields.inventoryLocations.valid = aggregated.length > 0;
|
|
1043
1046
|
}
|
|
1044
1047
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
1045
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
1048
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
1046
1049
|
let options = fieldOptions || [];
|
|
1047
1050
|
let hidden = false;
|
|
1048
1051
|
if (fieldType === 'singleSelect') {
|
|
@@ -1060,7 +1063,16 @@ class ProductFormState extends FormState_1.default {
|
|
|
1060
1063
|
onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
1061
1064
|
}
|
|
1062
1065
|
if (fieldKey === 'isTaxable') {
|
|
1063
|
-
|
|
1066
|
+
const hasExplicitValue = this._rawProps && this._rawProps.isTaxable;
|
|
1067
|
+
selectedValue = hasExplicitValue ? this.props[fieldKey] || '' : ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.isConsignment) ? 'no' : '';
|
|
1068
|
+
valid = true;
|
|
1069
|
+
onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
1070
|
+
}
|
|
1071
|
+
if (fieldKey === 'taxCategory') {
|
|
1072
|
+
const hasExplicitValue = this._rawProps && this._rawProps.taxCategory;
|
|
1073
|
+
selectedValue = hasExplicitValue
|
|
1074
|
+
? this.props[fieldKey] || 'STANDARD'
|
|
1075
|
+
: (0, product_constants_1.getDefaultTaxCategory)(!!((_b = this.opts) === null || _b === void 0 ? void 0 : _b.isConsignment), (_c = this.opts) === null || _c === void 0 ? void 0 : _c.countryCode);
|
|
1064
1076
|
valid = true;
|
|
1065
1077
|
onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
1066
1078
|
}
|
|
@@ -1090,7 +1102,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1090
1102
|
});
|
|
1091
1103
|
}
|
|
1092
1104
|
}
|
|
1093
|
-
if ((
|
|
1105
|
+
if ((_e = (_d = this.opts) === null || _d === void 0 ? void 0 : _d.materials) === null || _e === void 0 ? void 0 : _e.length) {
|
|
1094
1106
|
const materialsOptions = this.opts.materials.map((t) => ({
|
|
1095
1107
|
label: t,
|
|
1096
1108
|
value: t,
|
|
@@ -1151,7 +1163,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1151
1163
|
options.splice(0, 0, ...selectedSizeOptions);
|
|
1152
1164
|
}
|
|
1153
1165
|
}
|
|
1154
|
-
if ((
|
|
1166
|
+
if ((_g = (_f = this.opts) === null || _f === void 0 ? void 0 : _f.sizes) === null || _g === void 0 ? void 0 : _g.length) {
|
|
1155
1167
|
const sizesOptions = this.opts.sizes.map((t) => ({ label: t, value: t }));
|
|
1156
1168
|
options = this.utilities.uniqObjArray([...selectedSizeOptions, ...sizesOptions], 'value');
|
|
1157
1169
|
}
|
|
@@ -1165,7 +1177,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1165
1177
|
options.splice(0, 0, ...selectedJeanSizeOptions);
|
|
1166
1178
|
}
|
|
1167
1179
|
}
|
|
1168
|
-
if ((
|
|
1180
|
+
if ((_j = (_h = this.opts) === null || _h === void 0 ? void 0 : _h.jeanSizes) === null || _j === void 0 ? void 0 : _j.length) {
|
|
1169
1181
|
const jeanSizesOptions = this.opts.jeanSizes.map((t) => ({ label: t, value: t }));
|
|
1170
1182
|
options = this.utilities.uniqObjArray([...selectedJeanSizeOptions, ...jeanSizesOptions], 'value');
|
|
1171
1183
|
}
|
|
@@ -1179,7 +1191,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1179
1191
|
options.splice(0, 0, ...selectedShoeSizeOptions);
|
|
1180
1192
|
}
|
|
1181
1193
|
}
|
|
1182
|
-
if ((
|
|
1194
|
+
if ((_l = (_k = this.opts) === null || _k === void 0 ? void 0 : _k.shoeSizes) === null || _l === void 0 ? void 0 : _l.length) {
|
|
1183
1195
|
const shoeSizesOptions = this.opts.shoeSizes.map((t) => ({ label: t, value: t }));
|
|
1184
1196
|
options = this.utilities.uniqObjArray([...selectedShoeSizeOptions, ...shoeSizesOptions], 'value');
|
|
1185
1197
|
}
|
|
@@ -1192,7 +1204,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1192
1204
|
options.splice(0, 0, ...selectedBrandOptions);
|
|
1193
1205
|
}
|
|
1194
1206
|
}
|
|
1195
|
-
if ((
|
|
1207
|
+
if ((_o = (_m = this.opts) === null || _m === void 0 ? void 0 : _m.brands) === null || _o === void 0 ? void 0 : _o.length) {
|
|
1196
1208
|
const brandsOptions = this.opts.brands.map((t) => ({ label: t, value: t }));
|
|
1197
1209
|
options = this.utilities.uniqObjArray([...selectedBrandOptions, ...brandsOptions], 'value');
|
|
1198
1210
|
}
|
|
@@ -1205,7 +1217,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1205
1217
|
options.splice(0, 0, ...selectedColorOptions);
|
|
1206
1218
|
}
|
|
1207
1219
|
}
|
|
1208
|
-
if ((
|
|
1220
|
+
if ((_q = (_p = this.opts) === null || _p === void 0 ? void 0 : _p.colors) === null || _q === void 0 ? void 0 : _q.length) {
|
|
1209
1221
|
const colorsOptions = this.opts.colors.map((t) => ({ label: t, value: t }));
|
|
1210
1222
|
options = this.utilities.uniqObjArray([...selectedColorOptions, ...colorsOptions], 'value');
|
|
1211
1223
|
}
|
|
@@ -1230,7 +1242,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1230
1242
|
options.splice(0, 0, ...selectedPrimaryAgeCategoryOptions);
|
|
1231
1243
|
}
|
|
1232
1244
|
}
|
|
1233
|
-
if ((
|
|
1245
|
+
if ((_s = (_r = this.opts) === null || _r === void 0 ? void 0 : _r.primaryAgeCategories) === null || _s === void 0 ? void 0 : _s.length) {
|
|
1234
1246
|
const suppliedPrimaryAgeCategoryOptions = this.opts.primaryAgeCategories.map((t) => ({ label: t, value: t }));
|
|
1235
1247
|
options = this.utilities.uniqObjArray([...selectedPrimaryAgeCategoryOptions, ...suppliedPrimaryAgeCategoryOptions], 'value');
|
|
1236
1248
|
}
|
|
@@ -1243,7 +1255,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1243
1255
|
options.splice(0, 0, ...selectedOptions);
|
|
1244
1256
|
}
|
|
1245
1257
|
}
|
|
1246
|
-
if ((
|
|
1258
|
+
if ((_u = (_t = this.opts) === null || _t === void 0 ? void 0 : _t.conditions) === null || _u === void 0 ? void 0 : _u.length) {
|
|
1247
1259
|
const conditionsOptions = this.opts.conditions.map((t) => ({
|
|
1248
1260
|
label: t.label || '',
|
|
1249
1261
|
value: t.value || '',
|
|
@@ -1298,7 +1310,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1298
1310
|
if (this.props.gender === 'Man') {
|
|
1299
1311
|
options = options_1.manClothingSizeOptions;
|
|
1300
1312
|
}
|
|
1301
|
-
if ((
|
|
1313
|
+
if ((_w = (_v = this.opts) === null || _v === void 0 ? void 0 : _v.clothingSizes) === null || _w === void 0 ? void 0 : _w.length) {
|
|
1302
1314
|
const clothingSizesOptions = this.opts.clothingSizes.map((t) => ({ label: t, value: t }));
|
|
1303
1315
|
options = this.utilities.uniqObjArray(clothingSizesOptions, 'value');
|
|
1304
1316
|
}
|
|
@@ -1311,7 +1323,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1311
1323
|
selectedMajorDefectsOptions = this.props.majorDefects.map((t) => ({ label: t, value: t }));
|
|
1312
1324
|
}
|
|
1313
1325
|
let majorDefectsOptions = [];
|
|
1314
|
-
if ((
|
|
1326
|
+
if ((_y = (_x = this.opts) === null || _x === void 0 ? void 0 : _x.majorDefects) === null || _y === void 0 ? void 0 : _y.length) {
|
|
1315
1327
|
majorDefectsOptions = this.opts.majorDefects.map((t) => ({ label: t, value: t }));
|
|
1316
1328
|
}
|
|
1317
1329
|
options = this.utilities.uniqObjArray([...selectedMajorDefectsOptions, ...majorDefectsOptions], 'value');
|
|
@@ -1323,7 +1335,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
1323
1335
|
selectedMinorDefectsOptions = this.props.minorDefects.map((t) => ({ label: t, value: t }));
|
|
1324
1336
|
}
|
|
1325
1337
|
let minorDefectsOptions = [];
|
|
1326
|
-
if ((
|
|
1338
|
+
if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.minorDefects) === null || _0 === void 0 ? void 0 : _0.length) {
|
|
1327
1339
|
minorDefectsOptions = this.opts.minorDefects.map((t) => ({ label: t, value: t }));
|
|
1328
1340
|
}
|
|
1329
1341
|
options = this.utilities.uniqObjArray([...selectedMinorDefectsOptions, ...minorDefectsOptions], 'value');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.primaryAgeCategoryOptions = exports.adminStatusOptionsSimplified = exports.adminStatusOptions = exports.measurementCategoryOptions = exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productClassOptions = exports.productYesNoOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.weightUnits = exports.productWeightRanges = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.genderOptions = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
3
|
+
exports.primaryAgeCategoryOptions = exports.adminStatusOptionsSimplified = exports.adminStatusOptions = exports.measurementCategoryOptions = exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productClassOptions = exports.taxCategoryOptions = exports.productYesNoOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.weightUnits = exports.productWeightRanges = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.genderOptions = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
4
4
|
const product_constants_1 = require("../../constants/product-constants");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const availableForSaleOptions = [
|
|
@@ -1058,6 +1058,13 @@ const productYesNoOptions = [
|
|
|
1058
1058
|
},
|
|
1059
1059
|
];
|
|
1060
1060
|
exports.productYesNoOptions = productYesNoOptions;
|
|
1061
|
+
const taxCategoryOptions = [
|
|
1062
|
+
{ label: 'Standard', value: 'STANDARD' },
|
|
1063
|
+
{ label: 'Food & Beverages', value: 'FOOD' },
|
|
1064
|
+
{ label: 'Books & Culture', value: 'CULTURE' },
|
|
1065
|
+
{ label: 'Exempt', value: 'EXEMPT' },
|
|
1066
|
+
];
|
|
1067
|
+
exports.taxCategoryOptions = taxCategoryOptions;
|
|
1061
1068
|
const productClassOptions = [
|
|
1062
1069
|
{
|
|
1063
1070
|
label: 'Unique',
|
|
@@ -47,12 +47,15 @@ export default class OrderHelpers {
|
|
|
47
47
|
getPaymentTerminalReceiptInfo(payload?: any): PaymentTerminalReceiptInfo;
|
|
48
48
|
getFormattedFulfillmentLocation(order: ReRobeOrderObj): string;
|
|
49
49
|
generateReceiptLabels(locale: string, paymentMethod: string, entryMode?: string): ReceiptLabels;
|
|
50
|
-
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl, receiptNumber, additionalInfo, }: {
|
|
50
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl, receiptNumber, additionalInfo, isRefund, refundId, originalReceiptNumber, }: {
|
|
51
51
|
order: ReRobeOrderObj;
|
|
52
52
|
merchant: MerchantObj;
|
|
53
53
|
merchantLogoUrl: string;
|
|
54
54
|
receiptNumber: string;
|
|
55
55
|
additionalInfo: string;
|
|
56
|
+
isRefund?: boolean;
|
|
57
|
+
refundId?: string | null;
|
|
58
|
+
originalReceiptNumber?: string | null;
|
|
56
59
|
}): ReceiptObj;
|
|
57
60
|
/**
|
|
58
61
|
* Generates an idempotency key from a ReRobeOrderObj to prevent duplicate order creation
|
|
@@ -579,23 +579,29 @@ class OrderHelpers {
|
|
|
579
579
|
entryModeLabel,
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
|
-
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', receiptNumber = '', additionalInfo = '', }) {
|
|
583
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
582
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', receiptNumber = '', additionalInfo = '', isRefund = false, refundId = null, originalReceiptNumber = null, }) {
|
|
583
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
584
584
|
const { address: merchantAddress, legalName, name, contactEmail, phone = '', organizationNumber = '', primaryDomain, currency: storeCurrencyCode, returnPolicy, } = merchant;
|
|
585
585
|
const currencyCode = ((_a = order.totalPricePresentment) === null || _a === void 0 ? void 0 : _a.currencyCode) || storeCurrencyCode;
|
|
586
586
|
const presentmentLocale = (0, Utilities_1.getPresentmentLocaleByCurrencyCode)(currencyCode);
|
|
587
587
|
const mapLineItem = (l) => {
|
|
588
|
-
var _a, _b, _c;
|
|
588
|
+
var _a, _b, _c, _d, _e;
|
|
589
589
|
let totalPrice = Number((_a = l.presentmentTotalPrice) === null || _a === void 0 ? void 0 : _a.amount);
|
|
590
590
|
if (l.isTaxable && l.taxRate) {
|
|
591
591
|
const taxRate = Number(l.taxRate);
|
|
592
592
|
totalPrice *= 1 + taxRate;
|
|
593
593
|
}
|
|
594
|
+
if (isRefund) {
|
|
595
|
+
totalPrice = -Math.abs(totalPrice);
|
|
596
|
+
}
|
|
594
597
|
let title = l.title || l.brand || '';
|
|
595
598
|
if (Number(l === null || l === void 0 ? void 0 : l.quantity) > 1) {
|
|
599
|
+
const unitPrice = isRefund
|
|
600
|
+
? -Math.abs(Number((_c = (_b = l === null || l === void 0 ? void 0 : l.originalUnitPrice) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0))
|
|
601
|
+
: (_e = (_d = l === null || l === void 0 ? void 0 : l.originalUnitPrice) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : '';
|
|
596
602
|
title += `\n${Number(l === null || l === void 0 ? void 0 : l.quantity)} x ${(0, Utilities_1.formatPrice)({
|
|
597
603
|
currencyCode,
|
|
598
|
-
amount:
|
|
604
|
+
amount: unitPrice,
|
|
599
605
|
fractionDigits: 2,
|
|
600
606
|
})}`;
|
|
601
607
|
}
|
|
@@ -642,7 +648,8 @@ class OrderHelpers {
|
|
|
642
648
|
if (!acc[cur.taxRate]) {
|
|
643
649
|
acc[cur.taxRate] = 0;
|
|
644
650
|
}
|
|
645
|
-
|
|
651
|
+
const amount = Number(cur.taxAmount);
|
|
652
|
+
acc[cur.taxRate] += isRefund ? -Math.abs(amount) : amount;
|
|
646
653
|
acc[cur.taxRate] = parseFloat(acc[cur.taxRate].toFixed(2));
|
|
647
654
|
}
|
|
648
655
|
return acc;
|
|
@@ -664,31 +671,42 @@ class OrderHelpers {
|
|
|
664
671
|
};
|
|
665
672
|
const paymentTerminalInfo = this.getPaymentTerminalReceiptInfo(order);
|
|
666
673
|
const receiptLabels = this.generateReceiptLabels(presentmentLocale, (_b = order.paymentType) !== null && _b !== void 0 ? _b : '', (_c = paymentTerminalInfo.entryMode) !== null && _c !== void 0 ? _c : '');
|
|
674
|
+
if (isRefund) {
|
|
675
|
+
receiptLabels.receiptLabel = translations_1.refundReceiptTranslations[presentmentLocale] || translations_1.refundReceiptTranslations['en-US'];
|
|
676
|
+
receiptLabels.purchaseLabel =
|
|
677
|
+
translations_1.refundPurchaseTranslations[presentmentLocale] || translations_1.refundPurchaseTranslations['en-US'];
|
|
678
|
+
}
|
|
667
679
|
let info = additionalInfo;
|
|
668
|
-
if (returnPolicy) {
|
|
680
|
+
if (returnPolicy && !isRefund) {
|
|
669
681
|
info = `${returnPolicy}`;
|
|
670
682
|
if (additionalInfo) {
|
|
671
683
|
info = `${info}\n\n${additionalInfo}`;
|
|
672
684
|
}
|
|
673
685
|
}
|
|
686
|
+
const negateForRefund = (amount) => {
|
|
687
|
+
if (!isRefund)
|
|
688
|
+
return amount;
|
|
689
|
+
const num = Number(amount);
|
|
690
|
+
return isNaN(num) ? amount : -Math.abs(num);
|
|
691
|
+
};
|
|
674
692
|
return Object.assign(Object.assign({ merchantLogoUrl, merchantName: name, legalName, storeAddress: buildStoreAddress(), phone,
|
|
675
693
|
contactEmail,
|
|
676
694
|
organizationNumber,
|
|
677
|
-
primaryDomain, storeUrl: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale, order === null || order === void 0 ? void 0 : order.createdAtTimestamp), receiptNumber, additionalInfo: info, lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
695
|
+
primaryDomain, storeUrl: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale, order === null || order === void 0 ? void 0 : order.createdAtTimestamp), receiptNumber, additionalInfo: info, isRefund, originalReceiptNumber: originalReceiptNumber || null, originalReceiptLabel: translations_1.originalReceiptTranslations[presentmentLocale] || translations_1.originalReceiptTranslations['en-US'], lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
678
696
|
currencyCode,
|
|
679
|
-
amount: (_e = (_d = order.subtotalPricePresentment) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : '',
|
|
697
|
+
amount: (_f = negateForRefund((_e = (_d = order.subtotalPricePresentment) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : '')) !== null && _f !== void 0 ? _f : '',
|
|
680
698
|
fractionDigits: 2,
|
|
681
699
|
}), total: (0, Utilities_1.formatPrice)({
|
|
682
700
|
currencyCode,
|
|
683
|
-
amount: (
|
|
701
|
+
amount: (_j = negateForRefund((_h = (_g = order.totalPricePresentment) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : '')) !== null && _j !== void 0 ? _j : '',
|
|
684
702
|
fractionDigits: 2,
|
|
685
703
|
}), amountPaid: (0, Utilities_1.formatPrice)({
|
|
686
704
|
currencyCode,
|
|
687
|
-
amount: (
|
|
705
|
+
amount: (_m = negateForRefund((_l = (_k = order.totalPricePresentment) === null || _k === void 0 ? void 0 : _k.amount) !== null && _l !== void 0 ? _l : '')) !== null && _m !== void 0 ? _m : '',
|
|
688
706
|
fractionDigits: 2,
|
|
689
707
|
}), tax: (0, Utilities_1.formatPrice)({
|
|
690
708
|
currencyCode,
|
|
691
|
-
amount: (
|
|
709
|
+
amount: (_q = negateForRefund((_p = (_o = order.totalTaxPresentment) === null || _o === void 0 ? void 0 : _o.amount) !== null && _p !== void 0 ? _p : '')) !== null && _q !== void 0 ? _q : '',
|
|
692
710
|
fractionDigits: 2,
|
|
693
711
|
}), taxRates: formattedTaxRates }, paymentTerminalInfo), receiptLabels);
|
|
694
712
|
}
|
package/lib/models/Product.js
CHANGED
|
@@ -42,6 +42,7 @@ class Product extends Base_1.default {
|
|
|
42
42
|
metaDataTitle: (props === null || props === void 0 ? void 0 : props.metaDataTitle) || '',
|
|
43
43
|
metaDataDescription: (props === null || props === void 0 ? void 0 : props.metaDataDescription) || '',
|
|
44
44
|
isTaxable: (props === null || props === void 0 ? void 0 : props.isTaxable) || '',
|
|
45
|
+
taxCategory: (props === null || props === void 0 ? void 0 : props.taxCategory) || 'STANDARD',
|
|
45
46
|
productClass: (props === null || props === void 0 ? void 0 : props.productClass) || 'UNIQUE',
|
|
46
47
|
};
|
|
47
48
|
this.filterAttributes = {
|
package/lib/translations.d.ts
CHANGED
|
@@ -28,3 +28,12 @@ export declare const contactlessTranslations: {
|
|
|
28
28
|
export declare const referenceTranslations: {
|
|
29
29
|
[key: string]: string;
|
|
30
30
|
};
|
|
31
|
+
export declare const refundReceiptTranslations: {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const refundPurchaseTranslations: {
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const originalReceiptTranslations: {
|
|
38
|
+
[key: string]: string;
|
|
39
|
+
};
|
package/lib/translations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.receiptTranslations = void 0;
|
|
4
4
|
exports.receiptTranslations = {
|
|
5
5
|
'sv-SE': 'Kvitto',
|
|
6
6
|
'nb-NO': 'Kvittering',
|
|
@@ -71,3 +71,24 @@ exports.referenceTranslations = {
|
|
|
71
71
|
'en-UK': 'Reference',
|
|
72
72
|
'en-DE': 'Referenz',
|
|
73
73
|
};
|
|
74
|
+
exports.refundReceiptTranslations = {
|
|
75
|
+
'sv-SE': 'RETUR',
|
|
76
|
+
'nb-NO': 'RETUR',
|
|
77
|
+
'en-US': 'REFUND',
|
|
78
|
+
'en-UK': 'REFUND',
|
|
79
|
+
'en-DE': 'RÜCKERSTATTUNG',
|
|
80
|
+
};
|
|
81
|
+
exports.refundPurchaseTranslations = {
|
|
82
|
+
'sv-SE': 'Retur',
|
|
83
|
+
'nb-NO': 'Retur',
|
|
84
|
+
'en-US': 'Refund',
|
|
85
|
+
'en-UK': 'Refund',
|
|
86
|
+
'en-DE': 'Rückerstattung',
|
|
87
|
+
};
|
|
88
|
+
exports.originalReceiptTranslations = {
|
|
89
|
+
'sv-SE': 'Originalkvitto',
|
|
90
|
+
'nb-NO': 'Originalkvittering',
|
|
91
|
+
'en-US': 'Original receipt',
|
|
92
|
+
'en-UK': 'Original receipt',
|
|
93
|
+
'en-DE': 'Originalquittung',
|
|
94
|
+
};
|
|
@@ -75,6 +75,9 @@ type ReceiptObj = {
|
|
|
75
75
|
[key: string]: string;
|
|
76
76
|
};
|
|
77
77
|
additionalInfo: string;
|
|
78
|
+
isRefund?: boolean;
|
|
79
|
+
originalReceiptNumber?: string | null;
|
|
80
|
+
originalReceiptLabel?: string;
|
|
78
81
|
} & ReceiptLabelsAndPaymentTerminalInfo;
|
|
79
82
|
type ReceiptLog = {
|
|
80
83
|
createdAtTimestamp: number;
|
|
@@ -31,6 +31,7 @@ type ProductAttributes = {
|
|
|
31
31
|
metaDataTitle?: string;
|
|
32
32
|
metaDataDescription?: string;
|
|
33
33
|
isTaxable?: string;
|
|
34
|
+
taxCategory?: string;
|
|
34
35
|
productClass?: 'UNIQUE' | 'MULTIVARIANT' | 'TEMPLATE' | 'SUPPLY' | 'DIGITAL' | string;
|
|
35
36
|
variantInventory?: VariantInventory[];
|
|
36
37
|
};
|
|
@@ -206,6 +207,7 @@ type ProductAttributesFormFields = {
|
|
|
206
207
|
metaDataDescription: TextInputFormField<string>;
|
|
207
208
|
handle: TextInputFormField<string>;
|
|
208
209
|
isTaxable: SingleSelectFormField<string>;
|
|
210
|
+
taxCategory: SingleSelectFormField<string>;
|
|
209
211
|
productClass: SingleSelectFormField<string>;
|
|
210
212
|
variantInventory: MultiSelectFormField<VariantInventory>;
|
|
211
213
|
};
|