@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.
@@ -689,6 +689,8 @@ if (false) {
689
689
  TransactionDocument.prototype.externalTransactionDetails;
690
690
  /** @type {?|undefined} */
691
691
  TransactionDocument.prototype.refundRequest;
692
+ /** @type {?|undefined} */
693
+ TransactionDocument.prototype.isInStoreOrder;
692
694
  }
693
695
  /**
694
696
  * @record
@@ -1468,6 +1470,8 @@ if (false) {
1468
1470
  OrderDetails.prototype.tax_rounded_at_group;
1469
1471
  /** @type {?|undefined} */
1470
1472
  OrderDetails.prototype.tax_total;
1473
+ /** @type {?|undefined} */
1474
+ OrderDetails.prototype.c_isInStoreOrder;
1471
1475
  }
1472
1476
  /** @enum {string} */
1473
1477
  var PROVIDERS = {
@@ -7231,6 +7235,7 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
7231
7235
  terminalId: "",
7232
7236
  initiatingModule: "",
7233
7237
  export: false,
7238
+ isInStoreOrder: false,
7234
7239
  basket: {},
7235
7240
  basketSummary: {},
7236
7241
  baseCurrency: "",
@@ -7643,66 +7648,47 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
7643
7648
  */
7644
7649
  function (txDoc, promotion) {
7645
7650
  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);
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 {?} product
7675
+ * @return {?}
7676
+ */
7677
+ function (product) {
7678
+ product = _this.validateProductItemDiscount(product);
7679
+ if (promotion.itemLineIds.includes(+product.itemLineId)) {
7694
7680
  /** @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
- }
7681
+ var productItem = _this.orderDetails.product_items.find((/**
7682
+ * @param {?} productItem
7683
+ * @return {?}
7684
+ */
7685
+ function (productItem) { return productItem.product_id === product.SKU; }));
7686
+ /** @type {?} */
7687
+ var transactionPromotionPortion = (productItem && productItem.price_after_item_discount && productItem.price_after_order_discount) ?
7688
+ (productItem.price_after_item_discount - productItem.price_after_order_discount) : 0;
7689
+ product.itemDiscounts.trnPromotionsPortion += _this.numberUtilService.trimTo2Decimal2(transactionPromotionPortion);
7690
+ }
7691
+ }));
7706
7692
  }
7707
7693
  return txDoc;
7708
7694
  };
@@ -7789,6 +7775,24 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
7789
7775
  console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: customer mapping ended...");
7790
7776
  return (/** @type {?} */ (this));
7791
7777
  };
7778
+ /**
7779
+ * @template THIS
7780
+ * @this {THIS}
7781
+ * @return {THIS}
7782
+ */
7783
+ WebReturnSalesforceMapperBuilderClass.prototype.isInStoreOrder = /**
7784
+ * @template THIS
7785
+ * @this {THIS}
7786
+ * @return {THIS}
7787
+ */
7788
+ function () {
7789
+ console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping started...");
7790
+ if ((/** @type {?} */ (this)).orderDetails.c_isInStoreOrder) {
7791
+ (/** @type {?} */ (this)).webReturnObject.isInStoreOrder = true;
7792
+ }
7793
+ console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping ended...");
7794
+ return (/** @type {?} */ (this));
7795
+ };
7792
7796
  /**
7793
7797
  * @template THIS
7794
7798
  * @this {THIS}