@pmcretail/mapper-library 0.0.14 → 0.0.15

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.
@@ -3556,7 +3556,7 @@ class RJMapperBuilderClass {
3556
3556
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TerminalNumber = (/** @type {?} */ (this)).terminalNumber;
3557
3557
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TransactionNumber = (/** @type {?} */ (this)).transactionNumber;
3558
3558
  (/** @type {?} */ (this)).rjObject['Header'].TaxMethodID = (/** @type {?} */ (this)).taxMethodId;
3559
- (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp(); //todo
3559
+ (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp();
3560
3560
  (/** @type {?} */ (this)).rjObject['Header'].BasketLanguageID = (/** @type {?} */ (this)).basketLanguageId; //todo
3561
3561
  (/** @type {?} */ (this)).rjObject['Header'].BasketCountryID = (/** @type {?} */ (this)).basketCountryId; //todo
3562
3562
  (/** @type {?} */ (this)).rjObject['Header'].BasketCurrencyID = (/** @type {?} */ (this)).transactionDocument.baseCurrency;
@@ -3787,50 +3787,94 @@ class RJMapperBuilderClass {
3787
3787
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
3788
3788
  (/** @type {?} */ (this)).rjObject['Trailer']['TaxItem'].push(obj);
3789
3789
  }));
3790
- // TODO: make Trailer object from promotion
3791
- if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
3790
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0 || (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
3792
3791
  (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
3793
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
3794
- * @param {?} element
3795
- * @return {?}
3796
- */
3797
- (element) => {
3798
- /** @type {?} */
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
3792
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
3793
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
3794
+ * @param {?} element
3812
3795
  * @return {?}
3813
3796
  */
3814
- (subElement) => {
3797
+ (element) => {
3798
+ /** @type {?} */
3799
+ let obj = {};
3800
+ obj['PromotionID'] = element.promotionId;
3801
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
3802
+ obj['PromotionQuantity'] = "1";
3803
+ obj['PromotionDescription'] = element.displayText;
3804
+ obj['PromotionHit'] = {};
3805
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
3806
+ obj['PromotionHit']['HitNumber'] = "1";
3807
+ obj['PromotionHit']['HitQuantity'] = "1";
3808
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
3809
+ obj['PromotionHit']['PromotionTrigger'] = {};
3815
3810
  /** @type {?} */
3816
3811
  let product = (/** @type {?} */ (this)).transactionDocument.basket.products.find((/**
3817
3812
  * @param {?} item
3818
3813
  * @return {?}
3819
3814
  */
3820
- (item) => item.itemLineId == subElement.itemLineId));
3815
+ (item) => item.itemLineId == element.itemLineId));
3821
3816
  obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
3822
3817
  obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
3823
3818
  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));
3819
+ obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (this)).getNumber(product.SKU);
3820
+ obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (this)).convertToString(product.quantity.toFixed(1));
3826
3821
  obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
3827
3822
  * @param {?} item
3828
3823
  * @return {?}
3829
3824
  */
3830
3825
  (item) => item.itemLineId == element.itemLineId)).VATCode; // todo
3826
+ (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'].push(obj);
3831
3827
  }));
