@pmcretail/mapper-library 0.0.8 → 0.0.9

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.
@@ -4874,32 +4874,6 @@
4874
4874
  this.itemCount = 0;
4875
4875
  this.largestNumber = 0;
4876
4876
  this.rjObject = {};
4877
- this.paymentTypes = [
4878
- {
4879
- paymentType: 'Card',
4880
- type: 'SEPAY',
4881
- tenderType: '5',
4882
- tenderSubType: '8',
4883
- },
4884
- {
4885
- paymentType: 'Cash',
4886
- type: 'TMC_CASH',
4887
- tenderType: '1',
4888
- tenderSubType: '0'
4889
- },
4890
- {
4891
- paymentType: 'PDQ',
4892
- type: 'Unintegrated',
4893
- tenderType: '2',
4894
- tenderSubType: '8'
4895
- },
4896
- {
4897
- paymentType: 'Gift Card',
4898
- type: 'TMC_GIFTCARD',
4899
- tenderType: '5',
4900
- tenderSubType: '8'
4901
- }
4902
- ];
4903
4877
  if (transactionDoc) {
4904
4878
  this.transactionDocument = transactionDoc;
4905
4879
  }
@@ -4932,6 +4906,8 @@
4932
4906
  }
4933
4907
  this.initilizeItemCount();
4934
4908
  this.setLineNumberForProducts();
4909
+ this.createdAt = this.getdate(this.transactionDocument.createdAt);
4910
+ this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
4935
4911
  }
4936
4912
  /**
4937
4913
  * @template THIS
@@ -4945,9 +4921,9 @@
4945
4921
  */
4946
4922
  function () {
4947
4923
  (/** @type {?} */ (this)).rjObject['Keyword'] = (/** @type {?} */ (this)).generateKeyword();
4948
- (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).transactionDocument.createdAt);
4924
+ (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).createdAt);
4949
4925
  (/** @type {?} */ (this)).rjObject['XMLSchemaVersion'] = '2';
4950
- (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).transactionDocument.updatedAt;
4926
+ (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).updatedAt;
4951
4927
  (/** @type {?} */ (this)).rjObject['MajorVersion'] = (/** @type {?} */ (this)).majorVersion;
4952
4928
  (/** @type {?} */ (this)).rjObject['MinorVersion'] = (/** @type {?} */ (this)).minorVersion;
4953
4929
  (/** @type {?} */ (this)).rjObject['ManifestVersion'] = (/** @type {?} */ (this)).manifestVersion;
