@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.
@@ -4736,7 +4736,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4736
4736
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TerminalNumber = (/** @type {?} */ (this)).terminalNumber;
4737
4737
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TransactionNumber = (/** @type {?} */ (this)).transactionNumber;
4738
4738
  (/** @type {?} */ (this)).rjObject['Header'].TaxMethodID = (/** @type {?} */ (this)).taxMethodId;
4739
- (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp(); //todo
4739
+ (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp();
4740
4740
  (/** @type {?} */ (this)).rjObject['Header'].BasketLanguageID = (/** @type {?} */ (this)).basketLanguageId; //todo
4741
4741
  (/** @type {?} */ (this)).rjObject['Header'].BasketCountryID = (/** @type {?} */ (this)).basketCountryId; //todo
4742
4742
  (/** @type {?} */ (this)).rjObject['Header'].BasketCurrencyID = (/** @type {?} */ (this)).transactionDocument.baseCurrency;
@@ -4990,50 +4990,94 @@ var RJMapperBuilderClass = /** @class */ (function () {
4990
4990
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
4991
4991
  (/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
4992
4992
  }));
4993
- // TODO: make Trailer object from promotion
4994
- if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
4993
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0 || (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
4995
4994
  (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
4996
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
4997
- * @param {?} element
4998
- * @return {?}
4999
- */
5000
- function (element) {
5001
- /** @type {?} */
5002
- var obj = {};
5003
- obj['PromotionID'] = element.promotionId;
5004
- obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5005
- obj['PromotionQuantity'] = ""; // todo - not avaialble
5006
- obj['PromotionDescription'] = element.displayText;
5007
- obj['PromotionHit'] = {};
5008
- obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5009
- obj['PromotionHit']['HitNumber'] = ""; // todo;
5010
- obj['PromotionHit']['HitQuantity'] = ""; // todo;
5011
- obj['PromotionHit']['HitSaving'] = ""; // todo;
5012
- obj['PromotionHit']['PromotionTrigger'] = {};
5013
- element.trigger.forEach((/**
5014
- * @param {?} subElement
4995
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
4996
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
4997
+ * @param {?} element
5015
4998
  * @return {?}
5016
4999
  */
5017
- function (subElement) {
5000
+ function (element) {
5001
+ /** @type {?} */
5002
+ var obj = {};
5003
+ obj['PromotionID'] = element.promotionId;
5004
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5005
+ obj['PromotionQuantity'] = "1";
5006
+ obj['PromotionDescription'] = element.displayText;
5007
+ obj['PromotionHit'] = {};
5008
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5009
+ obj['PromotionHit']['HitNumber'] = "1";
5010
+ obj['PromotionHit']['HitQuantity'] = "1";
5011
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5012
+ obj['PromotionHit']['PromotionTrigger'] = {};
5018
5013
  /** @type {?} */
5019
5014
  var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5020
5015
  * @param {?} item
5021
5016
  * @return {?}
5022
5017
  */
5023
- function (item) { return item.itemLineId == subElement.itemLineId; }));
5018
+ function (item) { return item.itemLineId == element.itemLineId; }));
5024
5019
  obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5025
5020
  obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
5026
5021
  obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5027
- obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5028
- obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5022
+ obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).getNumber(product.SKU);
5023
+ obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(product.quantity.toFixed(1));
5029
5024
  obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5030
5025
  * @param {?} item
5031
5026
  * @return {?}
5032
5027
  */
5033
5028
  function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5029
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5034
5030
  }));
5035
- (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5036
- }));
5031
+ }
5032
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
5033
+ (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.forEach((/**
5034
+ * @param {?} element
5035
+ * @return {?}
5036
+ */
5037
+ function (element) {
5038
+ /** @type {?} */
5039
+ var obj = {};
5040
+ console.log('element');
5041
+ obj['PromotionID'] = element.promotionId;
5042
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5043
+ obj['PromotionQuantity'] = "1";
5044
+ obj['PromotionDescription'] = element.displayText;
5045
+ obj['PromotionHit'] = {};
5046
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5047
+ obj['PromotionHit']['HitNumber'] = "1";
5048
+ obj['PromotionHit']['HitQuantity'] = "1";
5049
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5050
+ obj['PromotionHit']['PromotionTrigger'] = [];
5051
+ (/** @type {?} */ (_this)).transactionDocument.basket.products.forEach((/**
5052
+ * @param {?} product
5053
+ * @return {?}
5054
+ */
5055
+ function (product) {
5056
+ /** @type {?} */
5057
+ var promotionTrigger = {};
5058
+ element.itemLineIds.forEach((/**
5059
+ * @param {?} itemLineId
5060
+ * @return {?}
5061
+ */
5062
+ function (itemLineId) {
5063
+ if (JSON.stringify(itemLineId) === product.itemLineId) {
5064
+ promotionTrigger['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5065
+ promotionTrigger['ProductID'] = product.SKU;
5066
+ promotionTrigger['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5067
+ promotionTrigger['LineNumber'] = (/** @type {?} */ (_this)).getNumber(product.SKU);
5068
+ promotionTrigger['Quantity'] = (/** @type {?} */ (_this)).convertToString(product.quantity);
5069
+ promotionTrigger['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5070
+ * @param {?} item
5071
+ * @return {?}
5072
+ */
5073
+ function (item) { return item.itemLineId == product.itemLineId; })).VATCode;
5074
+ obj['PromotionHit']['PromotionTrigger'].push(promotionTrigger);
5075
+ }
5076
+ }));
5077
+ }));
5078
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5079
+ }));
5080
+ }
5037
5081
  }
