@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.
@@ -4956,7 +4956,7 @@
4956
4956
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TerminalNumber = (/** @type {?} */ (this)).terminalNumber;
4957
4957
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.TransactionNumber = (/** @type {?} */ (this)).transactionNumber;
4958
4958
  (/** @type {?} */ (this)).rjObject['Header'].TaxMethodID = (/** @type {?} */ (this)).taxMethodId;
4959
- (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp(); //todo
4959
+ (/** @type {?} */ (this)).rjObject['Header'].DynamicStockLookup = (/** @type {?} */ (this)).generateDynamicStockLookUp();
4960
4960
  (/** @type {?} */ (this)).rjObject['Header'].BasketLanguageID = (/** @type {?} */ (this)).basketLanguageId; //todo
4961
4961
  (/** @type {?} */ (this)).rjObject['Header'].BasketCountryID = (/** @type {?} */ (this)).basketCountryId; //todo
4962
4962
  (/** @type {?} */ (this)).rjObject['Header'].BasketCurrencyID = (/** @type {?} */ (this)).transactionDocument.baseCurrency;
@@ -5210,50 +5210,94 @@
5210
5210
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
5211
5211
  (/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
5212
5212
  }));
5213
- // TODO: make Trailer object from promotion
5214
- if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5213
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0 || (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5215
5214
  (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
5216
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5217
- * @param {?} element
5218
- * @return {?}
5219
- */
5220
- function (element) {
5221
- /** @type {?} */
5222
- var obj = {};
5223
- obj['PromotionID'] = element.promotionId;
5224
- obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5225
- obj['PromotionQuantity'] = ""; // todo - not avaialble
5226
- obj['PromotionDescription'] = element.displayText;
5227
- obj['PromotionHit'] = {};
5228
- obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5229
- obj['PromotionHit']['HitNumber'] = ""; // todo;
5230
- obj['PromotionHit']['HitQuantity'] = ""; // todo;
5231
- obj['PromotionHit']['HitSaving'] = ""; // todo;
5232
- obj['PromotionHit']['PromotionTrigger'] = {};
5233
- element.trigger.forEach((/**
5234
- * @param {?} subElement
5215
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5216
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5217
+ * @param {?} element
5235
5218
  * @return {?}
5236
5219
  */
5237
- function (subElement) {
5220
+ function (element) {
5221
+ /** @type {?} */
5222
+ var obj = {};
5223
+ obj['PromotionID'] = element.promotionId;
5224
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5225
+ obj['PromotionQuantity'] = "1";
5226
+ obj['PromotionDescription'] = element.displayText;
5227
+ obj['PromotionHit'] = {};
5228
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5229
+ obj['PromotionHit']['HitNumber'] = "1";
5230
+ obj['PromotionHit']['HitQuantity'] = "1";
5231
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5232
+ obj['PromotionHit']['PromotionTrigger'] = {};
5238
5233
  /** @type {?} */
5239
5234
  var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5240
5235
  * @param {?} item
5241
5236
  * @return {?}
5242
5237
  */
5243
- function (item) { return item.itemLineId == subElement.itemLineId; }));
5238
+ function (item) { return item.itemLineId == element.itemLineId; }));
5244
5239
  obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5245
5240
  obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
5246
5241
  obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5247
- obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5248
- obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5242
+ obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).getNumber(product.SKU);
5243
+ obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(product.quantity.toFixed(1));
5249
5244
  obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5250
5245
  * @param {?} item
5251
5246
  * @return {?}
5252
5247
  */
5253
5248
  function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5249
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5254
5250
  }));