3832
- (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'].push(obj);
3833
- }));
3828
+ }
3829
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
3830
+ (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.forEach((/**
3831
+ * @param {?} element
3832
+ * @return {?}
3833
+ */
3834
+ (element) => {
3835
+ /** @type {?} */
3836
+ let obj = {};
3837
+ console.log('element');
3838
+ obj['PromotionID'] = element.promotionId;
3839
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
3840
+ obj['PromotionQuantity'] = "1";
3841
+ obj['PromotionDescription'] = element.displayText;
3842
+ obj['PromotionHit'] = {};
3843
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
3844
+ obj['PromotionHit']['HitNumber'] = "1";
3845
+ obj['PromotionHit']['HitQuantity'] = "1";
3846
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
3847
+ obj['PromotionHit']['PromotionTrigger'] = [];
3848
+ (/** @type {?} */ (this)).transactionDocument.basket.products.forEach((/**
3849
+ * @param {?} product
3850
+ * @return {?}
3851
+ */
3852
+ (product) => {
3853
+ /** @type {?} */
3854
+ let promotionTrigger = {};
3855
+ element.itemLineIds.forEach((/**
3856
+ * @param {?} itemLineId
3857
+ * @return {?}
3858
+ */
3859
+ (itemLineId) => {
3860
+ if (JSON.stringify(itemLineId) === product.itemLineId) {
3861
+ promotionTrigger['XMLSchemaVersion'] = (/** @type {?} */ (this)).xmlSchemaVersion;
3862
+ promotionTrigger['ProductID'] = product.SKU;
3863
+ promotionTrigger['UnitValue'] = (/** @type {?} */ (this)).convertToString(element.promotionLinePrice / product.quantity);
3864
+ promotionTrigger['LineNumber'] = (/** @type {?} */ (this)).getNumber(product.SKU);
3865
+ promotionTrigger['Quantity'] = (/** @type {?} */ (this)).convertToString(product.quantity);
3866
+ promotionTrigger['TaxCode'] = (/** @type {?} */ (this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
3867
+ * @param {?} item
3868
+ * @return {?}
3869
+ */
3870
+ (item) => item.itemLineId == product.itemLineId)).VATCode;
3871
+ obj['PromotionHit']['PromotionTrigger'].push(promotionTrigger);
3872
+ }
3873
+ }));
3874
+ }));
3875
+ (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'].push(obj);
3876
+ }));
3877
+ }
3834
3878
  }
3835
3879
  return (/** @type {?} */ (this));
3836
3880
  }
