ordering-ui-admin-external 1.43.58 → 1.43.59

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.
@@ -19,7 +19,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
19
19
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
21
  var OrderToPrintTicket = exports.OrderToPrintTicket = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
22
- var _configs$driver_tip_t, _configs$driver_tip_u, _order$summary2, _replace$trim, _ref2, _order$customer$name, _order$customer, _order$customer$middl, _order$customer2, _order$customer$lastn, _order$customer3, _order$customer$secon, _order$customer4, _getOrderStatus, _order$paymethod, _order$customer5, _order$customer6, _order$customer7, _order$customer8, _order$customer9, _order$customer10, _order$customer11, _order$customer12, _order$business, _order$business2, _order$business3, _order$business4, _order$business5, _order$business6, _order$business7, _order$business8, _order$business9, _order$products, _order$products2, _ref3, _order$summary3, _order$summary4, _order$summary$subtot, _order$summary5, _order$summary6, _order$summary7, _order$summary8, _order$summary9, _order$summary$tax2, _order$summary10, _order$summary11, _order$summary12, _order$summary$driver, _order$summary13, _order$summary14, _order$summary$servic, _order$summary15, _order$summary$total, _order$summary16;
22
+ var _configs$driver_tip_t, _configs$driver_tip_u, _order$summary2, _replace$trim, _ref2, _order$customer$name, _order$customer, _order$customer$middl, _order$customer2, _order$customer$lastn, _order$customer3, _order$customer$secon, _order$customer4, _getOrderStatus, _order$paymethod, _order$customer5, _order$customer6, _order$customer7, _order$customer8, _order$customer9, _order$customer10, _order$customer11, _order$customer12, _order$business, _order$business2, _order$business3, _order$business4, _order$business5, _order$business6, _order$business7, _order$business8, _order$business9, _order$products, _order$products2, _order$summary$subtot, _order$summary3, _ref3, _order$summary4, _order$offers, _order$summary$discou, _order$summary5, _order$offers2, _order$offers3, _order$summary6, _order$summary7, _order$summary8, _ref4, _order$summary9, _order$summary$subtot2, _order$summary10, _order$taxes3, _order$summary$tax2, _order$summary11, _order$fees, _order$summary$servic, _order$summary12, _order$taxes4, _order$taxes5, _order$fees2, _order$fees3, _order$offers4, _order$offers5, _order$summary13, _order$summary14, _order$taxes6, _order$taxes7, _order$offers6, _order$offers7, _order$summary$driver, _order$summary15, _order$summary$total, _order$summary16;
23
23
  var order = props.order,
24
24
  getOrderStatus = props.getOrderStatus;
25
25
  var _useLanguage = (0, _orderingComponentsAdminExternal.useLanguage)(),
@@ -94,16 +94,25 @@ var OrderToPrintTicket = exports.OrderToPrintTicket = /*#__PURE__*/(0, _react.fo
94
94
  });
95
95
  return array.join('');
96
96
  };