5255
- (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5256
- }));
5251
+ }
5252
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
5253
+ (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.forEach((/**
5254
+ * @param {?} element
5255
+ * @return {?}
5256
+ */
5257
+ function (element) {
5258
+ /** @type {?} */
5259
+ var obj = {};
5260
+ console.log('element');
5261
+ obj['PromotionID'] = element.promotionId;
5262
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5263
+ obj['PromotionQuantity'] = "1";
5264
+ obj['PromotionDescription'] = element.displayText;
5265
+ obj['PromotionHit'] = {};
5266
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5267
+ obj['PromotionHit']['HitNumber'] = "1";
5268
+ obj['PromotionHit']['HitQuantity'] = "1";
5269
+ obj['PromotionHit']['HitSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5270
+ obj['PromotionHit']['PromotionTrigger'] = [];
5271
+ (/** @type {?} */ (_this)).transactionDocument.basket.products.forEach((/**
5272
+ * @param {?} product
5273
+ * @return {?}
5274
+ */
5275
+ function (product) {
5276
+ /** @type {?} */
5277
+ var promotionTrigger = {};
5278
+ element.itemLineIds.forEach((/**
5279
+ * @param {?} itemLineId
5280
+ * @return {?}
5281
+ */
5282
+ function (itemLineId) {
5283
+ if (JSON.stringify(itemLineId) === product.itemLineId) {
5284
+ promotionTrigger['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5285
+ promotionTrigger['ProductID'] = product.SKU;
5286
+ promotionTrigger['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5287
+ promotionTrigger['LineNumber'] = (/** @type {?} */ (_this)).getNumber(product.SKU);
5288
+ promotionTrigger['Quantity'] = (/** @type {?} */ (_this)).convertToString(product.quantity);
5289
+ promotionTrigger['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5290
+ * @param {?} item
5291
+ * @return {?}
5292
+ */
5293
+ function (item) { return item.itemLineId == product.itemLineId; })).VATCode;
5294
+ obj['PromotionHit']['PromotionTrigger'].push(promotionTrigger);
5295
+ }
5296
+ }));
5297
+ }));
5298
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5299
+ }));
5300
+ }
5257
5301
  }
5258
5302
  return (/** @type {?} */ (this));
5259
5303
  };
@@ -5269,64 +5313,136 @@
5269
5313
  */