@@ -3840,64 +3884,132 @@ class RJMapperBuilderClass {
3840
3884
  * @return {THIS}
3841
3885
  */
3842
3886
  getTenderInfo() {
3843
- (/** @type {?} */ (this)).rjObject['CashTender'] = [];
3844
3887
  if ((/** @type {?} */ (this)).transactionDocument.paymentDetails && (/** @type {?} */ (this)).transactionDocument.paymentDetails.length > 0) {
3845
3888
  (/** @type {?} */ (this)).transactionDocument.paymentDetails.forEach((/**
3846
3889
  * @param {?} element
3847
3890
  * @return {?}
3848
3891
  */
3849
3892
  (element) => {
3850
- if (element.paymentType.toUpperCase() === 'GIFT CARD') {
3851
- /** @type {?} */
3852
- let obj = {
3853
- XMLSchemaVersion: (/** @type {?} */ (this)).xmlSchemaVersion,
3854
- LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3855
- NetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3856
- EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3857
- Description: (/** @type {?} */ (this)).getDescription(element),
3858
- DeviceID: (/** @type {?} */ (this)).deviceId,
3859
- UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3860
- DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3861
- TenderType: element.externalTenderType ? element.externalTenderType : '',
3862
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3863
- TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3864
- CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3865
- CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3866
- GiftVoucherSalesAllowed: '',
3867
- //todo
3868
- AllowRechargeableVoucherSales: '',
3869
- //todo
3870
- GiftVoucherID: ''
3871
- };
3872
- (/** @type {?} */ (this)).rjObject['CashTender'].push(obj);
3893
+ if (element.externalTenderKey) {
3894
+ (/** @type {?} */ (this)).rjObject[element.externalTenderKey] = [];
3895
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
3896
+ /** @type {?} */
3897
+ let obj = {
3898
+ XMLSchemaVersion: (/** @type {?} */ (this)).xmlSchemaVersion,
3899
+ LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3900
+ NetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3901
+ EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3902
+ Description: (/** @type {?} */ (this)).getDescription(element),
3903
+ DeviceID: (/** @type {?} */ (this)).deviceId,
3904
+ UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3905
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3906
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
3907
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3908
+ TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3909
+ CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3910
+ CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3911
+ GiftVoucherSalesAllowed: '',
3912
+ //todo
3913
+ AllowRechargeableVoucherSales: '',
3914
+ //todo
3915
+ GiftVoucherID: ''
3916
+ };
3917
+ (/** @type {?} */ (this)).rjObject[element.externalTenderKey].push(obj);
3918
+ }
3919
+ else {
3920
+ /** @type {?} */
3921
+ let obj1 = {
3922
+ XMLSchemaVersion: "1",
3923
+ LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3924
+ //todo
3925
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3926
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3927
+ Description: (/** @type {?} */ (this)).getDescription(element),
3928
+ DeviceID: (/** @type {?} */ (this)).deviceId,
3929
+ UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3930
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3931
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
3932
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3933
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
3934
+ CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3935
+ CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3936
+ IncludeInTransactionTotalCheck: "1",
3937
+ AllowRechargeableVoucherSales: "1",
3938
+ OpenDrawerAtEnd: "1"
3939
+ };
3940
+ (/** @type {?} */ (this)).rjObject[element.externalTenderKey].push(obj1);
3941
+ }
3873
3942
  }
3874
3943
  else {
3875
- /** @type {?} */
3876
- let obj1 = {
3877
- XMLSchemaVersion: "1",
3878
- LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3879
- //todo
3880
- NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3881
- EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3882
- Description: (/** @type {?} */ (this)).getDescription(element),
3883
- DeviceID: (/** @type {?} */ (this)).deviceId,
3884
- UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3885
- DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3886
- TenderType: element.externalTenderType ? element.externalTenderType : '',
3887
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3888
- TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
3889
- CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3890
- CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3891
- IncludeInTransactionTotalCheck: "1",
3892
- AllowRechargeableVoucherSales: "1",
3893
- OpenDrawerAtEnd: "1"
3894
- };
3895
- (/** @type {?} */ (this)).rjObject['CashTender'].push(obj1);
3944
+ (/** @type {?} */ (this)).rjObject['CashTender'] = [];
3945
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
3946
+ /** @type {?} */
3947
+ let obj = {
3948
+ XMLSchemaVersion: (/** @type {?} */ (this)).xmlSchemaVersion,
3949
+ LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3950
+ NetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3951
+ EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3952
+ Description: (/** @type {?} */ (this)).getDescription(element),
3953
+ DeviceID: (/** @type {?} */ (this)).deviceId,
3954
+ UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3955
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3956
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
3957
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3958
+ TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3959
+ CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3960
+ CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3961
+ GiftVoucherSalesAllowed: '',
3962
+ //todo
3963
+ AllowRechargeableVoucherSales: '',
3964
+ //todo
3965
+ GiftVoucherID: ''
3966
+ };
3967
+ (/** @type {?} */ (this)).rjObject['CashTender'].push(obj);
3968
+ }
3969
+ else {
3970
+ /** @type {?} */
3971
+ let obj1 = {
3972
+ XMLSchemaVersion: "1",
3973
+ LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3974
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3975
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3976
+ Description: (/** @type {?} */ (this)).getDescription(element),
3977
+ DeviceID: (/** @type {?} */ (this)).deviceId,
3978
+ UserID: (/** @type {?} */ (this)).transactionDocument.userName,
3979
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3980
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
3981
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
3982
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
3983
+ CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3984
+ CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3985
+ IncludeInTransactionTotalCheck: "1",
3986
+ AllowRechargeableVoucherSales: "1",
3987
+ OpenDrawerAtEnd: "1"
3988
+ };
3989
+ (/** @type {?} */ (this)).rjObject['CashTender'].push(obj1);
3990
+ }
3896
3991
  }
3897
3992
  }));
3898
3993
  }
3899
3994
  return (/** @type {?} */ (this));
3900
3995
  }
3996
+ /**
3997
+ * @param {?} productId
3998
+ * @return {?}
3999
+ */
4000
+ getNumber(productId) {
4001
+ /** @type {?} */
4002
+ let lineNumber;
4003
+ for (let i = 0; i < this.rjObject['ProductSale'].length; i++) {
4004
+ /** @type {?} */
4005
+ const element = this.rjObject['ProductSale'][i];
4006
+ if (JSON.stringify(productId) === JSON.stringify(element.ProductID)) {
4007
+ lineNumber = element.LineNumber;
4008
+ break;
4009
+ }
4010
+ }
4011
+ return lineNumber;
4012
+ }
3901
4013
  /**
3902
4014
  * @return {?}
3903
4015
  */
