washday-sdk 0.0.164 → 0.0.165

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.
@@ -13,6 +13,7 @@ export const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasS
13
13
  // DISCOUNT TOTAL AND SHIPPING SERVICE COST
14
14
  let discountCodeAmount = 0;
15
15
  let shippingCost = getShippingCost(discountCodeObj, hasShippingCost, storeSettings);
16
+ // TODO: MAYBE THIS KIND OF DISCOUNT IS WRONG BECAUSE TAXES ARE CALCULATED BEFORE THIS POINT;
16
17
  if (discountCodeObj && discountCodeObj.type === DiscountCodeTypes.NUMBER && discountCodeObj.applyOnceOnOrder) {
17
18
  const includesProducts = discountCodeObj.applyToAllProducts || order.products.some((curr) => discountCodeObj.products.includes(curr._id));
18
19
  discountCodeAmount = includesProducts ? discountCodeObj.value : 0;
@@ -58,7 +58,7 @@ export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettin
58
58
  const productLineImportTotal = +(totalNetWithoutDiscount * taxFactor).toFixed(2);
59
59
  const productLineTotalWithDiscount = +(totalNetWithDiscount * taxFactor).toFixed(2);
60
60
  // Calculate the taxes as the difference between gross and net:
61
- const totalTaxesApplied = +(productLineImportTotal - totalNetWithoutDiscount).toFixed(2);
61
+ const totalTaxesApplied = +(productLineTotalWithDiscount - totalNetWithDiscount).toFixed(2);
62
62
  const lineDiscount = +(discountAmountPerUnit * qty).toFixed(2);
63
63
  return {
64
64
  product: current,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.164",
3
+ "version": "0.0.165",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -32,6 +32,7 @@ export const calculateOrderTotal = (
32
32
  let discountCodeAmount = 0;
33
33
  let shippingCost = getShippingCost(discountCodeObj, hasShippingCost, storeSettings);
34
34
 
35
+ // TODO: MAYBE THIS KIND OF DISCOUNT IS WRONG BECAUSE TAXES ARE CALCULATED BEFORE THIS POINT;
35
36
  if (discountCodeObj && discountCodeObj.type === DiscountCodeTypes.NUMBER && discountCodeObj.applyOnceOnOrder) {
36
37
  const includesProducts = discountCodeObj.applyToAllProducts || order.products.some((curr: any) => discountCodeObj.products.includes(curr._id));
37
38
  discountCodeAmount = includesProducts ? discountCodeObj.value : 0;
@@ -74,7 +74,7 @@ export const calculateTotalTaxesIncluded = (
74
74
  const productLineTotalWithDiscount = + (totalNetWithDiscount * taxFactor).toFixed(2);
75
75
 
76
76
  // Calculate the taxes as the difference between gross and net:
77
- const totalTaxesApplied = + (productLineImportTotal - totalNetWithoutDiscount).toFixed(2);
77
+ const totalTaxesApplied = + (productLineTotalWithDiscount - totalNetWithDiscount).toFixed(2);
78
78
 
79
79
  const lineDiscount = + (discountAmountPerUnit * qty).toFixed(2);
80
80