5270
5314
  function () {
5271
5315
  var _this = this;
5272
- (/** @type {?} */ (this)).rjObject['CashTender'] = [];
5273
5316
  if ((/** @type {?} */ (this)).transactionDocument.paymentDetails && (/** @type {?} */ (this)).transactionDocument.paymentDetails.length > 0) {
5274
5317
  (/** @type {?} */ (this)).transactionDocument.paymentDetails.forEach((/**
5275
5318
  * @param {?} element
5276
5319
  * @return {?}
5277
5320
  */
5278
5321
  function (element) {
5279
- if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5280
- /** @type {?} */
5281
- var obj = {
5282
- XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5283
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5284
- NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5285
- EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5286
- Description: (/** @type {?} */ (_this)).getDescription(element),
5287
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5288
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5289
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5290
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5291
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5292
- TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5293
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5294
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5295
- GiftVoucherSalesAllowed: '',
5296
- //todo
5297
- AllowRechargeableVoucherSales: '',
5298
- //todo
5299
- GiftVoucherID: ''
5300
- };
5301
- (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj);
5322
+ if (element.externalTenderKey) {
5323
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey] = [];
5324
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5325
+ /** @type {?} */
5326
+ var obj = {
5327
+ XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5328
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5329
+ NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5330
+ EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5331
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5332
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5333
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5334
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5335
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5336
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5337
+ TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5338
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5339
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5340
+ GiftVoucherSalesAllowed: '',
5341
+ //todo
5342
+ AllowRechargeableVoucherSales: '',
5343
+ //todo
5344
+ GiftVoucherID: ''
5345
+ };
5346
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey].push(obj);
5347
+ }
5348
+ else {
5349
+ /** @type {?} */
5350
+ var obj1 = {
5351
+ XMLSchemaVersion: "1",
5352
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5353
+ //todo
5354
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5355
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5356
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5357
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5358
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5359
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5360
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5361
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5362
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5363
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5364
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5365
+ IncludeInTransactionTotalCheck: "1",
5366
+ AllowRechargeableVoucherSales: "1",
5367
+ OpenDrawerAtEnd: "1"
5368
+ };
5369
+ (/** @type {?} */ (_this)).rjObject[element.externalTenderKey].push(obj1);
5370
+ }
5302
5371
  }
5303
5372
  else {
5304
- /** @type {?} */
5305
- var obj1 = {
5306
- XMLSchemaVersion: "1",
5307
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5308
- //todo
5309
- NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5310
- EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5311
- Description: (/** @type {?} */ (_this)).getDescription(element),
5312
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5313
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5314
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5315
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5316
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5317
- TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5318
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5319
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5320
- IncludeInTransactionTotalCheck: "1",
5321
- AllowRechargeableVoucherSales: "1",
5322
- OpenDrawerAtEnd: "1"
5323
- };
5324
- (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj1);
5373
+ (/** @type {?} */ (_this)).rjObject['CashTender'] = [];
5374
+ if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5375
+ /** @type {?} */
5376
+ var obj = {
5377
+ XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5378
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5379
+ NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5380
+ EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5381
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5382
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5383
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5384
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5385
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5386
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5387
+ TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5388
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5389
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5390
+ GiftVoucherSalesAllowed: '',
5391
+ //todo
5392
+ AllowRechargeableVoucherSales: '',
5393
+ //todo
5394
+ GiftVoucherID: ''
5395
+ };
5396
+ (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj);
5397
+ }
5398
+ else {
5399
+ /** @type {?} */
5400
+ var obj1 = {
5401
+ XMLSchemaVersion: "1",
5402
+ LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5403
+ NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5404
+ EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5405
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5406
+ DeviceID: (/** @type {?} */ (_this)).deviceId,
5407
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5408
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5409
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5410
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5411
+ TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5412
+ CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5413
+ CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5414
+ IncludeInTransactionTotalCheck: "1",
5415
+ AllowRechargeableVoucherSales: "1",
5416
+ OpenDrawerAtEnd: "1"
5417
+ };
5418
+ (/** @type {?} */ (_this)).rjObject['CashTender'].push(obj1);
5419
+ }
5325
5420
  }
5326
5421
  }));
5327
5422
  }
5328
5423
  return (/** @type {?} */ (this));
5329
5424
  };
5425
+ /**
5426
+ * @param {?} productId
5427
+ * @return {?}
5428
+ */
5429
+ RJMapperBuilderClass.prototype.getNumber = /**
5430
+ * @param {?} productId
5431
+ * @return {?}
5432
+ */
5433
+ function (productId) {
5434
+ /** @type {?} */
5435
+ var lineNumber;
5436
+ for (var i = 0; i < this.rjObject['ProductSale'].length; i++) {
5437
+ /** @type {?} */
5438
+ var element = this.rjObject['ProductSale'][i];
5439
+ if (JSON.stringify(productId) === JSON.stringify(element.ProductID)) {
5440
+ lineNumber = element.LineNumber;
5441
+ break;
5442
+ }
5443
+ }
5444
+ return lineNumber;
5445
+ };
5330
5446
  /**
5331
5447
  * @return {?}
5332
5448
  */
@@ -5794,7 +5910,7 @@
5794
5910
  obj['DisplayTaxCode'] = ''; // todo
5795
5911
  obj['ProductAttributes'] = ''; //todo - not required
5796
5912
  obj['Perishable'] = this.getAttributes();
5797
- obj['MMGroupID'] = this.getAttributes();
5913
+ obj['MMGroupID'] = this.getCaregories(element);
5798
5914
  obj['CustomerDetails'] = ""; // todo - blank
5799
5915
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5800
5916
  obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
@@ -5841,7 +5957,7 @@
5841
5957
  */