5038
5082
  return (/** @type {?} */ (this));
5039
5083
  };
@@ -5049,64 +5093,136 @@ var RJMapperBuilderClass = /** @class */ (function () {
5049
5093
  */
5050
5094
  function () {
5051
5095
  var _this = this;
5052
- (/** @type {?} */ (this)).rjObject['CashTender'] = [];
5053
5096
  if ((/** @type {?} */ (this)).transactionDocument.paymentDetails && (/** @type {?} */ (this)).transactionDocument.paymentDetails.length > 0) {
5054
5097
  (/** @type {?} */ (this)).transactionDocument.paymentDetails.forEach((/**
5055
5098
  * @param {?} element
5056
5099
  * @return {?}
5057
5100
  */
5058
5101
  function (element) {
5059
- if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5060
- /** @type {?} */
5061
- var obj = {
5062
- XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5063
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5064
- NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5065
- EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5066
- Description: (/** @type {?} */ (_this)).getDescription(element),
5067
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5068
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5069
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5070
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5071
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5072
- TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5073
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5074
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5075
- GiftVoucherSalesAllowed: '',
5076
- //todo
5077
- AllowRechargeableVoucherSales: '',
5078
- //todo
5079
- GiftVoucherID: ''
5080
- };
5081
- (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj);
5102
+ if (element.externalTenderKey) {
5103
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey] = [];
5104
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5105
+ /** @type {?} */
5106
+ var obj = {
5107
+ XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5108
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5109
+ NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5110
+ EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5111
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5112
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5113
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5114
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5115
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5116
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5117
+ TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5118
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5119
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5120
+ GiftVoucherSalesAllowed: '',
5121
+ //todo
5122
+ AllowRechargeableVoucherSales: '',
5123
+ //todo
5124
+ GiftVoucherID: ''
5125
+ };
5126
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey].push(obj);
5127
+ }
5128
+ else {
5129
+ /** @type {?} */
5130
+ var obj1 = {
5131
+ XMLSchemaVersion: "1",
5132
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5133
+ //todo
5134
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5135
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5136
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5137
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5138
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5139
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5140
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5141
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5142
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5143
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5144
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5145
+ IncludeInTransactionTotalCheck: "1",
5146
+ AllowRechargeableVoucherSales: "1",
5147
+ OpenDrawerAtEnd: "1"
5148
+ };
5149
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey].push(obj1);
5150
+ }
5082
5151
  }
5083
5152
  else {
5084
- /** @type {?} */
5085
- var obj1 = {
5086
- XMLSchemaVersion: "1",
5087
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5088
- //todo
5089
- NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5090
- EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5091
- Description: (/** @type {?} */ (_this)).getDescription(element),
5092
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5093
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5094
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5095
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5096
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5097
- TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5098
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5099
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5100
- IncludeInTransactionTotalCheck: "1",
5101
- AllowRechargeableVoucherSales: "1",
5102
- OpenDrawerAtEnd: "1"
5103
- };
5104
- (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj1);
5153
+ (/** @type {?} */ (_this)).rjObject['CashTender'] = [];
5154
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5155
+ /** @type {?} */
5156
+ var obj = {
5157
+ XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5158
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5159
+ NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5160
+ EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5161
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5162
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5163
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5164
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5165
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5166
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5167
+ TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5168
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5169
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5170
+ GiftVoucherSalesAllowed: '',
5171
+ //todo
5172
+ AllowRechargeableVoucherSales: '',
5173
+ //todo
5174
+ GiftVoucherID: ''
5175
+ };
5176
+ (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj);
5177
+ }
5178
+ else {
5179
+ /** @type {?} */
5180
+ var obj1 = {
5181
+ XMLSchemaVersion: "1",
5182
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5183
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5184
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5185
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5186
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5187
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5188
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5189
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5190
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5191
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5192
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5193
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5194
+ IncludeInTransactionTotalCheck: "1",
5195
+ AllowRechargeableVoucherSales: "1",
5196
+ OpenDrawerAtEnd: "1"
5197
+ };
5198
+ (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj1);
5199
+ }
5105
5200
  }
5106
5201
  }));
