@pmcretail/mapper-library 0.0.13 → 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;
@@ -4978,6 +4978,11 @@
4978
4978
  */
4979
4979
  function () {
4980
4980
  var _this = this;
4981
+ /** @type {?} */
4982
+ var transactionDiscount = [];
4983
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount && (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.length > 0) {
4984
+ transactionDiscount = (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount;
4985
+ }
4981
4986
  if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.SALE) {
4982
4987
  (/** @type {?} */ (this)).rjObject['ProductSale'] = [];
4983
4988
  (/** @type {?} */ (this)).rjObject['ModifierItem'] = [];
@@ -5003,7 +5008,7 @@
5003
5008
  }
5004
5009
  }
5005
5010
  /** @type {?} */
5006
- var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null));
5011
+ var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
5007
5012
  (/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
5008
5013
  (/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
5009
5014
  }));
@@ -5023,7 +5028,7 @@
5023
5028
  */
5024
5029
  function (element) {
5025
5030
  /** @type {?} */
5026
- var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
5031
+ var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
5027
5032
  (/** @type {?} */ (_this)).rjObject['ProductReturn'].push(data);
5028
5033
  (/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
5029
5034
  }));
@@ -5039,7 +5044,7 @@
5039
5044
  */
5040
5045
  function (element) {
5041
5046
  /** @type {?} */
5042
- var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
5047
+ var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
5043
5048
  /** @type {?} */
5044
5049
  var obj = {
5045
5050
  "OriginalReceiptSupplied": 0,
@@ -5066,7 +5071,7 @@
5066
5071
  function (element) {
5067
5072
  if (element.refundedQuantity > 0) {
5068
5073
  /** @type {?} */
5069
- var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
5074
+ var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
5070
5075
  /** @type {?} */
5071
5076
  var obj = {
5072
5077
  "OriginalReceiptSupplied": 0,
@@ -5080,7 +5085,7 @@
5080
5085
  }
5081
5086
  else {
5082
5087
  /** @type {?} */
5083
- var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
5088
+ var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
5084
5089
  (/** @type {?} */ (_this)).rjObject['ProductSale'].push(addProduct);
5085
5090
  }
5086
5091
  (/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
@@ -5110,18 +5115,24 @@
5110
5115
  function (element) {
5111
5116
  /** @type {?} */
5112
5117
  var obj = {};
5113
- obj['XMLSchemaVersion'] = "1";
5114
- obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
5115
- obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
5118
+ obj['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5119
+ obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
5120
+ obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
5116
5121
  obj['Description'] = element.reasonDisplayText;
5117
5122
  obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
5118
5123
  obj['ReasonCodeID'] = element.reasonCode;
5119
- obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1); // todo - compare values
5124
+ obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
5120
5125
  obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
5121
5126
  obj['ModifiedLineNumber'] = element.itemLineIds;
5122
5127
  obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
5123
- // obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
5124
- // obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
5128
+ obj['DiscountedValue'] = (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal + (/** @type {?} */ (_this)).transactionDocument.basketSummary.discountTotal;
5129
+ if (element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase()) {
5130
+ obj['DiscountPercentage'] = (/** @type {?} */ (_this)).convertToString((element.discountAmount / (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal).toFixed(1));
5131
+ }
5132
+ if ((/** @type {?} */ (_this)).transactionDocument.type === 'REFUND') {
5133
+ obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
5134
+ obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
5135
+ }
5125
5136
  (/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
5126
5137
  }));
5127
5138
  return (/** @type {?} */ (this));
@@ -5199,51 +5210,94 @@
5199
5210
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
5200
5211
  (/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
5201
5212
  }));
5202
- // TODO: make Trailer object from promotion
5203
- if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5213
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0 || (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5204
5214
  (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
5205
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5206
- * @param {?} element
5207
- * @return {?}
5208
- */
5209
- function (element) {
5210
- console.log('element', element);
5211
- /** @type {?} */
5212
- var obj = {};
5213
- obj['PromotionID'] = element.promotionId;
5214
- obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5215
- obj['PromotionQuantity'] = ""; // todo - not avaialble
5216
- obj['PromotionDescription'] = element.displayText;
5217
- obj['PromotionHit'] = {};
5218
- obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5219
- obj['PromotionHit']['HitNumber'] = ""; // todo;
5220
- obj['PromotionHit']['HitQuantity'] = ""; // todo;
5221
- obj['PromotionHit']['HitSaving'] = ""; // todo;
5222
- obj['PromotionHit']['PromotionTrigger'] = {};
5223
- element.trigger.forEach((/**
5224
- * @param {?} subElement
5215
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5216
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5217
+ * @param {?} element
5225
5218
  * @return {?}
5226
5219
  */
5227
- 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'] = {};
5228
5233
  /** @type {?} */
5229
5234
  var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5230
5235
  * @param {?} item
5231
5236
  * @return {?}
5232
5237
  */
5233
- function (item) { return item.itemLineId == subElement.itemLineId; }));
5238
+ function (item) { return item.itemLineId == element.itemLineId; }));
5234
5239
  obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5235
5240
  obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
5236
5241
  obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5237
- obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5238
- 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));
5239
5244
  obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5240
5245
  * @param {?} item
5241
5246
  * @return {?}
5242
5247
  */
5243
5248
  function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5249
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5244
5250
  }));