5842
5958
  function (e) {
5843
5959
  /** @type {?} */
5844
- var obj1 = {};
5960
+ var discountObj = {};
5845
5961
  e.itemLineIds.forEach((/**
5846
5962
  * @param {?} x
5847
5963
  * @return {?}
@@ -5850,10 +5966,10 @@
5850
5966
  if (x == element.itemLineId) {
5851
5967
  /** @type {?} */
5852
5968
  var discountAmount = _this.convertToString(e.discountAmount * -1);
5853
- obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5854
- obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
5855
- obj1.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
5856
- obj['BasketDiscountModifier'].push(obj1);
5969
+ discountObj.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5970
+ discountObj.XMLSchemaVersion = _this.xmlSchemaVersion;
5971
+ discountObj.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
5972
+ obj['BasketDiscountModifier'].push(discountObj);
5857
5973
  }
5858
5974
  }));
5859
5975
  }));
@@ -5869,6 +5985,35 @@
5869
5985
  //update the product price
5870
5986
  obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
5871
5987
  }
5988
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
5989
+ obj['PromotionSaving'] = [];
5990
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
5991
+ * @param {?} transactionPromo
5992
+ * @return {?}
5993
+ */
5994
+ function (transactionPromo) {
5995
+ /** @type {?} */
5996
+ var promotionObj = {};
5997
+ transactionPromo.itemLineIds.forEach((/**
5998
+ * @param {?} itemLineId
5999
+ * @return {?}
6000
+ */
6001
+ function (itemLineId) {
6002
+ if (itemLineId == element.itemLineId) {
6003
+ promotionObj.ModifierValue = transactionPromo.promotionAmount;
6004
+ promotionObj.ModifierDateTime = _this.transactionDocument.createdAt;
6005
+ promotionObj.ModifierDescription = transactionPromo.displayText;
6006
+ promotionObj.XMLSchemaVersion = _this.xmlSchemaVersion;
6007
+ promotionObj.PromotionID = transactionPromo.promotionId;
6008
+ promotionObj.PromotionDescription = transactionPromo.displayText;
6009
+ promotionObj.HitNumber = '1';
6010
+ promotionObj.PromotionHitProductQuantity = _this.getQuantity(element);
6011
+ promotionObj.PromotionHitQuantity = _this.getQuantity(element) * -1;
6012
+ obj['PromotionSaving'].push(promotionObj);
6013
+ }
6014
+ }));
6015
+ }));
6016
+ }
5872
6017
  return obj;
5873
6018
  };
5874
6019
  /**
@@ -5903,8 +6048,7 @@
5903
6048
  DateTimeCreated: this.createdAt,
5904
6049
  ExtendedValue: this.removeDecimal(element.price),
5905
6050
  UnitPrice: this.removeDecimal(element.price),
5906
- MMGroupID: this.getAttributes(),
5907
- //todo
6051
+ MMGroupID: this.getCaregories(element),
5908
6052
  Quantity: element.quantity.toFixed(1),
5909
6053
  SalespersonID: this.transactionDocument.userId,
5910
6054
  SalespersonName: this.transactionDocument.userName,
@@ -5913,14 +6057,14 @@
5913
6057
  * @return {?}
5914
6058
  */
5915
6059
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5916
- TaxModifiable: 1,
6060
+ TaxModifiable: "1",
5917
6061
  //todo
5918
6062
  OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5919
6063
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5920
- OriginalTaxAmountSet: 1,
6064
+ OriginalTaxAmountSet: "1",
5921
6065
  //todo
5922
6066
  ProductID: element.SKU,
5923
- HandKeyed: 1,
6067
+ HandKeyed: "1",
5924
6068
  //todo
5925
6069
  CustomerDetails: "",
5926
6070
  Perishable: this.getAttributes()
@@ -5967,36 +6111,104 @@
5967
6111
  */
