@pmcretail/mapper-library 0.0.12 → 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.
@@ -5110,16 +5110,16 @@
5110
5110
  function (element) {
5111
5111
  /** @type {?} */
5112
5112
  var obj = {};
5113
- obj['XMLSchemaVersion'] = 1;
5114
- obj['NetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
5115
- obj['EffectiveNetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
5116
- obj['Description'] = element.reasonCode;
5113
+ obj['XMLSchemaVersion'] = "1";
5114
+ obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
5115
+ obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
5116
+ obj['Description'] = element.reasonDisplayText;
5117
5117
  obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
5118
5118
  obj['ReasonCodeID'] = element.reasonCode;
5119
- obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
5120
- obj['RoundingRule'] = 2;
5121
- obj['ModifiedLineNumber '] = element.itemLineIds;
5122
- obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
5119
+ obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1); // todo - compare values
5120
+ obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
5121
+ obj['ModifiedLineNumber'] = element.itemLineIds;
5122
+ obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
5123
5123
  // obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
5124
5124
  // obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
5125
5125
  (/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
@@ -5199,56 +5199,52 @@
5199
5199
  obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
5200
5200
  (/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
5201
5201
  }));
5202
- // TODO: make Trailer object from promotion
5203
- (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
5204
- (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5205
- * @param {?} element
5206
- * @return {?}
5207
- */
5208
- function (element) {
5209
- /** @type {?} */
5210
- var obj = {};
5211
- obj['PromotionID'] = element.promotionId;
5212
- obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5213
- obj['PromotionQuantity'] = ""; // todo - not avaialble
5214
- obj['PromotionDescription'] = element.displayText;
5215
- obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).transactionDocument.storeId;
5216
- obj['PromotionHit']['HitNumber'] = ""; // todo;
5217
- obj['PromotionHit']['HitQuantity'] = ""; // todo;
5218
- obj['PromotionHit']['HitSaving'] = ""; // todo;
5219
- obj['PromotionHit']['PromotionTrigger'] = [];
5220
- element.trigger.forEach((/**
5221
- * @param {?} subElement
5202
+ // TODO: make Trailer object from promotion
5203
+ if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
5204
+ (/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
5205
+ (/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
5206
+ * @param {?} element
5222
5207
  * @return {?}
5223
5208
  */
5224
- function (subElement) {
5225
- /** @type {?} */
5226
- var objSub = {};
5209
+ function (element) {
5210
+ console.log('element', element);
5227
5211
  /** @type {?} */
5228
- var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5229
- * @param {?} item
5230
- * @return {?}
5231
- */
5232
- function (item) { return item.lineItemId == subElement.itemLineId; }));
5233
- objSub['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5234
- objSub['ProductID'] = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5235
- * @param {?} item
5212
+ var obj = {};
5213
+ obj['PromotionID'] = element.promotionId;
5214
+ obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
5215
+ obj['PromotionQuantity'] = ""; // todo - not avaialble
5216
+ obj['PromotionDescription'] = element.displayText;
5217
+ obj['PromotionHit'] = {};
5218
+ obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5219
+ obj['PromotionHit']['HitNumber'] = ""; // todo;
5220
+ obj['PromotionHit']['HitQuantity'] = ""; // todo;
5221
+ obj['PromotionHit']['HitSaving'] = ""; // todo;
5222
+ obj['PromotionHit']['PromotionTrigger'] = {};
5223
+ element.trigger.forEach((/**
5224
+ * @param {?} subElement
5236
5225
  * @return {?}
5237
5226
  */
5238
- function (item) { return item.itemLineId === subElement.itemLineId; })).SKU;
5239
- objSub['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5240
- objSub['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5241
- objSub['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5242
- objSub['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5243
- * @param {?} item
5244
- * @return {?}
5245
- */
5246
- function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5247
- obj['PromotionHit']['PromotionTrigger'].push(objSub);
5227
+ function (subElement) {
5228
+ /** @type {?} */
5229
+ var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
5230
+ * @param {?} item
5231
+ * @return {?}
5232
+ */
5233
+ function (item) { return item.itemLineId == subElement.itemLineId; }));
5234
+ obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
5235
+ obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
5236
+ obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
5237
+ obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
5238
+ obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
5239
+ obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
5240
+ * @param {?} item
5241
+ * @return {?}
5242
+ */
5243
+ function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
5244
+ }));
5245
+ (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5248
5246
  }));
5249
- (/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
5250
- }));
5251
- //console.log(this.rjObject);
5247
+ }
5252
5248
  return (/** @type {?} */ (this));
5253
5249
  };
5254
5250
  /**
@@ -5595,16 +5591,14 @@
5595
5591
  /**
5596
5592
  * @template THIS
5597
5593
  * @this {THIS}
5598
- * @param {?} value
5599
5594
  * @return {THIS}
5600
5595
  */
5601
5596
  RJMapperBuilderClass.prototype.setCashierID = /**
5602
5597
  * @template THIS
5603
5598
  * @this {THIS}
5604
- * @param {?} value
5605
5599
  * @return {THIS}
5606
5600
  */
5607
- function (value) {
5601
+ function () {
5608
5602
  (/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
5609
5603
  return (/** @type {?} */ (this));
5610
5604
  };
@@ -5770,7 +5764,7 @@
5770
5764
  obj['DateTimeCreated'] = this.createdAt;
5771
5765
  obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
5772
5766
  obj['UnitPrice'] = this.removeDecimal(element['price']);
5773
- obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
5767
+ obj['Quantity'] = this.getQuantity(element);
5774
5768
  obj['OriginalTaxAmountSet'] = 1;
5775
5769
  obj['ProductID'] = element['SKU'];
5776
5770
  obj['HandKeyed'] = 1;
@@ -5778,7 +5772,7 @@
5778
5772
  obj['Return'] = {};
5779
5773
  obj['Return']['ReturnReasonID'] = element['refundedReason'];
5780
5774
  obj['Return']['ReturnDescription'] = element['refundedReasonDescription'];
5781
- obj['Return']['ReturnToStock'] = element['refundedQuantity'] > 0 ? element['refundedQuantity'].toFixed(1) : -1 * element['refundedQuantity'].toFixed(1);
5775
+ obj['Return']['ReturnToStock'] = this.getQuantity(element);
5782
5776
  obj['TaxCode'] = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
5783
5777
  * @param {?} item
5784
5778
  * @return {?}
@@ -6051,6 +6045,25 @@
6051
6045
  this.rjObject['BasketDiscount']['RoundingRule'] = 2;
6052
6046
  }
6053
6047
  };
6048
+ /**
6049
+ * @param {?} element
6050
+ * @return {?}
6051
+ */
6052
+ RJMapperBuilderClass.prototype.getQuantity = /**
6053
+ * @param {?} element
6054
+ * @return {?}
6055
+ */
6056
+ function (element) {
6057
+ /** @type {?} */
6058
+ var quantity;
6059
+ if (this.transactionDocument.unreferencedRefund) {
6060
+ quantity = element['quantity'] < 0 ? element['quantity'].toFixed(1) : (-element['quantity']).toFixed(1);
6061
+ }
6062
+ else {
6063
+ quantity = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
6064
+ }
6065
+ return quantity;
6066
+ };
6054
6067
  return RJMapperBuilderClass;
6055
6068
  }());
6056
6069
  if (false) {