@pmcretail/mapper-library 0.0.8 → 0.0.10

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.
@@ -4654,32 +4654,6 @@ var RJMapperBuilderClass = /** @class */ (function () {
4654
4654
  this.itemCount = 0;
4655
4655
  this.largestNumber = 0;
4656
4656
  this.rjObject = {};
4657
- this.paymentTypes = [
4658
- {
4659
- paymentType: 'Card',
4660
- type: 'SEPAY',
4661
- tenderType: '5',
4662
- tenderSubType: '8',
4663
- },
4664
- {
4665
- paymentType: 'Cash',
4666
- type: 'TMC_CASH',
4667
- tenderType: '1',
4668
- tenderSubType: '0'
4669
- },
4670
- {
4671
- paymentType: 'PDQ',
4672
- type: 'Unintegrated',
4673
- tenderType: '2',
4674
- tenderSubType: '8'
4675
- },
4676
- {
4677
- paymentType: 'Gift Card',
4678
- type: 'TMC_GIFTCARD',
4679
- tenderType: '5',
4680
- tenderSubType: '8'
4681
- }
4682
- ];
4683
4657
  if (transactionDoc) {
4684
4658
  this.transactionDocument = transactionDoc;
4685
4659
  }
@@ -4712,6 +4686,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
4712
4686
  }
4713
4687
  this.initilizeItemCount();
4714
4688
  this.setLineNumberForProducts();
4689
+ this.createdAt = this.getdate(this.transactionDocument.createdAt);
4690
+ this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
4715
4691
  }
