@pmcretail/mapper-library 0.0.11 → 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.
@@ -4906,8 +4906,8 @@
4906
4906
  }
4907
4907
  this.initilizeItemCount();
4908
4908
  this.setLineNumberForProducts();
4909
- this.createdAt = this.getdate(this.transactionDocument.createdAt);
4910
- this.updatedAt = this.getdate(this.transactionDocument.updatedAt);
4909
+ this.createdAt = this.getDate(this.transactionDocument.createdAt);
4910
+ this.updatedAt = this.getDate(this.transactionDocument.updatedAt);
4911
4911
  }
4912
4912
  /**
4913
4913
  * @template THIS
@@ -5007,6 +5007,12 @@
5007
5007
  (/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
5008
5008
  (/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
5009
5009
  }));
5010
+ /** @type {?} */
5011
+ var transactionPromotion = [];
5012
+ if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion && (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
5013
+ transactionPromotion = (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion;
5014
+ (/** @type {?} */ (this)).getTransactionPromotion(transactionPromotion);
5015
+ }
5010
5016
  }
5011
5017
  else if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.REFUND) {
5012
5018
  (/** @type {?} */ (this)).rjObject['ProductReturn'] = [];
@@ -5094,9 +5100,9 @@
5094
5100
  */
5095
5101
  function () {
5096
5102
  var _this = this;
5097
- (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
5098
5103
  if (!(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount)
5099
5104
  return (/** @type {?} */ (this));
5105
+ (/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
5100
5106
  (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.forEach((/**
5101
5107
  * @param {?} element
5102
5108
  * @return {?}
@@ -5764,7 +5770,7 @@
5764
5770
  obj['DateTimeCreated'] = this.createdAt;
5765
5771
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5766
5772
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5767
- obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
5773
+ obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
5768
5774
  obj['OriginalTaxAmountSet'] = 1;
5769
5775
  obj['ProductID'] = element['SKU'];
5770
5776
  obj['HandKeyed'] = 1;
@@ -5784,7 +5790,7 @@
5784
5790
  obj['MMGroupID'] = this.getAttributes();
5785
5791
  obj['CustomerDetails'] = ""; // todo - blank
5786
5792
  obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
5787
- obj['OriginalTaxAmount'] = this.convertToString(this.getoriginltax(element, taxTotal.VAT) * -1);
5793
+ obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
5788
5794
  obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
5789
5795
  if (lineDiscount) {
5790
5796
  if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
@@ -5863,7 +5869,7 @@
5863
5869
  function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
5864
5870
  TaxModifiable: 1,
5865
5871
  //todo
5866
- OriginalTaxAmount: this.convertToString(this.getoriginltax(element, taxTotal.VAT)),
5872
+ OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
5867
5873
  TaxAmount: this.convertToString(taxTotal.taxLineTotal),
5868
5874
  OriginalTaxAmountSet: 1,
5869
5875
  //todo
@@ -5914,7 +5920,7 @@
5914
5920
  * @param {?} VAT
5915
5921
  * @return {?}
5916
5922
  */
5917
- RJMapperBuilderClass.prototype.getoriginltax = /**
5923
+ RJMapperBuilderClass.prototype.getOriginalTax = /**
5918
5924
  * @param {?} element
5919
5925
  * @param {?} VAT
5920
5926
  * @return {?}
@@ -5996,7 +6002,7 @@
5996
6002
  * @param {?} date
5997
6003
  * @return {?}
5998
6004
  */
5999
- RJMapperBuilderClass.prototype.getdate = /**
6005
+ RJMapperBuilderClass.prototype.getDate = /**
6000
6006
  * @param {?} date
6001
6007
  * @return {?}
6002
6008
  */
@@ -6015,9 +6021,36 @@
6015
6021
  /** @type {?} */
6016
6022
  var newdate = date.substring(0, 19);
6017
6023
  /** @type {?} */
6018
- var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
6024
+ var x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
6019
6025
  return x;
6020
6026
  };
6027
+ /**
6028
+ * @param {?} transactionPromotion
6029
+ * @return {?}
6030
+ */
6031
+ RJMapperBuilderClass.prototype.getTransactionPromotion = /**
6032
+ * @param {?} transactionPromotion
6033
+ * @return {?}
6034
+ */
6035
+ function (transactionPromotion) {
6036
+ if (transactionPromotion && transactionPromotion.length > 0) {
6037
+ this.rjObject['BasketDiscount'] = {};
6038
+ this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
6039
+ this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
6040
+ this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6041
+ this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
6042
+ this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
6043
+ this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
6044
+ this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
6045
+ this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
6046
+ this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
6047
+ this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
6048
+ this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
6049
+ this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
6050
+ this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
6051
+ this.rjObject['BasketDiscount']['RoundingRule'] = 2;
6052
+ }
6053
+ };
6021
6054
  return RJMapperBuilderClass;
6022
6055
  }());
6023
6056
  if (false) {
@@ -6141,11 +6174,6 @@
6141
6174
  * @private
6142
6175
  */
6143
6176
  RJMapperBuilderClass.prototype.rjObject;
6144
- /**
6145
- * @type {?}
6146
- * @private
6147
- */
6148
- RJMapperBuilderClass.prototype.paymentTypes;
6149
6177
  }
6150
6178
 
6151
6179
  exports.MapperLibraryComponent = MapperLibraryComponent;