5107
5202
  }
5108
5203
  return (/** @type {?} */ (this));
5109
5204
  };
5205
+ /**
5206
+ * @param {?} productId
5207
+ * @return {?}
5208
+ */
5209
+ RJMapperBuilderClass.prototype.getNumber = /**
5210
+ * @param {?} productId
5211
+ * @return {?}
5212
+ */
5213
+ function (productId) {
5214
+ /** @type {?} */
5215
+ var lineNumber;
5216
+ for (var i = 0; i < this.rjObject['ProductSale'].length; i++) {
5217
+ /** @type {?} */
5218
+ var element = this.rjObject['ProductSale'][i];
5219
+ if (JSON.stringify(productId) === JSON.stringify(element.ProductID)) {
5220
+ lineNumber = element.LineNumber;
5221
+ break;
5222
+ }
5223
+ }
5224
+ return lineNumber;
5225
+ };
5110
5226
  /**
5111
5227
  * @return {?}
5112
5228
  */
@@ -5574,7 +5690,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5574
5690
  obj['DisplayTaxCode'] = ''; // todo
5575
5691
  obj['ProductAttributes'] = ''; //todo - not required
5576
5692
  obj['Perishable'] = this.getAttributes();
5577
- obj['MMGroupID'] = this.getAttributes();
5693
+ obj['MMGroupID'] = this.getCaregories(element);
5578
5694
  obj['CustomerDetails'] = ""; // todo - blank
5579
5695
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5580
5696
  obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
@@ -5621,7 +5737,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5621
5737
  */
