@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.
@@ -3484,32 +3484,6 @@ class RJMapperBuilderClass {
3484
3484
  this.itemCount = 0;
3485
3485
  this.largestNumber = 0;
3486
3486
  this.rjObject = {};
3487
- this.paymentTypes = [
3488
- {
3489
- paymentType: 'Card',
3490
- type: 'SEPAY',
3491
- tenderType: '5',
3492
- tenderSubType: '8',
3493
- },
3494
- {
3495
- paymentType: 'Cash',
3496
- type: 'TMC_CASH',
3497
- tenderType: '1',
3498
- tenderSubType: '0'
3499
- },
3500
- {
3501
- paymentType: 'PDQ',
3502
- type: 'Unintegrated',
3503
- tenderType: '2',
3504
- tenderSubType: '8'
3505
- },
3506
- {
3507
- paymentType: 'Gift Card',
3508
- type: 'TMC_GIFTCARD',
3509
- tenderType: '5',
3510
- tenderSubType: '8'
3511
- }
3512
- ];
3513
3487
  if (transactionDoc) {
3514
3488
  this.transactionDocument = transactionDoc;
3515
3489
  }
@@ -3542,6 +3516,8 @@ class RJMapperBuilderClass {
3542
3516
  }
3543
3517
  this.initilizeItemCount();
3544
3518
  this.setLineNumberForProducts();
3519
+ this.createdAt = this.getdate(this.transactionDocument.createdAt);
3520
+ this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
3545
3521
  }
3546
3522
  /**
3547
3523
  * @template THIS
@@ -3550,9 +3526,9 @@ class RJMapperBuilderClass {
3550
3526
  */
3551
3527
  getPosbasketInfo() {
3552
3528
  (/** @type {?} */ (this)).rjObject['Keyword'] = (/** @type {?} */ (this)).generateKeyword();
3553
- (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).transactionDocument.createdAt);
3529
+ (/** @type {?} */ (this)).rjObject['ID'] = (/** @type {?} */ (this)).generateId((/** @type {?} */ (this)).createdAt);
3554
3530
  (/** @type {?} */ (this)).rjObject['XMLSchemaVersion'] = '2';
3555
- (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).transactionDocument.updatedAt;
3531
+ (/** @type {?} */ (this)).rjObject['LastUpdated'] = (/** @type {?} */ (this)).updatedAt;
3556
3532
  (/** @type {?} */ (this)).rjObject['MajorVersion'] = (/** @type {?} */ (this)).majorVersion;
3557
3533
  (/** @type {?} */ (this)).rjObject['MinorVersion'] = (/** @type {?} */ (this)).minorVersion;
3558
3534
  (/** @type {?} */ (this)).rjObject['ManifestVersion'] = (/** @type {?} */ (this)).manifestVersion;