97
- var getIncludedTaxes = function getIncludedTaxes(isDeliveryFee) {
97
+ var getIncludedTaxesDiscounts = function getIncludedTaxesDiscounts() {
98
98
  var _order$taxes;
99
+ return order === null || order === void 0 || (_order$taxes = order.taxes) === null || _order$taxes === void 0 || (_order$taxes = _order$taxes.filter(function (tax) {
100
+ return (tax === null || tax === void 0 ? void 0 : tax.type) === 1 && (tax === null || tax === void 0 ? void 0 : tax.target) === 'product';
101
+ })) === null || _order$taxes === void 0 ? void 0 : _order$taxes.reduce(function (carry, tax) {
102
+ var _tax$summary$tax_afte, _tax$summary, _tax$summary2;
103
+ return carry + ((_tax$summary$tax_afte = tax === null || tax === void 0 || (_tax$summary = tax.summary) === null || _tax$summary === void 0 ? void 0 : _tax$summary.tax_after_discount) !== null && _tax$summary$tax_afte !== void 0 ? _tax$summary$tax_afte : tax === null || tax === void 0 || (_tax$summary2 = tax.summary) === null || _tax$summary2 === void 0 ? void 0 : _tax$summary2.tax);
104
+ }, 0);
105
+ };
106
+ var getIncludedTaxes = function getIncludedTaxes(isDeliveryFee) {
107
+ var _order$taxes2;
99
108
  if (!(order !== null && order !== void 0 && order.taxes)) return 0;
100
- if ((order === null || order === void 0 || (_order$taxes = order.taxes) === null || _order$taxes === void 0 ? void 0 : _order$taxes.length) === 0) {
109
+ if ((order === null || order === void 0 || (_order$taxes2 = order.taxes) === null || _order$taxes2 === void 0 ? void 0 : _order$taxes2.length) === 0) {
101
110
  var _order$summary$tax, _order$summary;
102
111
  return order.tax_type === 1 ? (_order$summary$tax = order === null || order === void 0 || (_order$summary = order.summary) === null || _order$summary === void 0 ? void 0 : _order$summary.tax) !== null && _order$summary$tax !== void 0 ? _order$summary$tax : 0 : 0;
103
112
  } else {
104
113
  return order === null || order === void 0 ? void 0 : order.taxes.reduce(function (taxIncluded, tax) {
105
- var _tax$summary;
106
- return taxIncluded + (!isDeliveryFee && tax.type === 1 && tax.target === 'product' || isDeliveryFee && tax.type === 1 && tax.target === 'delivery_fee' ? (_tax$summary = tax.summary) === null || _tax$summary === void 0 ? void 0 : _tax$summary.tax : 0);
114
+ var _tax$summary3;
115
+ return taxIncluded + (!isDeliveryFee && tax.type === 1 && tax.target === 'product' || isDeliveryFee && tax.type === 1 && tax.target === 'delivery_fee' ? (_tax$summary3 = tax.summary) === null || _tax$summary3 === void 0 ? void 0 : _tax$summary3.tax : 0);
107
116
  }, 0);
108
117
  }
109
118
  };
@@ -134,8 +143,74 @@ var OrderToPrintTicket = exports.OrderToPrintTicket = /*#__PURE__*/(0, _react.fo
134
143
  key: i
135
144
  }, option);
136
145
  })));
