@pmcretail/mapper-library 0.0.10 → 0.0.12

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.
@@ -4906,8 +4906,8 @@
4906
4906
  }
4907
4907
  this.initilizeItemCount();
4908
4908
  this.setLineNumberForProducts();
4909
- this.createdAt = this.getdate(this.transactionDocument.createdAt);
4910
- this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
4909
+ this.createdAt = this.getDate(this.transactionDocument.createdAt);
4910
+ this.updatedAt = this.getDate(this.transactionDocument.updatedAt);
4911
4911
  }
4912
4912
  /**
4913
4913
  * @template THIS
@@ -5007,6 +5007,12 @@
5007
5007
  (/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
5008
5008
  (/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
5009
5009
  }));
5010
+ /** @type {?} */
5011
+ var transactionPromotion = [];
5012
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion && (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
5013
+ transactionPromotion = (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion;
5014
+ (/** @type {?} */ (this)).getTransactionPromotion(transactionPromotion);
5015
+ }
5010
5016
  }
5011
5017
  else if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.REFUND) {
5012
5018
  (/** @type {?} */ (this)).rjObject['ProductReturn'] = [];
@@ -5094,9 +5100,9 @@
5094
5100
  */
5095
5101
  function () {
5096
5102
  var _this = this;
5097
- (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
5098
5103
  if (!(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount)
5099
5104
  return (/** @type {?} */ (this));
5105
+ (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
5100
5106
  (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.forEach((/**
5101
5107
  * @param {?} element
5102
5108
  * @return {?}
@@ -5112,14 +5118,7 @@
5112
5118
  obj['ReasonCodeID'] = element.reasonCode;
5113
5119
  obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
5114
5120
  obj['RoundingRule'] = 2;
5115
- obj['ModifiedLineNumber '] = [];
5116
- element.itemLineIds.forEach((/**
5117
- * @param {?} element
5118
- * @return {?}
5119
- */
5120
- function (element) {
5121
- obj['ModifiedLineNumber'].push(element);
5122
- }));
5121
+ obj['ModifiedLineNumber '] = element.itemLineIds;
5123
5122
  obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
5124
5123
  // obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
5125
5124
  // obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
@@ -5149,7 +5148,7 @@
5149
5148
  obj.DeviceID = this.deviceId;
5150
5149
  obj.UserID = this.transactionDocument.userName;
5151
5150
  obj.DateTimeCreated = this.updatedAt;
5152
- obj.AuthorisingUserID = this.userId;
5151
+ obj.AuthorisingUserID = this.transactionDocument.userName;
5153
5152
  obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
5154
5153
  obj.ModifiedLineNumber = lineNo;
5155
5154
  obj.ModifiedIndex = 1;
@@ -5271,12 +5270,6 @@
5271
5270
  * @return {?}
5272
5271
  */
5273
5272
  function (element) {
5274
- /** @type {?} */
5275
- var value = (/** @type {?} */ (_this)).paymentTypes.filter((/**
5276
- * @param {?} x
5277
- * @return {?}
5278
- */
5279
- function (x) { return x.name.toUpperCase() === element.paymentType.toUpperCase(); }));
5280
5273
  if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5281
5274
  /** @type {?} */
5282
5275
  var obj = {
@@ -5284,12 +5277,12 @@
5284
5277
  LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5285
5278
  NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5286
5279
  EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5287
- Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5280
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5288
5281
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5289
5282
  UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5290
5283
  DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5291
- TenderType: value[0].tenderType,
5292
- TenderSubType: value[0].tenderSubType,
5284
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5285
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5293
5286
  TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5294
5287
  CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5295
5288
  CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
@@ -5309,12 +5302,12 @@
5309
5302
  //todo
5310
5303
  NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5311
5304
  EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5312
- Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5305
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5313
5306
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5314
5307
  UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5315
5308
  DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5316
- TenderType: value[0].tenderType,
5317
- TenderSubType: value[0].tenderSubType,
5309
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5310
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5318
5311
  TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5319
5312
  CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5320
5313
  CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
@@ -5381,21 +5374,19 @@
5381
5374
  return this.rjObject;
5382
5375
  };
5383
5376
  /**
5384
- * @param {?} paymentType
5385
5377
  * @param {?} element
5386
5378
  * @return {?}
5387
5379
  */
5388
5380
  RJMapperBuilderClass.prototype.getDescription = /**
5389
- * @param {?} paymentType
5390
5381
  * @param {?} element
5391
5382
  * @return {?}
5392
5383
  */
5393
- function (paymentType, element) {
5394
- if (paymentType.toUpperCase() === 'CARD') {
5384
+ function (element) {
5385
+ if (element.paymentType.toUpperCase() === 'CARD') {
5395
5386
  return element.cardType;
5396
5387
  }
5397
5388
  else {
5398
- return paymentType;
5389
+ return element.paymentType;
5399
5390
  }
5400
5391
  };
5401
5392
  /**
@@ -5414,22 +5405,6 @@
5414
5405
  (/** @type {?} */ (this)).deviceId = id;
5415
5406
  return (/** @type {?} */ (this));
5416
5407
  };
5417
- /**
5418
- * @template THIS
5419
- * @this {THIS}
5420
- * @param {?} id
5421
- * @return {THIS}
5422
- */
5423
- RJMapperBuilderClass.prototype.setUserInfo = /**
5424
- * @template THIS
5425
- * @this {THIS}
5426
- * @param {?} id
5427
- * @return {THIS}
5428
- */
5429
- function (id) {
5430
- (/** @type {?} */ (this)).userId = id;
5431
- return (/** @type {?} */ (this));
5432
- };
5433
5408
  /**
5434
5409
  * @param {?} value
5435
5410
  * @return {?}
@@ -5713,22 +5688,6 @@
5713
5688
  (/** @type {?} */ (this)).branchId = value;
5714
5689
  return (/** @type {?} */ (this));
5715
5690
  };
5716
- /**
5717
- * @template THIS
5718
- * @this {THIS}
5719
- * @param {?} value
5720
- * @return {THIS}
5721
- */
5722
- RJMapperBuilderClass.prototype.setPaymentDetails = /**
5723
- * @template THIS
5724
- * @this {THIS}
5725
- * @param {?} value
5726
- * @return {THIS}
5727
- */
5728
- function (value) {
5729
- (/** @type {?} */ (this)).paymentTypes = value;
5730
- return (/** @type {?} */ (this));
5731
- };
5732
5691
  /**
5733
5692
  * @param {?} date
5734
5693
  * @return {?}
@@ -5807,11 +5766,11 @@
5807
5766
  obj['EffectiveNetValue'] = this.removeDecimal(element['refundedTotal']);
5808
5767
  obj['Description'] = element['description'];
5809
5768
  obj['DeviceID'] = this.transactionDocument['terminalId'];
5810
- obj['UserID'] = this.userId;
5769
+ obj['UserID'] = this.transactionDocument.userName;
5811
5770
  obj['DateTimeCreated'] = this.createdAt;
5812
5771
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5813
5772
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5814
- obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
5773
+ obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
5815
5774
  obj['OriginalTaxAmountSet'] = 1;
5816
5775
  obj['ProductID'] = element['SKU'];
5817
5776
  obj['HandKeyed'] = 1;
@@ -5831,7 +5790,7 @@
5831
5790
  obj['MMGroupID'] = this.getAttributes();
5832
5791
  obj['CustomerDetails'] = ""; // todo - blank
5833
5792
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5834
- obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5793
+ obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
5835
5794
  obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5836
5795
  if (lineDiscount) {
5837
5796
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
@@ -5841,7 +5800,7 @@
5841
5800
  obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
5842
5801
  obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
5843
5802
  obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
5844
- obj['Discount'].AuthorisingUserID = this.userId;
5803
+ obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
5845
5804
  obj['Discount'].DiscountType = lineDiscount.discountType;
5846
5805
  obj['Discount'].XMLSchemaVersion = 1;
5847
5806
  obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
@@ -5856,7 +5815,7 @@
5856
5815
  obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
5857
5816
  obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
5858
5817
  obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
5859
- obj['PriceOverride'].AuthorisingUserID = this.userId;
5818
+ obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
5860
5819
  obj['PriceOverride'].XMLSchemaVersion = 1;
5861
5820
  obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
5862
5821
  obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
@@ -5910,7 +5869,7 @@
5910
5869
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5911
5870
  TaxModifiable: 1,
5912
5871
  //todo
5913
- OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5872
+ OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5914
5873
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5915
5874
  OriginalTaxAmountSet: 1,
5916
5875
  //todo
@@ -5928,7 +5887,7 @@
5928
5887
  obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
5929
5888
  obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
5930
5889
  obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
5931
- obj['Discount'].AuthorisingUserID = this.userId;
5890
+ obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
5932
5891
  obj['Discount'].DiscountType = lineDiscount.discountType;
5933
5892
  obj['Discount'].XMLSchemaVersion = 1;
5934
5893
  obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
@@ -5943,7 +5902,7 @@
5943
5902
  obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
5944
5903
  obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
5945
5904
  obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
5946
- obj['PriceOverride'].AuthorisingUserID = this.userId;
5905
+ obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
5947
5906
  obj['PriceOverride'].XMLSchemaVersion = 1;
5948
5907
  obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
5949
5908
  obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
@@ -5961,7 +5920,7 @@
5961
5920
  * @param {?} VAT
5962
5921
  * @return {?}
5963
5922
  */
5964
- RJMapperBuilderClass.prototype.getoriginltax = /**
5923
+ RJMapperBuilderClass.prototype.getOriginalTax = /**
5965
5924
  * @param {?} element
5966
5925
  * @param {?} VAT
5967
5926
  * @return {?}
@@ -6043,7 +6002,7 @@
6043
6002
  * @param {?} date
6044
6003
  * @return {?}
6045
6004
  */
6046
- RJMapperBuilderClass.prototype.getdate = /**
6005
+ RJMapperBuilderClass.prototype.getDate = /**
6047
6006
  * @param {?} date
6048
6007
  * @return {?}
6049
6008
  */
@@ -6062,9 +6021,36 @@
6062
6021
  /** @type {?} */
6063
6022
  var newdate = date.substring(0, 19);
6064
6023
  /** @type {?} */
6065
- var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
6024
+ var x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
6066
6025
  return x;
6067
6026
  };
6027
+ /**
6028
+ * @param {?} transactionPromotion
6029
+ * @return {?}
6030
+ */
6031
+ RJMapperBuilderClass.prototype.getTransactionPromotion = /**
6032
+ * @param {?} transactionPromotion
6033
+ * @return {?}
6034
+ */
6035
+ function (transactionPromotion) {
6036
+ if (transactionPromotion && transactionPromotion.length > 0) {
6037
+ this.rjObject['BasketDiscount'] = {};
6038
+ this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
6039
+ this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
6040
+ this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6041
+ this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6042
+ this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
6043
+ this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
6044
+ this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
6045
+ this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
6046
+ this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
6047
+ this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
6048
+ this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
6049
+ this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
6050
+ this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
6051
+ this.rjObject['BasketDiscount']['RoundingRule'] = 2;
6052
+ }
6053
+ };
6068
6054
  return RJMapperBuilderClass;
6069
6055
  }());
6070
6056
  if (false) {
@@ -6073,11 +6059,6 @@
6073
6059
  * @private
6074
6060
  */
6075
6061
  RJMapperBuilderClass.prototype.transactionDocument;
6076
- /**
6077
- * @type {?}
6078
- * @private
6079
- */
6080
- RJMapperBuilderClass.prototype.userId;
6081
6062
  /**
6082
6063
  * @type {?}
6083
6064
  * @private
@@ -6193,11 +6174,6 @@
6193
6174
  * @private
6194
6175
  */
6195
6176
  RJMapperBuilderClass.prototype.rjObject;
6196
- /**
6197
- * @type {?}
6198
- * @private
6199
- */
6200
- RJMapperBuilderClass.prototype.paymentTypes;
6201
6177
  }
6202
6178
 
6203
6179
  exports.MapperLibraryComponent = MapperLibraryComponent;