@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.
@@ -2022,10 +2022,13 @@ var AzzasTracker = (() => {
2022
2022
  total_discount: (context) => {
2023
2023
  var _a, _b, _c;
2024
2024
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
2025
- if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
2026
- const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
2027
- const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
2028
- return Math.abs(productDiscount) / 100 || null;
2025
+ const orderForm = context == null ? void 0 : context.orderForm;
2026
+ const items = orderForm == null ? void 0 : orderForm.items;
2027
+ if (!(items == null ? void 0 : items.length) || typeof (orderForm == null ? void 0 : orderForm.value) !== "number") return null;
2028
+ const itemsFullValue = items.reduce((acc, item) => acc + item.listPrice * item.quantity, 0);
2029
+ 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;
2030
+ const derived = itemsFullValue + shipping - orderForm.value;
2031
+ return derived > 0 ? derived / 100 : null;
2029
2032
  },
2030
2033
  subtotal: (context) => {
2031
2034
  var _a, _b;