@pmcretail/mapper-library 0.0.53 → 0.0.55

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.
@@ -94,6 +94,7 @@
94
94
  PROVIDERS["SALESFORCE"] = "Salesforce";
95
95
  PROVIDERS["MAGENTO"] = "Magento";
96
96
  PROVIDERS["MAGENTO2"] = "Magento2";
97
+ PROVIDERS["SALESFORCE_OSU"] = "SalesforceOSU";
97
98
  })(PROVIDERS || (PROVIDERS = {}));
98
99
  var PROMOTION_LEVEL;
99
100
  (function (PROMOTION_LEVEL) {
@@ -3816,7 +3817,7 @@
3816
3817
  return '';
3817
3818
  }
3818
3819
  };
3819
- WebReturnSalesforceMapperBuilderClass.prototype.product = function () {
3820
+ WebReturnSalesforceMapperBuilderClass.prototype.product = function (subprovider) {
3820
3821
  var _this = this;
3821
3822
  appLogger_service.AppLoggerService.logDebug(this.className, "product", "product mapping started...");
3822
3823
  this.webReturnObject.basket['products'] = [];
@@ -3832,6 +3833,10 @@
3832
3833
  deliveryMethod: _this.getDeliveryMethod().toString(),
3833
3834
  totalLinePrice: product.price ? product.price : 0
3834
3835
  };
3836
+ if ((subprovider === null || subprovider === void 0 ? void 0 : subprovider.toLocaleUpperCase()) === PROVIDERS.SALESFORCE_OSU.toLocaleUpperCase() && (product === null || product === void 0 ? void 0 : product.c_osuObjectData)) {
3837
+ var availableQty = _this.getAvailableQty(JSON.parse(product === null || product === void 0 ? void 0 : product.c_osuObjectData));
3838
+ productObj.availableQuantity = availableQty > 0 ? availableQty : 0;
3839
+ }
3835
3840
  if (product && product.price != 0) {
3836
3841
  _this.webReturnObject.basket['products'].push(productObj);
3837
3842
  }
@@ -4163,6 +4168,27 @@
4163
4168
  return new Date(date).toISOString();
4164
4169
  }
4165
4170
  };
4171
+ WebReturnSalesforceMapperBuilderClass.prototype.getAvailableQty = function (status) {
4172
+ var shippedQtys = 0;
4173
+ var returnedQtys = 0;
4174
+ if (status === null || status === void 0 ? void 0 : status.SHIPPED) {
4175
+ var shipped = Object.values(status.SHIPPED);
4176
+ var shippedQty = shipped.reduce(function (n, _a) {
4177
+ var qty = _a.qty;
4178
+ return n + ((typeof qty == 'string') ? +qty : qty);
4179
+ }, 0);
4180
+ shippedQtys += Number(shippedQty);
4181
+ }
4182
+ if (status === null || status === void 0 ? void 0 : status.RETURNED) {
4183
+ var returned = Object.values(status.RETURNED);
4184
+ var refundQty = returned.reduce(function (n, _a) {
4185
+ var qty = _a.qty;
4186
+ return n + ((typeof qty == 'string') ? +qty : qty);
4187
+ }, 0);
4188
+ returnedQtys += Number(refundQty);
4189
+ }
4190
+ return shippedQtys - returnedQtys;
4191
+ };
4166
4192
  return WebReturnSalesforceMapperBuilderClass;
4167
4193
  }());
4168
4194