@@ -4970,7 +4946,7 @@
4970
4946
  function () {
4971
4947
  (/** @type {?} */ (this)).rjObject['Header'] = {};
4972
4948
  (/** @type {?} */ (this)).rjObject['Header'].TimeZoneOffset = (/** @type {?} */ (this)).convertToString((/** @type {?} */ (this)).generateTimezoneoffset((/** @type {?} */ (this)).transactionDocument.createdAt));
4973
- (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).transactionDocument.createdAt;
4949
+ (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).createdAt;
4974
4950
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy = {};
4975
4951
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.DeviceID = (/** @type {?} */ (this)).deviceId;
4976
4952
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.CashierID = (/** @type {?} */ (this)).cashierId;
@@ -5172,7 +5148,7 @@
5172
5148
  obj.Description = data.percentageDiscountReasonName ? data.percentageDiscountReasonName : data.priceOverrideReasonName;
5173
5149
  obj.DeviceID = this.deviceId;
5174
5150
  obj.UserID = this.userId;
5175
- obj.DateTimeCreated = this.transactionDocument.updatedAt;
5151
+ obj.DateTimeCreated = this.updatedAt;
5176
5152
  obj.AuthorisingUserID = this.userId;
5177
5153
  obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
5178
5154
  obj.ModifiedLineNumber = lineNo;
@@ -5193,7 +5169,7 @@
5193
5169
  function () {
5194
5170
  var _this = this;
5195
5171
  (/** @type {?} */ (this)).rjObject['Trailer'] = {};
5196
- (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).transactionDocument.updatedAt;
5172
+ (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).updatedAt;
5197
5173
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy = {};
5198
5174
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.DeviceID = (/** @type {?} */ (this)).deviceId; //todo
5199
5175
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.CashierID = (/** @type {?} */ (this)).cashierId; //todo
@@ -5300,24 +5276,23 @@
5300
5276
  * @param {?} x
5301
5277
  * @return {?}
5302
5278
  */
5303
- function (x) { return x.paymentType.toUpperCase() === element.paymentType.toUpperCase(); }));
5279
+ function (x) { return x.name.toUpperCase() === element.paymentType.toUpperCase(); }));
5304
5280
  if (element.paymentType.toUpperCase() === 'GIFT CARD') {
5305
5281
  /** @type {?} */
5306
5282
  var obj = {
5307
5283
  XMLSchemaVersion: (/** @type {?} */ (_this)).xmlSchemaVersion,
5308
5284
  LineNumber: (/** @type {?} */ (_this)).generateLineNumber(),
5309
- NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5310
- EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5311
- Description: (/** @type {?} */ (_this)).getDescription(value[0].paymentType, element),
5312
- //todo
5285
+ NetValue: (/** @type {?} */ (_this)).convertToString(-1 * (Math.round(element.amount))),
5286
+ EffectiveNetValue: (/** @type {?} */ (_this)).convertToString(-1 * (Math.round(element.amount))),
5287
+ Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5313
5288
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5314
5289
  //todo
5315
5290
  UserID: (/** @type {?} */ (_this)).userId,
5316
5291
  //todo
5317
- DateTimeCreated: (/** @type {?} */ (_this)).transactionDocument.updatedAt,
5292
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5318
5293
  TenderType: value[0].tenderType,
5319
5294
  TenderSubType: value[0].tenderSubType,
5320
- TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (/** @type {?} */ (_this)).removeDecimal((Math.round(element.amount)))),
5295
+ TenderAmount: (/** @type {?} */ (_this)).convertToString(-1 * (Math.round(element.amount))),
5321
5296
  CurrencyID: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5322
5297
  CurrencyDescription: (/** @type {?} */ (_this)).transactionDocument.baseCurrency,
5323
5298
  GiftVoucherSalesAllowed: '',
@@ -5336,13 +5311,12 @@
5336
5311
  //todo
5337
5312
  NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5338
5313
  EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
5339
- Description: (/** @type {?} */ (_this)).getDescription(value[0].paymentType, element),
5340
- //todo
5314
+ Description: (/** @type {?} */ (_this)).getDescription(value[0].name, element),
5341
5315
  DeviceID: (/** @type {?} */ (_this)).deviceId,
5342
5316
  //todo
5343
5317
  UserID: (/** @type {?} */ (_this)).userId,
5344
5318
  //todo
5345
- DateTimeCreated: (/** @type {?} */ (_this)).transactionDocument.updatedAt,
5319
+ DateTimeCreated: (/** @type {?} */ (_this)).updatedAt,
5346
5320
  TenderType: value[0].tenderType,
5347
5321
  TenderSubType: value[0].tenderSubType,
5348
5322
  TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
@@ -5743,6 +5717,22 @@
5743
5717
  (/** @type {?} */ (this)).branchId = value;
5744
5718
  return (/** @type {?} */ (this));
5745
5719
  };
5720
+ /**
5721
+ * @template THIS
5722
+ * @this {THIS}
5723
+ * @param {?} value
5724
+ * @return {THIS}
5725
+ */
5726
+ RJMapperBuilderClass.prototype.setPaymentDetails = /**
5727
+ * @template THIS
5728
+ * @this {THIS}
5729
+ * @param {?} value
5730
+ * @return {THIS}
5731
+ */
5732
+ function (value) {
5733
+ (/** @type {?} */ (this)).paymentTypes = value;
5734
+ return (/** @type {?} */ (this));
5735
+ };
5746
5736
  /**
5747
5737
  * @param {?} date
5748
5738
  * @return {?}
@@ -5809,6 +5799,12 @@
5809
5799
  function (element, lineDiscount) {
5810
5800
  /** @type {?} */
5811
5801
  var obj = {};
5802
+ /** @type {?} */
5803
+ var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5804
+ * @param {?} item
5805
+ * @return {?}
5806
+ */
5807
+ function (item) { return item.itemLineId == element['itemLineId']; }));
5812
5808
  obj['XMLSchemaVersion'] = this.xmlSchemaVersion;
5813
5809
  obj['LineNumber'] = element['itemLineId'];
5814
5810
  obj['NetValue'] = this.removeDecimal(element['refundedTotal']);
@@ -5816,7 +5812,7 @@
5816
5812
  obj['Description'] = element['description'];
5817
5813
  obj['DeviceID'] = this.transactionDocument['terminalId'];