5968
6112
  function (e) {
5969
6113
  /** @type {?} */
5970
- var obj1 = {};
6114
+ var discountObj = {};
5971
6115
  e.itemLineIds.forEach((/**
5972
- * @param {?} x
6116
+ * @param {?} itemLineId
5973
6117
  * @return {?}
5974
6118
  */
5975
- function (x) {
5976
- if (x == element.itemLineId) {
6119
+ function (itemLineId) {
6120
+ if (itemLineId == element.itemLineId) {
5977
6121
  /** @type {?} */
5978
6122
  var discountAmount = _this.convertToString(e.discountAmount * -1);
5979
- obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
5980
- obj1.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
5981
- obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
5982
- obj['BasketDiscountModifier'].push(obj1);
6123
+ discountObj.XMLSchemaVersion = _this.xmlSchemaVersion;
6124
+ discountObj.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
6125
+ discountObj.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
6126
+ obj['BasketDiscountModifier'].push(discountObj);
5983
6127
  }
5984
6128
  }));
5985
6129
  }));
5986
6130
  /** @type {?} */
5987
- var totaltransactionDiscount = 0;
6131
+ var totaltransactionDiscount_1 = 0;
5988
6132
  obj['BasketDiscountModifier'].forEach((/**
5989
6133
  * @param {?} value
5990
6134
  * @return {?}
5991
6135
  */
5992
6136
  function (value) {
5993
- totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
6137
+ totaltransactionDiscount_1 = totaltransactionDiscount_1 + value.DiscountedValue;
5994
6138
  }));
5995
6139
  //update the product price
5996
- obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
6140
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount_1;
6141
+ }
6142
+ if (this.transactionDocument.basket.transactionPromotion.length > 0 || this.transactionDocument.basket.linePromotion.length > 0) {
6143
+ obj['DistributedPromotionSaving'] = [];
6144
+ if (this.transactionDocument.basket.transactionPromotion.length > 0) {
6145
+ this.transactionDocument.basket.transactionPromotion.forEach((/**
6146
+ * @param {?} e
6147
+ * @return {?}
6148
+ */
6149
+ function (e) {
6150
+ /** @type {?} */
6151
+ var promotionObj = {};
6152
+ e.itemLineIds.forEach((/**
6153
+ * @param {?} itemLineId
6154
+ * @return {?}
6155
+ */
6156
+ function (itemLineId) {
6157
+ if (itemLineId == element.itemLineId) {
6158
+ promotionObj.PromotionID = e.promotionId;
6159
+ promotionObj.Hit = '1';
6160
+ promotionObj.Saving = _this.getSaving(element.totalLinePrice, e.promotionAmount);
6161
+ promotionObj.ISaving = _this.getSaving(element.totalLinePrice, e.promotionAmount);
6162
+ obj['DistributedPromotionSaving'].push(promotionObj);
6163
+ }
6164
+ }));
6165
+ }));
6166
+ }
6167
+ if (this.transactionDocument.basket.linePromotion.length > 0) {
6168
+ this.transactionDocument.basket.linePromotion.forEach((/**
6169
+ * @param {?} linePromotion
6170
+ * @return {?}
6171
+ */
6172
+ function (linePromotion) {
6173
+ /** @type {?} */
6174
+ var promotionObj = {};
6175
+ if (element.itemLineId == linePromotion.itemLineId) {
6176
+ promotionObj.PromotionID = linePromotion.promotionId;
6177
+ promotionObj.Hit = "1";
6178
+ promotionObj.Saving = linePromotion.promotionLinePrice;
6179
+ promotionObj.ISaving = linePromotion.promotionLinePrice;
6180
+ obj['DistributedPromotionSaving'].push(promotionObj);
6181
+ }
6182
+ }));
6183
+ }
6184
+ /** @type {?} */
6185
+ var transactionPromotion_1 = 0;
6186
+ obj['DistributedPromotionSaving'].forEach((/**
6187
+ * @param {?} value
6188
+ * @return {?}
6189
+ */
6190
+ function (value) {
6191
+ transactionPromotion_1 = transactionPromotion_1 + value.Saving;
6192
+ }));
6193
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + transactionPromotion_1;
5997
6194
  }
