@pmcretail/mapper-library 0.0.12 → 0.0.14
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 +207 -68
- 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/RJ-mapper.class.js +190 -68
- package/esm5/lib/RJ-mapper.class.js +208 -69
- package/fesm2015/pmcretail-mapper-library.js +189 -67
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +207 -68
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/RJ-mapper.class.d.ts +7 -4
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -3572,6 +3572,11 @@ class RJMapperBuilderClass {
|
|
|
3572
3572
|
* @return {THIS}
|
|
3573
3573
|
*/
|
|
3574
3574
|
rjMapper() {
|
|
3575
|
+
/** @type {?} */
|
|
3576
|
+
var transactionDiscount = [];
|
|
3577
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount && (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.length > 0) {
|
|
3578
|
+
transactionDiscount = (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount;
|
|
3579
|
+
}
|
|
3575
3580
|
if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.SALE) {
|
|
3576
3581
|
(/** @type {?} */ (this)).rjObject['ProductSale'] = [];
|
|
3577
3582
|
(/** @type {?} */ (this)).rjObject['ModifierItem'] = [];
|
|
@@ -3597,7 +3602,7 @@ class RJMapperBuilderClass {
|
|
|
3597
3602
|
}
|
|
3598
3603
|
}
|
|
3599
3604
|
/** @type {?} */
|
|
3600
|
-
let data = (/** @type {?} */ (this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null));
|
|
3605
|
+
let data = (/** @type {?} */ (this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
3601
3606
|
(/** @type {?} */ (this)).rjObject['ProductSale'].push(data);
|
|
3602
3607
|
(/** @type {?} */ (this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
|
|
3603
3608
|
}));
|
|
@@ -3617,7 +3622,7 @@ class RJMapperBuilderClass {
|
|
|
3617
3622
|
*/
|
|
3618
3623
|
(element) => {
|
|
3619
3624
|
/** @type {?} */
|
|
3620
|
-
let data = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
3625
|
+
let data = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
3621
3626
|
(/** @type {?} */ (this)).rjObject['ProductReturn'].push(data);
|
|
3622
3627
|
(/** @type {?} */ (this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
3623
3628
|
}));
|
|
@@ -3633,7 +3638,7 @@ class RJMapperBuilderClass {
|
|
|
3633
3638
|
*/
|
|
3634
3639
|
(element) => {
|
|
3635
3640
|
/** @type {?} */
|
|
3636
|
-
let data = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
3641
|
+
let data = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
3637
3642
|
/** @type {?} */
|
|
3638
3643
|
let obj = {
|
|
3639
3644
|
"OriginalReceiptSupplied": 0,
|
|
@@ -3660,7 +3665,7 @@ class RJMapperBuilderClass {
|
|
|
3660
3665
|
(element) => {
|
|
3661
3666
|
if (element.refundedQuantity > 0) {
|
|
3662
3667
|
/** @type {?} */
|
|
3663
|
-
let returnProduct = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
3668
|
+
let returnProduct = (/** @type {?} */ (this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
3664
3669
|
/** @type {?} */
|
|
3665
3670
|
let obj = {
|
|
3666
3671
|
"OriginalReceiptSupplied": 0,
|
|
@@ -3674,7 +3679,7 @@ class RJMapperBuilderClass {
|
|
|
3674
3679
|
}
|
|
3675
3680
|
else {
|
|
3676
3681
|
/** @type {?} */
|
|
3677
|
-
let addProduct = (/** @type {?} */ (this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
3682
|
+
let addProduct = (/** @type {?} */ (this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
3678
3683
|
(/** @type {?} */ (this)).rjObject['ProductSale'].push(addProduct);
|
|
3679
3684
|
}
|
|
3680
3685
|
(/** @type {?} */ (this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
@@ -3698,18 +3703,24 @@ class RJMapperBuilderClass {
|
|
|
3698
3703
|
(element) => {
|
|
3699
3704
|
/** @type {?} */
|
|
3700
3705
|
let obj = {};
|
|
3701
|
-
obj['XMLSchemaVersion'] =
|
|
3702
|
-
obj['NetValue'] =
|
|
3703
|
-
obj['EffectiveNetValue'] =
|
|
3704
|
-
obj['Description'] = element.
|
|
3706
|
+
obj['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
|
|
3707
|
+
obj['NetValue'] = (/** @type {?} */ (this)).convertToString(element.discountAmount * -1);
|
|
3708
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (this)).convertToString(element.discountAmount * -1);
|
|
3709
|
+
obj['Description'] = element.reasonDisplayText;
|
|
3705
3710
|
obj['UserID'] = (/** @type {?} */ (this)).transactionDocument.userName;
|
|
3706
3711
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
3707
|
-
obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1;
|
|
3708
|
-
obj['RoundingRule'] = 2;
|
|
3709
|
-
obj['ModifiedLineNumber
|
|
3710
|
-
obj['LineNumber'] = (/** @type {?} */ (this)).generateLineNumber();
|
|
3711
|
-
|
|
3712
|
-
|
|
3712
|
+
obj['DiscountType'] = (/** @type {?} */ (this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
3713
|
+
obj['RoundingRule'] = (/** @type {?} */ (this)).convertToString(2);
|
|
3714
|
+
obj['ModifiedLineNumber'] = element.itemLineIds;
|
|
3715
|
+
obj['LineNumber'] = (/** @type {?} */ (this)).convertToString((/** @type {?} */ (this)).generateLineNumber());
|
|
3716
|
+
obj['DiscountedValue'] = (/** @type {?} */ (this)).transactionDocument.basketSummary.basketTotal + (/** @type {?} */ (this)).transactionDocument.basketSummary.discountTotal;
|
|
3717
|
+
if (element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase()) {
|
|
3718
|
+
obj['DiscountPercentage'] = (/** @type {?} */ (this)).convertToString((element.discountAmount / (/** @type {?} */ (this)).transactionDocument.basketSummary.basketTotal).toFixed(1));
|
|
3719
|
+
}
|
|
3720
|
+
if ((/** @type {?} */ (this)).transactionDocument.type === 'REFUND') {
|
|
3721
|
+
obj['NetValue'] = (/** @type {?} */ (this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
3722
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
3723
|
+
}
|
|
3713
3724
|
(/** @type {?} */ (this)).rjObject['BasketDiscount'].push(obj);
|
|
3714
3725
|
}));
|
|
3715
3726
|
return (/** @type {?} */ (this));
|
|
@@ -3776,56 +3787,51 @@ class RJMapperBuilderClass {
|
|
|
3776
3787
|
obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
|
|
3777
3788
|
(/** @type {?} */ (this)).rjObject['Trailer']['TaxItem'].push(obj);
|
|
3778
3789
|
}));
|
|
3779
|
-
// TODO: make Trailer object from promotion
|
|
3780
|
-
(/** @type {?} */ (this)).
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
*/
|
|
3785
|
-
(element) => {
|
|
3786
|
-
/** @type {?} */
|
|
3787
|
-
let obj = {};
|
|
3788
|
-
obj['PromotionID'] = element.promotionId;
|
|
3789
|
-
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
3790
|
-
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
3791
|
-
obj['PromotionDescription'] = element.displayText;
|
|
3792
|
-
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (this)).transactionDocument.storeId;
|
|
3793
|
-
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
3794
|
-
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
3795
|
-
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
3796
|
-
obj['PromotionHit']['PromotionTrigger'] = [];
|
|
3797
|
-
element.trigger.forEach((/**
|
|
3798
|
-
* @param {?} subElement
|
|
3790
|
+
// TODO: make Trailer object from promotion
|
|
3791
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
|
|
3792
|
+
(/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
|
|
3793
|
+
(/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
|
|
3794
|
+
* @param {?} element
|
|
3799
3795
|
* @return {?}
|
|
3800
3796
|
*/
|
|
3801
|
-
(
|
|
3802
|
-
/** @type {?} */
|
|
3803
|
-
let objSub = {};
|
|
3797
|
+
(element) => {
|
|
3804
3798
|
/** @type {?} */
|
|
3805
|
-
let
|
|
3806
|
-
|
|
3799
|
+
let obj = {};
|
|
3800
|
+
obj['PromotionID'] = element.promotionId;
|
|
3801
|
+
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
3802
|
+
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
3803
|
+
obj['PromotionDescription'] = element.displayText;
|
|
3804
|
+
obj['PromotionHit'] = {};
|
|
3805
|
+
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
|
|
3806
|
+
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
3807
|
+
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
3808
|
+
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
3809
|
+
obj['PromotionHit']['PromotionTrigger'] = {};
|
|
3810
|
+
element.trigger.forEach((/**
|
|
3811
|
+
* @param {?} subElement
|
|
3807
3812
|
* @return {?}
|
|
3808
3813
|
*/
|
|
3809
|
-
(
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3814
|
+
(subElement) => {
|
|
3815
|
+
/** @type {?} */
|
|
3816
|
+
let product = (/** @type {?} */ (this)).transactionDocument.basket.products.find((/**
|
|
3817
|
+
* @param {?} item
|
|
3818
|
+
* @return {?}
|
|
3819
|
+
*/
|
|
3820
|
+
(item) => item.itemLineId == subElement.itemLineId));
|
|
3821
|
+
obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
|
|
3822
|
+
obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
|
|
3823
|
+
obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (this)).convertToString(element.promotionLinePrice / product.quantity);
|
|
3824
|
+
obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (this)).convertToString(subElement.itemLineId);
|
|
3825
|
+
obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (this)).convertToString(subElement.quantity.toFixed(1));
|
|
3826
|
+
obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
|
|
3827
|
+
* @param {?} item
|
|
3828
|
+
* @return {?}
|
|
3829
|
+
*/
|
|
3830
|
+
(item) => item.itemLineId == element.itemLineId)).VATCode; // todo
|
|
3831
|
+
}));
|
|
3832
|
+
(/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'].push(obj);
|
|
3825
3833
|
}));
|
|
3826
|
-
|
|
3827
|
-
}));
|
|
3828
|
-
//console.log(this.rjObject);
|
|
3834
|
+
}
|
|
3829
3835
|
return (/** @type {?} */ (this));
|
|
3830
3836
|
}
|
|
3831
3837
|
/**
|
|
@@ -4074,10 +4080,9 @@ class RJMapperBuilderClass {
|
|
|
4074
4080
|
/**
|
|
4075
4081
|
* @template THIS
|
|
4076
4082
|
* @this {THIS}
|
|
4077
|
-
* @param {?} value
|
|
4078
4083
|
* @return {THIS}
|
|
4079
4084
|
*/
|
|
4080
|
-
setCashierID(
|
|
4085
|
+
setCashierID() {
|
|
4081
4086
|
(/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
|
|
4082
4087
|
return (/** @type {?} */ (this));
|
|
4083
4088
|
}
|
|
@@ -4173,9 +4178,10 @@ class RJMapperBuilderClass {
|
|
|
4173
4178
|
/**
|
|
4174
4179
|
* @param {?} element
|
|
4175
4180
|
* @param {?} lineDiscount
|
|
4181
|
+
* @param {?} transactionDiscount
|
|
4176
4182
|
* @return {?}
|
|
4177
4183
|
*/
|
|
4178
|
-
returnProduct(element, lineDiscount) {
|
|
4184
|
+
returnProduct(element, lineDiscount, transactionDiscount) {
|
|
4179
4185
|
/** @type {?} */
|
|
4180
4186
|
let obj = {};
|
|
4181
4187
|
/** @type {?} */
|
|
@@ -4194,7 +4200,7 @@ class RJMapperBuilderClass {
|
|
|
4194
4200
|
obj['DateTimeCreated'] = this.createdAt;
|
|
4195
4201
|
obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
|
|
4196
4202
|
obj['UnitPrice'] = this.removeDecimal(element['price']);
|
|
4197
|
-
obj['Quantity'] =
|
|
4203
|
+
obj['Quantity'] = this.getQuantity(element);
|
|
4198
4204
|
obj['OriginalTaxAmountSet'] = 1;
|
|
4199
4205
|
obj['ProductID'] = element['SKU'];
|
|
4200
4206
|
obj['HandKeyed'] = 1;
|
|
@@ -4202,7 +4208,7 @@ class RJMapperBuilderClass {
|
|
|
4202
4208
|
obj['Return'] = {};
|
|
4203
4209
|
obj['Return']['ReturnReasonID'] = element['refundedReason'];
|
|
4204
4210
|
obj['Return']['ReturnDescription'] = element['refundedReasonDescription'];
|
|
4205
|
-
obj['Return']['ReturnToStock'] =
|
|
4211
|
+
obj['Return']['ReturnToStock'] = this.getQuantity(element);
|
|
4206
4212
|
obj['TaxCode'] = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
4207
4213
|
* @param {?} item
|
|
4208
4214
|
* @return {?}
|
|
@@ -4250,14 +4256,51 @@ class RJMapperBuilderClass {
|
|
|
4250
4256
|
obj.ExtendedValue = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
4251
4257
|
obj.UnitPrice = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
4252
4258
|
}
|
|
4259
|
+
if (transactionDiscount) {
|
|
4260
|
+
obj['BasketDiscountModifier'] = [];
|
|
4261
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
4262
|
+
* @param {?} e
|
|
4263
|
+
* @return {?}
|
|
4264
|
+
*/
|
|
4265
|
+
(e) => {
|
|
4266
|
+
/** @type {?} */
|
|
4267
|
+
let obj1 = {};
|
|
4268
|
+
e.itemLineIds.forEach((/**
|
|
4269
|
+
* @param {?} x
|
|
4270
|
+
* @return {?}
|
|
4271
|
+
*/
|
|
4272
|
+
(x) => {
|
|
4273
|
+
if (x == element.itemLineId) {
|
|
4274
|
+
/** @type {?} */
|
|
4275
|
+
var discountAmount = this.convertToString(e.discountAmount * -1);
|
|
4276
|
+
obj1.BasketDiscountLineNumber = this.getLineNumber(e, discountAmount);
|
|
4277
|
+
obj1.XMLSchemaVersion = this.xmlSchemaVersion;
|
|
4278
|
+
obj1.DiscountedValue = this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
|
|
4279
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
4280
|
+
}
|
|
4281
|
+
}));
|
|
4282
|
+
}));
|
|
4283
|
+
/** @type {?} */
|
|
4284
|
+
var totaltransactionDiscount = 0;
|
|
4285
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
4286
|
+
* @param {?} value
|
|
4287
|
+
* @return {?}
|
|
4288
|
+
*/
|
|
4289
|
+
(value) => {
|
|
4290
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
4291
|
+
}));
|
|
4292
|
+
//update the product price
|
|
4293
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
4294
|
+
}
|
|
4253
4295
|
return obj;
|
|
4254
4296
|
}
|
|
4255
4297
|
/**
|
|
4256
4298
|
* @param {?} element
|
|
4257
4299
|
* @param {?} lineDiscount
|
|
4300
|
+
* @param {?} transactionDiscount
|
|
4258
4301
|
* @return {?}
|
|
4259
4302
|
*/
|
|
4260
|
-
addProduct(element, lineDiscount) {
|
|
4303
|
+
addProduct(element, lineDiscount, transactionDiscount) {
|
|
4261
4304
|
/** @type {?} */
|
|
4262
4305
|
let taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
4263
4306
|
* @param {?} item
|
|
@@ -4322,7 +4365,7 @@ class RJMapperBuilderClass {
|
|
|
4322
4365
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
4323
4366
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
4324
4367
|
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
4325
|
-
obj['PriceOverride'].XMLSchemaVersion =
|
|
4368
|
+
obj['PriceOverride'].XMLSchemaVersion = this.xmlSchemaVersion;
|
|
4326
4369
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
4327
4370
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
4328
4371
|
}
|
|
@@ -4332,8 +4375,72 @@ class RJMapperBuilderClass {
|
|
|
4332
4375
|
obj['ExtendedValue'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
4333
4376
|
obj['UnitPrice'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
4334
4377
|
}
|
|
4378
|
+
if (transactionDiscount) {
|
|
4379
|
+
obj['BasketDiscountModifier'] = [];
|
|
4380
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
4381
|
+
* @param {?} e
|
|
4382
|
+
* @return {?}
|
|
4383
|
+
*/
|
|
4384
|
+
(e) => {
|
|
4385
|
+
/** @type {?} */
|
|
4386
|
+
var obj1 = {};
|
|
4387
|
+
e.itemLineIds.forEach((/**
|
|
4388
|
+
* @param {?} x
|
|
4389
|
+
* @return {?}
|
|
4390
|
+
*/
|
|
4391
|
+
(x) => {
|
|
4392
|
+
if (x == element.itemLineId) {
|
|
4393
|
+
/** @type {?} */
|
|
4394
|
+
var discountAmount = this.convertToString(e.discountAmount * -1);
|
|
4395
|
+
obj1.XMLSchemaVersion = this.xmlSchemaVersion;
|
|
4396
|
+
obj1.DiscountedValue = -(this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
|
|
4397
|
+
obj1.BasketDiscountLineNumber = this.getLineNumber(e, discountAmount);
|
|
4398
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
4399
|
+
}
|
|
4400
|
+
}));
|
|
4401
|
+
}));
|
|
4402
|
+
/** @type {?} */
|
|
4403
|
+
var totaltransactionDiscount = 0;
|
|
4404
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
4405
|
+
* @param {?} value
|
|
4406
|
+
* @return {?}
|
|
4407
|
+
*/
|
|
4408
|
+
(value) => {
|
|
4409
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
4410
|
+
}));
|
|
4411
|
+
//update the product price
|
|
4412
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
4413
|
+
}
|
|
4335
4414
|
return obj;
|
|
4336
4415
|
}
|
|
4416
|
+
/**
|
|
4417
|
+
* @param {?} value
|
|
4418
|
+
* @param {?} discountAmount
|
|
4419
|
+
* @return {?}
|
|
4420
|
+
*/
|
|
4421
|
+
getLineNumber(value, discountAmount) {
|
|
4422
|
+
/** @type {?} */
|
|
4423
|
+
let lineNumber;
|
|
4424
|
+
for (let i = 0; i < this.rjObject['BasketDiscount'].length; i++) {
|
|
4425
|
+
/** @type {?} */
|
|
4426
|
+
const element = this.rjObject['BasketDiscount'][i];
|
|
4427
|
+
if (value.reasonCode === element.ReasonCodeID && discountAmount === element.NetValue) {
|
|
4428
|
+
lineNumber = element.LineNumber;
|
|
4429
|
+
break;
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
return lineNumber;
|
|
4433
|
+
}
|
|
4434
|
+
/**
|
|
4435
|
+
* @param {?} price
|
|
4436
|
+
* @param {?} discountAmount
|
|
4437
|
+
* @return {?}
|
|
4438
|
+
*/
|
|
4439
|
+
getDiscountedValue(price, discountAmount) {
|
|
4440
|
+
/** @type {?} */
|
|
4441
|
+
let DiscountedValue = (price * discountAmount) / this.transactionDocument.basketSummary.saleTotal;
|
|
4442
|
+
return DiscountedValue;
|
|
4443
|
+
}
|
|
4337
4444
|
/**
|
|
4338
4445
|
* @param {?} element
|
|
4339
4446
|
* @param {?} VAT
|
|
@@ -4356,7 +4463,7 @@ class RJMapperBuilderClass {
|
|
|
4356
4463
|
return value;
|
|
4357
4464
|
}
|
|
4358
4465
|
catch (e) {
|
|
4359
|
-
console.log(value, '
|
|
4466
|
+
console.log(value, 'can not be converted in string', e);
|
|
4360
4467
|
}
|
|
4361
4468
|
}
|
|
4362
4469
|
/**
|
|
@@ -4447,6 +4554,21 @@ class RJMapperBuilderClass {
|
|
|
4447
4554
|
this.rjObject['BasketDiscount']['RoundingRule'] = 2;
|
|
4448
4555
|
}
|
|
4449
4556
|
}
|
|
4557
|
+
/**
|
|
4558
|
+
* @param {?} element
|
|
4559
|
+
* @return {?}
|
|
4560
|
+
*/
|
|
4561
|
+
getQuantity(element) {
|
|
4562
|
+
/** @type {?} */
|
|
4563
|
+
let quantity;
|
|
4564
|
+
if (this.transactionDocument.unreferencedRefund) {
|
|
4565
|
+
quantity = element['quantity'] < 0 ? element['quantity'].toFixed(1) : (-element['quantity']).toFixed(1);
|
|
4566
|
+
}
|
|
4567
|
+
else {
|
|
4568
|
+
quantity = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
|
|
4569
|
+
}
|
|
4570
|
+
return quantity;
|
|
4571
|
+
}
|
|
4450
4572
|
}
|
|
4451
4573
|
if (false) {
|
|
4452
4574
|
/**
|