5818
5814
  obj['UserID'] = this.userId;
5819
- obj['DateTimeCreated'] = this.transactionDocument['createdAt'];
5815
+ obj['DateTimeCreated'] = this.createdAt;
5820
5816
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5821
5817
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5822
5818
  obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
@@ -5839,15 +5835,8 @@
5839
5835
  obj['MMGroupID'] = this.getAttributes();
5840
5836
  obj['CustomerDetails'] = ""; // todo - blank
5841
5837
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5842
- // TODO
5843
- /** @type {?} */
5844
- var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5845
- * @param {?} item
5846
- * @return {?}
5847
- */
5848
- function (item) { return item.itemLineId == element['itemLineId']; }));
5849
- obj['OriginalTaxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal); //todo
5850
- obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal);
5838
+ obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5839
+ obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5851
5840
  if (lineDiscount) {
5852
5841
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
5853
5842
  // line discount
@@ -5912,7 +5901,7 @@
5912
5901
  //to do
5913
5902
  UserID: this.userId,
5914
5903
  //to do,
5915
- DateTimeCreated: this.transactionDocument.createdAt,
5904
+ DateTimeCreated: this.createdAt,
5916
5905
  ExtendedValue: this.removeDecimal(element.price),
5917
5906
  UnitPrice: this.removeDecimal(element.price),
5918
5907
  MMGroupID: this.getAttributes(),
@@ -5927,8 +5916,8 @@
5927
5916
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5928
5917
  TaxModifiable: 1,
5929
5918
  //todo
5930
- OriginalTaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
5931
- TaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
5919
+ OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5920
+ TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5932
5921
  OriginalTaxAmountSet: 1,
5933
5922
  //todo
5934
5923
  ProductID: element.SKU,
@@ -5973,6 +5962,23 @@
5973
5962
  }
5974
5963
  return obj;
5975
5964
  };
5965
+ /**
5966
+ * @param {?} element
5967
+ * @param {?} VAT
5968
+ * @return {?}
5969
+ */
5970
+ RJMapperBuilderClass.prototype.getoriginltax = /**
5971
+ * @param {?} element
5972
+ * @param {?} VAT
5973
+ * @return {?}
5974
+ */
5975
+ function (element, VAT) {
5976
+ /** @type {?} */
5977
+ var pricebeforetax = (element.price * 100) / (100 + VAT);
5978
+ /** @type {?} */
5979
+ var originaltax = element.price - pricebeforetax;
5980
+ return originaltax;
5981
+ };
5976
5982
  /**
5977
5983
  * @param {?} value
5978
5984
  * @return {?}
@@ -6039,6 +6045,32 @@
6039
6045
  return "";
6040
6046
  }
6041
6047
  };
6048
+ /**
6049
+ * @param {?} date
6050
+ * @return {?}
6051
+ */
6052
+ RJMapperBuilderClass.prototype.getdate = /**
6053
+ * @param {?} date
6054
+ * @return {?}
6055
+ */
6056
+ function (date) {
6057
+ /** @type {?} */
6058
+ var offset = this.generateTimezoneoffset(date) * -1;
6059
+ /** @type {?} */
6060
+ var offsetHours = Math.abs(Math.floor(offset / 60));
6061
+ /** @type {?} */
6062
+ var offsetMinutes = Math.abs(offset) - offsetHours * 60;
6063
+ /** @type {?} */
6064
+ var offsetSign = '+';
6065
+ if (offset < 0) {
6066
+ offsetSign = '-';
6067
+ }
6068
+ /** @type {?} */
6069
+ var newdate = date.substring(0, 19);
6070
+ /** @type {?} */
6071
+ var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
6072
+ return x;
6073
+ };
6042
6074
  return RJMapperBuilderClass;
6043
6075
  }());
6044
6076
  if (false) {
@@ -6152,6 +6184,16 @@
6152
6184
  * @private
6153
6185
  */
6154
6186
  RJMapperBuilderClass.prototype.branchId;
6187
+ /**
6188
+ * @type {?}
6189
+ * @private
6190
+ */
6191
+ RJMapperBuilderClass.prototype.createdAt;
6192
+ /**
6193
+ * @type {?}
6194
+ * @private
6195
+ */
6196
+ RJMapperBuilderClass.prototype.updatedAt;
6155
6197
  /**
6156
6198
  * @type {?}
6157
6199
  * @private