4716
4692
  /**
4717
4693
  * @template THIS
@@ -4725,9 +4701,9 @@ var RJMapperBuilderClass = /** @class */ (function () {
4725
4701
  */
4726
4702
  function () {
4727
4703
  (/** @type {?} */ (this)).rjObject['Keyword'] = (/** @type {?} */ (this)).generateKeyword();
4728
- (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).transactionDocument.createdAt);
4704
+ (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).createdAt);
4729
4705
  (/** @type {?} */ (this)).rjObject['XMLSchemaVersion'] = '2';
4730
- (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).transactionDocument.updatedAt;
4706
+ (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).updatedAt;
4731
4707
  (/** @type {?} */ (this)).rjObject['MajorVersion'] = (/** @type {?} */ (this)).majorVersion;
4732
4708
  (/** @type {?} */ (this)).rjObject['MinorVersion'] = (/** @type {?} */ (this)).minorVersion;
4733
4709
  (/** @type {?} */ (this)).rjObject['ManifestVersion'] = (/** @type {?} */ (this)).manifestVersion;
@@ -4750,7 +4726,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4750
4726
  function () {
4751
4727
  (/** @type {?} */ (this)).rjObject['Header'] = {};
4752
4728
  (/** @type {?} */ (this)).rjObject['Header'].TimeZoneOffset = (/** @type {?} */ (this)).convertToString((/** @type {?} */ (this)).generateTimezoneoffset((/** @type {?} */ (this)).transactionDocument.createdAt));
4753
- (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).transactionDocument.createdAt;
4729
+ (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).createdAt;
4754
4730
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy = {};
4755
4731
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.DeviceID = (/** @type {?} */ (this)).deviceId;
4756
4732
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.CashierID = (/** @type {?} */ (this)).cashierId;
@@ -4767,7 +4743,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4767
4743
  (/** @type {?} */ (this)).rjObject['Header'].TradingRegionID = (/** @type {?} */ (this)).tradingRegionId;
4768
4744
  (/** @type {?} */ (this)).rjObject['Header'].Eurozone = " "; //unknown
4769
4745
  (/** @type {?} */ (this)).rjObject['Header'].EuroBaseExchangeRate = ""; //unknown
4770
- (/** @type {?} */ (this)).rjObject['Header'].PrintableName = ""; //unknown
4746
+ (/** @type {?} */ (this)).rjObject['Header'].PrintableName = (/** @type {?} */ (this)).transactionDocument.userName; //unknown
4771
4747
  return (/** @type {?} */ (this));
4772
4748
  };
4773
4749
  /**
@@ -4912,7 +4888,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
4912
4888
  obj['NetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
4913
4889
  obj['EffectiveNetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
4914
4890
  obj['Description'] = element.reasonCode;
4915
- obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.basket.userId;
4891
+ obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
4916
4892
  obj['ReasonCodeID'] = element.reasonCode;
4917
4893
  obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
4918
4894
  obj['RoundingRule'] = 2;
@@ -4951,8 +4927,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
4951
4927
  obj.EffectiveNetValue = 0;
4952
4928
  obj.Description = data.percentageDiscountReasonName ? data.percentageDiscountReasonName : data.priceOverrideReasonName;
4953
4929
  obj.DeviceID = this.deviceId;
4954
- obj.UserID = this.userId;
4955
- obj.DateTimeCreated = this.transactionDocument.updatedAt;
4930
+ obj.UserID = this.transactionDocument.userName;
4931
+ obj.DateTimeCreated = this.updatedAt;
4956
4932
  obj.AuthorisingUserID = this.userId;
4957
4933
  obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
4958
4934
  obj.ModifiedLineNumber = lineNo;
@@ -4973,10 +4949,10 @@ var RJMapperBuilderClass = /** @class */ (function () {
4973
4949
  function () {
4974
4950
  var _this = this;
4975
4951
  (/** @type {?} */ (this)).rjObject['Trailer'] = {};
4976
- (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).transactionDocument.updatedAt;
4952
+ (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).updatedAt;
4977
4953
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy = {};
4978
- (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.DeviceID = (/** @type {?} */ (this)).deviceId; //todo
4979
- (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.CashierID = (/** @type {?} */ (this)).cashierId; //todo
4954
+ (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.DeviceID = (/** @type {?} */ (this)).deviceId;
4955
+ (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.CashierID = (/** @type {?} */ (this)).cashierId;
4980
4956
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.StoreID = (/** @type {?} */ (this)).transactionDocument.storeId;
4981
4957
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.BranchID = (/** @type {?} */ (this)).branchId;
4982
4958
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.TerminalNumber = (/** @type {?} */ (this)).transactionDocument.terminalId;
@@ -5080,7 +5056,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5080
5056
  * @param {?} x
5081
5057
  * @return {?}
5082
5058
  */
5083
- function (x) { return x.paymentType.toUpperCase() === element.paymentType.toUpperCase(); }));
5059
+ function (x) { return x.name.toUpperCase() === element.paymentType.toUpperCase(); }));
5084
5060
  if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5085
5061
  /** @type {?} */
5086
5062
  var obj = {
@@ -5088,13 +5064,10 @@ var RJMapperBuilderClass = /** @class */ (function () {
5088
5064
  LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5089
5065
  NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5090
5066
  EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5091
- Description: (/** @type {?} */ (_this)).getDescription(value[0].paymentType, element),
5092
- //todo
5067
+ Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5093
5068
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5094
- //todo
5095
- UserID: (/** @type {?} */ (_this)).userId,
5096
- //todo
5097
- DateTimeCreated: (/** @type {?} */ (_this)).transactionDocument.updatedAt,
5069
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5070
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5098
5071
  TenderType: value[0].tenderType,
5099
5072
  TenderSubType: value[0].tenderSubType,
5100
5073
  TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
@@ -5116,13 +5089,10 @@ var RJMapperBuilderClass = /** @class */ (function () {
5116
5089
  //todo
5117
5090
  NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5118
5091
  EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5119
- Description: (/** @type {?} */ (_this)).getDescription(value[0].paymentType, element),
5120
- //todo
5092
+ Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5121
5093
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5122
- //todo
5123
- UserID: (/** @type {?} */ (_this)).userId,
5124
- //todo
5125
- DateTimeCreated: (/** @type {?} */ (_this)).transactionDocument.updatedAt,
5094
+ UserID: (/** @type {?} */ (_this)).transactionDocument.userName,
5095
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5126
5096
  TenderType: value[0].tenderType,
5127
5097
  TenderSubType: value[0].tenderSubType,
5128
5098
  TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
@@ -5440,7 +5410,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5440
5410
  * @return {THIS}
5441
5411
  */
5442
5412
  function (value) {
5443
- (/** @type {?} */ (this)).cashierId = value;
5413
+ (/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
5444
5414
  return (/** @type {?} */ (this));
5445
5415
  };
5446
5416
  /**
@@ -5523,6 +5493,22 @@ var RJMapperBuilderClass = /** @class */ (function () {
5523
5493
  (/** @type {?} */ (this)).branchId = value;
5524
5494
  return (/** @type {?} */ (this));
5525
5495
  };
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
+ };
5526
5512
  /**
5527
5513
  * @param {?} date
5528
5514
  * @return {?}
@@ -5589,6 +5575,12 @@ var RJMapperBuilderClass = /** @class */ (function () {
5589
5575
  function (element, lineDiscount) {
5590
5576
  /** @type {?} */
5591
5577
  var obj = {};
5578
+ /** @type {?} */
5579
+ var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5580
+ * @param {?} item
5581
+ * @return {?}
5582
+ */
5583
+ function (item) { return item.itemLineId == element['itemLineId']; }));
5592
5584
  obj['XMLSchemaVersion'] = this.xmlSchemaVersion;
5593
5585
  obj['LineNumber'] = element['itemLineId'];
5594
5586
  obj['NetValue'] = this.removeDecimal(element['refundedTotal']);
@@ -5596,7 +5588,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5596
5588
  obj['Description'] = element['description'];
5597
5589
  obj['DeviceID'] = this.transactionDocument['terminalId'];
5598
5590
  obj['UserID'] = this.userId;
5599
- obj['DateTimeCreated'] = this.transactionDocument['createdAt'];
5591
+ obj['DateTimeCreated'] = this.createdAt;
5600
5592
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5601
5593
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5602
5594
  obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
@@ -5619,15 +5611,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
5619
5611
  obj['MMGroupID'] = this.getAttributes();
5620
5612
  obj['CustomerDetails'] = ""; // todo - blank
5621
5613
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5622
- // TODO
5623
- /** @type {?} */
5624
- var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5625
- * @param {?} item
5626
- * @return {?}
5627
- */
5628
- function (item) { return item.itemLineId == element['itemLineId']; }));
5629
- obj['OriginalTaxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal); //todo
5630
- obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal);
5614
+ obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5615
+ obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5631
5616
  if (lineDiscount) {
5632
5617
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
5633
5618
  // line discount
@@ -5689,10 +5674,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
5689
5674
  EffectiveNetValue: this.removeDecimal(element.totalLinePrice),
5690
5675
  Description: element.description,
5691
5676
  DeviceID: this.deviceId,
5692
- //to do
5693
- UserID: this.userId,
5694
- //to do,
5695
- DateTimeCreated: this.transactionDocument.createdAt,
5677
+ UserID: this.transactionDocument.userName,
5678
+ DateTimeCreated: this.createdAt,
5696
5679
  ExtendedValue: this.removeDecimal(element.price),
5697
5680
  UnitPrice: this.removeDecimal(element.price),
5698
5681
  MMGroupID: this.getAttributes(),
@@ -5707,8 +5690,8 @@ var RJMapperBuilderClass = /** @class */ (function () {
5707
5690
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5708
5691
  TaxModifiable: 1,
5709
5692
  //todo
5710
- OriginalTaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
5711
- TaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
5693
+ OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5694
+ TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5712
5695
  OriginalTaxAmountSet: 1,
5713
5696
  //todo
5714
5697
  ProductID: element.SKU,
@@ -5753,6 +5736,23 @@ var RJMapperBuilderClass = /** @class */ (function () {
5753
5736
  }
5754
5737
  return obj;
5755
5738
  };
5739
+ /**
5740
+ * @param {?} element
5741
+ * @param {?} VAT
5742
+ * @return {?}
5743
+ */
5744
+ RJMapperBuilderClass.prototype.getoriginltax = /**
5745
+ * @param {?} element
5746
+ * @param {?} VAT
5747
+ * @return {?}
5748
+ */
5749
+ function (element, VAT) {
5750
+ /** @type {?} */
5751
+ var pricebeforetax = (element.price * 100) / (100 + VAT);
5752
+ /** @type {?} */
5753
+ var originaltax = element.price - pricebeforetax;
5754
+ return originaltax;
5755
+ };
5756
5756
  /**
5757
5757
  * @param {?} value
5758
5758
  * @return {?}
@@ -5819,6 +5819,32 @@ var RJMapperBuilderClass = /** @class */ (function () {
5819
5819
  return "";
5820
5820
  }
5821
5821
  };
5822
+ /**
5823
+ * @param {?} date
5824
+ * @return {?}
5825
+ */
5826
+ RJMapperBuilderClass.prototype.getdate = /**
5827
+ * @param {?} date
5828
+ * @return {?}
5829
+ */
5830
+ function (date) {
5831
+ /** @type {?} */
5832
+ var offset = this.generateTimezoneoffset(date) * -1;
5833
+ /** @type {?} */
5834
+ var offsetHours = Math.abs(Math.floor(offset / 60));
5835
+ /** @type {?} */
5836
+ var offsetMinutes = Math.abs(offset) - offsetHours * 60;
5837
+ /** @type {?} */
5838
+ var offsetSign = '+';
5839
+ if (offset < 0) {
5840
+ offsetSign = '-';
5841
+ }
5842
+ /** @type {?} */
5843
+ var newdate = date.substring(0, 19);
5844
+ /** @type {?} */
5845
+ var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
5846
+ return x;
5847
+ };
5822
5848
  return RJMapperBuilderClass;
5823
5849
  }());
5824
5850
  if (false) {
@@ -5932,6 +5958,16 @@ if (false) {
5932
5958
  * @private
5933
5959
  */
5934
5960
  RJMapperBuilderClass.prototype.branchId;
5961
+ /**
5962
+ * @type {?}
5963
+ * @private
5964
+ */
5965
+ RJMapperBuilderClass.prototype.createdAt;
5966
+ /**
5967
+ * @type {?}
5968
+ * @private
5969
+ */
5970
+ RJMapperBuilderClass.prototype.updatedAt;
5935
5971
  /**
5936
5972
  * @type {?}
5937
5973
  * @private