rerobe-js-orm 3.6.5 → 3.6.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.
- package/lib/helpers/OrderHelpers.js +11 -4
- package/package.json +1 -1
|
@@ -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));
|
|
@@ -422,7 +429,7 @@ class OrderHelpers {
|
|
|
422
429
|
};
|
|
423
430
|
}
|
|
424
431
|
const subtotalPricePresentmentWithSalePrice = lineItems
|
|
425
|
-
.map((i) => { var _a; return Number((_a = i.presentmentTotalPrice) === null || _a === void 0 ? void 0 : _a.amount); })
|
|
432
|
+
.map((i) => { var _a, _b; return Number((_a = i.presentmentTotalPrice) === null || _a === void 0 ? void 0 : _a.amount) + Number(((_b = i.presentmentTaxPrice) === null || _b === void 0 ? void 0 : _b.amount) || 0); })
|
|
426
433
|
.reduce((a, b) => a + b, 0);
|
|
427
434
|
const saleDiscountPresentmentAmount = subtotalOriginalPresentment - subtotalPricePresentmentWithSalePrice;
|
|
428
435
|
const creditDiscountPresentmentAmount = convertAndFixPrice(creditDiscountAmount || 0);
|