@pmcretail/mapper-library 0.0.34 → 0.0.35

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.
@@ -7643,66 +7643,47 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
7643
7643
  */
7644
7644
  function (txDoc, promotion) {
7645
7645
  var _this = this;
7646
- /** @type {?} */
7647
- var total = 0;
7648
- /** @type {?} */
7649
- var percentage = 0;
7650
- {
7651
- console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
7652
- if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
7653
- txDoc.basket.products.forEach((/**
7654
- * @param {?} product
7655
- * @return {?}
7656
- */
7657
- function (product) {
7658
- product = _this.validateProductItemDiscount(product);
7659
- if (promotion.trigger && promotion.trigger.length > 0) {
7660
- promotion.trigger.forEach((/**
7661
- * @param {?} t
7662
- * @return {?}
7663
- */
7664
- function (t) {
7665
- if (t.itemLineId === product.itemLineId.toString()) {
7666
- product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
7667
- }
7668
- }));
7669
- }
7670
- }));
7671
- }
7672
- else {
7673
- txDoc.basket.products.forEach((/**
7674
- * @param {?} p
7675
- * @return {?}
7676
- */
7677
- function (p) {
7678
- if (promotion.itemLineIds && promotion.itemLineIds.includes(p.itemLineId) && !p.giftCard) {
7679
- p = _this.validateProductItemDiscount(p);
7680
- /** @type {?} */
7681
- var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnDiscountsPortion) +
7682
- _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnPromotionsPortion) -
7683
- _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.refundPortion);
7684
- total += (p.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
7685
- }
7686
- }));
7687
- console.log("ebasket: trnsactionPromotion: " + JSON.stringify(promotion) + ", selected products total: " + total);
7688
- txDoc.basket.products.forEach((/**
7689
- * @param {?} product
7690
- * @return {?}
7691
- */
7692
- function (product) {
7693
- product = _this.validateProductItemDiscount(product);
7646
+ console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
7647
+ if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
7648
+ txDoc.basket.products.forEach((/**
7649
+ * @param {?} product
7650
+ * @return {?}
7651
+ */
7652
+ function (product) {
7653
+ product = _this.validateProductItemDiscount(product);
7654
+ if (promotion.trigger && promotion.trigger.length > 0) {
7655
+ promotion.trigger.forEach((/**
7656
+ * @param {?} t
7657
+ * @return {?}
7658
+ */
7659
+ function (t) {
7660
+ if (t.itemLineId === product.itemLineId.toString()) {
7661
+ product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
7662
+ }
7663
+ }));
7664
+ }
7665
+ }));
7666
+ }
7667
+ else {
7668
+ txDoc.basket.products.forEach((/**
7669
+ * @param {?} product
7670
+ * @return {?}
7671
+ */
7672
+ function (product) {
7673
+ product = _this.validateProductItemDiscount(product);
7674
+ if (promotion.itemLineIds.includes(+product.itemLineId)) {
7694
7675
  /** @type {?} */
7695
- var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
7696
- _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
7697
- _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
7698
- if (promotion.itemLineIds.includes(product.itemLineId)) {
7699
- percentage = ((product.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal)) / total) * 100;
7700
- product.itemDiscounts.trnPromotionsPortion +=
7701
- (promotion.promotionAmount * percentage) / 100;
7702
- product.itemDiscounts.trnPromotionsPortion = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion);
7703
- }
7704
- }));
7705
- }
7676
+ var productItem = _this.orderDetails.product_items.find((/**
7677
+ * @param {?} productItem
7678
+ * @return {?}
7679
+ */
7680
+ function (productItem) { return productItem.product_id === product.SKU; }));
7681
+ /** @type {?} */
7682
+ var transactionPromotionPortion = (productItem && productItem.price_after_item_discount && productItem.price_after_order_discount) ?
7683
+ (productItem.price_after_item_discount - productItem.price_after_order_discount) : 0;
7684
+ product.itemDiscounts.trnPromotionsPortion += _this.numberUtilService.trimTo2Decimal2(transactionPromotionPortion);
7685
+ }
7686
+ }));
7706
7687
  }
7707
7688
  return txDoc;
7708
7689
  };