@pmcretail/mapper-library 0.0.11 → 0.0.13

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 {?}
@@ -4884,16 +4890,16 @@ var RJMapperBuilderClass = /** @class */ (function () {
4884
4890
  function (element) {
4885
4891
  /** @type {?} */
4886
4892
  var obj = {};
4887
- obj['XMLSchemaVersion'] = 1;
4888
- obj['NetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
4889
- obj['EffectiveNetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
4890
- obj['Description'] = element.reasonCode;
4893
+ obj['XMLSchemaVersion'] = "1";
4894
+ obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
4895
+ obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
4896
+ obj['Description'] = element.reasonDisplayText;
4891
4897
  obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
4892
4898
  obj['ReasonCodeID'] = element.reasonCode;
4893
- obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
4894
- obj['RoundingRule'] = 2;
4895
- obj['ModifiedLineNumber '] = element.itemLineIds;
4896
- obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
4899
+ obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1); // todo - compare values
4900
+ obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
4901
+ obj['ModifiedLineNumber'] = element.itemLineIds;
4902
+ obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
4897
4903
  // obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
4898
4904
  // obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
4899
4905
  (/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
@@ -4973,56 +4979,52 @@ var RJMapperBuilderClass = /** @class */ (function () {
4973
4979
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
4974
4980
  (/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
4975
4981
  }));
4976
- // TODO: make Trailer object from promotion
4977
- (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
4978
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
4979
- * @param {?} element
4980
- * @return {?}
4981
- */
4982
- function (element) {
4983
- /** @type {?} */
4984
- var obj = {};
4985
- obj['PromotionID'] = element.promotionId;
4986
- obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
4987
- obj['PromotionQuantity'] = ""; // todo - not avaialble
4988
- obj['PromotionDescription'] = element.displayText;
4989
- obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).transactionDocument.storeId;
4990
- obj['PromotionHit']['HitNumber'] = ""; // todo;
4991
- obj['PromotionHit']['HitQuantity'] = ""; // todo;
4992
- obj['PromotionHit']['HitSaving'] = ""; // todo;
4993
- obj['PromotionHit']['PromotionTrigger'] = [];
4994
- element.trigger.forEach((/**
4995
- * @param {?} subElement
4982
+ // TODO: make Trailer object from promotion
4983
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
4984
+ (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
4985
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
4986
+ * @param {?} element
4996
4987
  * @return {?}
4997
4988
  */
4998
- function (subElement) {
4999
- /** @type {?} */
5000
- var objSub = {};
4989
+ function (element) {
4990
+ console.log('element', element);
5001
4991
  /** @type {?} */
5002
- var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5003
- * @param {?} item
5004
- * @return {?}
5005
- */
5006
- function (item) { return item.lineItemId == subElement.itemLineId; }));
5007
- objSub['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5008
- objSub['ProductID'] = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5009
- * @param {?} item
5010
- * @return {?}
5011
- */
5012
- function (item) { return item.itemLineId === subElement.itemLineId; })).SKU;
5013
- objSub['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5014
- objSub['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5015
- objSub['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5016
- objSub['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5017
- * @param {?} item
4992
+ var obj = {};
4993
+ obj['PromotionID'] = element.promotionId;
4994
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
4995
+ obj['PromotionQuantity'] = ""; // todo - not avaialble
4996
+ obj['PromotionDescription'] = element.displayText;
4997
+ obj['PromotionHit'] = {};
4998
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
4999
+ obj['PromotionHit']['HitNumber'] = ""; // todo;
5000
+ obj['PromotionHit']['HitQuantity'] = ""; // todo;
5001
+ obj['PromotionHit']['HitSaving'] = ""; // todo;
5002
+ obj['PromotionHit']['PromotionTrigger'] = {};
5003
+ element.trigger.forEach((/**
5004
+ * @param {?} subElement
5018
5005
  * @return {?}
5019
5006
  */
5020
- function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5021
- obj['PromotionHit']['PromotionTrigger'].push(objSub);
5007
+ function (subElement) {
5008
+ /** @type {?} */
5009
+ var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5010
+ * @param {?} item
5011
+ * @return {?}
5012
+ */
5013
+ function (item) { return item.itemLineId == subElement.itemLineId; }));
5014
+ obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5015
+ obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
5016
+ obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5017
+ obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5018
+ obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5019
+ obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5020
+ * @param {?} item
5021
+ * @return {?}
5022
+ */
5023
+ function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5024
+ }));
5025
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5022
5026
  }));
5023
- (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5024
- }));
5025
- //console.log(this.rjObject);
5027
+ }
5026
5028
  return (/** @type {?} */ (this));
5027
5029
  };
5028
5030
  /**
@@ -5369,16 +5371,14 @@ var RJMapperBuilderClass = /** @class */ (function () {
5369
5371
  /**
5370
5372
  * @template THIS
5371
5373
  * @this {THIS}
5372
- * @param {?} value
5373
5374
  * @return {THIS}
5374
5375
  */
5375
5376
  RJMapperBuilderClass.prototype.setCashierID = /**
5376
5377
  * @template THIS
5377
5378
  * @this {THIS}
5378
- * @param {?} value
5379
5379
  * @return {THIS}
5380
5380
  */
5381
- function (value) {
5381
+ function () {
5382
5382
  (/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
5383
5383
  return (/** @type {?} */ (this));
5384
5384
  };
@@ -5544,7 +5544,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5544
5544
  obj['DateTimeCreated'] = this.createdAt;
5545
5545
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5546
5546
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5547
- obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
5547
+ obj['Quantity'] = this.getQuantity(element);
5548
5548
  obj['OriginalTaxAmountSet'] = 1;
5549
5549
  obj['ProductID'] = element['SKU'];
5550
5550
  obj['HandKeyed'] = 1;
@@ -5552,7 +5552,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5552
5552
  obj['Return'] = {};
5553
5553
  obj['Return']['ReturnReasonID'] = element['refundedReason'];
5554
5554
  obj['Return']['ReturnDescription'] = element['refundedReasonDescription'];
5555
- obj['Return']['ReturnToStock'] = element['refundedQuantity'] > 0 ? element['refundedQuantity'].toFixed(1) : -1 * element['refundedQuantity'].toFixed(1);
5555
+ obj['Return']['ReturnToStock'] = this.getQuantity(element);
5556
5556
  obj['TaxCode'] = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5557
5557
  * @param {?} item
5558
5558
  * @return {?}
@@ -5564,7 +5564,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5564
5564
  obj['MMGroupID'] = this.getAttributes();
5565
5565
  obj['CustomerDetails'] = ""; // todo - blank
5566
5566
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5567
- obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5567
+ obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
5568
5568
  obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5569
5569
  if (lineDiscount) {
5570
5570
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
@@ -5643,7 +5643,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5643
5643
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5644
5644
  TaxModifiable: 1,
5645
5645
  //todo
5646
- OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5646
+ OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5647
5647
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5648
5648
  OriginalTaxAmountSet: 1,
5649
5649
  //todo
@@ -5694,7 +5694,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5694
5694
  * @param {?} VAT
5695
5695
  * @return {?}
5696
5696
  */
5697
- RJMapperBuilderClass.prototype.getoriginltax = /**
5697
+ RJMapperBuilderClass.prototype.getOriginalTax = /**
5698
5698
  * @param {?} element
5699
5699
  * @param {?} VAT
5700
5700
  * @return {?}
@@ -5776,7 +5776,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
5776
5776
  * @param {?} date
5777
5777
  * @return {?}
5778
5778
  */
5779
- RJMapperBuilderClass.prototype.getdate = /**
5779
+ RJMapperBuilderClass.prototype.getDate = /**
5780
5780
  * @param {?} date
5781
5781
  * @return {?}
5782
5782
  */
@@ -5795,9 +5795,55 @@ var RJMapperBuilderClass = /** @class */ (function () {
5795
5795
  /** @type {?} */
5796
5796
  var newdate = date.substring(0, 19);
5797
5797
  /** @type {?} */
5798
- var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
5798
+ var x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
5799
5799
  return x;
5800
5800
  };
5801
+ /**
5802
+ * @param {?} transactionPromotion
5803
+ * @return {?}
5804
+ */
5805
+ RJMapperBuilderClass.prototype.getTransactionPromotion = /**
5806
+ * @param {?} transactionPromotion
5807
+ * @return {?}
5808
+ */
5809
+ function (transactionPromotion) {
5810
+ if (transactionPromotion && transactionPromotion.length > 0) {
5811
+ this.rjObject['BasketDiscount'] = {};
5812
+ this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
5813
+ this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
5814
+ this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5815
+ this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
5816
+ this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
5817
+ this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
5818
+ this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
5819
+ this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
5820
+ this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
5821
+ this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
5822
+ this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
5823
+ this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
5824
+ this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
5825
+ this.rjObject['BasketDiscount']['RoundingRule'] = 2;
5826
+ }
5827
+ };
5828
+ /**
5829
+ * @param {?} element
5830
+ * @return {?}
5831
+ */
5832
+ RJMapperBuilderClass.prototype.getQuantity = /**
5833
+ * @param {?} element
5834
+ * @return {?}
5835
+ */
5836
+ function (element) {
5837
+ /** @type {?} */
5838
+ var quantity;
5839
+ if (this.transactionDocument.unreferencedRefund) {
5840
+ quantity = element['quantity'] < 0 ? element['quantity'].toFixed(1) : (-element['quantity']).toFixed(1);
5841
+ }
5842
+ else {
5843
+ quantity = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
5844
+ }
5845
+ return quantity;
5846
+ };
5801
5847
  return RJMapperBuilderClass;
5802
5848
  }());
5803
5849
  if (false) {
@@ -5921,11 +5967,6 @@ if (false) {
5921
5967
  * @private
5922
5968
  */
5923
5969
  RJMapperBuilderClass.prototype.rjObject;
5924
- /**
5925
- * @type {?}
5926
- * @private
5927
- */
5928
- RJMapperBuilderClass.prototype.paymentTypes;
5929
5970
  }
5930
5971
 
5931
5972
  /**