rerobe-js-orm 3.6.4 → 3.6.6
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.
|
@@ -353,9 +353,16 @@ class OrderHelpers {
|
|
|
353
353
|
return 0;
|
|
354
354
|
}
|
|
355
355
|
const cumsum = productsFullInfoWithQuantity
|
|
356
|
-
.map((
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
.map((item) => {
|
|
357
|
+
// Determine if the product is on sale and set the price accordingly
|
|
358
|
+
const price = item.product.isOnSale && item.product.clearanceTimestamp ? item.product.salePrice : item.product.price;
|
|
359
|
+
const basePrice = Number(price || 0) * Number(item.quantity);
|
|
360
|
+
// Apply tax if the item is taxable
|
|
361
|
+
if (item.isTaxable && item.taxRate) {
|
|
362
|
+
const taxAmount = basePrice * Number(item.taxRate); // Calculate the tax based on the base price
|
|
363
|
+
return basePrice + taxAmount; // Return the total including tax
|
|
364
|
+
}
|
|
365
|
+
return basePrice; // Return the price without tax for non-taxable items
|
|
359
366
|
})
|
|
360
367
|
.reduce((a, b) => a + b, 0);
|
|
361
368
|
return Number(this.toFixedPointPrice(cumsum));
|
|
@@ -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;
|