5622
5738
  function (e) {
5623
5739
  /** @type {?} */
5624
- var obj1 = {};
5740
+ var discountObj = {};
5625
5741
  e.itemLineIds.forEach((/**
5626
5742
  * @param {?} x
5627
5743
  * @return {?}
@@ -5630,10 +5746,10 @@ var RJMapperBuilderClass = /** @class */ (function () {
5630
5746
  if (x == element.itemLineId) {
5631
5747
  /** @type {?} */
5632
5748
  var discountAmount = _this.convertToString(e.discountAmount * -1);
5633
- obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5634
- obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
5635
- obj1.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
5636
- obj['BasketDiscountModifier'].push(obj1);
5749
+ discountObj.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5750
+ discountObj.XMLSchemaVersion = _this.xmlSchemaVersion;
5751
+ discountObj.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
5752
+ obj['BasketDiscountModifier'].push(discountObj);
5637
5753
  }
5638
5754
  }));
5639
5755
  }));
@@ -5649,6 +5765,35 @@ var RJMapperBuilderClass = /** @class */ (function () {
5649
5765
  //update the product price
5650
5766
  obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
5651
5767
  }
5768
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
5769
+ obj['PromotionSaving'] = [];
5770
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
5771
+ * @param {?} transactionPromo
5772
+ * @return {?}
5773
+ */
5774
+ function (transactionPromo) {
5775
+ /** @type {?} */
5776
+ var promotionObj = {};
5777
+ transactionPromo.itemLineIds.forEach((/**
5778
+ * @param {?} itemLineId
5779
+ * @return {?}
5780
+ */
5781
+ function (itemLineId) {
5782
+ if (itemLineId == element.itemLineId) {
5783
+ promotionObj.ModifierValue = transactionPromo.promotionAmount;
5784
+ promotionObj.ModifierDateTime = _this.transactionDocument.createdAt;
5785
+ promotionObj.ModifierDescription = transactionPromo.displayText;
5786
+ promotionObj.XMLSchemaVersion = _this.xmlSchemaVersion;
5787
+ promotionObj.PromotionID = transactionPromo.promotionId;
5788
+ promotionObj.PromotionDescription = transactionPromo.displayText;
5789
+ promotionObj.HitNumber = '1';
5790
+ promotionObj.PromotionHitProductQuantity = _this.getQuantity(element);
5791
+ promotionObj.PromotionHitQuantity = _this.getQuantity(element) * -1;
5792
+ obj['PromotionSaving'].push(promotionObj);
5793
+ }
5794
+ }));
5795
+ }));
5796
+ }
5652
5797
  return obj;
5653
5798
  };