5245
- (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5246
- }));
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
+ }
5247
5301
  }
5248
5302
  return (/** @type {?} */ (this));
5249
5303
  };
@@ -5259,64 +5313,136 @@
5259
5313
  */
5260
5314
  function () {
5261
5315
  var _this = this;
5262
- (/** @type {?} */ (this)).rjObject['CashTender'] = [];
5263
5316
  if ((/** @type {?} */ (this)).transactionDocument.paymentDetails && (/** @type {?} */ (this)).transactionDocument.paymentDetails.length > 0) {
5264
5317
  (/** @type {?} */ (this)).transactionDocument.paymentDetails.forEach((/**
5265
5318
  * @param {?} element
5266
5319
  * @return {?}
5267
5320
  */
5268
5321
  function (element) {
5269
- if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5270
- /** @type {?} */
5271
- var obj = {
5272
- XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5273
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5274
- NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5275
- EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5276
- Description: (/** @type {?} */ (_this)).getDescription(element),
5277
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5278
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5279
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5280
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5281
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5282
- TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5283
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5284
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5285
- GiftVoucherSalesAllowed: '',
5286
- //todo
5287
- AllowRechargeableVoucherSales: '',
5288
- //todo
5289
- GiftVoucherID: ''
5290
- };
5291
- (/** @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
+ }
5292
5371
  }
5293
5372
  else {
5294
- /** @type {?} */
5295
- var obj1 = {
5296
- XMLSchemaVersion: "1",
5297
- LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5298
- //todo
5299
- NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5300
- EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5301
- Description: (/** @type {?} */ (_this)).getDescription(element),
5302
- DeviceID: (/** @type {?} */ (_this)).deviceId,
5303
- UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5304
- DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5305
- TenderType: element.externalTenderType ? element.externalTenderType : '',
5306
- TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5307
- TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5308
- CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5309
- CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5310
- IncludeInTransactionTotalCheck: "1",
5311
- AllowRechargeableVoucherSales: "1",
5312
- OpenDrawerAtEnd: "1"
5313
- };
5314
- (/** @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
+ }
5315
5420
  }
5316
5421
  }));
5317
5422
  }
5318
5423
  return (/** @type {?} */ (this));
5319
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
+ };
5320
5446
  /**
5321
5447
  * @return {?}
5322
5448
  */
@@ -5738,14 +5864,17 @@
5738
5864
  /**
5739
5865
  * @param {?} element
5740
5866
  * @param {?} lineDiscount
5867
+ * @param {?} transactionDiscount
5741
5868
  * @return {?}
5742
5869
  */
5743
5870
  RJMapperBuilderClass.prototype.returnProduct = /**
5744
5871
  * @param {?} element
5745
5872
  * @param {?} lineDiscount
5873
+ * @param {?} transactionDiscount
5746
5874
  * @return {?}
5747
5875
  */
5748
- function (element, lineDiscount) {
5876
+ function (element, lineDiscount, transactionDiscount) {
5877
+ var _this = this;
5749
5878
  /** @type {?} */
5750
5879
  var obj = {};
5751
5880
  /** @type {?} */
@@ -5781,7 +5910,7 @@
5781
5910
  obj['DisplayTaxCode'] = ''; // todo
5782
5911
  obj['ProductAttributes'] = ''; //todo - not required
5783
5912
  obj['Perishable'] = this.getAttributes();
5784
- obj['MMGroupID'] = this.getAttributes();
5913
+ obj['MMGroupID'] = this.getCaregories(element);
5785
5914
  obj['CustomerDetails'] = ""; // todo - blank
5786
5915
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5787
5916
  obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
@@ -5820,19 +5949,87 @@
5820
5949
  obj.ExtendedValue = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
5821
5950
  obj.UnitPrice = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
5822
5951
  }
5952
+ if (transactionDiscount) {
5953
+ obj['BasketDiscountModifier'] = [];
5954
+ this.transactionDocument.basket.transactionDiscount.forEach((/**
5955
+ * @param {?} e
5956
+ * @return {?}
5957
+ */
5958
+ function (e) {
5959
+ /** @type {?} */
5960
+ var discountObj = {};
5961
+ e.itemLineIds.forEach((/**
5962
+ * @param {?} x
5963
+ * @return {?}
5964
+ */
5965
+ function (x) {
5966
+ if (x == element.itemLineId) {
5967
+ /** @type {?} */
5968
+ var discountAmount = _this.convertToString(e.discountAmount * -1);
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);
5973
+ }
5974
+ }));
5975
+ }));
5976
+ /** @type {?} */
5977
+ var totaltransactionDiscount = 0;
5978
+ obj['BasketDiscountModifier'].forEach((/**
5979
+ * @param {?} value
5980
+ * @return {?}
5981
+ */
5982
+ function (value) {
5983
+ totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
5984
+ }));
5985
+ //update the product price
5986
+ obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
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
+ }
5823
6017
  return obj;
5824
6018
  };
5825
6019
  /**
5826
6020
  * @param {?} element
5827
6021
  * @param {?} lineDiscount
6022
+ * @param {?} transactionDiscount
5828
6023
  * @return {?}
5829
6024
  */
5830
6025
  RJMapperBuilderClass.prototype.addProduct = /**
5831
6026
  * @param {?} element
5832
6027
  * @param {?} lineDiscount
6028
+ * @param {?} transactionDiscount
5833
6029
  * @return {?}
5834
6030
  */
5835
- function (element, lineDiscount) {
6031
+ function (element, lineDiscount, transactionDiscount) {
6032
+ var _this = this;
5836
6033
  /** @type {?} */
5837
6034
  var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5838
6035
  * @param {?} item
@@ -5851,8 +6048,7 @@
5851
6048
  DateTimeCreated: this.createdAt,
5852
6049
  ExtendedValue: this.removeDecimal(element.price),
5853
6050
  UnitPrice: this.removeDecimal(element.price),
5854
- MMGroupID: this.getAttributes(),
5855
- //todo
6051
+ MMGroupID: this.getCaregories(element),
5856
6052
  Quantity: element.quantity.toFixed(1),
5857
6053
  SalespersonID: this.transactionDocument.userId,
5858
6054
  SalespersonName: this.transactionDocument.userName,
@@ -5861,14 +6057,14 @@
5861
6057
  * @return {?}
5862
6058
  */
5863
6059
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5864
- TaxModifiable: 1,
6060
+ TaxModifiable: "1",
5865
6061
  //todo
5866
6062
  OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5867
6063
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5868
- OriginalTaxAmountSet: 1,
6064
+ OriginalTaxAmountSet: "1",
5869
6065
  //todo
5870
6066
  ProductID: element.SKU,
5871
- HandKeyed: 1,
6067
+ HandKeyed: "1",
5872
6068
  //todo
5873
6069
  CustomerDetails: "",
5874
6070
  Perishable: this.getAttributes()
@@ -5897,7 +6093,7 @@
5897
6093
  obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
5898
6094
  obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
5899
6095
  obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
5900
- obj['PriceOverride'].XMLSchemaVersion = 1;
6096
+ obj['PriceOverride'].XMLSchemaVersion = this.xmlSchemaVersion;
5901
6097
  obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
5902
6098
  obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
5903
6099
  }
@@ -5907,8 +6103,150 @@
5907
6103
  obj['ExtendedValue'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
5908
6104
  obj['UnitPrice'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
5909
6105
  }
6106
+ if (transactionDiscount) {
6107
+ obj['BasketDiscountModifier'] = [];
6108
+ this.transactionDocument.basket.transactionDiscount.forEach((/**
6109
+ * @param {?} e
6110
+ * @return {?}
6111
+ */
6112
+ function (e) {
6113
+ /** @type {?} */
6114
+ var discountObj = {};
6115
+ e.itemLineIds.forEach((/**
6116
+ * @param {?} itemLineId
6117
+ * @return {?}
6118
+ */
6119
+ function (itemLineId) {
6120
+ if (itemLineId == element.itemLineId) {
6121
+ /** @type {?} */
6122
+ var discountAmount = _this.convertToString(e.discountAmount * -1);
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);
6127
+ }
6128
+ }));
6129
+ }));
6130
+ /** @type {?} */
6131
+ var totaltransactionDiscount_1 = 0;
6132
+ obj['BasketDiscountModifier'].forEach((/**
6133
+ * @param {?} value
6134
+ * @return {?}
6135
+ */
6136
+ function (value) {
6137
+ totaltransactionDiscount_1 = totaltransactionDiscount_1 + value.DiscountedValue;
6138
+ }));
6139
+ //update the product price
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;
6194
+ }
5910
6195
  return obj;
5911
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
+ };
6212
+ /**
6213
+ * @param {?} value
6214
+ * @param {?} discountAmount
6215
+ * @return {?}
6216
+ */
6217
+ RJMapperBuilderClass.prototype.getLineNumber = /**
6218
+ * @param {?} value
6219
+ * @param {?} discountAmount
6220
+ * @return {?}
6221
+ */
6222
+ function (value, discountAmount) {
6223
+ /** @type {?} */
6224
+ var lineNumber;
6225
+ for (var i = 0; i < this.rjObject['BasketDiscount'].length; i++) {
6226
+ /** @type {?} */
6227
+ var element = this.rjObject['BasketDiscount'][i];
6228
+ if (value.reasonCode === element.ReasonCodeID && discountAmount === element.NetValue) {
6229
+ lineNumber = element.LineNumber;
6230
+ break;
6231
+ }
6232
+ }
6233
+ return lineNumber;
6234
+ };
6235
+ /**
6236
+ * @param {?} price
6237
+ * @param {?} discountAmount
6238
+ * @return {?}
6239
+ */
6240
+ RJMapperBuilderClass.prototype.getDiscountedValue = /**
6241
+ * @param {?} price
6242
+ * @param {?} discountAmount
6243
+ * @return {?}
6244
+ */
6245
+ function (price, discountAmount) {
6246
+ /** @type {?} */
6247
+ var DiscountedValue = (price * discountAmount) / this.transactionDocument.basketSummary.saleTotal;
6248
+ return DiscountedValue;
6249
+ };
5912
6250
  /**
5913
6251
  * @param {?} element
5914
6252
  * @param {?} VAT
@@ -5940,7 +6278,7 @@
5940
6278
  return value;
5941
6279
  }
5942
6280
  catch (e) {
5943
- console.log(value, ' can not be converted in string', e);
6281
+ console.log(value, 'can not be converted in string', e);
5944
6282
  }
5945
6283
  };
5946
6284
  /**
@@ -5992,6 +6330,34 @@
5992
6330
  return "";
5993
6331
  }
5994
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
+ };
5995
6361
  /**
5996
6362
  * @param {?} date
5997
6363
  * @return {?}
@@ -6028,21 +6394,18 @@
6028
6394
  */
6029
6395
  function (transactionPromotion) {
6030
6396
  if (transactionPromotion && transactionPromotion.length > 0) {
6031
- this.rjObject['BasketDiscount'] = {};
6032
- this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
6033
- this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
6034
- this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6035
- this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6036
- this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
6037
- this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
6038
- this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
6039
- this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
6040
- this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
6041
- this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
6042
- this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
6043
- this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
6044
- this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
6045
- 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'] = "";
6046
6409
  }
6047
6410
  };
6048
6411
  /**