@azzas/azzas-tracker-web 2.0.0 → 2.0.1-preview.0

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/dist/mod.js CHANGED
@@ -1993,10 +1993,13 @@ var orderFormAdapter = {
1993
1993
  total_discount: (context) => {
1994
1994
  var _a, _b, _c;
1995
1995
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
1996
- if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1997
- const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
1998
- const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
1999
- return Math.abs(productDiscount) / 100 || null;
1996
+ const orderForm = context == null ? void 0 : context.orderForm;
1997
+ const items = orderForm == null ? void 0 : orderForm.items;
1998
+ if (!(items == null ? void 0 : items.length) || typeof (orderForm == null ? void 0 : orderForm.value) !== "number") return null;
1999
+ const itemsFullValue = items.reduce((acc, item) => acc + item.listPrice * item.quantity, 0);
2000
+ const shipping = (_c = (_b = (_a = orderForm == null ? void 0 : orderForm.totalizers) == null ? void 0 : _a.find((t) => t.id === "Shipping")) == null ? void 0 : _b.value) != null ? _c : 0;
2001
+ const derived = itemsFullValue + shipping - orderForm.value;
2002
+ return derived > 0 ? derived / 100 : null;
2000
2003
  },
2001
2004
  subtotal: (context) => {
2002
2005
  var _a, _b;