@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
|
@@ -486,6 +486,16 @@ if (false) {
|
|
|
486
486
|
Trigger.prototype.quantity;
|
|
487
487
|
/** @type {?|undefined} */
|
|
488
488
|
Trigger.prototype.totalQuantity;
|
|
489
|
+
/** @type {?|undefined} */
|
|
490
|
+
Trigger.prototype.linePromotionAmount;
|
|
491
|
+
/** @type {?|undefined} */
|
|
492
|
+
Trigger.prototype.promotionAmount;
|
|
493
|
+
/** @type {?|undefined} */
|
|
494
|
+
Trigger.prototype.refundedReason;
|
|
495
|
+
/** @type {?|undefined} */
|
|
496
|
+
Trigger.prototype.refundedReasonDescription;
|
|
497
|
+
/** @type {?|undefined} */
|
|
498
|
+
Trigger.prototype.promotionId;
|
|
489
499
|
}
|
|
490
500
|
/**
|
|
491
501
|
* Transaction Promotion
|
|
@@ -507,6 +517,14 @@ if (false) {
|
|
|
507
517
|
TransactionPromotion.prototype.promotionType;
|
|
508
518
|
/** @type {?} */
|
|
509
519
|
TransactionPromotion.prototype.itemLineIds;
|
|
520
|
+
/** @type {?|undefined} */
|
|
521
|
+
TransactionPromotion.prototype.type;
|
|
522
|
+
/** @type {?|undefined} */
|
|
523
|
+
TransactionPromotion.prototype.subLevelType;
|
|
524
|
+
/** @type {?|undefined} */
|
|
525
|
+
TransactionPromotion.prototype.trigger;
|
|
526
|
+
/** @type {?|undefined} */
|
|
527
|
+
TransactionPromotion.prototype.couponCode;
|
|
510
528
|
}
|
|
511
529
|
/**
|
|
512
530
|
* @record
|
|
@@ -669,6 +687,8 @@ if (false) {
|
|
|
669
687
|
TransactionDocument.prototype.isChecked;
|
|
670
688
|
/** @type {?|undefined} */
|
|
671
689
|
TransactionDocument.prototype.externalTransactionDetails;
|
|
690
|
+
/** @type {?|undefined} */
|
|
691
|
+
TransactionDocument.prototype.refundRequest;
|
|
672
692
|
}
|
|
673
693
|
/**
|
|
674
694
|
* @record
|
|
@@ -1242,6 +1262,8 @@ if (false) {
|
|
|
1242
1262
|
ProductItem.prototype.tax_class_id;
|
|
1243
1263
|
/** @type {?|undefined} */
|
|
1244
1264
|
ProductItem.prototype.tax_rate;
|
|
1265
|
+
/** @type {?|undefined} */
|
|
1266
|
+
ProductItem.prototype.c_osuObjectData;
|
|
1245
1267
|
}
|
|
1246
1268
|
/**
|
|
1247
1269
|
* @record
|
|
@@ -1450,6 +1472,15 @@ if (false) {
|
|
|
1450
1472
|
/** @enum {string} */
|
|
1451
1473
|
var PROVIDERS = {
|
|
1452
1474
|
SALESFORCE: "Salesforce",
|
|
1475
|
+
};
|
|
1476
|
+
/** @enum {string} */
|
|
1477
|
+
var PROMOTION_LEVEL = {
|
|
1478
|
+
LINE: "LINE",
|
|
1479
|
+
TRANSACTION: "TRANSACTION",
|
|
1480
|
+
};
|
|
1481
|
+
/** @enum {string} */
|
|
1482
|
+
var PROMOTION_TYPE = {
|
|
1483
|
+
COUPON: "COUPON",
|
|
1453
1484
|
};
|
|
1454
1485
|
|
|
1455
1486
|
/**
|
|
@@ -2554,7 +2585,8 @@ var NumberUtilService = /** @class */ (function () {
|
|
|
2554
2585
|
* @return {?}
|
|
2555
2586
|
*/
|
|
2556
2587
|
function (no) {
|
|
2557
|
-
|
|
2588
|
+
// SEAM-11411 - Had to change 2nd param to 3 to fix rounding issue (FIXME - Needs a new story for refactoring)
|
|
2589
|
+
return Number(this.getFlooredFixed(no, 3));
|
|
2558
2590
|
};
|
|
2559
2591
|
/**
|
|
2560
2592
|
* @param {?} v
|
|
@@ -7187,7 +7219,8 @@ if (false) {
|
|
|
7187
7219
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
7188
7220
|
*/
|
|
7189
7221
|
var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
|
|
7190
|
-
function WebReturnSalesforceMapperBuilderClass(orderDetails) {
|
|
7222
|
+
function WebReturnSalesforceMapperBuilderClass(orderDetails, currencyPipe) {
|
|
7223
|
+
this.currencyPipe = currencyPipe;
|
|
7191
7224
|
this.webReturnObject = {
|
|
7192
7225
|
id: '',
|
|
7193
7226
|
orgCode: "",
|
|
@@ -7218,6 +7251,7 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
|
|
|
7218
7251
|
if (orderDetails) {
|
|
7219
7252
|
this.orderDetails = orderDetails;
|
|
7220
7253
|
}
|
|
7254
|
+
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
7221
7255
|
}
|
|
7222
7256
|
/**
|
|
7223
7257
|
* @template THIS
|
|
@@ -7356,7 +7390,7 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
|
|
|
7356
7390
|
quantity: product.quantity ? product.quantity : 0,
|
|
7357
7391
|
refundedQuantity: 0,
|
|
7358
7392
|
price: product.base_price ? product.base_price : 0,
|
|
7359
|
-
itemLineId: index + 1,
|
|
7393
|
+
itemLineId: (index + 1).toString(),
|
|
7360
7394
|
deliveryMethod: (/** @type {?} */ (_this)).getDeliveryMethod().toString(),
|
|
7361
7395
|
totalLinePrice: product.price ? product.price : 0
|
|
7362
7396
|
};
|
|
@@ -7397,23 +7431,25 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
|
|
|
7397
7431
|
* @return {?}
|
|
7398
7432
|
*/
|
|
7399
7433
|
function (promotion) {
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7434
|
+
if (!promotion.coupon_code) {
|
|
7435
|
+
/** @type {?} */
|
|
7436
|
+
var linePromotionObj = (/** @type {?} */ ({}));
|
|
7437
|
+
/** @type {?} */
|
|
7438
|
+
var trigger = (/** @type {?} */ ({}));
|
|
7439
|
+
trigger.itemLineId = product.item_id;
|
|
7440
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
7441
|
+
linePromotionObj.trigger = (/** @type {?} */ ([]));
|
|
7442
|
+
linePromotionObj.trigger.push(trigger);
|
|
7443
|
+
linePromotionObj.itemLineId = index + 1;
|
|
7444
|
+
linePromotionObj.promotionId = promotion.promotion_id ? promotion.promotion_id : '';
|
|
7445
|
+
linePromotionObj.displayText = promotion.item_text ? promotion.item_text : '';
|
|
7446
|
+
linePromotionObj.promotionType = promotion.applied_discount && promotion.applied_discount.type ? promotion.applied_discount.type : '';
|
|
7447
|
+
linePromotionObj.promotionAmount = promotion.price ? Math.abs(promotion.price) : 0;
|
|
7448
|
+
linePromotionObj.name = promotion.coupon_code ? promotion.coupon_code : (promotion.item_text ? promotion.item_text : '');
|
|
7449
|
+
linePromotionObj.promotionInfo = promotion.item_text ? promotion.item_text : '';
|
|
7450
|
+
linePromotionObj.promotionLinePrice = product.price - Math.abs(promotion.price);
|
|
7451
|
+
linePromotionArray.push(linePromotionObj);
|
|
7452
|
+
}
|
|
7417
7453
|
}));
|
|
7418
7454
|
}
|
|
7419
7455
|
}));
|
|
@@ -7433,38 +7469,263 @@ var WebReturnSalesforceMapperBuilderClass = /** @class */ (function () {
|
|
|
7433
7469
|
* @return {THIS}
|
|
7434
7470
|
*/
|
|
7435
7471
|
function () {
|
|
7436
|
-
var _this = this;
|
|
7437
7472
|
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping started...");
|
|
7438
7473
|
/** @type {?} */
|
|
7439
|
-
var transactionPromotionArray = (/** @type {?} */ (
|
|
7440
|
-
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion =
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7474
|
+
var transactionPromotionArray = (/** @type {?} */ (this)).getTransactionPromotions((/** @type {?} */ (this)).orderDetails);
|
|
7475
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = transactionPromotionArray;
|
|
7476
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping ended...");
|
|
7477
|
+
return (/** @type {?} */ (this));
|
|
7478
|
+
};
|
|
7479
|
+
/**
|
|
7480
|
+
* @param {?} basket
|
|
7481
|
+
* @return {?}
|
|
7482
|
+
*/
|
|
7483
|
+
WebReturnSalesforceMapperBuilderClass.prototype.getTransactionPromotions = /**
|
|
7484
|
+
* @param {?} basket
|
|
7485
|
+
* @return {?}
|
|
7486
|
+
*/
|
|
7487
|
+
function (basket) {
|
|
7488
|
+
var _this = this;
|
|
7489
|
+
try {
|
|
7490
|
+
/** @type {?} */
|
|
7491
|
+
var transactionPromotionArray_1 = (/** @type {?} */ ([]));
|
|
7492
|
+
if (basket.order_price_adjustments && basket.order_price_adjustments.length > 0) {
|
|
7493
|
+
basket.order_price_adjustments.forEach((/**
|
|
7494
|
+
* @param {?} transactionPromotion
|
|
7495
|
+
* @return {?}
|
|
7496
|
+
*/
|
|
7497
|
+
function (transactionPromotion) {
|
|
7498
|
+
/** @type {?} */
|
|
7499
|
+
var transactionPromotionObj = (/** @type {?} */ ({}));
|
|
7500
|
+
transactionPromotionObj.displayText = transactionPromotion.item_text ? transactionPromotion.item_text : '';
|
|
7501
|
+
transactionPromotionObj.name = transactionPromotion.coupon_code ? transactionPromotion.coupon_code : (transactionPromotion.item_text ? transactionPromotion.item_text : '');
|
|
7502
|
+
transactionPromotionObj.promotionAmount = transactionPromotion.price ? -Math.abs(transactionPromotion.price) : 0;
|
|
7503
|
+
transactionPromotionObj.promotionId = transactionPromotion.promotion_id ? transactionPromotion.promotion_id : '';
|
|
7504
|
+
transactionPromotionObj.promotionInfo = transactionPromotion.item_text ? transactionPromotion.item_text : '';
|
|
7505
|
+
transactionPromotionObj.promotionType = transactionPromotion.applied_discount && transactionPromotion.applied_discount.type ? transactionPromotion.applied_discount.type : '';
|
|
7506
|
+
transactionPromotionObj.itemLineIds = _this.orderDetails.product_items.map((/**
|
|
7507
|
+
* @param {?} product
|
|
7508
|
+
* @param {?} index
|
|
7509
|
+
* @return {?}
|
|
7510
|
+
*/
|
|
7511
|
+
function (product, index) { return index + 1; }));
|
|
7512
|
+
if (transactionPromotion.coupon_code) {
|
|
7513
|
+
transactionPromotionObj.type = PROMOTION_TYPE.COUPON;
|
|
7514
|
+
transactionPromotionObj.couponCode = transactionPromotion.coupon_code;
|
|
7515
|
+
transactionPromotionObj.subLevelType = PROMOTION_LEVEL.TRANSACTION;
|
|
7516
|
+
}
|
|
7517
|
+
transactionPromotionArray_1.push(transactionPromotionObj);
|
|
7518
|
+
}));
|
|
7519
|
+
}
|
|
7520
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: getTransactionPromotions : ", JSON.stringify(transactionPromotionArray_1));
|
|
7521
|
+
return transactionPromotionArray_1;
|
|
7522
|
+
}
|
|
7523
|
+
catch (error) {
|
|
7524
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", error);
|
|
7525
|
+
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", JSON.stringify(error));
|
|
7526
|
+
throw new Error(error);
|
|
7527
|
+
}
|
|
7528
|
+
};
|
|
7529
|
+
/**
|
|
7530
|
+
* @template THIS
|
|
7531
|
+
* @this {THIS}
|
|
7532
|
+
* @return {THIS}
|
|
7533
|
+
*/
|
|
7534
|
+
WebReturnSalesforceMapperBuilderClass.prototype.updateLinePromotionWithCoupon = /**
|
|
7535
|
+
* @template THIS
|
|
7536
|
+
* @this {THIS}
|
|
7537
|
+
* @return {THIS}
|
|
7538
|
+
*/
|
|
7539
|
+
function () {
|
|
7540
|
+
try {
|
|
7541
|
+
/** @type {?} */
|
|
7542
|
+
var transactionPromotion = (/** @type {?} */ ({}));
|
|
7543
|
+
/** @type {?} */
|
|
7544
|
+
var triggerPromotion_1 = (/** @type {?} */ ([]));
|
|
7545
|
+
if ((/** @type {?} */ (this)).orderDetails.product_items && (/** @type {?} */ (this)).orderDetails.product_items.length > 0) {
|
|
7546
|
+
(/** @type {?} */ (this)).orderDetails.product_items.forEach((/**
|
|
7456
7547
|
* @param {?} product
|
|
7457
7548
|
* @param {?} index
|
|
7458
7549
|
* @return {?}
|
|
7459
7550
|
*/
|
|
7460
|
-
function (product, index) {
|
|
7461
|
-
|
|
7551
|
+
function (product, index) {
|
|
7552
|
+
product.item_id = (index + 1).toString();
|
|
7553
|
+
if (product.price_adjustments && product.price_adjustments.length > 0) {
|
|
7554
|
+
product.price_adjustments.forEach((/**
|
|
7555
|
+
* @param {?} promotion
|
|
7556
|
+
* @return {?}
|
|
7557
|
+
*/
|
|
7558
|
+
function (promotion) {
|
|
7559
|
+
if (promotion.coupon_code) {
|
|
7560
|
+
/** @type {?} */
|
|
7561
|
+
var trigger = (/** @type {?} */ ({}));
|
|
7562
|
+
trigger.itemLineId = product.item_id;
|
|
7563
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
7564
|
+
trigger.totalQuantity = product.quantity ? product.quantity : 0;
|
|
7565
|
+
trigger.promotionAmount = promotion.price ? Math.abs(promotion.price) : 0;
|
|
7566
|
+
trigger.refundedReason = promotion.coupon_code ? promotion.coupon_code : '';
|
|
7567
|
+
trigger.refundedReasonDescription = promotion.item_text ? promotion.item_text : '';
|
|
7568
|
+
trigger.promotionId = promotion.promotion_id;
|
|
7569
|
+
triggerPromotion_1.push(trigger);
|
|
7570
|
+
}
|
|
7571
|
+
}));
|
|
7572
|
+
}
|
|
7573
|
+
}));
|
|
7574
|
+
}
|
|
7575
|
+
if (triggerPromotion_1.length > 0) {
|
|
7576
|
+
transactionPromotion.displayText = triggerPromotion_1[0].refundedReasonDescription;
|
|
7577
|
+
transactionPromotion.name = triggerPromotion_1[0].refundedReason;
|
|
7578
|
+
transactionPromotion.promotionAmount = -(triggerPromotion_1.reduce((/**
|
|
7579
|
+
* @param {?} n
|
|
7580
|
+
* @param {?} __1
|
|
7581
|
+
* @return {?}
|
|
7582
|
+
*/
|
|
7583
|
+
function (n, _a) {
|
|
7584
|
+
var promotionAmount = _a.promotionAmount;
|
|
7585
|
+
return n + promotionAmount;
|
|
7586
|
+
}), 0));
|
|
7587
|
+
transactionPromotion.promotionId = triggerPromotion_1[0].promotionId;
|
|
7588
|
+
transactionPromotion.promotionInfo = triggerPromotion_1[0].refundedReasonDescription;
|
|
7589
|
+
transactionPromotion.couponCode = triggerPromotion_1[0].refundedReason;
|
|
7590
|
+
transactionPromotion.itemLineIds = [];
|
|
7591
|
+
transactionPromotion.type = PROMOTION_TYPE.COUPON;
|
|
7592
|
+
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
7593
|
+
transactionPromotion.trigger = triggerPromotion_1;
|
|
7594
|
+
}
|
|
7595
|
+
console.log("linePromotion mapping ended...");
|
|
7596
|
+
console.log("e-basket: updateLinePromotionWithCoupon", JSON.stringify(transactionPromotion));
|
|
7597
|
+
if (!(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
7598
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = [];
|
|
7599
|
+
}
|
|
7600
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.push(transactionPromotion);
|
|
7601
|
+
return (/** @type {?} */ (this));
|
|
7602
|
+
}
|
|
7603
|
+
catch (error) {
|
|
7604
|
+
console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", error);
|
|
7605
|
+
console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", JSON.stringify(error));
|
|
7606
|
+
throw new Error(error);
|
|
7607
|
+
}
|
|
7608
|
+
};
|
|
7609
|
+
/**
|
|
7610
|
+
* @template THIS
|
|
7611
|
+
* @this {THIS}
|
|
7612
|
+
* @return {THIS}
|
|
7613
|
+
*/
|
|
7614
|
+
WebReturnSalesforceMapperBuilderClass.prototype.updateTransactionPromotionPrtionCalc = /**
|
|
7615
|
+
* @template THIS
|
|
7616
|
+
* @this {THIS}
|
|
7617
|
+
* @return {THIS}
|
|
7618
|
+
*/
|
|
7619
|
+
function () {
|
|
7620
|
+
var _this = this;
|
|
7621
|
+
/** @type {?} */
|
|
7622
|
+
var doc;
|
|
7623
|
+
if ((/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
7624
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.forEach((/**
|
|
7625
|
+
* @param {?} tr
|
|
7626
|
+
* @return {?}
|
|
7627
|
+
*/
|
|
7628
|
+
function (tr) {
|
|
7629
|
+
doc =
|
|
7630
|
+
(/** @type {?} */ (_this)).transactionPromotionProductPortionCalc((/** @type {?} */ (_this)).webReturnObject, tr);
|
|
7462
7631
|
}));
|
|
7632
|
+
(/** @type {?} */ (this)).webReturnObject = doc;
|
|
7463
7633
|
}
|
|
7464
|
-
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = transactionPromotionArray;
|
|
7465
|
-
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping ended...");
|
|
7466
7634
|
return (/** @type {?} */ (this));
|
|
7467
7635
|
};
|
|
7636
|
+
/**
|
|
7637
|
+
* @param {?} txDoc
|
|
7638
|
+
* @param {?} promotion
|
|
7639
|
+
* @return {?}
|
|
7640
|
+
*/
|
|
7641
|
+
WebReturnSalesforceMapperBuilderClass.prototype.transactionPromotionProductPortionCalc = /**
|
|
7642
|
+
* @param {?} txDoc
|
|
7643
|
+
* @param {?} promotion
|
|
7644
|
+
* @return {?}
|
|
7645
|
+
*/
|
|
7646
|
+
function (txDoc, promotion) {
|
|
7647
|
+
var _this = this;
|
|
7648
|
+
/** @type {?} */
|
|
7649
|
+
var total = 0;
|
|
7650
|
+
/** @type {?} */
|
|
7651
|
+
var percentage = 0;
|
|
7652
|
+
{
|
|
7653
|
+
console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
|
|
7654
|
+
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
7655
|
+
txDoc.basket.products.forEach((/**
|
|
7656
|
+
* @param {?} product
|
|
7657
|
+
* @return {?}
|
|
7658
|
+
*/
|
|
7659
|
+
function (product) {
|
|
7660
|
+
product = _this.validateProductItemDiscount(product);
|
|
7661
|
+
if (promotion.trigger && promotion.trigger.length > 0) {
|
|
7662
|
+
promotion.trigger.forEach((/**
|
|
7663
|
+
* @param {?} t
|
|
7664
|
+
* @return {?}
|
|
7665
|
+
*/
|
|
7666
|
+
function (t) {
|
|
7667
|
+
if (t.itemLineId === product.itemLineId.toString()) {
|
|
7668
|
+
product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
|
|
7669
|
+
}
|
|
7670
|
+
}));
|
|
7671
|
+
}
|
|
7672
|
+
}));
|
|
7673
|
+
}
|
|
7674
|
+
else {
|
|
7675
|
+
txDoc.basket.products.forEach((/**
|
|
7676
|
+
* @param {?} p
|
|
7677
|
+
* @return {?}
|
|
7678
|
+
*/
|
|
7679
|
+
function (p) {
|
|
7680
|
+
if (promotion.itemLineIds && promotion.itemLineIds.includes(p.itemLineId) && !p.giftCard) {
|
|
7681
|
+
p = _this.validateProductItemDiscount(p);
|
|
7682
|
+
/** @type {?} */
|
|
7683
|
+
var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnDiscountsPortion) +
|
|
7684
|
+
_this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.trnPromotionsPortion) -
|
|
7685
|
+
_this.numberUtilService.trimTo2Decimal2(p.itemDiscounts.refundPortion);
|
|
7686
|
+
total += (p.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
|
|
7687
|
+
}
|
|
7688
|
+
}));
|
|
7689
|
+
console.log("ebasket: trnsactionPromotion: " + JSON.stringify(promotion) + ", selected products total: " + total);
|
|
7690
|
+
txDoc.basket.products.forEach((/**
|
|
7691
|
+
* @param {?} product
|
|
7692
|
+
* @return {?}
|
|
7693
|
+
*/
|
|
7694
|
+
function (product) {
|
|
7695
|
+
product = _this.validateProductItemDiscount(product);
|
|
7696
|
+
/** @type {?} */
|
|
7697
|
+
var productContributionInTotal = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
|
|
7698
|
+
_this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
|
|
7699
|
+
_this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
|
|
7700
|
+
if (promotion.itemLineIds.includes(product.itemLineId)) {
|
|
7701
|
+
percentage = ((product.total - _this.numberUtilService.trimTo2Decimal2(productContributionInTotal)) / total) * 100;
|
|
7702
|
+
product.itemDiscounts.trnPromotionsPortion +=
|
|
7703
|
+
(promotion.promotionAmount * percentage) / 100;
|
|
7704
|
+
product.itemDiscounts.trnPromotionsPortion = _this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion);
|
|
7705
|
+
}
|
|
7706
|
+
}));
|
|
7707
|
+
}
|
|
7708
|
+
}
|
|
7709
|
+
return txDoc;
|
|
7710
|
+
};
|
|
7711
|
+
/**
|
|
7712
|
+
* @param {?} product
|
|
7713
|
+
* @return {?}
|
|
7714
|
+
*/
|
|
7715
|
+
WebReturnSalesforceMapperBuilderClass.prototype.validateProductItemDiscount = /**
|
|
7716
|
+
* @param {?} product
|
|
7717
|
+
* @return {?}
|
|
7718
|
+
*/
|
|
7719
|
+
function (product) {
|
|
7720
|
+
if (!product.itemDiscounts) {
|
|
7721
|
+
product.itemDiscounts = {
|
|
7722
|
+
trnDiscountsPortion: 0,
|
|
7723
|
+
trnPromotionsPortion: 0,
|
|
7724
|
+
refundPortion: 0,
|
|
7725
|
+
};
|
|
7726
|
+
}
|
|
7727
|
+
return product;
|
|
7728
|
+
};
|
|
7468
7729
|
/**
|
|
7469
7730
|
* @template THIS
|
|
7470
7731
|
* @this {THIS}
|
|
@@ -7799,6 +8060,13 @@ if (false) {
|
|
|
7799
8060
|
* @private
|
|
7800
8061
|
*/
|
|
7801
8062
|
WebReturnSalesforceMapperBuilderClass.prototype.webReturnObject;
|
|
8063
|
+
/** @type {?} */
|
|
8064
|
+
WebReturnSalesforceMapperBuilderClass.prototype.numberUtilService;
|
|
8065
|
+
/**
|
|
8066
|
+
* @type {?}
|
|
8067
|
+
* @private
|
|
8068
|
+
*/
|
|
8069
|
+
WebReturnSalesforceMapperBuilderClass.prototype.currencyPipe;
|
|
7802
8070
|
}
|
|
7803
8071
|
|
|
7804
8072
|
/**
|