@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
|
@@ -7093,7 +7093,8 @@
|
|
|
7093
7093
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
7094
7094
|
*/
|
|
7095
7095
|
var WebReturnMapperBuilderClass = /** @class */ (function () {
|
|
7096
|
-
function WebReturnMapperBuilderClass(document) {
|
|
7096
|
+
function WebReturnMapperBuilderClass(document, currencyPipe) {
|
|
7097
|
+
this.currencyPipe = currencyPipe;
|
|
7097
7098
|
this.webReturnObject = {
|
|
7098
7099
|
id: '',
|
|
7099
7100
|
orgCode: "",
|
|
@@ -7122,6 +7123,7 @@
|
|
|
7122
7123
|
if (document) {
|
|
7123
7124
|
this.document = document;
|
|
7124
7125
|
}
|
|
7126
|
+
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
7125
7127
|
}
|
|
7126
7128
|
/**
|
|
7127
7129
|
* @template THIS
|
|
@@ -7164,55 +7166,76 @@
|
|
|
7164
7166
|
(/** @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) : '';
|
|
7165
7167
|
(/** @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) : '';
|
|
7166
7168
|
// basketSummary
|
|
7167
|
-
(/** @type {?} */ (this)).webReturnObject.basketSummary['discountTotal'] = Number((/** @type {?} */ (this)).document.discount_amount ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount) : 0);
|
|
7169
|
+
(/** @type {?} */ (this)).webReturnObject.basketSummary['discountTotal'] = Math.abs(Number((/** @type {?} */ (this)).document.discount_amount ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount) : 0));
|
|
7168
7170
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['VATTotal'] = Number((/** @type {?} */ (this)).document.base_total_paid ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_paid) : 0);
|
|
7169
7171
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['saleTotal'] = Number((/** @type {?} */ (this)).document.base_total_invoiced ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_invoiced) : 0);
|
|
7170
7172
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['basketTotal'] = Number((/** @type {?} */ (this)).document.base_total_paid ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_paid) : 0);
|
|
7171
7173
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['totalItems'] = Number((/** @type {?} */ (this)).document.total_qty_ordered ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.total_qty_ordered) : 0);
|
|
7172
7174
|
(/** @type {?} */ (this)).webReturnObject.basketSummary['refundTotal'] = Number((/** @type {?} */ (this)).document.base_total_refunded ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.base_total_refunded) : 0);
|
|
7173
|
-
// basket line discount
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
(/** @type {?} */ (this)).webReturnObject.basket['lineDiscount'].push(lineDiscount);
|
|
7175
|
+
// // basket line discount
|
|
7176
|
+
// this.webReturnObject.basket['lineDiscount'] = [];
|
|
7177
|
+
// let lineDiscount = {
|
|
7178
|
+
// itemLineId: (this.document.items && this.document.items.item && this.document.items.item.item_id) ? this.getText(this.document.items.item.item_id) : 0,
|
|
7179
|
+
// discountAmount: (this.document.items && this.document.items.item && this.document.items.item.discount_amount) ? Number(this.getText(this.document.items.item.discount_amount)) : 0
|
|
7180
|
+
// }
|
|
7181
|
+
// this.webReturnObject.basket['lineDiscount'].push(lineDiscount);
|
|
7181
7182
|
// basket transaction discount
|
|
7182
|
-
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'] = [];
|
|
7183
|
-
/** @type {?} */
|
|
7184
|
-
var transactionDiscount = {
|
|
7185
|
-
discountAmount: ((/** @type {?} */ (this)).document && (/** @type {?} */ (this)).document.discount_amount) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_amount)) : 0
|
|
7186
|
-
};
|
|
7187
|
-
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'].push(transactionDiscount);
|
|
7188
7183
|
// basket products
|
|
7189
7184
|
(/** @type {?} */ (this)).webReturnObject.basket['products'] = [];
|
|
7185
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'] = [];
|
|
7186
|
+
(/** @type {?} */ (this)).webReturnObject.basket['transactionDiscount'] = [];
|
|
7187
|
+
(/** @type {?} */ (this)).webReturnObject.basket['transactionPromotion'] = [];
|
|
7188
|
+
// let transactionDiscount = {
|
|
7189
|
+
// discountAmount: (this.document && this.document.discount_amount) ? Number(this.getText(this.document.discount_amount)) : 0
|
|
7190
|
+
// }
|
|
7191
|
+
// this.webReturnObject.basket['transactionDiscount'].push(transactionDiscount);
|
|
7190
7192
|
/** @type {?} */
|
|
7191
7193
|
var product = {};
|
|
7192
7194
|
if ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item) {
|
|
7193
7195
|
if ((/** @type {?} */ (this)).document.items.item instanceof Array) {
|
|
7194
7196
|
(/** @type {?} */ (this)).document.items.item.forEach((/**
|
|
7195
7197
|
* @param {?} element
|
|
7198
|
+
* @param {?} index
|
|
7196
7199
|
* @return {?}
|
|
7197
7200
|
*/
|
|
7198
|
-
function (element) {
|
|
7201
|
+
function (element, index) {
|
|
7199
7202
|
/** @type {?} */
|
|
7200
7203
|
var qty = (/** @type {?} */ (_this)).getText(element.qty_ordered) ? Number((/** @type {?} */ (_this)).getText(element.qty_ordered)) : 0;
|
|
7201
7204
|
/** @type {?} */
|
|
7202
7205
|
var refundQty = (/** @type {?} */ (_this)).getText(element.qty_refunded) ? Number((/** @type {?} */ (_this)).getText(element.qty_refunded)) : 0;
|
|
7203
7206
|
/** @type {?} */
|
|
7204
|
-
var price = (/** @type {?} */ (_this)).getText(element.
|
|
7207
|
+
var price = (/** @type {?} */ (_this)).getText(element.price_incl_tax) ? Number((/** @type {?} */ (_this)).getText(element.price_incl_tax)) : 0;
|
|
7205
7208
|
product = {
|
|
7206
7209
|
description: (element.name) ? (/** @type {?} */ (_this)).getText(element.name) : '',
|
|
7207
7210
|
SKU: (element.sku) ? (/** @type {?} */ (_this)).getText(element.sku) : '',
|
|
7208
7211
|
quantity: (element.qty_ordered) ? Number((/** @type {?} */ (_this)).getText(element.qty_ordered)) : 0,
|
|
7209
7212
|
refundedQuantity: (element.qty_refunded) ? Number((/** @type {?} */ (_this)).getText(element.qty_refunded)) : 0,
|
|
7210
|
-
price: (element.original_price) ? Number(
|
|
7211
|
-
|
|
7213
|
+
//price: (element.original_price) ? Number(this.getText(element.original_price)) : 0,
|
|
7214
|
+
price: price,
|
|
7215
|
+
itemLineId: (index + 1).toString(),
|
|
7212
7216
|
// totalLinePrice: (element.row_invoiced) ? Number(this.getText(element.row_invoiced)) : 0,
|
|
7213
7217
|
totalLinePrice: ((qty - refundQty) * price),
|
|
7214
7218
|
};
|
|
7219
|
+
/** @type {?} */
|
|
7220
|
+
var promotionAmount = (/** @type {?} */ (_this)).getText(element.discount_amount) ? Number((/** @type {?} */ (_this)).getText(element.discount_amount)) : 0;
|
|
7221
|
+
/** @type {?} */
|
|
7222
|
+
var appliedIDs = (/** @type {?} */ (_this)).getText(element.applied_rule_ids) ? (/** @type {?} */ (_this)).getText(element.applied_rule_ids) : '';
|
|
7215
7223
|
if (product && product.price != 0) {
|
|
7224
|
+
if (promotionAmount) {
|
|
7225
|
+
/** @type {?} */
|
|
7226
|
+
var trigger = (/** @type {?} */ ({}));
|
|
7227
|
+
trigger.itemLineId = product.itemLineId;
|
|
7228
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
7229
|
+
/** @type {?} */
|
|
7230
|
+
var promotion = {
|
|
7231
|
+
promotionAmount: promotionAmount,
|
|
7232
|
+
promotionId: appliedIDs,
|
|
7233
|
+
itemLineId: product.itemLineId,
|
|
7234
|
+
promotionLinePrice: product.totalLinePrice - promotionAmount,
|
|
7235
|
+
trigger: trigger
|
|
7236
|
+
};
|
|
7237
|
+
(/** @type {?} */ (_this)).webReturnObject.basket['linePromotion'].push(promotion);
|
|
7238
|
+
}
|
|
7216
7239
|
(/** @type {?} */ (_this)).webReturnObject.basket['products'].push(product);
|
|
7217
7240
|
}
|
|
7218
7241
|
}));
|
|
@@ -7223,24 +7246,214 @@
|
|
|
7223
7246
|
/** @type {?} */
|
|
7224
7247
|
var 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;
|
|
7225
7248
|
/** @type {?} */
|
|
7226
|
-
var price = ((/** @type {?} */ (this)).document.items && (/** @type {?} */ (this)).document.items.item && (/** @type {?} */ (this)).document.items.item.
|
|
7249
|
+
var 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;
|
|
7227
7250
|
product = {
|
|
7228
7251
|
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) : '',
|
|
7229
7252
|
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) : '',
|
|
7230
7253
|
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,
|
|
7231
7254
|
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,
|
|
7232
|
-
price: (
|
|
7233
|
-
|
|
7255
|
+
// price: (this.document.items && this.document.items.item && this.document.items.item.original_price) ? Number(this.getText(this.document.items.item.original_price)) : 0,
|
|
7256
|
+
price: price,
|
|
7257
|
+
itemLineId: "1",
|
|
7234
7258
|
// totalLinePrice: (this.document.items && this.document.items.item && this.document.items.item.row_invoiced) ? Number(this.getText(this.document.items.item.row_invoiced)) : 0,
|
|
7235
7259
|
totalLinePrice: ((qty - refundQty) * price),
|
|
7236
7260
|
};
|
|
7261
|
+
/** @type {?} */
|
|
7262
|
+
var promotionAmount = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.discount_amount) ? Number((/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.discount_amount)) : 0;
|
|
7263
|
+
/** @type {?} */
|
|
7264
|
+
var appliedIDs_1 = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.applied_rule_ids) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.items.item.applied_rule_ids) : '';
|
|
7237
7265
|
if (product && product.price != 0) {
|
|
7266
|
+
if (promotionAmount) {
|
|
7267
|
+
/** @type {?} */
|
|
7268
|
+
var trigger = (/** @type {?} */ ({}));
|
|
7269
|
+
trigger.itemLineId = product.itemLineId;
|
|
7270
|
+
trigger.quantity = product.quantity ? product.quantity : 0;
|
|
7271
|
+
/** @type {?} */
|
|
7272
|
+
var promotion = {
|
|
7273
|
+
promotionAmount: promotionAmount,
|
|
7274
|
+
promotionId: appliedIDs_1,
|
|
7275
|
+
itemLineId: product.itemLineId,
|
|
7276
|
+
promotionLinePrice: product.totalLinePrice - promotionAmount,
|
|
7277
|
+
trigger: trigger
|
|
7278
|
+
};
|
|
7279
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].push(promotion);
|
|
7280
|
+
}
|
|
7238
7281
|
(/** @type {?} */ (this)).webReturnObject.basket['products'].push(product);
|
|
7239
7282
|
}
|
|
7240
7283
|
}
|
|
7284
|
+
/** @type {?} */
|
|
7285
|
+
var couponCode_1 = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.coupon_code) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.coupon_code) : 0;
|
|
7286
|
+
/** @type {?} */
|
|
7287
|
+
var appliedIDs_2 = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.applied_rule_ids) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.applied_rule_ids) : '';
|
|
7288
|
+
/** @type {?} */
|
|
7289
|
+
var discountDescription_1 = (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_description) ? (/** @type {?} */ (this)).getText((/** @type {?} */ (this)).document.discount_description) : '';
|
|
7290
|
+
/** @type {?} */
|
|
7291
|
+
var couponTriggerPromotions_1 = (/** @type {?} */ ([]));
|
|
7292
|
+
if (couponCode_1 && appliedIDs_2) {
|
|
7293
|
+
/** @type {?} */
|
|
7294
|
+
var transactionPromotion = (/** @type {?} */ ({}));
|
|
7295
|
+
if ((/** @type {?} */ (this)).webReturnObject.basket['linePromotion'] && (/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].length > 0) {
|
|
7296
|
+
(/** @type {?} */ (this)).webReturnObject.basket['linePromotion'].forEach((/**
|
|
7297
|
+
* @param {?} promotion
|
|
7298
|
+
* @return {?}
|
|
7299
|
+
*/
|
|
7300
|
+
function (promotion) {
|
|
7301
|
+
if (promotion.promotionId === appliedIDs_2) {
|
|
7302
|
+
/** @type {?} */
|
|
7303
|
+
var trigger = (/** @type {?} */ ({}));
|
|
7304
|
+
trigger.itemLineId = promotion.itemLineId;
|
|
7305
|
+
trigger.quantity = promotion.trigger.quantity;
|
|
7306
|
+
trigger.totalQuantity = promotion.trigger.quantity;
|
|
7307
|
+
trigger.promotionAmount = promotion.promotionAmount;
|
|
7308
|
+
trigger.refundedReason = couponCode_1;
|
|
7309
|
+
trigger.refundedReasonDescription = discountDescription_1;
|
|
7310
|
+
trigger.promotionId = promotion.promotionId;
|
|
7311
|
+
couponTriggerPromotions_1.push(trigger);
|
|
7312
|
+
(/** @type {?} */ (_this)).webReturnObject.basket['linePromotion'] = (/** @type {?} */ (_this)).webReturnObject.basket['linePromotion'].filter((/**
|
|
7313
|
+
* @param {?} x
|
|
7314
|
+
* @return {?}
|
|
7315
|
+
*/
|
|
7316
|
+
function (x) { return x.itemLineId !== promotion.itemLineId; }));
|
|
7317
|
+
}
|
|
7318
|
+
}));
|
|
7319
|
+
}
|
|
7320
|
+
if (couponTriggerPromotions_1.length > 0) {
|
|
7321
|
+
transactionPromotion.displayText = couponTriggerPromotions_1[0].refundedReasonDescription;
|
|
7322
|
+
transactionPromotion.name = couponTriggerPromotions_1[0].refundedReason;
|
|
7323
|
+
transactionPromotion.promotionAmount = -(couponTriggerPromotions_1.reduce((/**
|
|
7324
|
+
* @param {?} n
|
|
7325
|
+
* @param {?} __1
|
|
7326
|
+
* @return {?}
|
|
7327
|
+
*/
|
|
7328
|
+
function (n, _a) {
|
|
7329
|
+
var promotionAmount = _a.promotionAmount;
|
|
7330
|
+
return n + promotionAmount;
|
|
7331
|
+
}), 0));
|
|
7332
|
+
transactionPromotion.promotionId = couponTriggerPromotions_1[0].promotionId;
|
|
7333
|
+
transactionPromotion.promotionInfo = couponTriggerPromotions_1[0].refundedReasonDescription;
|
|
7334
|
+
transactionPromotion.couponCode = couponCode_1;
|
|
7335
|
+
transactionPromotion.itemLineIds = [];
|
|
7336
|
+
transactionPromotion.type = PROMOTION_TYPE.COUPON;
|
|
7337
|
+
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
7338
|
+
transactionPromotion.trigger = couponTriggerPromotions_1;
|
|
7339
|
+
}
|
|
7340
|
+
console.log("e-basket: update LinePromotion With Coupon", JSON.stringify(transactionPromotion));
|
|
7341
|
+
if (!(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion) {
|
|
7342
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion = [];
|
|
7343
|
+
}
|
|
7344
|
+
if (transactionPromotion && transactionPromotion.promotionId) {
|
|
7345
|
+
(/** @type {?} */ (this)).webReturnObject.basket.transactionPromotion.push(transactionPromotion);
|
|
7346
|
+
}
|
|
7347
|
+
}
|
|
7348
|
+
(/** @type {?} */ (this)).updateTransactionPromotionPrtionCalc();
|
|
7241
7349
|
}
|
|
7242
7350
|
return (/** @type {?} */ (this));
|
|
7243
7351
|
};
|
|
7352
|
+
/**
|
|
7353
|
+
* @param {?} product
|
|
7354
|
+
* @return {?}
|
|
7355
|
+
*/
|
|
7356
|
+
WebReturnMapperBuilderClass.prototype.validateProductItemDiscount = /**
|
|
7357
|
+
* @param {?} product
|
|
7358
|
+
* @return {?}
|
|
7359
|
+
*/
|
|
7360
|
+
function (product) {
|
|
7361
|
+
if (!product.itemDiscounts) {
|
|
7362
|
+
product.itemDiscounts = {
|
|
7363
|
+
trnDiscountsPortion: 0,
|
|
7364
|
+
trnPromotionsPortion: 0,
|
|
7365
|
+
refundPortion: 0,
|
|
7366
|
+
};
|
|
7367
|
+
}
|
|
7368
|
+
return product;
|
|
7369
|
+
};
|
|
7370
|
+
/**
|
|
7371
|
+
* @param {?} txDoc
|
|
7372
|
+
* @param {?} promotion
|
|
7373
|
+
* @return {?}
|
|
7374
|
+
*/
|
|
7375
|
+
WebReturnMapperBuilderClass.prototype.transactionPromotionProductPortionCalc = /**
|
|
7376
|
+
* @param {?} txDoc
|
|
7377
|
+
* @param {?} promotion
|
|
7378
|
+
* @return {?}
|
|
7379
|
+
*/
|
|
7380
|
+
function (txDoc, promotion) {
|
|
7381
|
+
var _this = this;
|
|
7382
|
+
console.log("ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: " + JSON.stringify(promotion));
|
|
7383
|
+
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
7384
|
+
txDoc.basket.products.forEach((/**
|
|
7385
|
+
* @param {?} product
|
|
7386
|
+
* @return {?}
|
|
7387
|
+
*/
|
|
7388
|
+
function (product) {
|
|
7389
|
+
product = _this.validateProductItemDiscount(product);
|
|
7390
|
+
if (promotion.trigger && promotion.trigger.length > 0) {
|
|
7391
|
+
promotion.trigger.forEach((/**
|
|
7392
|
+
* @param {?} t
|
|
7393
|
+
* @return {?}
|
|
7394
|
+
*/
|
|
7395
|
+
function (t) {
|
|
7396
|
+
if (t.itemLineId === product.itemLineId.toString()) {
|
|
7397
|
+
product.itemDiscounts.trnPromotionsPortion += t.promotionAmount;
|
|
7398
|
+
}
|
|
7399
|
+
}));
|
|
7400
|
+
}
|
|
7401
|
+
}));
|
|
7402
|
+
}
|
|
7403
|
+
else {
|
|
7404
|
+
txDoc.basket.products.forEach((/**
|
|
7405
|
+
* @param {?} product
|
|
7406
|
+
* @return {?}
|
|
7407
|
+
*/
|
|
7408
|
+
function (product) {
|
|
7409
|
+
product = _this.validateProductItemDiscount(product);
|
|
7410
|
+
if (promotion.itemLineIds.includes(+product.itemLineId)) {
|
|
7411
|
+
/** @type {?} */
|
|
7412
|
+
var discountAmount = 0;
|
|
7413
|
+
if (_this.document.items.item instanceof Array) {
|
|
7414
|
+
/** @type {?} */
|
|
7415
|
+
var productItem = _this.document.items.item.find((/**
|
|
7416
|
+
* @param {?} productItem
|
|
7417
|
+
* @return {?}
|
|
7418
|
+
*/
|
|
7419
|
+
function (productItem) { return productItem.sku === product.SKU; }));
|
|
7420
|
+
discountAmount = productItem.discount_amount ? +productItem.discount_amount : 0;
|
|
7421
|
+
}
|
|
7422
|
+
else {
|
|
7423
|
+
discountAmount = _this.document.items.item.sku === product.SKU && _this.document.items.item.discount_amount ?
|
|
7424
|
+
+_this.document.items.item.discount_amount : 0;
|
|
7425
|
+
}
|
|
7426
|
+
/** @type {?} */
|
|
7427
|
+
var transactionPromotionPortion = discountAmount;
|
|
7428
|
+
product.itemDiscounts.trnPromotionsPortion += _this.numberUtilService.trimTo2Decimal2(transactionPromotionPortion);
|
|
7429
|
+
}
|
|
7430
|
+
}));
|
|
7431
|
+
}
|
|
7432
|
+
return txDoc;
|
|
7433
|
+
};
|
|
7434
|
+
/**
|
|
7435
|
+
* @return {?}
|
|
7436
|
+
*/
|
|
7437
|
+
WebReturnMapperBuilderClass.prototype.updateTransactionPromotionPrtionCalc = /**
|
|
7438
|
+
* @return {?}
|
|
7439
|
+
*/
|
|
7440
|
+
function () {
|
|
7441
|
+
var _this = this;
|
|
7442
|
+
try {
|
|
7443
|
+
if (this.webReturnObject.basket.transactionPromotion && this.webReturnObject.basket.transactionPromotion.length > 0) {
|
|
7444
|
+
this.webReturnObject.basket.transactionPromotion.forEach((/**
|
|
7445
|
+
* @param {?} tr
|
|
7446
|
+
* @return {?}
|
|
7447
|
+
*/
|
|
7448
|
+
function (tr) {
|
|
7449
|
+
_this.transactionPromotionProductPortionCalc(_this.webReturnObject, tr);
|
|
7450
|
+
}));
|
|
7451
|
+
}
|
|
7452
|
+
}
|
|
7453
|
+
catch (error) {
|
|
7454
|
+
console.log("updateTransactionPromotionPrtionCalc => failed:", JSON.stringify(error));
|
|
7455
|
+
}
|
|
7456
|
+
};
|
|
7244
7457
|
/**
|
|
7245
7458
|
* @template THIS
|
|
7246
7459
|
* @this {THIS}
|
|
@@ -7454,6 +7667,13 @@
|
|
|
7454
7667
|
* @private
|
|
7455
7668
|
*/
|
|
7456
7669
|
WebReturnMapperBuilderClass.prototype.webReturnObject;
|
|
7670
|
+
/** @type {?} */
|
|
7671
|
+
WebReturnMapperBuilderClass.prototype.numberUtilService;
|
|
7672
|
+
/**
|
|
7673
|
+
* @type {?}
|
|
7674
|
+
* @private
|
|
7675
|
+
*/
|
|
7676
|
+
WebReturnMapperBuilderClass.prototype.currencyPipe;
|
|
7457
7677
|
}
|
|
7458
7678
|
|
|
7459
7679
|
/**
|