5654
5799
  /**
@@ -5683,8 +5828,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5683
5828
  DateTimeCreated: this.createdAt,
5684
5829
  ExtendedValue: this.removeDecimal(element.price),
5685
5830
  UnitPrice: this.removeDecimal(element.price),
5686
- MMGroupID: this.getAttributes(),
5687
- //todo
5831
+ MMGroupID: this.getCaregories(element),
5688
5832
  Quantity: element.quantity.toFixed(1),
5689
5833
  SalespersonID: this.transactionDocument.userId,
5690
5834
  SalespersonName: this.transactionDocument.userName,
@@ -5693,14 +5837,14 @@ var RJMapperBuilderClass = /** @class */ (function () {
5693
5837
  * @return {?}
5694
5838
  */
5695
5839
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5696
- TaxModifiable: 1,
5840
+ TaxModifiable: "1",
5697
5841
  //todo
5698
5842
  OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5699
5843
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5700
- OriginalTaxAmountSet: 1,
5844
+ OriginalTaxAmountSet: "1",
5701
5845
  //todo
5702
5846
  ProductID: element.SKU,
5703
- HandKeyed: 1,
5847
+ HandKeyed: "1",
5704
5848
  //todo
5705
5849
  CustomerDetails: "",
5706
5850
  Perishable: this.getAttributes()
@@ -5747,36 +5891,104 @@ var RJMapperBuilderClass = /** @class */ (function () {
5747
5891
  */
5748
5892
  function (e) {
5749
5893
  /** @type {?} */
5750
- var obj1 = {};
5894
+ var discountObj = {};
5751
5895
  e.itemLineIds.forEach((/**
5752
- * @param {?} x
5896
+ * @param {?} itemLineId
5753
5897
  * @return {?}
5754
5898
  */
5755
- function (x) {
5756
- if (x == element.itemLineId) {
5899
+ function (itemLineId) {
5900
+ if (itemLineId == element.itemLineId) {
5757
5901
  /** @type {?} */
5758
5902
  var discountAmount = _this.convertToString(e.discountAmount * -1);
5759
- obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
5760
- obj1.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
5761
- obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5762
- obj['BasketDiscountModifier'].push(obj1);
5903
+ discountObj.XMLSchemaVersion = _this.xmlSchemaVersion;
5904
+ discountObj.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
5905
+ discountObj.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5906
+ obj['BasketDiscountModifier'].push(discountObj);
5763
5907
  }
5764
5908
  }));
5765
5909
  }));
5766
5910
  /** @type {?} */
5767
- var totaltransactionDiscount = 0;
5911
+ var totaltransactionDiscount_1 = 0;
5768
5912
  obj['BasketDiscountModifier'].forEach((/**
5769
5913
  * @param {?} value
5770
5914
  * @return {?}
5771
5915
  */
5772
5916
  function (value) {
5773
- totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
5917
+ totaltransactionDiscount_1 = totaltransactionDiscount_1 + value.DiscountedValue;
5774
5918
  }));
5775
5919
  //update the product price
5776
- obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
5920
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount_1;
5921
+ }
5922
+ if (this.transactionDocument.basket.transactionPromotion.length > 0 || this.transactionDocument.basket.linePromotion.length > 0) {
5923
+ obj['DistributedPromotionSaving'] = [];
5924
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
5925
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
5926
+ * @param {?} e
5927
+ * @return {?}
5928
+ */
5929
+ function (e) {
5930
+ /** @type {?} */
5931
+ var promotionObj = {};
5932
+ e.itemLineIds.forEach((/**
5933
+ * @param {?} itemLineId
5934
+ * @return {?}
5935
+ */
5936
+ function (itemLineId) {
5937
+ if (itemLineId == element.itemLineId) {
5938
+ promotionObj.PromotionID = e.promotionId;
5939
+ promotionObj.Hit = '1';
5940
+ promotionObj.Saving = _this.getSaving(element.totalLinePrice, e.promotionAmount);
5941
+ promotionObj.ISaving = _this.getSaving(element.totalLinePrice, e.promotionAmount);
5942
+ obj['DistributedPromotionSaving'].push(promotionObj);
5943
+ }
5944
+ }));
5945
+ }));
5946
+ }
5947
+ if (this.transactionDocument.basket.linePromotion.length > 0) {
5948
+ this.transactionDocument.basket.linePromotion.forEach((/**
5949
+ * @param {?} linePromotion
5950
+ * @return {?}
5951
+ */
5952
+ function (linePromotion) {
5953
+ /** @type {?} */
5954
+ var promotionObj = {};
5955
+ if (element.itemLineId == linePromotion.itemLineId) {
5956
+ promotionObj.PromotionID = linePromotion.promotionId;
5957
+ promotionObj.Hit = "1";
5958
+ promotionObj.Saving = linePromotion.promotionLinePrice;
5959
+ promotionObj.ISaving = linePromotion.promotionLinePrice;
5960
+ obj['DistributedPromotionSaving'].push(promotionObj);
5961
+ }
5962
+ }));
5963
+ }
5964
+ /** @type {?} */
5965
+ var transactionPromotion_1 = 0;
5966
+ obj['DistributedPromotionSaving'].forEach((/**
5967
+ * @param {?} value
5968
+ * @return {?}
5969
+ */
5970
+ function (value) {
5971
+ transactionPromotion_1 = transactionPromotion_1 + value.Saving;
5972
+ }));
5973
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + transactionPromotion_1;
5777
5974
  }