137
- }))), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('SUBTOTAL', 'Subtotal')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((order === null || order === void 0 ? void 0 : order.tax_type) === 1 ? (_ref3 = (order === null || order === void 0 || (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.subtotal) + (order === null || order === void 0 || (_order$summary4 = order.summary) === null || _order$summary4 === void 0 ? void 0 : _order$summary4.tax)) !== null && _ref3 !== void 0 ? _ref3 : 0 : (_order$summary$subtot = order === null || order === void 0 || (_order$summary5 = order.summary) === null || _order$summary5 === void 0 ? void 0 : _order$summary5.subtotal) !== null && _order$summary$subtot !== void 0 ? _order$summary$subtot : 0))), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, (order === null || order === void 0 || (_order$summary6 = order.summary) === null || _order$summary6 === void 0 ? void 0 : _order$summary6.discount) > 0 ? (order === null || order === void 0 ? void 0 : order.offer_type) === 1 ? /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DISCOUNT', 'Discount'), " (", (0, _utils.verifyDecimals)(order === null || order === void 0 ? void 0 : order.offer_rate, parsePrice), "%)") : /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, " ", t('DISCOUNT', 'Discount')) : '', (order === null || order === void 0 || (_order$summary7 = order.summary) === null || _order$summary7 === void 0 ? void 0 : _order$summary7.discount) > 0 ? /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, "- ", parsePrice(order === null || order === void 0 || (_order$summary8 = order.summary) === null || _order$summary8 === void 0 ? void 0 : _order$summary8.discount)) : ''), (order === null || order === void 0 ? void 0 : order.tax_type) !== 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('TAX', 'Tax'), ' ', "(".concat((0, _utils.verifyDecimals)(order === null || order === void 0 || (_order$summary9 = order.summary) === null || _order$summary9 === void 0 ? void 0 : _order$summary9.tax_rate, parseNumber), "%)")), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$tax2 = order === null || order === void 0 || (_order$summary10 = order.summary) === null || _order$summary10 === void 0 ? void 0 : _order$summary10.tax) !== null && _order$summary$tax2 !== void 0 ? _order$summary$tax2 : 0)))), (order === null || order === void 0 || (_order$summary11 = order.summary) === null || _order$summary11 === void 0 ? void 0 : _order$summary11.delivery_price) > 0 && /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DELIVERY_FEE', 'Delivery Fee')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((order === null || order === void 0 || (_order$summary12 = order.summary) === null || _order$summary12 === void 0 ? void 0 : _order$summary12.delivery_price) + getIncludedTaxes(true), {
146
+ }))), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('SUBTOTAL', 'Subtotal')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice(((_order$summary$subtot = order === null || order === void 0 || (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.subtotal) !== null && _order$summary$subtot !== void 0 ? _order$summary$subtot : order === null || order === void 0 ? void 0 : order.subtotal) + getIncludedTaxes(), {
147
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
148
+ }))), ((_ref3 = (order === null || order === void 0 || (_order$summary4 = order.summary) === null || _order$summary4 === void 0 ? void 0 : _order$summary4.discount) > 0) !== null && _ref3 !== void 0 ? _ref3 : (order === null || order === void 0 ? void 0 : order.discount) > 0) && (order === null || order === void 0 || (_order$offers = order.offers) === null || _order$offers === void 0 ? void 0 : _order$offers.length) === 0 && /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, (order === null || order === void 0 ? void 0 : order.offer_type) === 1 ? /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DISCOUNT', 'Discount'), ' ', "(".concat((0, _utils.verifyDecimals)(order === null || order === void 0 ? void 0 : order.offer_rate, parsePrice), "%)")) : /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DISCOUNT', 'Discount')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, "- ", parsePrice((_order$summary$discou = order === null || order === void 0 || (_order$summary5 = order.summary) === null || _order$summary5 === void 0 ? void 0 : _order$summary5.discount) !== null && _order$summary$discou !== void 0 ? _order$summary$discou : order === null || order === void 0 ? void 0 : order.discount, {
149
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
150
+ }))), (order === null || order === void 0 || (_order$offers2 = order.offers) === null || _order$offers2 === void 0 ? void 0 : _order$offers2.length) > 0 && (order === null || order === void 0 || (_order$offers3 = order.offers) === null || _order$offers3 === void 0 || (_order$offers3 = _order$offers3.filter(function (offer) {
151
+ return (offer === null || offer === void 0 ? void 0 : offer.target) === 1;
152
+ })) === null || _order$offers3 === void 0 ? void 0 : _order$offers3.map(function (offer) {
153
+ var _offer$name, _offer$summary;
154
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
155
+ key: offer.id
156
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t(offer === null || offer === void 0 || (_offer$name = offer.name) === null || _offer$name === void 0 || (_offer$name = _offer$name.toUpperCase()) === null || _offer$name === void 0 ? void 0 : _offer$name.replaceAll(' ', '_'), offer.name), offer.rate_type === 1 && ' '.concat("(".concat((0, _utils.verifyDecimals)(offer === null || offer === void 0 ? void 0 : offer.rate, parsePrice), "%)"))), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, "- ", parsePrice(offer === null || offer === void 0 || (_offer$summary = offer.summary) === null || _offer$summary === void 0 ? void 0 : _offer$summary.discount, {
157
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
158
+ })));
159
+ })), (order === null || order === void 0 || (_order$summary6 = order.summary) === null || _order$summary6 === void 0 ? void 0 : _order$summary6.subtotal_with_discount) > 0 && (order === null || order === void 0 || (_order$summary7 = order.summary) === null || _order$summary7 === void 0 ? void 0 : _order$summary7.discount) > 0 && (order === null || order === void 0 || (_order$summary8 = order.summary) === null || _order$summary8 === void 0 ? void 0 : _order$summary8.total) >= 0 && /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')), (order === null || order === void 0 ? void 0 : order.tax_type) === 1 ? /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_ref4 = (order === null || order === void 0 || (_order$summary9 = order.summary) === null || _order$summary9 === void 0 ? void 0 : _order$summary9.subtotal_with_discount) + getIncludedTaxesDiscounts()) !== null && _ref4 !== void 0 ? _ref4 : 0, {
160
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
161
+ })) : /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$subtot2 = order === null || order === void 0 || (_order$summary10 = order.summary) === null || _order$summary10 === void 0 ? void 0 : _order$summary10.subtotal_with_discount) !== null && _order$summary$subtot2 !== void 0 ? _order$summary$subtot2 : 0, {
162
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
163
+ }))), (order === null || order === void 0 || (_order$taxes3 = order.taxes) === null || _order$taxes3 === void 0 ? void 0 : _order$taxes3.length) === 0 && (order === null || order === void 0 ? void 0 : order.tax_type) === 2 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('TAX', 'Tax'), ' ', "(".concat((0, _utils.verifyDecimals)(order === null || order === void 0 ? void 0 : order.tax, parseNumber), "%)")), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$tax2 = order === null || order === void 0 || (_order$summary11 = order.summary) === null || _order$summary11 === void 0 ? void 0 : _order$summary11.tax) !== null && _order$summary$tax2 !== void 0 ? _order$summary$tax2 : 0, {
164
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
165
+ })))), (order === null || order === void 0 || (_order$fees = order.fees) === null || _order$fees === void 0 ? void 0 : _order$fees.length) === 0 && /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('SERVICE_FEE', 'Service fee'), ' ', "(".concat((0, _utils.verifyDecimals)(order === null || order === void 0 ? void 0 : order.service_fee, parseNumber), "%)")), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$servic = order === null || order === void 0 || (_order$summary12 = order.summary) === null || _order$summary12 === void 0 ? void 0 : _order$summary12.service_fee) !== null && _order$summary$servic !== void 0 ? _order$summary$servic : 0, {
166
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
167
+ }))), (order === null || order === void 0 || (_order$taxes4 = order.taxes) === null || _order$taxes4 === void 0 ? void 0 : _order$taxes4.length) > 0 && (order === null || order === void 0 || (_order$taxes5 = order.taxes) === null || _order$taxes5 === void 0 ? void 0 : _order$taxes5.filter(function (tax) {
168
+ return (tax === null || tax === void 0 ? void 0 : tax.type) === 2 && (tax === null || tax === void 0 ? void 0 : tax.rate) !== 0 && (tax === null || tax === void 0 ? void 0 : tax.target) === 'product';
169
+ }).map(function (tax) {
170
+ var _tax$name, _ref5, _tax$summary$tax_afte2, _tax$summary4, _tax$summary5;
171
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
172
+ key: tax === null || tax === void 0 ? void 0 : tax.id
173
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t(tax === null || tax === void 0 || (_tax$name = tax.name) === null || _tax$name === void 0 || (_tax$name = _tax$name.toUpperCase()) === null || _tax$name === void 0 ? void 0 : _tax$name.replaceAll(' ', '_'), tax === null || tax === void 0 ? void 0 : tax.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business'), ' ', "(".concat((0, _utils.verifyDecimals)(tax === null || tax === void 0 ? void 0 : tax.rate, parseNumber), "%)")), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_ref5 = (_tax$summary$tax_afte2 = tax === null || tax === void 0 || (_tax$summary4 = tax.summary) === null || _tax$summary4 === void 0 ? void 0 : _tax$summary4.tax_after_discount) !== null && _tax$summary$tax_afte2 !== void 0 ? _tax$summary$tax_afte2 : tax === null || tax === void 0 || (_tax$summary5 = tax.summary) === null || _tax$summary5 === void 0 ? void 0 : _tax$summary5.tax) !== null && _ref5 !== void 0 ? _ref5 : 0, {
174
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
175
+ })));
176
+ })), (order === null || order === void 0 || (_order$fees2 = order.fees) === null || _order$fees2 === void 0 ? void 0 : _order$fees2.length) > 0 && (order === null || order === void 0 || (_order$fees3 = order.fees) === null || _order$fees3 === void 0 || (_order$fees3 = _order$fees3.filter(function (fee) {
177
+ return !((fee === null || fee === void 0 ? void 0 : fee.fixed) === 0 && (fee === null || fee === void 0 ? void 0 : fee.percentage) === 0);
178
+ })) === null || _order$fees3 === void 0 ? void 0 : _order$fees3.map(function (fee) {
179
+ var _fee$name, _ref6, _fee$summary, _fee$summary$percenta, _fee$summary2, _fee$summary3;
180
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
181
+ key: fee.id
182
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t(fee === null || fee === void 0 || (_fee$name = fee.name) === null || _fee$name === void 0 || (_fee$name = _fee$name.toUpperCase()) === null || _fee$name === void 0 ? void 0 : _fee$name.replace(/ /g, '_'), fee === null || fee === void 0 ? void 0 : fee.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business'), "(", (fee === null || fee === void 0 ? void 0 : fee.fixed) > 0 && "".concat(parsePrice(fee === null || fee === void 0 ? void 0 : fee.fixed), " + "), fee.percentage, "%)"), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_ref6 = (fee === null || fee === void 0 || (_fee$summary = fee.summary) === null || _fee$summary === void 0 ? void 0 : _fee$summary.fixed) + ((_fee$summary$percenta = fee === null || fee === void 0 || (_fee$summary2 = fee.summary) === null || _fee$summary2 === void 0 ? void 0 : _fee$summary2.percentage_after_discount) !== null && _fee$summary$percenta !== void 0 ? _fee$summary$percenta : fee === null || fee === void 0 || (_fee$summary3 = fee.summary) === null || _fee$summary3 === void 0 ? void 0 : _fee$summary3.percentage)) !== null && _ref6 !== void 0 ? _ref6 : 0, {
183
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
184
+ })));
185
+ })), (order === null || order === void 0 || (_order$offers4 = order.offers) === null || _order$offers4 === void 0 ? void 0 : _order$offers4.length) > 0 && (order === null || order === void 0 || (_order$offers5 = order.offers) === null || _order$offers5 === void 0 || (_order$offers5 = _order$offers5.filter(function (offer) {
186
+ return (offer === null || offer === void 0 ? void 0 : offer.target) === 3;
187
+ })) === null || _order$offers5 === void 0 ? void 0 : _order$offers5.map(function (offer) {
188
+ var _offer$name2, _offer$summary2;
189
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
190
+ key: offer.id
191
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t((_offer$name2 = offer.name) === null || _offer$name2 === void 0 || (_offer$name2 = _offer$name2.toUpperCase()) === null || _offer$name2 === void 0 ? void 0 : _offer$name2.replace(/ /g, '_'), offer.name), offer.rate_type === 1 && ' '.concat("(".concat((0, _utils.verifyDecimals)(offer === null || offer === void 0 ? void 0 : offer.rate, parsePrice), "%)"))), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, "- ", parsePrice(offer === null || offer === void 0 || (_offer$summary2 = offer.summary) === null || _offer$summary2 === void 0 ? void 0 : _offer$summary2.discount, {
192
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
193
+ })));
194
+ })), (order === null || order === void 0 || (_order$summary13 = order.summary) === null || _order$summary13 === void 0 ? void 0 : _order$summary13.delivery_price) > 0 && /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DELIVERY_FEE', 'Delivery Fee')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((order === null || order === void 0 || (_order$summary14 = order.summary) === null || _order$summary14 === void 0 ? void 0 : _order$summary14.delivery_price) + getIncludedTaxes(true), {
195
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
196
+ }))), (order === null || order === void 0 || (_order$taxes6 = order.taxes) === null || _order$taxes6 === void 0 ? void 0 : _order$taxes6.length) > 0 && (order === null || order === void 0 || (_order$taxes7 = order.taxes) === null || _order$taxes7 === void 0 ? void 0 : _order$taxes7.filter(function (tax) {
197
+ return (tax === null || tax === void 0 ? void 0 : tax.type) === 2 && (tax === null || tax === void 0 ? void 0 : tax.rate) !== 0 && (tax === null || tax === void 0 ? void 0 : tax.target) === 'delivery_fee';
198
+ }).map(function (tax) {
199
+ var _tax$name2, _ref7, _tax$summary$tax_afte3, _tax$summary6, _tax$summary7;
200
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
201
+ key: tax === null || tax === void 0 ? void 0 : tax.id
202
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t(tax === null || tax === void 0 || (_tax$name2 = tax.name) === null || _tax$name2 === void 0 || (_tax$name2 = _tax$name2.toUpperCase()) === null || _tax$name2 === void 0 ? void 0 : _tax$name2.replace(/ /g, '_'), tax === null || tax === void 0 ? void 0 : tax.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business'), ' ', "(".concat((0, _utils.verifyDecimals)(tax === null || tax === void 0 ? void 0 : tax.rate, parseNumber), "%)")), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_ref7 = (_tax$summary$tax_afte3 = tax === null || tax === void 0 || (_tax$summary6 = tax.summary) === null || _tax$summary6 === void 0 ? void 0 : _tax$summary6.tax_after_discount) !== null && _tax$summary$tax_afte3 !== void 0 ? _tax$summary$tax_afte3 : tax === null || tax === void 0 || (_tax$summary7 = tax.summary) === null || _tax$summary7 === void 0 ? void 0 : _tax$summary7.tax) !== null && _ref7 !== void 0 ? _ref7 : 0)));
203
+ })), (order === null || order === void 0 || (_order$offers6 = order.offers) === null || _order$offers6 === void 0 ? void 0 : _order$offers6.length) > 0 && (order === null || order === void 0 || (_order$offers7 = order.offers) === null || _order$offers7 === void 0 || (_order$offers7 = _order$offers7.filter(function (offer) {
204
+ return (offer === null || offer === void 0 ? void 0 : offer.target) === 2;
205
+ })) === null || _order$offers7 === void 0 ? void 0 : _order$offers7.map(function (offer) {
206
+ var _offer$name3, _offer$summary3;
207
+ return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
208
+ key: offer.id
209
+ }, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t(offer === null || offer === void 0 || (_offer$name3 = offer.name) === null || _offer$name3 === void 0 || (_offer$name3 = _offer$name3.toUpperCase()) === null || _offer$name3 === void 0 ? void 0 : _offer$name3.replaceAll(' ', '_'), offer.name), offer.rate_type === 1 && ' '.concat("(".concat((0, _utils.verifyDecimals)(offer === null || offer === void 0 ? void 0 : offer.rate, parsePrice), "%)"))), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, "- ", parsePrice(offer === null || offer === void 0 || (_offer$summary3 = offer.summary) === null || _offer$summary3 === void 0 ? void 0 : _offer$summary3.discount, {
210
+ currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
211
+ })));
212
+ })), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DRIVER_TIP', 'Driver tip'), percentTip ? "(".concat(percentTip, "%)") : ''), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$driver = order === null || order === void 0 || (_order$summary15 = order.summary) === null || _order$summary15 === void 0 ? void 0 : _order$summary15.driver_tip) !== null && _order$summary$driver !== void 0 ? _order$summary$driver : order === null || order === void 0 ? void 0 : order.totalDriverTip, {
138
213
  currency: (0, _utils.getCurrenySymbol)(order === null || order === void 0 ? void 0 : order.currency)
