@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.
@@ -4686,8 +4686,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
4686
4686
  }
4687
4687
  this.initilizeItemCount();
4688
4688
  this.setLineNumberForProducts();
4689
- this.createdAt = this.getdate(this.transactionDocument.createdAt);
4690
- this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
4689
+ this.createdAt = this.getDate(this.transactionDocument.createdAt);
4690
+ this.updatedAt = this.getDate(this.transactionDocument.updatedAt);
4691
4691
  }
4692
4692
  /**
4693
4693
  * @template THIS
@@ -4787,6 +4787,12 @@ var RJMapperBuilderClass = /** @class */ (function () {
4787
4787
  (/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
4788
4788
  (/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
4789
4789
  }));
4790
+ /** @type {?} */
4791
+ var transactionPromotion = [];
4792
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion && (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
4793
+ transactionPromotion = (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion;
4794
+ (/** @type {?} */ (this)).getTransactionPromotion(transactionPromotion);
4795
+ }
4790
4796
  }
4791
4797
  else if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.REFUND) {
4792
4798
  (/** @type {?} */ (this)).rjObject['ProductReturn'] = [];
@@ -4874,9 +4880,9 @@ var RJMapperBuilderClass = /** @class */ (function () {
4874
4880
  */
4875
4881
  function () {
4876
4882
  var _this = this;
4877
- (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
4878
4883
  if (!(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount)
4879
4884
  return (/** @type {?} */ (this));
4885
+ (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
4880
4886
  (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.forEach((/**
4881
4887
  * @param {?} element
4882
4888
  * @return {?}
@@ -4892,14 +4898,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4892
4898
  obj['ReasonCodeID'] = element.reasonCode;
4893
4899
  obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
4894
4900
  obj['RoundingRule'] = 2;
4895
- obj['ModifiedLineNumber '] = [];
4896
- element.itemLineIds.forEach((/**
4897
- * @param {?} element
4898
- * @return {?}
4899
- */
4900
- function (element) {
4901
- obj['ModifiedLineNumber'].push(element);
4902
- }));
4901
+ obj['ModifiedLineNumber '] = element.itemLineIds;
4903
4902
  obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
4904
4903
  // obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
4905
4904
  // obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
@@ -4929,7 +4928,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4929
4928
  obj.DeviceID = this.deviceId;
4930
4929
  obj.UserID = this.transactionDocument.userName;
4931
4930
  obj.DateTimeCreated = this.updatedAt;
4932
- obj.AuthorisingUserID = this.userId;
4931
+ obj.AuthorisingUserID = this.transactionDocument.userName;
4933
4932
  obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
4934
4933
  obj.ModifiedLineNumber = lineNo;
4935
4934
  obj.ModifiedIndex = 1;
@@ -5051,12 +5050,6 @@ var RJMapperBuilderClass = /** @class */ (function () {
5051
5050
  * @return {?}
5052
5051
  */
5053
5052
  function (element) {
5054
- /** @type {?} */
5055
- var value = (/** @type {?} */ (_this)).paymentTypes.filter((/**
5056
- * @param {?} x
5057
- * @return {?}
5058
- */
5059
- function (x) { return x.name.toUpperCase() === element.paymentType.toUpperCase(); }));
5060
5053
  if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5061
5054
  /** @type {?} */
5062
5055
  var obj = {
@@ -5064,12 +5057,12 @@ var RJMapperBuilderClass = /** @class */ (function () {
5064
5057
  LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5065
5058
  NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5066
5059
  EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5067
- Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5060
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5068
5061
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5069
5062
  UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5070
5063
  DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5071
- TenderType: value[0].tenderType,
5072
- TenderSubType: value[0].tenderSubType,
5064
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5065
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5073
5066
  TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5074
5067
  CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5075
5068
  CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
@@ -5089,12 +5082,12 @@ var RJMapperBuilderClass = /** @class */ (function () {
5089
5082
  //todo
5090
5083
  NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5091
5084
  EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5092
- Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5085
+ Description: (/** @type {?} */ (_this)).getDescription(element),
5093
5086
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5094
5087
  UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5095
5088
  DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5096
- TenderType: value[0].tenderType,
5097
- TenderSubType: value[0].tenderSubType,
5089
+ TenderType: element.externalTenderType ? element.externalTenderType : '',
5090
+ TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
5098
5091
  TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
5099
5092
  CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5100
5093
  CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
@@ -5161,21 +5154,19 @@ var RJMapperBuilderClass = /** @class */ (function () {
5161
5154
  return this.rjObject;
5162
5155
  };
5163
5156
  /**
5164
- * @param {?} paymentType
5165
5157
  * @param {?} element
5166
5158
  * @return {?}
5167
5159
  */
5168
5160
  RJMapperBuilderClass.prototype.getDescription = /**
5169
- * @param {?} paymentType
5170
5161
  * @param {?} element
5171
5162
  * @return {?}
5172
5163
  */
5173
- function (paymentType, element) {
5174
- if (paymentType.toUpperCase() === 'CARD') {
5164
+ function (element) {
5165
+ if (element.paymentType.toUpperCase() === 'CARD') {
5175
5166
  return element.cardType;
5176
5167
  }
5177
5168
  else {
5178
- return paymentType;
5169
+ return element.paymentType;
5179
5170
  }
5180
5171
  };
5181
5172
  /**
@@ -5194,22 +5185,6 @@ var RJMapperBuilderClass = /** @class */ (function () {
5194
5185
  (/** @type {?} */ (this)).deviceId = id;
5195
5186
  return (/** @type {?} */ (this));
5196
5187
  };
5197
- /**
5198
- * @template THIS
5199
- * @this {THIS}
5200
- * @param {?} id
5201
- * @return {THIS}
5202
- */
5203
- RJMapperBuilderClass.prototype.setUserInfo = /**
5204
- * @template THIS
5205
- * @this {THIS}
5206
- * @param {?} id
5207
- * @return {THIS}
5208
- */
5209
- function (id) {
5210
- (/** @type {?} */ (this)).userId = id;
5211
- return (/** @type {?} */ (this));
5212
- };
5213
5188
  /**
5214
5189
  * @param {?} value
5215
5190
  * @return {?}
@@ -5493,22 +5468,6 @@ var RJMapperBuilderClass = /** @class */ (function () {
5493
5468
  (/** @type {?} */ (this)).branchId = value;
5494
5469
  return (/** @type {?} */ (this));
5495
5470
  };
5496
- /**
5497
- * @template THIS
5498
- * @this {THIS}
5499
- * @param {?} value
5500
- * @return {THIS}
5501
- */
5502
- RJMapperBuilderClass.prototype.setPaymentDetails = /**
5503
- * @template THIS
5504
- * @this {THIS}
5505
- * @param {?} value
5506
- * @return {THIS}
5507
- */
5508
- function (value) {
5509
- (/** @type {?} */ (this)).paymentTypes = value;
5510
- return (/** @type {?} */ (this));
5511
- };
5512
5471
  /**
5513
5472
  * @param {?} date
5514
5473
  * @return {?}
@@ -5587,11 +5546,11 @@ var RJMapperBuilderClass = /** @class */ (function () {
5587
5546
  obj['EffectiveNetValue'] = this.removeDecimal(element['refundedTotal']);
5588
5547
  obj['Description'] = element['description'];
5589
5548
  obj['DeviceID'] = this.transactionDocument['terminalId'];
5590
- obj['UserID'] = this.userId;
5549
+ obj['UserID'] = this.transactionDocument.userName;
5591
5550
  obj['DateTimeCreated'] = this.createdAt;
5592
5551
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5593
5552
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5594
- obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
5553
+ obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
5595
5554
  obj['OriginalTaxAmountSet'] = 1;
5596
5555
  obj['ProductID'] = element['SKU'];
5597
5556
  obj['HandKeyed'] = 1;
@@ -5611,7 +5570,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5611
5570
  obj['MMGroupID'] = this.getAttributes();
5612
5571
  obj['CustomerDetails'] = ""; // todo - blank
5613
5572
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5614
- obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5573
+ obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
5615
5574
  obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5616
5575
  if (lineDiscount) {
5617
5576
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
@@ -5621,7 +5580,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5621
5580
  obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
5622
5581
  obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
5623
5582
  obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
5624
- obj['Discount'].AuthorisingUserID = this.userId;
5583
+ obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
5625
5584
  obj['Discount'].DiscountType = lineDiscount.discountType;
5626
5585
  obj['Discount'].XMLSchemaVersion = 1;
5627
5586
  obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
@@ -5636,7 +5595,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5636
5595
  obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
5637
5596
  obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
5638
5597
  obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
5639
- obj['PriceOverride'].AuthorisingUserID = this.userId;
5598
+ obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
5640
5599
  obj['PriceOverride'].XMLSchemaVersion = 1;
5641
5600
  obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
5642
5601
  obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
@@ -5690,7 +5649,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5690
5649
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5691
5650
  TaxModifiable: 1,
5692
5651
  //todo
5693
- OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5652
+ OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5694
5653
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5695
5654
  OriginalTaxAmountSet: 1,
5696
5655
  //todo
@@ -5708,7 +5667,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5708
5667
  obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
5709
5668
  obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
5710
5669
  obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
5711
- obj['Discount'].AuthorisingUserID = this.userId;
5670
+ obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
5712
5671
  obj['Discount'].DiscountType = lineDiscount.discountType;
5713
5672
  obj['Discount'].XMLSchemaVersion = 1;
5714
5673
  obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
@@ -5723,7 +5682,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5723
5682
  obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
5724
5683
  obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
5725
5684
  obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
5726
- obj['PriceOverride'].AuthorisingUserID = this.userId;
5685
+ obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
5727
5686
  obj['PriceOverride'].XMLSchemaVersion = 1;
5728
5687
  obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
5729
5688
  obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
@@ -5741,7 +5700,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5741
5700
  * @param {?} VAT
5742
5701
  * @return {?}
5743
5702
  */
5744
- RJMapperBuilderClass.prototype.getoriginltax = /**
5703
+ RJMapperBuilderClass.prototype.getOriginalTax = /**
5745
5704
  * @param {?} element
5746
5705
  * @param {?} VAT
5747
5706
  * @return {?}
@@ -5823,7 +5782,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5823
5782
  * @param {?} date
5824
5783
  * @return {?}
5825
5784
  */
5826
- RJMapperBuilderClass.prototype.getdate = /**
5785
+ RJMapperBuilderClass.prototype.getDate = /**
5827
5786
  * @param {?} date
5828
5787
  * @return {?}
5829
5788
  */
@@ -5842,9 +5801,36 @@ var RJMapperBuilderClass = /** @class */ (function () {
5842
5801
  /** @type {?} */
5843
5802
  var newdate = date.substring(0, 19);
5844
5803
  /** @type {?} */
5845
- var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
5804
+ var x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
5846
5805
  return x;
5847
5806
  };
5807
+ /**
5808
+ * @param {?} transactionPromotion
5809
+ * @return {?}
5810
+ */
5811
+ RJMapperBuilderClass.prototype.getTransactionPromotion = /**
5812
+ * @param {?} transactionPromotion
5813
+ * @return {?}
5814
+ */
5815
+ function (transactionPromotion) {
5816
+ if (transactionPromotion && transactionPromotion.length > 0) {
5817
+ this.rjObject['BasketDiscount'] = {};
5818
+ this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
5819
+ this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
5820
+ this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5821
+ this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5822
+ this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
5823
+ this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
5824
+ this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
5825
+ this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
5826
+ this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
5827
+ this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
5828
+ this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
5829
+ this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
5830
+ this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
5831
+ this.rjObject['BasketDiscount']['RoundingRule'] = 2;
5832
+ }
5833
+ };
5848
5834
  return RJMapperBuilderClass;
5849
5835
  }());
5850
5836
  if (false) {
@@ -5853,11 +5839,6 @@ if (false) {
5853
5839
  * @private
5854
5840
  */
5855
5841
  RJMapperBuilderClass.prototype.transactionDocument;
5856
- /**
5857
- * @type {?}
5858
- * @private
5859
- */
5860
- RJMapperBuilderClass.prototype.userId;
5861
5842
  /**
5862
5843
  * @type {?}
5863
5844
  * @private
@@ -5973,11 +5954,6 @@ if (false) {
5973
5954
  * @private
5974
5955
  */
5975
5956
  RJMapperBuilderClass.prototype.rjObject;
5976
- /**
5977
- * @type {?}
5978
- * @private
5979
- */
5980
- RJMapperBuilderClass.prototype.paymentTypes;
5981
5957
  }
5982
5958
 
5983
5959
  /**