@pmcretail/mapper-library 0.0.30 → 0.0.31
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.
- package/bundles/pmcretail-mapper-library.umd.js +310 -42
- package/bundles/pmcretail-mapper-library.umd.js.map +1 -1
- package/bundles/pmcretail-mapper-library.umd.min.js +1 -1
- package/bundles/pmcretail-mapper-library.umd.min.js.map +1 -1
- package/esm2015/lib/WebReturnSalesforceMapper.class.js +252 -42
- package/esm2015/lib/mapper-library.model.js +34 -1
- package/esm2015/lib/number-util.service.js +3 -2
- package/esm5/lib/WebReturnSalesforceMapper.class.js +280 -43
- package/esm5/lib/mapper-library.model.js +34 -1
- package/esm5/lib/number-util.service.js +3 -2
- package/fesm2015/pmcretail-mapper-library.js +282 -41
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +310 -42
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/WebReturnSalesforceMapper.class.d.ts +10 -2
- package/lib/mapper-library.model.d.ts +18 -0
- package/lib/number-util.service.d.ts +1 -1
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -481,6 +481,16 @@ if (false) {
|
|
|
481
481
|
Trigger.prototype.quantity;
|
|
482
482
|
/** @type {?|undefined} */
|
|
483
483
|
Trigger.prototype.totalQuantity;
|
|
484
|
+
/** @type {?|undefined} */
|
|
485
|
+
Trigger.prototype.linePromotionAmount;
|
|
486
|
+
/** @type {?|undefined} */
|
|
487
|
+
Trigger.prototype.promotionAmount;
|
|
488
|
+
/** @type {?|undefined} */
|
|
489
|
+
Trigger.prototype.refundedReason;
|
|
490
|
+
/** @type {?|undefined} */
|
|
491
|
+
Trigger.prototype.refundedReasonDescription;
|
|
492
|
+
/** @type {?|undefined} */
|
|
493
|
+
Trigger.prototype.promotionId;
|
|
484
494
|
}
|
|
485
495
|
/**
|
|
486
496
|
* Transaction Promotion
|
|
@@ -502,6 +512,14 @@ if (false) {
|
|
|
502
512
|
TransactionPromotion.prototype.promotionType;
|
|
503
513
|
/** @type {?} */
|
|
504
514
|
TransactionPromotion.prototype.itemLineIds;
|
|
515
|
+
/** @type {?|undefined} */
|
|
516
|
+
TransactionPromotion.prototype.type;
|
|
517
|
+
/** @type {?|undefined} */
|
|
518
|
+
TransactionPromotion.prototype.subLevelType;
|
|
519
|
+
/** @type {?|undefined} */
|
|
520
|
+
TransactionPromotion.prototype.trigger;
|
|
521
|
+
/** @type {?|undefined} */
|
|
522
|
+
TransactionPromotion.prototype.couponCode;
|
|
505
523
|
}
|
|
506
524
|
/**
|
|
507
525
|
* @record
|
|
@@ -664,6 +682,8 @@ if (false) {
|
|
|
664
682
|
TransactionDocument.prototype.isChecked;
|
|
665
683
|
/** @type {?|undefined} */
|
|
666
684
|
TransactionDocument.prototype.externalTransactionDetails;
|
|
685
|
+
/** @type {?|undefined} */
|
|
686
|
+
TransactionDocument.prototype.refundRequest;
|
|
667
687
|
}
|
|
668
688
|
/**
|
|
669
689
|
* @record
|
|
@@ -1237,6 +1257,8 @@ if (false) {
|
|
|
1237
1257
|
ProductItem.prototype.tax_class_id;
|
|
1238
1258
|
/** @type {?|undefined} */
|
|
1239
1259
|
ProductItem.prototype.tax_rate;
|
|
1260
|
+
/** @type {?|undefined} */
|
|
1261
|
+
ProductItem.prototype.c_osuObjectData;
|
|
1240
1262
|
}
|
|
1241
1263
|
/**
|
|
1242
1264
|
* @record
|
|
@@ -1445,6 +1467,15 @@ if (false) {
|
|
|
1445
1467
|
/** @enum {string} */
|
|
1446
1468
|
const PROVIDERS = {
|
|
1447
1469
|
SALESFORCE: "Salesforce",
|
|
1470
|
+
};
|
|
1471
|
+
/** @enum {string} */
|
|
1472
|
+
const PROMOTION_LEVEL = {
|
|
1473
|
+
LINE: "LINE",
|
|
1474
|
+
TRANSACTION: "TRANSACTION",
|
|
1475
|
+
};
|
|
1476
|
+
/** @enum {string} */
|
|
1477
|
+
const PROMOTION_TYPE = {
|
|
1478
|
+
COUPON: "COUPON",
|
|
1448
1479
|
};
|
|
1449
1480
|
|
|
1450
1481
|
/**
|
|
@@ -2321,7 +2352,8 @@ class NumberUtilService {
|
|
|
2321
2352
|
* @return {?}
|
|
2322
2353
|
*/
|
|
2323
2354
|
trimTo2Decimal2(no) {
|
|
2324
|
-
|
|
2355
|
+
// SEAM-11411 - Had to change 2nd param to 3 to fix rounding issue (FIXME - Needs a new story for refactoring)
|
|
2356
|
+
return Number(this.getFlooredFixed(no, 3));
|
|
2325
2357
|
}
|
|
2326
2358
|
/**
|
|
2327
2359
|
* @param {?} v
|
|
@@ -5651,8 +5683,10 @@ if (false) {
|
|
|
5651
5683
|
class WebReturnSalesforceMapperBuilderClass {
|
|
5652
5684
|
/**
|
|
5653
5685
|
* @param {?} orderDetails
|
|
5686
|
+
* @param {?=} currencyPipe
|
|
5654
5687
|
*/
|
|
5655
|
-
constructor(orderDetails) {
|
|
5688
|
+
constructor(orderDetails, currencyPipe) {
|
|
5689
|
+
this.currencyPipe = currencyPipe;
|
|
5656
5690
|
this.webReturnObject = {
|
|
5657
5691
|
id: '',
|
|
5658
5692
|
orgCode: "",
|
|
@@ -5683,6 +5717,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
5683
5717
|
if (orderDetails) {
|
|
5684
5718
|
this.orderDetails = orderDetails;
|
|
5685
5719
|
}
|
|
5720
|
+
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
5686
5721
|
}
|
|
5687
5722
|
/**
|
|
5688
5723
|
* @template THIS
|
|
@@ -5766,7 +5801,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
5766
5801
|
quantity: product.quantity ? product.quantity : 0,
|
|
5767
5802
|
refundedQuantity: 0,
|
|
5768
5803
|
price: product.base_price ? product.base_price : 0,
|
|
5769
|
-
itemLineId: index + 1,
|
|
5804
|
+
itemLineId: (index + 1).toString(),
|
|
5770
5805
|
deliveryMethod: (/** @type {?} */ (this)).getDeliveryMethod().toString(),
|
|
5771
5806
|
totalLinePrice: product.price ? product.price : 0
|
|
5772
5807
|
};
|
|
@@ -5802,23 +5837,25 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
5802
5837
|
* @return {?}
|
|
5803
5838
|
*/
|
|
5804
5839
|
(promotion) => {
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5840
|
+
if (!promotion.coupon_code) {
|
|
5841
|
+
/** @type {?} */
|
|
5842
|
+
let linePromotionObj = (/** @type {?} */ ({}));
|
|
5843
|
+
/** @type {?} */
|
|
5844
|
+
let trigger = (/** @type {?} */ ({}));
|
|
5845
|
+
trigger.itemLineId = product.item_id;
|
|
5846
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
5847
|
+
linePromotionObj.trigger = (/** @type {?} */ ([]));
|
|
5848
|
+
linePromotionObj.trigger.push(trigger);
|
|
5849
|
+
linePromotionObj.itemLineId = index + 1;
|
|
5850
|
+
linePromotionObj.promotionId = promotion.promotion_id ? promotion.promotion_id : '';
|
|
5851
|
+
linePromotionObj.displayText = promotion.item_text ? promotion.item_text : '';
|
|
5852
|
+
linePromotionObj.promotionType = promotion.applied_discount && promotion.applied_discount.type ? promotion.applied_discount.type : '';
|
|
5853
|
+
linePromotionObj.promotionAmount = promotion.price ? Math.abs(promotion.price) : 0;
|
|
5854
|
+
linePromotionObj.name = promotion.coupon_code ? promotion.coupon_code : (promotion.item_text ? promotion.item_text : '');
|
|
5855
|
+
linePromotionObj.promotionInfo = promotion.item_text ? promotion.item_text : '';
|
|
5856
|
+
linePromotionObj.promotionLinePrice = product.price - Math.abs(promotion.price);
|
|
5857
|
+
linePromotionArray.push(linePromotionObj);
|
|
5858
|
+
}
|
|
5822
5859
|
}));
|
|
5823
5860
|
}
|
|
5824
5861
|
}));
|
|
@@ -5835,35 +5872,232 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
5835
5872
|
transactionPromotion() {
|
|
5836
5873
|
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping started...");
|
|
5837
5874
|
/** @type {?} */
|
|
5838
|
-
let transactionPromotionArray = (/** @type {?} */ (
|
|
5839
|
-
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion =
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5875
|
+
let transactionPromotionArray = (/** @type {?} */ (this)).getTransactionPromotions((/** @type {?} */ (this)).orderDetails);
|
|
5876
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = transactionPromotionArray;
|
|
5877
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping ended...");
|
|
5878
|
+
return (/** @type {?} */ (this));
|
|
5879
|
+
}
|
|
5880
|
+
/**
|
|
5881
|
+
* @param {?} basket
|
|
5882
|
+
* @return {?}
|
|
5883
|
+
*/
|
|
5884
|
+
getTransactionPromotions(basket) {
|
|
5885
|
+
try {
|
|
5886
|
+
/** @type {?} */
|
|
5887
|
+
let transactionPromotionArray = (/** @type {?} */ ([]));
|
|
5888
|
+
if (basket.order_price_adjustments && basket.order_price_adjustments.length > 0) {
|
|
5889
|
+
basket.order_price_adjustments.forEach((/**
|
|
5890
|
+
* @param {?} transactionPromotion
|
|
5891
|
+
* @return {?}
|
|
5892
|
+
*/
|
|
5893
|
+
(transactionPromotion) => {
|
|
5894
|
+
/** @type {?} */
|
|
5895
|
+
let transactionPromotionObj = (/** @type {?} */ ({}));
|
|
5896
|
+
transactionPromotionObj.displayText = transactionPromotion.item_text ? transactionPromotion.item_text : '';
|
|
5897
|
+
transactionPromotionObj.name = transactionPromotion.coupon_code ? transactionPromotion.coupon_code : (transactionPromotion.item_text ? transactionPromotion.item_text : '');
|
|
5898
|
+
transactionPromotionObj.promotionAmount = transactionPromotion.price ? -Math.abs(transactionPromotion.price) : 0;
|
|
5899
|
+
transactionPromotionObj.promotionId = transactionPromotion.promotion_id ? transactionPromotion.promotion_id : '';
|
|
5900
|
+
transactionPromotionObj.promotionInfo = transactionPromotion.item_text ? transactionPromotion.item_text : '';
|
|
5901
|
+
transactionPromotionObj.promotionType = transactionPromotion.applied_discount && transactionPromotion.applied_discount.type ? transactionPromotion.applied_discount.type : '';
|
|
5902
|
+
transactionPromotionObj.itemLineIds = this.orderDetails.product_items.map((/**
|
|
5903
|
+
* @param {?} product
|
|
5904
|
+
* @param {?} index
|
|
5905
|
+
* @return {?}
|
|
5906
|
+
*/
|
|
5907
|
+
(product, index) => index + 1));
|
|
5908
|
+
if (transactionPromotion.coupon_code) {
|
|
5909
|
+
transactionPromotionObj.type = PROMOTION_TYPE.COUPON;
|
|
5910
|
+
transactionPromotionObj.couponCode = transactionPromotion.coupon_code;
|
|
5911
|
+
transactionPromotionObj.subLevelType = PROMOTION_LEVEL.TRANSACTION;
|
|
5912
|
+
}
|
|
5913
|
+
transactionPromotionArray.push(transactionPromotionObj);
|
|
5914
|
+
}));
|
|
5915
|
+
}
|
|
5916
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: getTransactionPromotions : ", JSON.stringify(transactionPromotionArray));
|
|
5917
|
+
return transactionPromotionArray;
|
|
5918
|
+
}
|
|
5919
|
+
catch (error) {
|
|
5920
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", error);
|
|
5921
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", JSON.stringify(error));
|
|
5922
|
+
throw new Error(error);
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
/**
|
|
5926
|
+
* @template THIS
|
|
5927
|
+
* @this {THIS}
|
|
5928
|
+
* @return {THIS}
|
|
5929
|
+
*/
|
|
5930
|
+
updateLinePromotionWithCoupon() {
|
|
5931
|
+
try {
|
|
5932
|
+
/** @type {?} */
|
|
5933
|
+
let transactionPromotion = (/** @type {?} */ ({}));
|
|
5934
|
+
/** @type {?} */
|
|
5935
|
+
let triggerPromotion = (/** @type {?} */ ([]));
|
|
5936
|
+
if ((/** @type {?} */ (this)).orderDetails.product_items && (/** @type {?} */ (this)).orderDetails.product_items.length > 0) {
|
|
5937
|
+
(/** @type {?} */ (this)).orderDetails.product_items.forEach((/**
|
|
5855
5938
|
* @param {?} product
|
|
5856
5939
|
* @param {?} index
|
|
5857
5940
|
* @return {?}
|
|
5858
5941
|
*/
|
|
5859
|
-
(product, index) =>
|
|
5860
|
-
|
|
5942
|
+
(product, index) => {
|
|
5943
|
+
product.item_id = (index + 1).toString();
|
|
5944
|
+
if (product.price_adjustments && product.price_adjustments.length > 0) {
|
|
5945
|
+
product.price_adjustments.forEach((/**
|
|
5946
|
+
* @param {?} promotion
|
|
5947
|
+
* @return {?}
|
|
5948
|
+
*/
|
|
5949
|
+
(promotion) => {
|
|
5950
|
+
if (promotion.coupon_code) {
|
|
5951
|
+
/** @type {?} */
|
|
5952
|
+
let trigger = (/** @type {?} */ ({}));
|
|
5953
|
+
trigger.itemLineId = product.item_id;
|
|
5954
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
5955
|
+
trigger.totalQuantity = product.quantity ? product.quantity : 0;
|
|
5956
|
+
trigger.promotionAmount = promotion.price ? Math.abs(promotion.price) : 0;
|
|
5957
|
+
trigger.refundedReason = promotion.coupon_code ? promotion.coupon_code : '';
|
|
5958
|
+
trigger.refundedReasonDescription = promotion.item_text ? promotion.item_text : '';
|
|
5959
|
+
trigger.promotionId = promotion.promotion_id;
|
|
5960
|
+
triggerPromotion.push(trigger);
|
|
5961
|
+
}
|
|
5962
|
+
}));
|
|
5963
|
+
}
|
|
5964
|
+
}));
|
|
5965
|
+
}
|
|
5966
|
+
if (triggerPromotion.length > 0) {
|
|
5967
|
+
transactionPromotion.displayText = triggerPromotion[0].refundedReasonDescription;
|
|
5968
|
+
transactionPromotion.name = triggerPromotion[0].refundedReason;
|
|
5969
|
+
transactionPromotion.promotionAmount = -(triggerPromotion.reduce((/**
|
|
5970
|
+
* @param {?} n
|
|
5971
|
+
* @param {?} __1
|
|
5972
|
+
* @return {?}
|
|
5973
|
+
*/
|
|
5974
|
+
(n, { promotionAmount }) => n + promotionAmount), 0));
|
|
5975
|
+
transactionPromotion.promotionId = triggerPromotion[0].promotionId;
|
|
5976
|
+
transactionPromotion.promotionInfo = triggerPromotion[0].refundedReasonDescription;
|
|
5977
|
+
transactionPromotion.couponCode = triggerPromotion[0].refundedReason;
|
|
5978
|
+
transactionPromotion.itemLineIds = [];
|
|
5979
|
+
transactionPromotion.type = PROMOTION_TYPE.COUPON;
|
|
5980
|
+
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
5981
|
+
transactionPromotion.trigger = triggerPromotion;
|
|
5982
|
+
}
|
|
5983
|
+
console.log("linePromotion mapping ended...");
|
|
5984
|
+
console.log("e-basket: updateLinePromotionWithCoupon", JSON.stringify(transactionPromotion));
|
|
5985
|
+
if (!(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
5986
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = [];
|
|
5987
|
+
}
|
|
5988
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.push(transactionPromotion);
|
|
5989
|
+
return (/** @type {?} */ (this));
|
|
5990
|
+
}
|
|
5991
|
+
catch (error) {
|
|
5992
|
+
console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", error);
|
|
5993
|
+
console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", JSON.stringify(error));
|
|
5994
|
+
throw new Error(error);
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
/**
|
|
5998
|
+
* @template THIS
|
|
5999
|
+
* @this {THIS}
|
|
6000
|
+
* @return {THIS}
|
|
6001
|
+
*/
|
|
6002
|
+
updateTransactionPromotionPrtionCalc() {
|
|
6003
|
+
/** @type {?} */
|
|
6004
|
+
let doc;
|
|
6005
|
+
if ((/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
6006
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.forEach((/**
|
|
6007
|
+
* @param {?} tr
|
|
6008
|
+
* @return {?}
|
|
6009
|
+
*/
|
|
6010
|
+
tr => {
|
|
6011
|
+
doc =
|
|
6012
|
+
(/** @type {?} */ (this)).transactionPromotionProductPortionCalc((/** @type {?} */ (this)).webReturnObject, tr);
|
|
5861
6013
|
}));
|
|
6014
|
+
(/** @type {?} */ (this)).webReturnObject = doc;
|
|
5862
6015
|
}
|
|
5863
|
-
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = transactionPromotionArray;
|
|
5864
|
-
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping ended...");
|
|
5865
6016
|
return (/** @type {?} */ (this));
|
|
5866
6017
|
}
|
|
6018
|
+
/**
|
|
6019
|
+
* @param {?} txDoc
|
|
6020
|
+
* @param {?} promotion
|
|
6021
|
+
* @return {?}
|
|
6022
|
+
*/
|
|
6023
|
+
transactionPromotionProductPortionCalc(txDoc, promotion) {
|
|
6024
|
+
/** @type {?} */
|
|
6025
|
+
let total = 0;
|
|
6026
|
+
/** @type {?} */
|
|
6027
|
+
let percentage = 0;
|
|
6028
|
+
{
|
|
6029
|
+
console.log(`ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: ${JSON.stringify(promotion)}`);
|
|
6030
|
+
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
6031
|
+
txDoc.basket.products.forEach((/**
|
|
6032
|
+
* @param {?} product
|
|
6033
|
+
* @return {?}
|
|
6034
|
+
*/
|
|
6035
|
+
(product) => {
|
|
6036
|
+
product = this.validateProductItemDiscount(product);
|
|
6037
|
+
if (promotion.trigger && promotion.trigger.length > 0) {
|
|
6038
|
+
promotion.trigger.forEach((/**
|
|
6039
|
+
* @param {?} t
|
|
6040
|
+
* @return {?}
|
|
6041
|
+
*/
|
|
6042
|
+
(t) => {
|
|
6043
|
+
if (t.itemLineId === product.itemLineId.toString()) {
|
|
6044
|
+
product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
|
|
6045
|
+
}
|
|
6046
|
+
}));
|
|
6047
|
+
}
|
|
6048
|
+
}));
|
|
6049
|
+
}
|
|
6050
|
+
else {
|
|
6051
|
+
txDoc.basket.products.forEach((/**
|
|
6052
|
+
* @param {?} p
|
|
6053
|
+
* @return {?}
|
|
6054
|
+
*/
|
|
6055
|
+
(p) => {
|
|
6056
|
+
if (promotion.itemLineIds && promotion.itemLineIds.includes(p.itemLineId) && !p.giftCard) {
|
|
6057
|
+
p = this.validateProductItemDiscount(p);
|
|
6058
|
+
/** @type {?} */
|
|
6059
|
+
const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnDiscountsPortion) +
|
|
6060
|
+
this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnPromotionsPortion) -
|
|
6061
|
+
this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.refundPortion);
|
|
6062
|
+
total += (p.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
|
|
6063
|
+
}
|
|
6064
|
+
}));
|
|
6065
|
+
console.log(`ebasket: trnsactionPromotion: ${JSON.stringify(promotion)}, selected products total: ${total}`);
|
|
6066
|
+
txDoc.basket.products.forEach((/**
|
|
6067
|
+
* @param {?} product
|
|
6068
|
+
* @return {?}
|
|
6069
|
+
*/
|
|
6070
|
+
(product) => {
|
|
6071
|
+
product = this.validateProductItemDiscount(product);
|
|
6072
|
+
/** @type {?} */
|
|
6073
|
+
const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
|
|
6074
|
+
this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
|
|
6075
|
+
this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
|
|
6076
|
+
if (promotion.itemLineIds.includes(product.itemLineId)) {
|
|
6077
|
+
percentage = ((product.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal)) / total) * 100;
|
|
6078
|
+
product.itemDiscounts.trnPromotionsPortion +=
|
|
6079
|
+
(promotion.promotionAmount * percentage) / 100;
|
|
6080
|
+
product.itemDiscounts.trnPromotionsPortion = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion);
|
|
6081
|
+
}
|
|
6082
|
+
}));
|
|
6083
|
+
}
|
|
6084
|
+
}
|
|
6085
|
+
return txDoc;
|
|
6086
|
+
}
|
|
6087
|
+
/**
|
|
6088
|
+
* @param {?} product
|
|
6089
|
+
* @return {?}
|
|
6090
|
+
*/
|
|
6091
|
+
validateProductItemDiscount(product) {
|
|
6092
|
+
if (!product.itemDiscounts) {
|
|
6093
|
+
product.itemDiscounts = {
|
|
6094
|
+
trnDiscountsPortion: 0,
|
|
6095
|
+
trnPromotionsPortion: 0,
|
|
6096
|
+
refundPortion: 0,
|
|
6097
|
+
};
|
|
6098
|
+
}
|
|
6099
|
+
return product;
|
|
6100
|
+
}
|
|
5867
6101
|
/**
|
|
5868
6102
|
* @template THIS
|
|
5869
6103
|
* @this {THIS}
|
|
@@ -6120,6 +6354,13 @@ if (false) {
|
|
|
6120
6354
|
* @private
|
|
6121
6355
|
*/
|
|
6122
6356
|
WebReturnSalesforceMapperBuilderClass.prototype.webReturnObject;
|
|
6357
|
+
/** @type {?} */
|
|
6358
|
+
WebReturnSalesforceMapperBuilderClass.prototype.numberUtilService;
|
|
6359
|
+
/**
|
|
6360
|
+
* @type {?}
|
|
6361
|
+
* @private
|
|
6362
|
+
*/
|
|
6363
|
+
WebReturnSalesforceMapperBuilderClass.prototype.currencyPipe;
|
|
6123
6364
|
}
|
|
6124
6365
|
|
|
6125
6366
|
/**
|