139
- }))), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('DRIVER_TIP', 'Driver tip'), percentTip ? "(".concat(percentTip, "%)") : ''), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$driver = order === null || order === void 0 || (_order$summary13 = order.summary) === null || _order$summary13 === void 0 ? void 0 : _order$summary13.driver_tip) !== null && _order$summary$driver !== void 0 ? _order$summary$driver : 0))), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('SERVICE_FEE', 'Service Fee'), "(", (0, _utils.verifyDecimals)(order === null || order === void 0 || (_order$summary14 = order.summary) === null || _order$summary14 === void 0 ? void 0 : _order$summary14.service_fee, parseNumber), "%)"), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$servic = order === null || order === void 0 || (_order$summary15 = order.summary) === null || _order$summary15 === void 0 ? void 0 : _order$summary15.service_fee) !== null && _order$summary$servic !== void 0 ? _order$summary$servic : 0))), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('TOTAL', 'Total')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$total = order === null || order === void 0 || (_order$summary16 = order.summary) === null || _order$summary16 === void 0 ? void 0 : _order$summary16.total) !== null && _order$summary$total !== void 0 ? _order$summary$total : 0))));
214
+ }))), /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, null, /*#__PURE__*/_react.default.createElement(_styles.InsideInfo, null, t('TOTAL', 'Total')), /*#__PURE__*/_react.default.createElement(_styles.InsideInfo2, null, parsePrice((_order$summary$total = order === null || order === void 0 || (_order$summary16 = order.summary) === null || _order$summary16 === void 0 ? void 0 : _order$summary16.total) !== null && _order$summary$total !== void 0 ? _order$summary$total : 0))));
140
215
  });
