@pmcretail/mapper-library 0.0.37 → 0.0.39
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 +243 -23
- 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/WebReturn-mapper.class.js +230 -24
- package/esm2015/lib/mapper-library.component.js +5 -5
- package/esm2015/lib/mapper-library.module.js +1 -1
- package/esm5/lib/WebReturn-mapper.class.js +246 -24
- package/esm5/lib/mapper-library.component.js +1 -1
- package/esm5/lib/mapper-library.module.js +1 -1
- package/fesm2015/pmcretail-mapper-library.js +231 -27
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +243 -23
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/WebReturn-mapper.class.d.ts +8 -2
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -18,10 +18,10 @@ class MapperLibraryComponent {
|
|
|
18
18
|
MapperLibraryComponent.decorators = [
|
|
19
19
|
{ type: Component, args: [{
|
|
20
20
|
selector: 'lib-mapper-library',
|
|
21
|
-
template: `
|
|
22
|
-
<p>
|
|
23
|
-
mapper-library works!
|
|
24
|
-
</p>
|
|
21
|
+
template: `
|
|
22
|
+
<p>
|
|
23
|
+
mapper-library works!
|
|
24
|
+
</p>
|
|
25
25
|
`
|
|
26
26
|
}] }
|
|
27
27
|
];
|
|
@@ -5406,8 +5406,10 @@ if (false) {
|
|
|
5406
5406
|
class WebReturnMapperBuilderClass {
|
|
5407
5407
|
/**
|
|
5408
5408
|
* @param {?} document
|
|
5409
|
+
* @param {?=} currencyPipe
|
|
5409
5410
|
*/
|
|
5410
|
-
constructor(document) {
|
|
5411
|
+
constructor(document, currencyPipe) {
|
|
5412
|
+
this.currencyPipe = currencyPipe;
|
|
5411
5413
|
this.webReturnObject = {
|
|
5412
5414
|
id: '',
|
|
5413
5415
|
orgCode: "",
|
|
@@ -5436,6 +5438,7 @@ class WebReturnMapperBuilderClass {
|
|
|
5436
5438
|
if (document) {
|
|
5437
5439
|
this.document = document;
|
|
5438
5440
|
}
|
|
5441
|
+
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
5439
5442
|
}
|
|
5440
5443
|
/**
|
|
5441
5444
|
* @template THIS
|
|
@@ -5472,55 +5475,76 @@ class WebReturnMapperBuilderClass {
|
|
|
5472
5475
|
(/** @type {?} */ (this)).webReturnObject['customer']['shippingAddress']['postCode'] = ((/** @type {?} */ (this)).document.shipping_address && (/** @type {?} */ (this)).document.shipping_address.postcode) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.shipping_address.postcode) : '';
|
|
5473
5476
|
(/** @type {?} */ (this)).webReturnObject['customer']['shippingAddress']['country'] = ((/** @type {?} */ (this)).document.shipping_address && (/** @type {?} */ (this)).document.shipping_address.country) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.shipping_address.country) : '';
|
|
5474
5477
|
// basketSummary
|
|
5475
|
-
(/** @type {?} */ (this)).webReturnObject.basketSummary['discountTotal'] = Number((/** @type {?} */ (this)).document.discount_amount ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount) : 0);
|
|
5478
|
+
(/** @type {?} */ (this)).webReturnObject.basketSummary['discountTotal'] = Math.abs(Number((/** @type {?} */ (this)).document.discount_amount ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount) : 0));
|
|
5476
5479
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['VATTotal'] = Number((/** @type {?} */ (this)).document.base_total_paid ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_paid) : 0);
|
|
5477
5480
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['saleTotal'] = Number((/** @type {?} */ (this)).document.base_total_invoiced ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_invoiced) : 0);
|
|
5478
5481
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['basketTotal'] = Number((/** @type {?} */ (this)).document.base_total_paid ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_paid) : 0);
|
|
5479
5482
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['totalItems'] = Number((/** @type {?} */ (this)).document.total_qty_ordered ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.total_qty_ordered) : 0);
|
|
5480
5483
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['refundTotal'] = Number((/** @type {?} */ (this)).document.base_total_refunded ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_refunded) : 0);
|
|
5481
|
-
// basket line discount
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
(/** @type {?} */ (this)).webReturnObject.basket['lineDiscount'].push(lineDiscount);
|
|
5484
|
+
// // basket line discount
|
|
5485
|
+
// this.webReturnObject.basket['lineDiscount'] = [];
|
|
5486
|
+
// let lineDiscount = {
|
|
5487
|
+
// itemLineId: (this.document.items && this.document.items.item && this.document.items.item.item_id) ? this.getText(this.document.items.item.item_id) : 0,
|
|
5488
|
+
// discountAmount: (this.document.items && this.document.items.item && this.document.items.item.discount_amount) ? Number(this.getText(this.document.items.item.discount_amount)) : 0
|
|
5489
|
+
// }
|
|
5490
|
+
// this.webReturnObject.basket['lineDiscount'].push(lineDiscount);
|
|
5489
5491
|
// basket transaction discount
|
|
5490
|
-
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'] = [];
|
|
5491
|
-
/** @type {?} */
|
|
5492
|
-
let transactionDiscount = {
|
|
5493
|
-
discountAmount: ((/** @type {?} */ (this)).document && (/** @type {?} */ (this)).document.discount_amount) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount)) : 0
|
|
5494
|
-
};
|
|
5495
|
-
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'].push(transactionDiscount);
|
|
5496
5492
|
// basket products
|
|
5497
5493
|
(/** @type {?} */ (this)).webReturnObject.basket['products'] = [];
|
|
5494
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'] = [];
|
|
5495
|
+
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'] = [];
|
|
5496
|
+
(/** @type {?} */ (this)).webReturnObject.basket['transactionPromotion'] = [];
|
|
5497
|
+
// let transactionDiscount = {
|
|
5498
|
+
// discountAmount: (this.document && this.document.discount_amount) ? Number(this.getText(this.document.discount_amount)) : 0
|
|
5499
|
+
// }
|
|
5500
|
+
// this.webReturnObject.basket['transactionDiscount'].push(transactionDiscount);
|
|
5498
5501
|
/** @type {?} */
|
|
5499
5502
|
let product = {};
|
|
5500
5503
|
if ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item) {
|
|
5501
5504
|
if ((/** @type {?} */ (this)).document.items.item instanceof Array) {
|
|
5502
5505
|
(/** @type {?} */ (this)).document.items.item.forEach((/**
|
|
5503
5506
|
* @param {?} element
|
|
5507
|
+
* @param {?} index
|
|
5504
5508
|
* @return {?}
|
|
5505
5509
|
*/
|
|
5506
|
-
element => {
|
|
5510
|
+
(element, index) => {
|
|
5507
5511
|
/** @type {?} */
|
|
5508
5512
|
let qty = (/** @type {?} */ (this)).getText(element.qty_ordered) ? Number((/** @type {?} */ (this)).getText(element.qty_ordered)) : 0;
|
|
5509
5513
|
/** @type {?} */
|
|
5510
5514
|
let refundQty = (/** @type {?} */ (this)).getText(element.qty_refunded) ? Number((/** @type {?} */ (this)).getText(element.qty_refunded)) : 0;
|
|
5511
5515
|
/** @type {?} */
|
|
5512
|
-
let price = (/** @type {?} */ (this)).getText(element.
|
|
5516
|
+
let price = (/** @type {?} */ (this)).getText(element.price_incl_tax) ? Number((/** @type {?} */ (this)).getText(element.price_incl_tax)) : 0;
|
|
5513
5517
|
product = {
|
|
5514
5518
|
description: (element.name) ? (/** @type {?} */ (this)).getText(element.name) : '',
|
|
5515
5519
|
SKU: (element.sku) ? (/** @type {?} */ (this)).getText(element.sku) : '',
|
|
5516
5520
|
quantity: (element.qty_ordered) ? Number((/** @type {?} */ (this)).getText(element.qty_ordered)) : 0,
|
|
5517
5521
|
refundedQuantity: (element.qty_refunded) ? Number((/** @type {?} */ (this)).getText(element.qty_refunded)) : 0,
|
|
5518
|
-
price: (element.original_price) ? Number(
|
|
5519
|
-
|
|
5522
|
+
//price: (element.original_price) ? Number(this.getText(element.original_price)) : 0,
|
|
5523
|
+
price: price,
|
|
5524
|
+
itemLineId: (index + 1).toString(),
|
|
5520
5525
|
// totalLinePrice: (element.row_invoiced) ? Number(this.getText(element.row_invoiced)) : 0,
|
|
5521
5526
|
totalLinePrice: ((qty - refundQty) * price),
|
|
5522
5527
|
};
|
|
5528
|
+
/** @type {?} */
|
|
5529
|
+
let promotionAmount = (/** @type {?} */ (this)).getText(element.discount_amount) ? Number((/** @type {?} */ (this)).getText(element.discount_amount)) : 0;
|
|
5530
|
+
/** @type {?} */
|
|
5531
|
+
let appliedIDs = (/** @type {?} */ (this)).getText(element.applied_rule_ids) ? (/** @type {?} */ (this)).getText(element.applied_rule_ids) : '';
|
|
5523
5532
|
if (product && product.price != 0) {
|
|
5533
|
+
if (promotionAmount) {
|
|
5534
|
+
/** @type {?} */
|
|
5535
|
+
let trigger = (/** @type {?} */ ({}));
|
|
5536
|
+
trigger.itemLineId = product.itemLineId;
|
|
5537
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
5538
|
+
/** @type {?} */
|
|
5539
|
+
let promotion = {
|
|
5540
|
+
promotionAmount: promotionAmount,
|
|
5541
|
+
promotionId: appliedIDs,
|
|
5542
|
+
itemLineId: product.itemLineId,
|
|
5543
|
+
promotionLinePrice: product.totalLinePrice - promotionAmount,
|
|
5544
|
+
trigger: trigger
|
|
5545
|
+
};
|
|
5546
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].push(promotion);
|
|
5547
|
+
}
|
|
5524
5548
|
(/** @type {?} */ (this)).webReturnObject.basket['products'].push(product);
|
|
5525
5549
|
}
|
|
5526
5550
|
}));
|
|
@@ -5531,24 +5555,197 @@ class WebReturnMapperBuilderClass {
|
|
|
5531
5555
|
/** @type {?} */
|
|
5532
5556
|
let refundQty = ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.qty_refunded) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.qty_refunded)) : 0;
|
|
5533
5557
|
/** @type {?} */
|
|
5534
|
-
let price = ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.
|
|
5558
|
+
let price = ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.price_incl_tax) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.price_incl_tax)) : 0;
|
|
5535
5559
|
product = {
|
|
5536
5560
|
description: ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.name) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.name) : '',
|
|
5537
5561
|
SKU: ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.sku) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.sku) : '',
|
|
5538
5562
|
quantity: ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.qty_ordered) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.qty_ordered)) : 0,
|
|
5539
5563
|
refundedQuantity: ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.qty_refunded) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.qty_refunded)) : 0,
|
|
5540
|
-
price: (
|
|
5541
|
-
|
|
5564
|
+
// price: (this.document.items && this.document.items.item && this.document.items.item.original_price) ? Number(this.getText(this.document.items.item.original_price)) : 0,
|
|
5565
|
+
price: price,
|
|
5566
|
+
itemLineId: "1",
|
|
5542
5567
|
// totalLinePrice: (this.document.items && this.document.items.item && this.document.items.item.row_invoiced) ? Number(this.getText(this.document.items.item.row_invoiced)) : 0,
|
|
5543
5568
|
totalLinePrice: ((qty - refundQty) * price),
|
|
5544
5569
|
};
|
|
5570
|
+
/** @type {?} */
|
|
5571
|
+
let promotionAmount = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.discount_amount) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.discount_amount)) : 0;
|
|
5572
|
+
/** @type {?} */
|
|
5573
|
+
let appliedIDs = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.applied_rule_ids) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.applied_rule_ids) : '';
|
|
5545
5574
|
if (product && product.price != 0) {
|
|
5575
|
+
if (promotionAmount) {
|
|
5576
|
+
/** @type {?} */
|
|
5577
|
+
let trigger = (/** @type {?} */ ({}));
|
|
5578
|
+
trigger.itemLineId = product.itemLineId;
|
|
5579
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
5580
|
+
/** @type {?} */
|
|
5581
|
+
let promotion = {
|
|
5582
|
+
promotionAmount: promotionAmount,
|
|
5583
|
+
promotionId: appliedIDs,
|
|
5584
|
+
itemLineId: product.itemLineId,
|
|
5585
|
+
promotionLinePrice: product.totalLinePrice - promotionAmount,
|
|
5586
|
+
trigger: trigger
|
|
5587
|
+
};
|
|
5588
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].push(promotion);
|
|
5589
|
+
}
|
|
5546
5590
|
(/** @type {?} */ (this)).webReturnObject.basket['products'].push(product);
|
|
5547
5591
|
}
|
|
5548
5592
|
}
|
|
5593
|
+
/** @type {?} */
|
|
5594
|
+
let couponCode = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.coupon_code) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.coupon_code) : 0;
|
|
5595
|
+
/** @type {?} */
|
|
5596
|
+
let appliedIDs = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.applied_rule_ids) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.applied_rule_ids) : '';
|
|
5597
|
+
/** @type {?} */
|
|
5598
|
+
let discountDescription = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_description) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_description) : '';
|
|
5599
|
+
/** @type {?} */
|
|
5600
|
+
let couponTriggerPromotions = (/** @type {?} */ ([]));
|
|
5601
|
+
if (couponCode && appliedIDs) {
|
|
5602
|
+
/** @type {?} */
|
|
5603
|
+
let transactionPromotion = (/** @type {?} */ ({}));
|
|
5604
|
+
if ((/** @type {?} */ (this)).webReturnObject.basket['linePromotion'] && (/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].length > 0) {
|
|
5605
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].forEach((/**
|
|
5606
|
+
* @param {?} promotion
|
|
5607
|
+
* @return {?}
|
|
5608
|
+
*/
|
|
5609
|
+
(promotion) => {
|
|
5610
|
+
if (promotion.promotionId === appliedIDs) {
|
|
5611
|
+
/** @type {?} */
|
|
5612
|
+
let trigger = (/** @type {?} */ ({}));
|
|
5613
|
+
trigger.itemLineId = promotion.itemLineId;
|
|
5614
|
+
trigger.quantity = promotion.trigger.quantity;
|
|
5615
|
+
trigger.totalQuantity = promotion.trigger.quantity;
|
|
5616
|
+
trigger.promotionAmount = promotion.promotionAmount;
|
|
5617
|
+
trigger.refundedReason = couponCode;
|
|
5618
|
+
trigger.refundedReasonDescription = discountDescription;
|
|
5619
|
+
trigger.promotionId = promotion.promotionId;
|
|
5620
|
+
couponTriggerPromotions.push(trigger);
|
|
5621
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'] = (/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].filter((/**
|
|
5622
|
+
* @param {?} x
|
|
5623
|
+
* @return {?}
|
|
5624
|
+
*/
|
|
5625
|
+
(x) => x.itemLineId !== promotion.itemLineId));
|
|
5626
|
+
}
|
|
5627
|
+
}));
|
|
5628
|
+
}
|
|
5629
|
+
if (couponTriggerPromotions.length > 0) {
|
|
5630
|
+
transactionPromotion.displayText = couponTriggerPromotions[0].refundedReasonDescription;
|
|
5631
|
+
transactionPromotion.name = couponTriggerPromotions[0].refundedReason;
|
|
5632
|
+
transactionPromotion.promotionAmount = -(couponTriggerPromotions.reduce((/**
|
|
5633
|
+
* @param {?} n
|
|
5634
|
+
* @param {?} __1
|
|
5635
|
+
* @return {?}
|
|
5636
|
+
*/
|
|
5637
|
+
(n, { promotionAmount }) => n + promotionAmount), 0));
|
|
5638
|
+
transactionPromotion.promotionId = couponTriggerPromotions[0].promotionId;
|
|
5639
|
+
transactionPromotion.promotionInfo = couponTriggerPromotions[0].refundedReasonDescription;
|
|
5640
|
+
transactionPromotion.couponCode = couponCode;
|
|
5641
|
+
transactionPromotion.itemLineIds = [];
|
|
5642
|
+
transactionPromotion.type = PROMOTION_TYPE.COUPON;
|
|
5643
|
+
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
5644
|
+
transactionPromotion.trigger = couponTriggerPromotions;
|
|
5645
|
+
}
|
|
5646
|
+
console.log("e-basket: update LinePromotion With Coupon", JSON.stringify(transactionPromotion));
|
|
5647
|
+
if (!(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
5648
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = [];
|
|
5649
|
+
}
|
|
5650
|
+
if (transactionPromotion && transactionPromotion.promotionId) {
|
|
5651
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.push(transactionPromotion);
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
(/** @type {?} */ (this)).updateTransactionPromotionPrtionCalc();
|
|
5549
5655
|
}
|
|
5550
5656
|
return (/** @type {?} */ (this));
|
|
5551
5657
|
}
|
|
5658
|
+
/**
|
|
5659
|
+
* @param {?} product
|
|
5660
|
+
* @return {?}
|
|
5661
|
+
*/
|
|
5662
|
+
validateProductItemDiscount(product) {
|
|
5663
|
+
if (!product.itemDiscounts) {
|
|
5664
|
+
product.itemDiscounts = {
|
|
5665
|
+
trnDiscountsPortion: 0,
|
|
5666
|
+
trnPromotionsPortion: 0,
|
|
5667
|
+
refundPortion: 0,
|
|
5668
|
+
};
|
|
5669
|
+
}
|
|
5670
|
+
return product;
|
|
5671
|
+
}
|
|
5672
|
+
/**
|
|
5673
|
+
* @param {?} txDoc
|
|
5674
|
+
* @param {?} promotion
|
|
5675
|
+
* @return {?}
|
|
5676
|
+
*/
|
|
5677
|
+
transactionPromotionProductPortionCalc(txDoc, promotion) {
|
|
5678
|
+
console.log(`ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: ${JSON.stringify(promotion)}`);
|
|
5679
|
+
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
5680
|
+
txDoc.basket.products.forEach((/**
|
|
5681
|
+
* @param {?} product
|
|
5682
|
+
* @return {?}
|
|
5683
|
+
*/
|
|
5684
|
+
(product) => {
|
|
5685
|
+
product = this.validateProductItemDiscount(product);
|
|
5686
|
+
if (promotion.trigger && promotion.trigger.length > 0) {
|
|
5687
|
+
promotion.trigger.forEach((/**
|
|
5688
|
+
* @param {?} t
|
|
5689
|
+
* @return {?}
|
|
5690
|
+
*/
|
|
5691
|
+
(t) => {
|
|
5692
|
+
if (t.itemLineId === product.itemLineId.toString()) {
|
|
5693
|
+
product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
|
|
5694
|
+
}
|
|
5695
|
+
}));
|
|
5696
|
+
}
|
|
5697
|
+
}));
|
|
5698
|
+
}
|
|
5699
|
+
else {
|
|
5700
|
+
txDoc.basket.products.forEach((/**
|
|
5701
|
+
* @param {?} product
|
|
5702
|
+
* @return {?}
|
|
5703
|
+
*/
|
|
5704
|
+
(product) => {
|
|
5705
|
+
product = this.validateProductItemDiscount(product);
|
|
5706
|
+
if (promotion.itemLineIds.includes(+product.itemLineId)) {
|
|
5707
|
+
/** @type {?} */
|
|
5708
|
+
let discountAmount = 0;
|
|
5709
|
+
if (this.document.items.item instanceof Array) {
|
|
5710
|
+
/** @type {?} */
|
|
5711
|
+
const productItem = this.document.items.item.find((/**
|
|
5712
|
+
* @param {?} productItem
|
|
5713
|
+
* @return {?}
|
|
5714
|
+
*/
|
|
5715
|
+
productItem => productItem.sku === product.SKU));
|
|
5716
|
+
discountAmount = productItem.discount_amount ? +productItem.discount_amount : 0;
|
|
5717
|
+
}
|
|
5718
|
+
else {
|
|
5719
|
+
discountAmount = this.document.items.item.sku === product.SKU && this.document.items.item.discount_amount ?
|
|
5720
|
+
+this.document.items.item.discount_amount : 0;
|
|
5721
|
+
}
|
|
5722
|
+
/** @type {?} */
|
|
5723
|
+
const transactionPromotionPortion = discountAmount;
|
|
5724
|
+
product.itemDiscounts.trnPromotionsPortion += this.numberUtilService.trimTo2Decimal2(transactionPromotionPortion);
|
|
5725
|
+
}
|
|
5726
|
+
}));
|
|
5727
|
+
}
|
|
5728
|
+
return txDoc;
|
|
5729
|
+
}
|
|
5730
|
+
/**
|
|
5731
|
+
* @return {?}
|
|
5732
|
+
*/
|
|
5733
|
+
updateTransactionPromotionPrtionCalc() {
|
|
5734
|
+
try {
|
|
5735
|
+
if (this.webReturnObject.basket.transactionPromotion && this.webReturnObject.basket.transactionPromotion.length > 0) {
|
|
5736
|
+
this.webReturnObject.basket.transactionPromotion.forEach((/**
|
|
5737
|
+
* @param {?} tr
|
|
5738
|
+
* @return {?}
|
|
5739
|
+
*/
|
|
5740
|
+
tr => {
|
|
5741
|
+
this.transactionPromotionProductPortionCalc(this.webReturnObject, tr);
|
|
5742
|
+
}));
|
|
5743
|
+
}
|
|
5744
|
+
}
|
|
5745
|
+
catch (error) {
|
|
5746
|
+
console.log("updateTransactionPromotionPrtionCalc => failed:", JSON.stringify(error));
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5552
5749
|
/**
|
|
5553
5750
|
* @template THIS
|
|
5554
5751
|
* @this {THIS}
|
|
@@ -5691,6 +5888,13 @@ if (false) {
|
|
|
5691
5888
|
* @private
|
|
5692
5889
|
*/
|
|
5693
5890
|
WebReturnMapperBuilderClass.prototype.webReturnObject;
|
|
5891
|
+
/** @type {?} */
|
|
5892
|
+
WebReturnMapperBuilderClass.prototype.numberUtilService;
|
|
5893
|
+
/**
|
|
5894
|
+
* @type {?}
|
|
5895
|
+
* @private
|
|
5896
|
+
*/
|
|
5897
|
+
WebReturnMapperBuilderClass.prototype.currencyPipe;
|
|
5694
5898
|
}
|
|
5695
5899
|
|
|
5696
5900
|
/**
|