@@ -4217,7 +4329,7 @@ class RJMapperBuilderClass {
4217
4329
  obj['DisplayTaxCode'] = ''; // todo
4218
4330
  obj['ProductAttributes'] = ''; //todo - not required
4219
4331
  obj['Perishable'] = this.getAttributes();
4220
- obj['MMGroupID'] = this.getAttributes();
4332
+ obj['MMGroupID'] = this.getCaregories(element);
4221
4333
  obj['CustomerDetails'] = ""; // todo - blank
4222
4334
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
4223
4335
  obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
@@ -4264,7 +4376,7 @@ class RJMapperBuilderClass {
4264
4376
  */
4265
4377
  (e) => {
4266
4378
  /** @type {?} */
4267
- let obj1 = {};
4379
+ let discountObj = {};
4268
4380
  e.itemLineIds.forEach((/**
4269
4381
  * @param {?} x
4270
4382
  * @return {?}
@@ -4273,10 +4385,10 @@ class RJMapperBuilderClass {
4273
4385
  if (x == element.itemLineId) {
4274
4386
  /** @type {?} */
4275
4387
  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);
4388
+ discountObj.BasketDiscountLineNumber = this.getLineNumber(e, discountAmount);
4389
+ discountObj.XMLSchemaVersion = this.xmlSchemaVersion;
4390
+ discountObj.DiscountedValue = this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
4391
+ obj['BasketDiscountModifier'].push(discountObj);
4280
4392
  }
4281
4393
  }));
4282
4394
  }));
@@ -4292,6 +4404,35 @@ class RJMapperBuilderClass {
4292
4404
  //update the product price
4293
4405
  obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
4294
4406
  }
4407
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
4408
+ obj['PromotionSaving'] = [];
4409
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
4410
+ * @param {?} transactionPromo
4411
+ * @return {?}
4412
+ */
4413
+ (transactionPromo) => {
4414
+ /** @type {?} */
4415
+ let promotionObj = {};
4416
+ transactionPromo.itemLineIds.forEach((/**
4417
+ * @param {?} itemLineId
4418
+ * @return {?}
4419
+ */
4420
+ (itemLineId) => {
4421
+ if (itemLineId == element.itemLineId) {
4422
+ promotionObj.ModifierValue = transactionPromo.promotionAmount;
4423
+ promotionObj.ModifierDateTime = this.transactionDocument.createdAt;
4424
+ promotionObj.ModifierDescription = transactionPromo.displayText;
4425
+ promotionObj.XMLSchemaVersion = this.xmlSchemaVersion;
4426
+ promotionObj.PromotionID = transactionPromo.promotionId;
4427
+ promotionObj.PromotionDescription = transactionPromo.displayText;
4428
+ promotionObj.HitNumber = '1';
4429
+ promotionObj.PromotionHitProductQuantity = this.getQuantity(element);
4430
+ promotionObj.PromotionHitQuantity = this.getQuantity(element) * -1;
4431
+ obj['PromotionSaving'].push(promotionObj);
4432
+ }
4433
+ }));
4434
+ }));
4435
+ }
4295
4436
  return obj;
4296
4437
  }
4297
4438
  /**
@@ -4319,8 +4460,7 @@ class RJMapperBuilderClass {
4319
4460
  DateTimeCreated: this.createdAt,
4320
4461
  ExtendedValue: this.removeDecimal(element.price),
4321
4462
  UnitPrice: this.removeDecimal(element.price),
4322
- MMGroupID: this.getAttributes(),
4323
- //todo
4463
+ MMGroupID: this.getCaregories(element),
4324
4464
  Quantity: element.quantity.toFixed(1),
4325
4465
  SalespersonID: this.transactionDocument.userId,
4326
4466
  SalespersonName: this.transactionDocument.userName,
@@ -4329,14 +4469,14 @@ class RJMapperBuilderClass {
4329
4469
  * @return {?}
4330
4470
  */