@@ -3570,7 +3546,7 @@ class RJMapperBuilderClass {
3570
3546
  getheaderInfo() {
3571
3547
  (/** @type {?} */ (this)).rjObject['Header'] = {};
3572
3548
  (/** @type {?} */ (this)).rjObject['Header'].TimeZoneOffset = (/** @type {?} */ (this)).convertToString((/** @type {?} */ (this)).generateTimezoneoffset((/** @type {?} */ (this)).transactionDocument.createdAt));
3573
- (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).transactionDocument.createdAt;
3549
+ (/** @type {?} */ (this)).rjObject['Header'].DateTimeCreated = (/** @type {?} */ (this)).createdAt;
3574
3550
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy = {};
3575
3551
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.DeviceID = (/** @type {?} */ (this)).deviceId;
3576
3552
  (/** @type {?} */ (this)).rjObject['Header'].OriginatedBy.CashierID = (/** @type {?} */ (this)).cashierId;
@@ -3755,7 +3731,7 @@ class RJMapperBuilderClass {
3755
3731
  obj.Description = data.percentageDiscountReasonName ? data.percentageDiscountReasonName : data.priceOverrideReasonName;
3756
3732
  obj.DeviceID = this.deviceId;
3757
3733
  obj.UserID = this.userId;
3758
- obj.DateTimeCreated = this.transactionDocument.updatedAt;
3734
+ obj.DateTimeCreated = this.updatedAt;
3759
3735
  obj.AuthorisingUserID = this.userId;
3760
3736
  obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
3761
3737
  obj.ModifiedLineNumber = lineNo;
@@ -3770,7 +3746,7 @@ class RJMapperBuilderClass {
3770
3746
  */
3771
3747
  getTrailerInfo() {
3772
3748
  (/** @type {?} */ (this)).rjObject['Trailer'] = {};
3773
- (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).transactionDocument.updatedAt;
3749
+ (/** @type {?} */ (this)).rjObject.Trailer.DateTimeCompleted = (/** @type {?} */ (this)).updatedAt;
3774
3750
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy = {};
3775
3751
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.DeviceID = (/** @type {?} */ (this)).deviceId; //todo
3776
3752
  (/** @type {?} */ (this)).rjObject.Trailer.CompletedBy.CashierID = (/** @type {?} */ (this)).cashierId; //todo
@@ -3871,24 +3847,23 @@ class RJMapperBuilderClass {
3871
3847
  * @param {?} x
3872
3848
  * @return {?}
3873
3849
  */
3874
- x => x.paymentType.toUpperCase() === element.paymentType.toUpperCase()));
3850
+ x => x.name.toUpperCase() === element.paymentType.toUpperCase()));
3875
3851
  if (element.paymentType.toUpperCase() === 'GIFT CARD') {
3876
3852
  /** @type {?} */
3877
3853
  let obj = {
3878
3854
  XMLSchemaVersion: (/** @type {?} */ (this)).xmlSchemaVersion,
3879
3855
  LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
3880
- NetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3881
- EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3882
- Description: (/** @type {?} */ (this)).getDescription(value[0].paymentType, element),
3883
- //todo
3856
+ NetValue: (/** @type {?} */ (this)).convertToString(-1 * (Math.round(element.amount))),
3857
+ EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (Math.round(element.amount))),
3858
+ Description: (/** @type {?} */ (this)).getDescription(value[0].name, element),
3884
3859
  DeviceID: (/** @type {?} */ (this)).deviceId,
3885
3860
  //todo
3886
3861
  UserID: (/** @type {?} */ (this)).userId,
3887
3862
  //todo
3888
- DateTimeCreated: (/** @type {?} */ (this)).transactionDocument.updatedAt,
3863
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3889
3864
  TenderType: value[0].tenderType,
3890
3865
  TenderSubType: value[0].tenderSubType,
3891
- TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
3866
+ TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (Math.round(element.amount))),
3892
3867
  CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3893
3868
  CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
3894
3869
  GiftVoucherSalesAllowed: '',
@@ -3907,13 +3882,12 @@ class RJMapperBuilderClass {
3907
3882
  //todo
3908
3883
  NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3909
3884
  EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
3910
- Description: (/** @type {?} */ (this)).getDescription(value[0].paymentType, element),
3911
- //todo
3885
+ Description: (/** @type {?} */ (this)).getDescription(value[0].name, element),
3912
3886
  DeviceID: (/** @type {?} */ (this)).deviceId,
3913
3887
  //todo
3914
3888
  UserID: (/** @type {?} */ (this)).userId,
3915
3889
  //todo
3916
- DateTimeCreated: (/** @type {?} */ (this)).transactionDocument.updatedAt,
3890
+ DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
3917
3891
  TenderType: value[0].tenderType,
3918
3892
  TenderSubType: value[0].tenderSubType,
3919
3893
  TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
@@ -4179,6 +4153,16 @@ class RJMapperBuilderClass {
4179
4153
  (/** @type {?} */ (this)).branchId = value;
4180
4154
  return (/** @type {?} */ (this));
4181
4155
  }
4156
+ /**
4157
+ * @template THIS
4158
+ * @this {THIS}
4159
+ * @param {?} value
4160
+ * @return {THIS}
4161
+ */
4162
+ setPaymentDetails(value) {
4163
+ (/** @type {?} */ (this)).paymentTypes = value;
4164
+ return (/** @type {?} */ (this));
4165
+ }
4182
4166
  /**
4183
4167
  * @param {?} date
4184
4168
  * @return {?}
@@ -4226,6 +4210,12 @@ class RJMapperBuilderClass {
4226
4210
  returnProduct(element, lineDiscount) {
4227
4211
  /** @type {?} */
4228
4212
  let obj = {};
4213
+ /** @type {?} */
4214
+ let taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
4215
+ * @param {?} item
4216
+ * @return {?}
4217
+ */
4218
+ (item) => item.itemLineId == element['itemLineId']));
4229
4219
  obj['XMLSchemaVersion'] = this.xmlSchemaVersion;
4230
4220
  obj['LineNumber'] = element['itemLineId'];
4231
4221
  obj['NetValue'] = this.removeDecimal(element['refundedTotal']);
@@ -4233,7 +4223,7 @@ class RJMapperBuilderClass {
4233
4223
  obj['Description'] = element['description'];
4234
4224
  obj['DeviceID'] = this.transactionDocument['terminalId'];
4235
4225
  obj['UserID'] = this.userId;
4236
- obj['DateTimeCreated'] = this.transactionDocument['createdAt'];
4226
+ obj['DateTimeCreated'] = this.createdAt;
4237
4227
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
4238
4228
  obj['UnitPrice'] = this.removeDecimal(element['price']);
4239
4229
  obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
@@ -4256,15 +4246,8 @@ class RJMapperBuilderClass {
4256
4246
  obj['MMGroupID'] = this.getAttributes();
4257
4247
  obj['CustomerDetails'] = ""; // todo - blank
4258
4248
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
4259
- // TODO
4260
- /** @type {?} */
4261
- let taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
4262
- * @param {?} item
4263
- * @return {?}
4264
- */
4265
- (item) => item.itemLineId == element['itemLineId']));
4266
- obj['OriginalTaxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal); //todo
4267
- obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal);
4249
+ obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
4250
+ obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
4268
4251
  if (lineDiscount) {
4269
4252
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
4270
4253
  // line discount
@@ -4324,7 +4307,7 @@ class RJMapperBuilderClass {
4324
4307
  //to do
4325
4308
  UserID: this.userId,
4326
4309
  //to do,
4327
- DateTimeCreated: this.transactionDocument.createdAt,
4310
+ DateTimeCreated: this.createdAt,
4328
4311
  ExtendedValue: this.removeDecimal(element.price),
4329
4312
  UnitPrice: this.removeDecimal(element.price),
4330
4313
  MMGroupID: this.getAttributes(),
@@ -4339,8 +4322,8 @@ class RJMapperBuilderClass {
4339
4322
  (item) => item.itemLineId == element['itemLineId'])).VATCode,
4340
4323
  TaxModifiable: 1,
4341
4324
  //todo
4342
- OriginalTaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
4343
- TaxAmount: taxTotal.taxLineTotal < 0 ? this.removeDecimal(taxTotal.taxLineTotal) : this.removeDecimal(-taxTotal.taxLineTotal),
4325
+ OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
4326
+ TaxAmount: this.convertToString(taxTotal.taxLineTotal),
4344
4327
  OriginalTaxAmountSet: 1,
4345
4328
  //todo
4346
4329
  ProductID: element.SKU,
@@ -4385,6 +4368,18 @@ class RJMapperBuilderClass {
4385
4368
  }
4386
4369
  return obj;
4387
4370
  }
4371
+ /**
4372
+ * @param {?} element
4373
+ * @param {?} VAT
4374
+ * @return {?}
4375
+ */
4376
+ getoriginltax(element, VAT) {
4377
+ /** @type {?} */
4378
+ let pricebeforetax = (element.price * 100) / (100 + VAT);
4379
+ /** @type {?} */
4380
+ let originaltax = element.price - pricebeforetax;
4381
+ return originaltax;
4382
+ }
4388
4383
  /**
4389
4384
  * @param {?} value
4390
4385
  * @return {?}
@@ -4441,6 +4436,28 @@ class RJMapperBuilderClass {
4441
4436
  return "";
4442
4437
  }
4443
4438
  }
4439
+ /**
4440
+ * @param {?} date
4441
+ * @return {?}
4442
+ */
4443
+ getdate(date) {
4444
+ /** @type {?} */
4445
+ let offset = this.generateTimezoneoffset(date) * -1;
4446
+ /** @type {?} */
4447
+ let offsetHours = Math.abs(Math.floor(offset / 60));
4448
+ /** @type {?} */
4449
+ let offsetMinutes = Math.abs(offset) - offsetHours * 60;
4450
+ /** @type {?} */
4451
+ let offsetSign = '+';
4452
+ if (offset < 0) {
4453
+ offsetSign = '-';
4454
+ }
4455
+ /** @type {?} */
4456
+ let newdate = date.substring(0, 19);
4457
+ /** @type {?} */
4458
+ let x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
4459
+ return x;
4460
+ }
4444
4461
  }
4445
4462
  if (false) {
4446
4463
  /**
@@ -4553,6 +4570,16 @@ if (false) {
4553
4570
  * @private
4554
4571
  */
4555
4572
  RJMapperBuilderClass.prototype.branchId;
4573
+ /**
4574
+ * @type {?}
4575
+ * @private
4576
+ */
4577
+ RJMapperBuilderClass.prototype.createdAt;
4578
+ /**
4579
+ * @type {?}
4580
+ * @private
4581
+ */
4582
+ RJMapperBuilderClass.prototype.updatedAt;
4556
4583
  /**
4557
4584
  * @type {?}
4558
4585
  * @private