5778
5975
  return obj;
5779
5976
  };
5977
+ /**
5978
+ * @param {?} price
5979
+ * @param {?} promotionAmount
5980
+ * @return {?}
5981
+ */
5982
+ RJMapperBuilderClass.prototype.getSaving = /**
5983
+ * @param {?} price
5984
+ * @param {?} promotionAmount
5985
+ * @return {?}
5986
+ */
5987
+ function (price, promotionAmount) {
5988
+ /** @type {?} */
5989
+ var Saving = (price * promotionAmount) / this.transactionDocument.basketSummary.saleTotal;
5990
+ return Saving;
5991
+ };
5780
5992
  /**
5781
5993
  * @param {?} value
5782
5994
  * @param {?} discountAmount
@@ -5898,6 +6110,34 @@ var RJMapperBuilderClass = /** @class */ (function () {
5898
6110
  return "";
5899
6111
  }
5900
6112
  };
6113
+ /**
6114
+ * @param {?} element
6115
+ * @return {?}
6116
+ */
6117
+ RJMapperBuilderClass.prototype.getCaregories = /**
6118
+ * @param {?} element
6119
+ * @return {?}
6120
+ */
6121
+ function (element) {
6122
+ /** @type {?} */
6123
+ var MMGroupId = " ";
6124
+ if (element.categories && element.categories.length > 0) {
6125
+ /** @type {?} */
6126
+ var categories = element.categories.filter((/**
6127
+ * @param {?} x
6128
+ * @return {?}
6129
+ */
6130
+ function (x) { return x.parentId != ''; }));
6131
+ /** @type {?} */
6132
+ var value = categories.filter((/**
6133
+ * @param {?} x
6134
+ * @return {?}
6135
+ */
6136
+ function (x) { return x.id != x.parentId; }));
6137
+ MMGroupId = value[0].name;
6138
+ }
6139
+ return MMGroupId;
6140
+ };
5901
6141
  /**
5902
6142
  * @param {?} date
5903
6143
  * @return {?}
@@ -5934,21 +6174,18 @@ var RJMapperBuilderClass = /** @class */ (function () {
5934
6174
  */
5935
6175
  function (transactionPromotion) {
5936
6176
  if (transactionPromotion && transactionPromotion.length > 0) {
5937
- this.rjObject['BasketDiscount'] = {};
5938
- this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
5939
- this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
5940
- this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5941
- this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5942
- this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
5943
- this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
5944
- this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
5945
- this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
5946
- this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
5947
- this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
5948
- this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
5949
- this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
5950
- this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
5951
- this.rjObject['BasketDiscount']['RoundingRule'] = 2;
6177
+ this.rjObject['PromoVoucherItem'] = {};
6178
+ this.rjObject['PromoVoucherItem']['XMLSchemaVersion'] = this.xmlSchemaVersion;
6179
+ this.rjObject['PromoVoucherItem']['LineNumber'] = this.generateLineNumber();
6180
+ this.rjObject['PromoVoucherItem']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6181
+ this.rjObject['PromoVoucherItem']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6182
+ this.rjObject['PromoVoucherItem']['Description'] = transactionPromotion[0].promotionInfo;
6183
+ this.rjObject['PromoVoucherItem']['DeviceID'] = this.deviceId;
6184
+ this.rjObject['PromoVoucherItem']['UserID'] = this.transactionDocument.userName;
6185
+ this.rjObject['PromoVoucherItem']['DateTimeCreated'] = this.createdAt;
6186
+ this.rjObject['PromoVoucherItem']['ProductId'] = ""; //todo
6187
+ this.rjObject['PromoVoucherItem']['SerialNumber'] = ""; //todo
6188
+ this.rjObject['PromoVoucherItem']['MMGroupId'] = "";
5952
6189
  }
5953
6190
  };
5954
6191
  /**