4331
4471
  (item) => item.itemLineId == element['itemLineId'])).VATCode,
4332
- TaxModifiable: 1,
4472
+ TaxModifiable: "1",
4333
4473
  //todo
4334
4474
  OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
4335
4475
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
4336
- OriginalTaxAmountSet: 1,
4476
+ OriginalTaxAmountSet: "1",
4337
4477
  //todo
4338
4478
  ProductID: element.SKU,
4339
- HandKeyed: 1,
4479
+ HandKeyed: "1",
4340
4480
  //todo
4341
4481
  CustomerDetails: "",
4342
4482
  Perishable: this.getAttributes()
@@ -4383,24 +4523,24 @@ class RJMapperBuilderClass {
4383
4523
  */
4384
4524
  (e) => {
4385
4525
  /** @type {?} */
4386
- var obj1 = {};
4526
+ let discountObj = {};
4387
4527
  e.itemLineIds.forEach((/**
4388
- * @param {?} x
4528
+ * @param {?} itemLineId
4389
4529
  * @return {?}
4390
4530
  */
4391
- (x) => {
4392
- if (x == element.itemLineId) {
4531
+ (itemLineId) => {
4532
+ if (itemLineId == element.itemLineId) {
4393
4533
  /** @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);
4534
+ let discountAmount = this.convertToString(e.discountAmount * -1);
4535
+ discountObj.XMLSchemaVersion = this.xmlSchemaVersion;
4536
+ discountObj.DiscountedValue = -(this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
4537
+ discountObj.BasketDiscountLineNumber = this.getLineNumber(e, discountAmount);
4538
+ obj['BasketDiscountModifier'].push(discountObj);
4399
4539
  }
4400
4540
  }));
4401
4541
  }));
4402
4542
  /** @type {?} */
4403
- var totaltransactionDiscount = 0;
4543
+ let totaltransactionDiscount = 0;
4404
4544
  obj['BasketDiscountModifier'].forEach((/**
4405
4545
  * @param {?} value
4406
4546
  * @return {?}
@@ -4411,8 +4551,71 @@ class RJMapperBuilderClass {
4411
4551
  //update the product price
4412
4552
  obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
4413
4553
  }
4554
+ if (this.transactionDocument.basket.transactionPromotion.length > 0 || this.transactionDocument.basket.linePromotion.length > 0) {
4555
+ obj['DistributedPromotionSaving'] = [];
4556
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
4557
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
4558
+ * @param {?} e
4559
+ * @return {?}
4560
+ */
4561
+ (e) => {
4562
+ /** @type {?} */
4563
+ let promotionObj = {};
4564
+ e.itemLineIds.forEach((/**
4565
+ * @param {?} itemLineId
4566
+ * @return {?}
4567
+ */
4568
+ (itemLineId) => {
4569
+ if (itemLineId == element.itemLineId) {
4570
+ promotionObj.PromotionID = e.promotionId;
4571
+ promotionObj.Hit = '1';
4572
+ promotionObj.Saving = this.getSaving(element.totalLinePrice, e.promotionAmount);
4573
+ promotionObj.ISaving = this.getSaving(element.totalLinePrice, e.promotionAmount);
4574
+ obj['DistributedPromotionSaving'].push(promotionObj);
4575
+ }
4576
+ }));
4577
+ }));
4578
+ }
4579
+ if (this.transactionDocument.basket.linePromotion.length > 0) {
4580
+ this.transactionDocument.basket.linePromotion.forEach((/**
4581
+ * @param {?} linePromotion
4582
+ * @return {?}
4583
+ */
4584
+ (linePromotion) => {
4585
+ /** @type {?} */
4586
+ let promotionObj = {};
4587
+ if (element.itemLineId == linePromotion.itemLineId) {
4588
+ promotionObj.PromotionID = linePromotion.promotionId;
4589
+ promotionObj.Hit = "1";
4590
+ promotionObj.Saving = linePromotion.promotionLinePrice;
4591
+ promotionObj.ISaving = linePromotion.promotionLinePrice;
4592
+ obj['DistributedPromotionSaving'].push(promotionObj);
4593
+ }
4594
+ }));
4595
+ }
4596
+ /** @type {?} */
4597
+ let transactionPromotion = 0;
4598
+ obj['DistributedPromotionSaving'].forEach((/**
4599
+ * @param {?} value
4600
+ * @return {?}
4601
+ */
4602
+ (value) => {
4603
+ transactionPromotion = transactionPromotion + value.Saving;
4604
+ }));
4605
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + transactionPromotion;
4606
+ }
4414
4607
  return obj;
4415
4608
  }
4609
+ /**
4610
+ * @param {?} price
4611
+ * @param {?} promotionAmount
4612
+ * @return {?}
4613
+ */
4614
+ getSaving(price, promotionAmount) {
4615
+ /** @type {?} */
4616
+ let Saving = (price * promotionAmount) / this.transactionDocument.basketSummary.saleTotal;
4617
+ return Saving;
4618
+ }
4416
4619
  /**
4417
4620
  * @param {?} value
4418
4621
  * @param {?} discountAmount
@@ -4509,6 +4712,30 @@ class RJMapperBuilderClass {
4509
4712
  return "";
4510
4713
  }
4511
4714
  }
4715
+ /**
4716
+ * @param {?} element
4717
+ * @return {?}
4718
+ */
4719
+ getCaregories(element) {
4720
+ /** @type {?} */
4721
+ let MMGroupId = " ";
4722
+ if (element.categories && element.categories.length > 0) {
4723
+ /** @type {?} */
4724
+ let categories = element.categories.filter((/**
4725
+ * @param {?} x
4726
+ * @return {?}
4727
+ */
4728
+ (x) => x.parentId != ''));
4729
+ /** @type {?} */
4730
+ let value = categories.filter((/**
4731
+ * @param {?} x
4732
+ * @return {?}
4733
+ */
4734
+ (x) => x.id != x.parentId));
4735
+ MMGroupId = value[0].name;
4736
+ }
4737
+ return MMGroupId;
4738
+ }
4512
4739
  /**
4513
4740
  * @param {?} date
4514
4741
  * @return {?}
@@ -4537,21 +4764,18 @@ class RJMapperBuilderClass {
4537
4764
  */
4538
4765
  getTransactionPromotion(transactionPromotion) {
4539
4766
  if (transactionPromotion && transactionPromotion.length > 0) {
4540
- this.rjObject['BasketDiscount'] = {};
4541
- this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
4542
- this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
4543
- this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
4544
- this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
4545
- this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
4546
- this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
4547
- this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
4548
- this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
4549
- this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
4550
- this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
4551
- this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
4552
- this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
4553
- this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
4554
- this.rjObject['BasketDiscount']['RoundingRule'] = 2;
4767
+ this.rjObject['PromoVoucherItem'] = {};
4768
+ this.rjObject['PromoVoucherItem']['XMLSchemaVersion'] = this.xmlSchemaVersion;
4769
+ this.rjObject['PromoVoucherItem']['LineNumber'] = this.generateLineNumber();
4770
+ this.rjObject['PromoVoucherItem']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
4771
+ this.rjObject['PromoVoucherItem']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
4772
+ this.rjObject['PromoVoucherItem']['Description'] = transactionPromotion[0].promotionInfo;
4773
+ this.rjObject['PromoVoucherItem']['DeviceID'] = this.deviceId;
4774
+ this.rjObject['PromoVoucherItem']['UserID'] = this.transactionDocument.userName;
4775
+ this.rjObject['PromoVoucherItem']['DateTimeCreated'] = this.createdAt;
4776
+ this.rjObject['PromoVoucherItem']['ProductId'] = ""; //todo
4777
+ this.rjObject['PromoVoucherItem']['SerialNumber'] = ""; //todo
4778
+ this.rjObject['PromoVoucherItem']['MMGroupId'] = "";
4555
4779
  }
4556
4780
  }
4557
4781
  /**