5998
6195
  return obj;
5999
6196
  };
6197
+ /**
6198
+ * @param {?} price
6199
+ * @param {?} promotionAmount
6200
+ * @return {?}
6201
+ */
6202
+ RJMapperBuilderClass.prototype.getSaving = /**
6203
+ * @param {?} price
6204
+ * @param {?} promotionAmount
6205
+ * @return {?}
6206
+ */
6207
+ function (price, promotionAmount) {
6208
+ /** @type {?} */
6209
+ var Saving = (price * promotionAmount) / this.transactionDocument.basketSummary.saleTotal;
6210
+ return Saving;
6211
+ };
6000
6212
  /**
6001
6213
  * @param {?} value
6002
6214
  * @param {?} discountAmount
@@ -6118,6 +6330,34 @@
6118
6330
  return "";
6119
6331
  }
6120
6332
  };
6333
+ /**
6334
+ * @param {?} element
6335
+ * @return {?}
6336
+ */
6337
+ RJMapperBuilderClass.prototype.getCaregories = /**
6338
+ * @param {?} element
6339
+ * @return {?}
6340
+ */
6341
+ function (element) {
6342
+ /** @type {?} */
6343
+ var MMGroupId = " ";
6344
+ if (element.categories && element.categories.length > 0) {
6345
+ /** @type {?} */
6346
+ var categories = element.categories.filter((/**
6347
+ * @param {?} x
6348
+ * @return {?}
6349
+ */
6350
+ function (x) { return x.parentId != ''; }));
6351
+ /** @type {?} */
6352
+ var value = categories.filter((/**
6353
+ * @param {?} x
6354
+ * @return {?}
6355
+ */
6356
+ function (x) { return x.id != x.parentId; }));
6357
+ MMGroupId = value[0].name;
6358
+ }
6359
+ return MMGroupId;
6360
+ };
6121
6361
  /**
6122
6362
  * @param {?} date
6123
6363
  * @return {?}
@@ -6154,21 +6394,18 @@
6154
6394
  */
6155
6395
  function (transactionPromotion) {
6156
6396
  if (transactionPromotion && transactionPromotion.length > 0) {
6157
- this.rjObject['BasketDiscount'] = {};
6158
- this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
6159
- this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
6160
- this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6161
- this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6162
- this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
6163
- this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
6164
- this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
6165
- this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
6166
- this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
6167
- this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
6168
- this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
6169
- this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
6170
- this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
6171
- this.rjObject['BasketDiscount']['RoundingRule'] = 2;
6397
+ this.rjObject['PromoVoucherItem'] = {};
6398
+ this.rjObject['PromoVoucherItem']['XMLSchemaVersion'] = this.xmlSchemaVersion;
6399
+ this.rjObject['PromoVoucherItem']['LineNumber'] = this.generateLineNumber();
6400
+ this.rjObject['PromoVoucherItem']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6401
+ this.rjObject['PromoVoucherItem']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6402
+ this.rjObject['PromoVoucherItem']['Description'] = transactionPromotion[0].promotionInfo;
6403
+ this.rjObject['PromoVoucherItem']['DeviceID'] = this.deviceId;
6404
+ this.rjObject['PromoVoucherItem']['UserID'] = this.transactionDocument.userName;
6405
+ this.rjObject['PromoVoucherItem']['DateTimeCreated'] = this.createdAt;
6406
+ this.rjObject['PromoVoucherItem']['ProductId'] = ""; //todo
6407
+ this.rjObject['PromoVoucherItem']['SerialNumber'] = ""; //todo
6408
+ this.rjObject['PromoVoucherItem']['MMGroupId'] = "";
6172
6409
  }
6173
6410
  };
6174
6411
  /**