@pmcretail/mapper-library 0.0.34 → 0.0.36

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.
@@ -909,6 +909,8 @@
909
909
  TransactionDocument.prototype.externalTransactionDetails;
910
910
  /** @type {?|undefined} */
911
911
  TransactionDocument.prototype.refundRequest;
912
+ /** @type {?|undefined} */
913
+ TransactionDocument.prototype.isInStoreOrder;
912
914
  }
913
915
  /**
914
916
  * @record
@@ -1688,6 +1690,8 @@
1688
1690
  OrderDetails.prototype.tax_rounded_at_group;
1689
1691
  /** @type {?|undefined} */
1690
1692
  OrderDetails.prototype.tax_total;
1693
+ /** @type {?|undefined} */
1694
+ OrderDetails.prototype.c_isInStoreOrder;
1691
1695
  }
1692
1696
  /** @enum {string} */
1693
1697
  var PROVIDERS = {
@@ -7451,6 +7455,7 @@
7451
7455
  terminalId: "",
7452
7456
  initiatingModule: "",
7453
7457
  export: false,
7458
+ isInStoreOrder: false,
7454
7459
  basket: {},
7455
7460
  basketSummary: {},
7456
7461
  baseCurrency: "",
@@ -7863,66 +7868,47 @@
7863
7868
  */
7864
7869
  function (txDoc, promotion) {
7865
7870
  var _this = this;
7866
- /** @type {?} */
7867
- var total = 0;
7868
- /** @type {?} */
7869
- var percentage = 0;
7870
- {
7871
- console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
7872
- if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
7873
- txDoc.basket.products.forEach((/**
7874
- * @param {?} product
7875
- * @return {?}
7876
- */
7877
- function (product) {
7878
- product = _this.validateProductItemDiscount(product);
7879
- if (promotion.trigger && promotion.trigger.length > 0) {
7880
- promotion.trigger.forEach((/**
7881
- * @param {?} t
7882
- * @return {?}
7883
- */
7884
- function (t) {
7885
- if (t.itemLineId === product.itemLineId.toString()) {
7886
- product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
7887
- }
7888
- }));
7889
- }
7890
- }));
7891
- }
7892
- else {
7893
- txDoc.basket.products.forEach((/**
7894
- * @param {?} p
7895
- * @return {?}
7896
- */
7897
- function (p) {
7898
- if (promotion.itemLineIds && promotion.itemLineIds.includes(p.itemLineId) && !p.giftCard) {
7899
- p = _this.validateProductItemDiscount(p);
7900
- /** @type {?} */
7901
- var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnDiscountsPortion) +
7902
- _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnPromotionsPortion) -
7903
- _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.refundPortion);
7904
- total += (p.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
7905
- }
7906
- }));
7907
- console.log("ebasket: trnsactionPromotion: " + JSON.stringify(promotion) + ", selected products total: " + total);
7908
- txDoc.basket.products.forEach((/**
7909
- * @param {?} product
7910
- * @return {?}
7911
- */
7912
- function (product) {
7913
- product = _this.validateProductItemDiscount(product);
7871
+ console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
7872
+ if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
7873
+ txDoc.basket.products.forEach((/**
7874
+ * @param {?} product
7875
+ * @return {?}
7876
+ */
7877
+ function (product) {
7878
+ product = _this.validateProductItemDiscount(product);
7879
+ if (promotion.trigger && promotion.trigger.length > 0) {
7880
+ promotion.trigger.forEach((/**
7881
+ * @param {?} t
7882
+ * @return {?}
7883
+ */
7884
+ function (t) {
7885
+ if (t.itemLineId === product.itemLineId.toString()) {
7886
+ product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
7887
+ }
7888
+ }));
7889
+ }
7890
+ }));
7891
+ }
7892
+ else {
7893
+ txDoc.basket.products.forEach((/**
7894
+ * @param {?} product
7895
+ * @return {?}
7896
+ */
7897
+ function (product) {
7898
+ product = _this.validateProductItemDiscount(product);
7899
+ if (promotion.itemLineIds.includes(+product.itemLineId)) {
7914
7900
  /** @type {?} */
7915
- var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
7916
- _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
7917
- _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
7918
- if (promotion.itemLineIds.includes(product.itemLineId)) {
7919
- percentage = ((product.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal)) / total) * 100;
7920
- product.itemDiscounts.trnPromotionsPortion +=
7921
- (promotion.promotionAmount * percentage) / 100;
7922
- product.itemDiscounts.trnPromotionsPortion = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion);
7923
- }
7924
- }));
7925
- }
7901
+ var productItem = _this.orderDetails.product_items.find((/**
7902
+ * @param {?} productItem
7903
+ * @return {?}
7904
+ */
7905
+ function (productItem) { return productItem.product_id === product.SKU; }));
7906
+ /** @type {?} */
7907
+ var transactionPromotionPortion = (productItem && productItem.price_after_item_discount && productItem.price_after_order_discount) ?
7908
+ (productItem.price_after_item_discount - productItem.price_after_order_discount) : 0;
7909
+ product.itemDiscounts.trnPromotionsPortion += _this.numberUtilService.trimTo2Decimal2(transactionPromotionPortion);
7910
+ }
7911
+ }));
7926
7912
  }
7927
7913
  return txDoc;
7928
7914
  };
@@ -8009,6 +7995,24 @@
8009
7995
  console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: customer mapping ended...");
8010
7996
  return (/** @type {?} */ (this));
8011
7997
  };
7998
+ /**
7999
+ * @template THIS
8000
+ * @this {THIS}
8001
+ * @return {THIS}
8002
+ */
8003
+ WebReturnSalesforceMapperBuilderClass.prototype.isInStoreOrder = /**
8004
+ * @template THIS
8005
+ * @this {THIS}
8006
+ * @return {THIS}
8007
+ */
8008
+ function () {
8009
+ console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping started...");
8010
+ if ((/** @type {?} */ (this)).orderDetails.c_isInStoreOrder) {
8011
+ (/** @type {?} */ (this)).webReturnObject.isInStoreOrder = true;
8012
+ }
8013
+ console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping ended...");
8014
+ return (/** @type {?} */ (this));
8015
+ };
8012
8016
  /**
8013
8017
  * @template THIS
8014
8018
  * @this {THIS}