141
216
  OrderToPrintTicket.displayName = 'OrderToPrintTicket';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-admin-external",
3
- "version": "1.43.58",
3
+ "version": "1.43.59",
4
4
  "description": "Ordering UI Admin Components",
5
5
  "main": "./_modules/index.js",
6
6
  "exports": {
@@ -59,6 +59,10 @@ export const OrderToPrintTicket = forwardRef((props, ref) => {
59
59
  return array.join('')
60
60
  }
61
61
 
62
+ const getIncludedTaxesDiscounts = () => {
63
+ return order?.taxes?.filter(tax => (tax?.type === 1 && tax?.target === 'product'))?.reduce((carry, tax) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
64
+ }
65
+
62
66
  const getIncludedTaxes = (isDeliveryFee) => {
63
67
  if (!order?.taxes) return 0
64
68
  if (order?.taxes?.length === 0) {
@@ -185,39 +189,108 @@ export const OrderToPrintTicket = forwardRef((props, ref) => {
185
189
  {t('SUBTOTAL', 'Subtotal')}
186
190
  </InsideInfo>
187
191
  <InsideInfo2>
188
- {parsePrice(
189
- order?.tax_type === 1
190
- ? order?.summary?.subtotal + order?.summary?.tax ?? 0
191
- : order?.summary?.subtotal ?? 0
192
- )}
192
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: getCurrenySymbol(order?.currency) })}
193
193
  </InsideInfo2>
194
194
  </InfoContainer>
195
- <InfoContainer>
196
- {order?.summary?.discount > 0
197
- ? order?.offer_type === 1
198
- ? <InsideInfo>{t('DISCOUNT', 'Discount')} ({verifyDecimals(order?.offer_rate, parsePrice)}%)</InsideInfo>
199
- : <InsideInfo> {t('DISCOUNT', 'Discount')}</InsideInfo>
200
- : ''}
201
- {order?.summary?.discount > 0
202
- ? <InsideInfo2>- {parsePrice(order?.summary?.discount)}</InsideInfo2>
203
- : ''}
204
- </InfoContainer>
205
195
 
206
- {order?.tax_type !== 1 && (
196
+ {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
197
+ <InfoContainer>
198
+ {order?.offer_type === 1
199
+ ? (
200
+ <InsideInfo>
201
+ {t('DISCOUNT', 'Discount')}{' '}
202
+ {`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}
203
+ </InsideInfo>
204
+ ) : (
205
+ <InsideInfo>{t('DISCOUNT', 'Discount')}</InsideInfo>
206
+ )}
207
+ <InsideInfo2>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>
208
+ </InfoContainer>
209
+ )}
210
+
211
+ {order?.offers?.length > 0 && order?.offers?.filter(offer => offer?.target === 1)?.map(offer => (
212
+ <InfoContainer key={offer.id}>
213
+ <InsideInfo>
214
+ {t(offer?.name?.toUpperCase()?.replaceAll(' ', '_'), offer.name)}
215
+ {offer.rate_type === 1 && (
216
+ `${' '}${`(${verifyDecimals(offer?.rate, parsePrice)}%)`}`
217
+ )}
218
+ </InsideInfo>
219
+ <InsideInfo2>
220
+ - {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
221
+ </InsideInfo2>
222
+ </InfoContainer>))}
223
+
224
+ {order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
225
+ <InfoContainer>
226
+ <InsideInfo>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</InsideInfo>
227
+ {order?.tax_type === 1
228
+ ? <InsideInfo2>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>
229
+ : <InsideInfo2>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>}
230
+ </InfoContainer>
231
+ )}
232
+
233
+ {order?.taxes?.length === 0 && order?.tax_type === 2 && (
207
234
  <>
208
235
  <InfoContainer>
209
236
  <InsideInfo>
210
237
  {t('TAX', 'Tax')}
211
238
  {' '}
212
- {`(${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%)`}
239
+ {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
213
240
  </InsideInfo>
214
241
  <InsideInfo2>
215
- {parsePrice(order?.summary?.tax ?? 0)}
242
+ {parsePrice(order?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
216
243
  </InsideInfo2>
217
244
  </InfoContainer>
218
245
  </>
219
246
  )}
220
247
 
248
+ {order?.fees?.length === 0 && (
249
+ <InfoContainer>
250
+ <InsideInfo>
251
+ {t('SERVICE_FEE', 'Service fee')}
252
+ {' '}
253
+ {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
254
+ </InsideInfo>
255
+ <InsideInfo2>{parsePrice(order?.summary?.service_fee ?? 0, { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>
256
+ </InfoContainer>
257
+ )}
258
+
259
+ {order?.taxes?.length > 0 && order?.taxes?.filter(tax => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'product').map(tax => (
260
+ <InfoContainer key={tax?.id}>
261
+ <InsideInfo>
262
+ {t(tax?.name?.toUpperCase()?.replaceAll(' ', '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
263
+ {' '}
264
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}
265
+ </InsideInfo>
266
+ <InsideInfo2>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>
267
+ </InfoContainer>
268
+ ))}
269
+
270
+ {order?.fees?.length > 0 && order?.fees?.filter(fee => !(fee?.fixed === 0 && fee?.percentage === 0))?.map(fee => (
271
+ <InfoContainer key={fee.id}>
272
+ <InsideInfo>
273
+ {t(fee?.name?.toUpperCase()?.replace(/ /g, '_'), fee?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
274
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%)
275
+ </InsideInfo>
276
+ <InsideInfo2>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: getCurrenySymbol(order?.currency) })}</InsideInfo2>
277
+ </InfoContainer>
278
+ ))}
279
+
280
+ {order?.offers?.length > 0 && order?.offers?.filter(offer => offer?.target === 3)?.map(offer => (
281
+ <InfoContainer key={offer.id}>
282
+ <InsideInfo>
283
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
284
+ {offer.rate_type === 1 && (
285
+ `${' '}${`(${verifyDecimals(offer?.rate, parsePrice)}%)`}`
286
+ )}
287
+ </InsideInfo>
288
+ <InsideInfo2>
289
+ - {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
290
+ </InsideInfo2>
291
+ </InfoContainer>
292
+ ))}
293
+
221
294
  {order?.summary?.delivery_price > 0 && (
222
295
  <InfoContainer>
223
296
  <InsideInfo>
@@ -229,23 +302,37 @@ export const OrderToPrintTicket = forwardRef((props, ref) => {
229
302
  </InfoContainer>
230
303
  )}
231
304
 
305
+ {order?.taxes?.length > 0 && order?.taxes?.filter(tax => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'delivery_fee').map(tax => (
306
+ <InfoContainer key={tax?.id}>
307
+ <InsideInfo>
308
+ {t(tax?.name?.toUpperCase()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
309
+ {' '}{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}
310
+ </InsideInfo>
311
+ <InsideInfo2>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</InsideInfo2>
312
+ </InfoContainer>
313
+ ))}
314
+
315
+ {order?.offers?.length > 0 && order?.offers?.filter(offer => offer?.target === 2)?.map(offer => (
316
+ <InfoContainer key={offer.id}>
317
+ <InsideInfo>
318
+ {t(offer?.name?.toUpperCase()?.replaceAll(' ', '_'), offer.name)}
319
+ {offer.rate_type === 1 && (
320
+ `${' '}${`(${verifyDecimals(offer?.rate, parsePrice)}%)`}`
321
+ )}
322
+ </InsideInfo>
323
+ <InsideInfo2>
324
+ - {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
325
+ </InsideInfo2>
326
+ </InfoContainer>
327
+ ))}
328
+
232
329
  <InfoContainer>
233
330
  <InsideInfo>
234
331
  {t('DRIVER_TIP', 'Driver tip')}
235
332
  {percentTip ? `(${percentTip}%)` : ''}
236
333
  </InsideInfo>
237
334
  <InsideInfo2>
238
- {parsePrice(order?.summary?.driver_tip ?? 0)}
239
- </InsideInfo2>
240
- </InfoContainer>
241
-
242
- <InfoContainer>
243
- <InsideInfo>
244
- {t('SERVICE_FEE', 'Service Fee')}
245
- ({verifyDecimals(order?.summary?.service_fee, parseNumber)}%)
246
- </InsideInfo>
247
- <InsideInfo2>
248
- {parsePrice(order?.summary?.service_fee ?? 0)}
335
+ {parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: getCurrenySymbol(order?.currency) })}
249
336
  </InsideInfo2>
250
337
  </InfoContainer>
251
338