rerobe-js-orm 3.6.3 → 3.6.5
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.
|
@@ -70,6 +70,10 @@ export default class OrderHelpers {
|
|
|
70
70
|
amount: string;
|
|
71
71
|
currencyCode: string;
|
|
72
72
|
};
|
|
73
|
+
presentmentTaxPrice: {
|
|
74
|
+
amount: string;
|
|
75
|
+
currencyCode: string;
|
|
76
|
+
};
|
|
73
77
|
brand?: string | null | undefined;
|
|
74
78
|
productId?: string | null | undefined;
|
|
75
79
|
shopifyProductId?: string | number | null | undefined;
|
|
@@ -80,7 +84,6 @@ export default class OrderHelpers {
|
|
|
80
84
|
status?: string | undefined;
|
|
81
85
|
isOnSale?: string | undefined;
|
|
82
86
|
salePrice?: string | undefined;
|
|
83
|
-
presentmentTaxPrice?: Money | undefined;
|
|
84
87
|
isTaxable?: boolean | undefined;
|
|
85
88
|
taxRate?: number | undefined;
|
|
86
89
|
fromCountry?: string | undefined;
|
|
@@ -140,6 +143,10 @@ export default class OrderHelpers {
|
|
|
140
143
|
amount: string;
|
|
141
144
|
currencyCode: string;
|
|
142
145
|
};
|
|
146
|
+
presentmentTaxPrice: {
|
|
147
|
+
amount: string;
|
|
148
|
+
currencyCode: string;
|
|
149
|
+
};
|
|
143
150
|
brand?: string | null | undefined;
|
|
144
151
|
productId?: string | null | undefined;
|
|
145
152
|
shopifyProductId?: string | number | null | undefined;
|
|
@@ -150,7 +157,6 @@ export default class OrderHelpers {
|
|
|
150
157
|
status?: string | undefined;
|
|
151
158
|
isOnSale?: string | undefined;
|
|
152
159
|
salePrice?: string | undefined;
|
|
153
|
-
presentmentTaxPrice?: Money | undefined;
|
|
154
160
|
isTaxable?: boolean | undefined;
|
|
155
161
|
taxRate?: number | undefined;
|
|
156
162
|
fromCountry?: string | undefined;
|
|
@@ -380,7 +380,7 @@ class OrderHelpers {
|
|
|
380
380
|
let subtotalOriginalPresentment = 0;
|
|
381
381
|
const totalTax = Number(itemsTax || 0) + Number(shippingFeeTax || 0);
|
|
382
382
|
const lineItems = productsFullInfoWithQuantity.map((item) => {
|
|
383
|
-
var _a;
|
|
383
|
+
var _a, _b;
|
|
384
384
|
const lineItem = this.buildLineItemFromProduct(item.product, merchantCurrency, item.quantity, {
|
|
385
385
|
price: item.price,
|
|
386
386
|
isTaxable: item.isTaxable,
|
|
@@ -395,8 +395,9 @@ class OrderHelpers {
|
|
|
395
395
|
const presentmentSalePrice = convertAndFixPrice(lineItem.salePrice, 5);
|
|
396
396
|
const presentmentItemPrice = lineItem.isOnSale === 'yes' ? presentmentSalePrice : presentmentUnitPrice;
|
|
397
397
|
const presentmentTotalPrice = this.toFixedPointPrice(Number(presentmentItemPrice) * Number(item.quantity));
|
|
398
|
+
const presentmentTaxPrice = convertAndFixPrice((_b = lineItem.taxAmountWithDiscount) === null || _b === void 0 ? void 0 : _b.amount, 5);
|
|
398
399
|
subtotalOriginalPresentment += Number(this.toFixedPointPrice(Number(presentmentUnitPrice) * Number(item.quantity)));
|
|
399
|
-
return Object.assign(Object.assign({}, lineItem), { presentmentTotalPrice: prepareMoneyObj(presentmentTotalPrice), presentmentUnitPrice: prepareMoneyObj(presentmentUnitPrice), presentmentSalePrice: prepareMoneyObj(presentmentSalePrice) });
|
|
400
|
+
return Object.assign(Object.assign({}, lineItem), { presentmentTotalPrice: prepareMoneyObj(presentmentTotalPrice), presentmentUnitPrice: prepareMoneyObj(presentmentUnitPrice), presentmentSalePrice: prepareMoneyObj(presentmentSalePrice), presentmentTaxPrice: prepareMoneyObj(presentmentTaxPrice) });
|
|
400
401
|
});
|
|
401
402
|
if (!presentmentCurrencyCode || presentmentCurrencyCode === merchantCurrency) {
|
|
402
403
|
return {
|
|
@@ -26,4 +26,5 @@ export default class ReRobeProductHelpers {
|
|
|
26
26
|
static convertReRobeSizeToStandardSize(productObj: CompleteProduct): string;
|
|
27
27
|
static mapToOldSizesToStandardSize(productObj: CompleteProduct): string;
|
|
28
28
|
static buildLineItem(productObj: CompleteProduct, quantity?: number): ProductLineItem;
|
|
29
|
+
static productStatusPretty(status: string): any;
|
|
29
30
|
}
|
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
3
|
const options_1 = require("../form-states/Product/options");
|
|
6
4
|
const product_constants_1 = require("../constants/product-constants");
|
|
5
|
+
function ldStartCase(str) {
|
|
6
|
+
// Convert the string to lowercase and replace underscores and hyphens with spaces
|
|
7
|
+
return (str
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.replace(/[_-]+/g, ' ')
|
|
10
|
+
// Replace any non-alphanumeric characters except whitespace with an empty string
|
|
11
|
+
.replace(/[^a-z0-9\s]/gi, '')
|
|
12
|
+
// Split the string into words and capitalize the first letter of each word
|
|
13
|
+
.split(' ')
|
|
14
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
15
|
+
.join(' '));
|
|
16
|
+
}
|
|
17
|
+
function toCamelCase(str) {
|
|
18
|
+
return (str
|
|
19
|
+
// Lower cases the string
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
// Replaces any - or _ characters with a space
|
|
22
|
+
.replace(/[-_]+/g, ' ')
|
|
23
|
+
// Removes any non alphanumeric characters except space
|
|
24
|
+
.replace(/[^a-z0-9\s]/gi, '')
|
|
25
|
+
// Converts the first letter of each word except the first to uppercase
|
|
26
|
+
.split(' ')
|
|
27
|
+
.map((word, index) => {
|
|
28
|
+
if (index === 0) {
|
|
29
|
+
return word; // return the first word as is
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
// Joins all the words into one string
|
|
36
|
+
.join(''));
|
|
37
|
+
}
|
|
7
38
|
class ReRobeProductHelpers {
|
|
8
39
|
static calculateProductionFee(commission) {
|
|
9
40
|
if (commission === 0.16) {
|
|
@@ -104,7 +135,7 @@ class ReRobeProductHelpers {
|
|
|
104
135
|
if (materialComposition) {
|
|
105
136
|
return Object.keys(materialComposition)
|
|
106
137
|
.reduce((acc, cur, idx) => {
|
|
107
|
-
acc.push(`${Object.values(materialComposition)[idx]}% ${(
|
|
138
|
+
acc.push(`${Object.values(materialComposition)[idx]}% ${ldStartCase(cur)}`);
|
|
108
139
|
return acc;
|
|
109
140
|
}, [])
|
|
110
141
|
.join(', ');
|
|
@@ -121,7 +152,7 @@ class ReRobeProductHelpers {
|
|
|
121
152
|
return Object.keys(measurementsObj)
|
|
122
153
|
.filter((key) => key !== 'unit' && !!measurementsObj[key])
|
|
123
154
|
.map((key) => {
|
|
124
|
-
const label = product_constants_1.MEASUREMENT_FIELDS_DICT[key] || (
|
|
155
|
+
const label = product_constants_1.MEASUREMENT_FIELDS_DICT[key] || ldStartCase(key);
|
|
125
156
|
return `${measurementsObj[key]} ${measurementsObj.unit} ${label}`;
|
|
126
157
|
})
|
|
127
158
|
.join(' x ');
|
|
@@ -486,5 +517,44 @@ class ReRobeProductHelpers {
|
|
|
486
517
|
quantity,
|
|
487
518
|
};
|
|
488
519
|
}
|
|
520
|
+
static productStatusPretty(status) {
|
|
521
|
+
switch (status) {
|
|
522
|
+
case product_constants_1.PRODUCT_STATES.sellRequestReview:
|
|
523
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellRequestReview;
|
|
524
|
+
case product_constants_1.PRODUCT_STATES.accepted:
|
|
525
|
+
return product_constants_1.PRODUCT_STATE_LABELS.accepted;
|
|
526
|
+
case product_constants_1.PRODUCT_STATES.rejected:
|
|
527
|
+
return product_constants_1.PRODUCT_STATE_LABELS.rejected;
|
|
528
|
+
case product_constants_1.PRODUCT_STATES.hold:
|
|
529
|
+
return product_constants_1.PRODUCT_STATE_LABELS.hold;
|
|
530
|
+
case product_constants_1.PRODUCT_STATES.listed:
|
|
531
|
+
return product_constants_1.PRODUCT_STATE_LABELS.listed;
|
|
532
|
+
case product_constants_1.PRODUCT_STATES.reserved:
|
|
533
|
+
return product_constants_1.PRODUCT_STATE_LABELS.reserved;
|
|
534
|
+
case product_constants_1.PRODUCT_STATES.qualityControl:
|
|
535
|
+
return product_constants_1.PRODUCT_STATE_LABELS.qualityControl;
|
|
536
|
+
case product_constants_1.PRODUCT_STATES.sellerToGetPickUp:
|
|
537
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellerToGetPickUp;
|
|
538
|
+
case product_constants_1.PRODUCT_STATES.pendingPublication:
|
|
539
|
+
return product_constants_1.PRODUCT_STATE_LABELS.pendingPublication;
|
|
540
|
+
case product_constants_1.PRODUCT_STATES.sold:
|
|
541
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sold;
|
|
542
|
+
case product_constants_1.PRODUCT_STATES.soldSellerToBePaid:
|
|
543
|
+
return product_constants_1.PRODUCT_STATE_LABELS.soldSellerToBePaid;
|
|
544
|
+
case product_constants_1.PRODUCT_STATES.soldSellerPaid:
|
|
545
|
+
return product_constants_1.PRODUCT_STATE_LABELS.soldSellerPaid;
|
|
546
|
+
case product_constants_1.PRODUCT_STATES.sellRequestReviewDraft:
|
|
547
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellRequestReviewDraft;
|
|
548
|
+
case product_constants_1.PRODUCT_STATES.sellerToDropOff:
|
|
549
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellerToDropOff;
|
|
550
|
+
case product_constants_1.PRODUCT_STATES.sellerSelfReject:
|
|
551
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellerSelfReject;
|
|
552
|
+
case 'DROP_OFF_AT_REROBE':
|
|
553
|
+
return product_constants_1.PRODUCT_STATE_LABELS.sellerToDropOff;
|
|
554
|
+
default:
|
|
555
|
+
// @ts-ignore
|
|
556
|
+
return product_constants_1.PRODUCT_STATE_LABELS[toCamelCase(status)] || status;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
489
559
|
}
|
|
490
560
|
exports.default = ReRobeProductHelpers;
|