shareneus 1.5.28 → 1.5.30

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.
@@ -118,7 +118,7 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
118
118
  const tier = ResolveTier(resolvedQty, priceList.QtyTiers);
119
119
  if (tier) {
120
120
  item.PriceTiers = (_c = priceList.QtyTiers) !== null && _c !== void 0 ? _c : undefined;
121
- if (item.Track === "TR" || item.Track === "SN" || ((0, util_1.IsNull)(item.Track) && (0, util_1.IsNotNull)(item.Sale))) {
121
+ if (item.Track === "TR" || item.Track === "SN") {
122
122
  item.Sale["MRP"] = item.Sale.Price;
123
123
  const basePrice = DetermineBasePriceForTier(item, priceList);
124
124
  item.Sale.Price = ApplyTierAdjustment(basePrice, tier, priceList, markUp);
@@ -144,7 +144,7 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
144
144
  if (priceList.Fixed && (0, util_1.IsNotNull)(priceList.Fixed.Price)) {
145
145
  const fixedPrice = priceList.Fixed.Price;
146
146
  const fixedDisc = priceList.Fixed.Disc || 0;
147
- if (item.Track === "TR" || item.Track === "SN" || ((0, util_1.IsNull)(item.Track) && (0, util_1.IsNotNull)(item.Sale))) {
147
+ if (item.Track === "TR" || item.Track === "SN") {
148
148
  item.Sale["MRP"] = item.Sale.Price;
149
149
  if ((0, util_1.IsNotNull)(fixedDisc) && fixedDisc > 0) {
150
150
  item.Sale.Price = CalcItemFinalSalePrice(fixedPrice, fixedDisc, priceList);
@@ -175,7 +175,7 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
175
175
  else if (priceList.PrCalc === "DISC") {
176
176
  const discPerc = calcDisc.Perc || 0;
177
177
  if (priceList.BasedOn === "SP") {
178
- if (item.Track === "TR" || item.Track === "SN" || ((0, util_1.IsNull)(item.Track) && (0, util_1.IsNotNull)(item.Sale))) {
178
+ if (item.Track === "TR" || item.Track === "SN") {
179
179
  item.Sale["MRP"] = item.Sale.Price;
180
180
  item.Sale.Price = CalcItemFinalSalePrice(item.Sale.Price, discPerc, priceList, markUp);
181
181
  if (includeMargin && (0, util_1.IsNotNull)(item.Pur) && (0, util_1.IsNotNull)(item.Pur.Cost)) {
@@ -193,7 +193,7 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
193
193
  }
194
194
  }
195
195
  else if (priceList.BasedOn === "PC") {
196
- if (item.Track === "TR" || item.Track === "SN" || ((0, util_1.IsNull)(item.Track) && (0, util_1.IsNotNull)(item.Sale))) {
196
+ if (item.Track === "TR" || item.Track === "SN") {
197
197
  item.Sale["MRP"] = item.Sale.Price;
198
198
  if ((0, util_1.IsNotNull)(item.Pur) && (0, util_1.IsNotNull)(item.Pur.Cost)) {
199
199
  item.Sale.Price = CalcItemFinalSalePrice(item.Pur.Cost, discPerc, priceList, markUp);
@@ -23,8 +23,8 @@ type PriceListDoc = {
23
23
  export declare function ApplyServicePriceListToProcedure(procedure: any, priceList: PriceListDoc | null, quantity?: number): any;
24
24
  export declare function ApplyServicePriceListToOpcode(opcode: any, priceList: PriceListDoc | null, quantity?: number): any;
25
25
  /**
26
- * Applies price list to Service with support for equipment-based pricing (FitPrices)
27
- * Handles both simple services (healthcare) and equipment-based services (automotive, HVAC)
26
+ * Applies price list to Service with support for equipment-based pricing (FitPriceCosts)
27
+ * Handles both simple services (healthcare) and equipment-based services (automotive, HVAC, medical, industrial, etc.)
28
28
  */
29
- export declare function GetServicePriceForPriceList(service: any, priceList: PriceListDoc | null, vehicle?: any, quantity?: number): any;
29
+ export declare function GetServicePriceForPriceList(service: any, priceList: PriceListDoc | null, equipment?: any, quantity?: number): any;
30
30
  export {};
@@ -235,14 +235,15 @@ function buildAppliedTierMeta(tier) {
235
235
  };
236
236
  }
237
237
  /**
238
- * Applies price list to Service with support for equipment-based pricing (FitPrices)
239
- * Handles both simple services (healthcare) and equipment-based services (automotive, HVAC)
238
+ * Applies price list to Service with support for equipment-based pricing (FitPriceCosts)
239
+ * Handles both simple services (healthcare) and equipment-based services (automotive, HVAC, medical, industrial, etc.)
240
240
  */
241
- function GetServicePriceForPriceList(service, priceList, vehicle = null, quantity = 1) {
241
+ function GetServicePriceForPriceList(service, priceList, equipment = null, quantity = 1) {
242
242
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
243
243
  if (!service || !priceList) {
244
244
  return service;
245
245
  }
246
+ console.log(service, priceList, equipment, quantity);
246
247
  const resolvedQty = Math.max(1, Number(quantity) || 1);
247
248
  const warnings = [];
248
249
  const priceListId = (_b = (_a = priceList === null || priceList === void 0 ? void 0 : priceList._id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a);
@@ -253,16 +254,16 @@ function GetServicePriceForPriceList(service, priceList, vehicle = null, quantit
253
254
  if (priceList.TType === "SALE" && service.Sale) {
254
255
  // Check if equipment-based service (FitPriceCosts) or simple service (Price)
255
256
  if (service.FitPriceCosts && service.FitPriceCosts.length > 0) {
256
- // Equipment-based service - need vehicle information
257
- if (!vehicle) {
258
- warnings.push("Vehicle information required for equipment-based service pricing.");
257
+ // Equipment-based service - need equipment information
258
+ if (!equipment) {
259
+ warnings.push("Equipment information required for equipment-based service pricing.");
259
260
  service.PriceListWarnings = warnings;
260
261
  return service;
261
262
  }
262
- // Find matching FitPriceCost for vehicle
263
- matchedFitPriceCost = findMatchingFitPriceCost(service.FitPriceCosts, vehicle);
263
+ // Find matching FitPriceCost for equipment
264
+ matchedFitPriceCost = findMatchingFitPriceCost(service.FitPriceCosts, equipment);
264
265
  if (!matchedFitPriceCost || !matchedFitPriceCost.Sale) {
265
- warnings.push(`No pricing found for ${vehicle.Make || 'Unknown'} ${vehicle.Model || ''}`);
266
+ warnings.push(`No pricing found for ${equipment.Make || 'Unknown'} ${equipment.Model || ''}`);
266
267
  service.PriceListWarnings = warnings;
267
268
  return service;
268
269
  }
@@ -373,16 +374,16 @@ function GetServicePriceForPriceList(service, priceList, vehicle = null, quantit
373
374
  let baseCost = null;
374
375
  let baseCostSource = "BASE";
375
376
  if (service.FitPriceCosts && service.FitPriceCosts.length > 0) {
376
- // Equipment-based service - need vehicle information
377
- if (!vehicle) {
378
- warnings.push("Vehicle information required for equipment-based service costing.");
377
+ // Equipment-based service - need equipment information
378
+ if (!equipment) {
379
+ warnings.push("Equipment information required for equipment-based service costing.");
379
380
  service.PriceListWarnings = warnings;
380
381
  return service;
381
382
  }
382
383
  // Reuse the matchedFitPriceCost from Sale section if available
383
- const fitPriceCostEntry = matchedFitPriceCost || findMatchingFitPriceCost(service.FitPriceCosts, vehicle);
384
+ const fitPriceCostEntry = matchedFitPriceCost || findMatchingFitPriceCost(service.FitPriceCosts, equipment);
384
385
  if (!fitPriceCostEntry || !fitPriceCostEntry.Pur) {
385
- warnings.push(`No costing found for ${vehicle.Make || 'Unknown'} ${vehicle.Model || ''}`);
386
+ warnings.push(`No costing found for ${equipment.Make || 'Unknown'} ${equipment.Model || ''}`);
386
387
  service.PriceListWarnings = warnings;
387
388
  return service;
388
389
  }
@@ -446,41 +447,41 @@ function GetServicePriceForPriceList(service, priceList, vehicle = null, quantit
446
447
  return service;
447
448
  }
448
449
  /**
449
- * Finds the matching FitPriceCost entry for a given vehicle
450
+ * Finds the matching FitPriceCost entry for a given equipment (automotive, HVAC, medical, industrial, etc.)
450
451
  * Tries most specific match first (Make + Model + Variant), then progressively less specific
451
452
  */
452
- function findMatchingFitPriceCost(fitPriceCosts, vehicle) {
453
+ function findMatchingFitPriceCost(fitPriceCosts, equipment) {
453
454
  var _a, _b, _c, _d, _e, _f, _g, _h;
454
- if (!Array.isArray(fitPriceCosts) || fitPriceCosts.length === 0 || !vehicle) {
455
+ if (!Array.isArray(fitPriceCosts) || fitPriceCosts.length === 0 || !equipment) {
455
456
  return null;
456
457
  }
457
- const vehicleMakeId = (_b = (_a = vehicle.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a);
458
- const vehicleModelId = (_d = (_c = vehicle.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c);
459
- const vehicleVarId = ((_f = (_e = vehicle.Var_Id) === null || _e === void 0 ? void 0 : _e.toString) === null || _f === void 0 ? void 0 : _f.call(_e)) || ((_h = (_g = vehicle.Variant_Id) === null || _g === void 0 ? void 0 : _g.toString) === null || _h === void 0 ? void 0 : _h.call(_g));
458
+ const equipmentMakeId = (_b = (_a = equipment.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a);
459
+ const equipmentModelId = (_d = (_c = equipment.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c);
460
+ const equipmentVarId = ((_f = (_e = equipment.Var_Id) === null || _e === void 0 ? void 0 : _e.toString) === null || _f === void 0 ? void 0 : _f.call(_e)) || ((_h = (_g = equipment.Variant_Id) === null || _g === void 0 ? void 0 : _g.toString) === null || _h === void 0 ? void 0 : _h.call(_g));
460
461
  // Try Make + Model + Variant
461
- if (vehicleMakeId && vehicleModelId && vehicleVarId) {
462
+ if (equipmentMakeId && equipmentModelId && equipmentVarId) {
462
463
  const match = fitPriceCosts.find((fpc) => {
463
464
  if (!Array.isArray(fpc.Fit) || fpc.Fit.length === 0)
464
465
  return false;
465
466
  return fpc.Fit.some((fit) => {
466
467
  var _a, _b, _c, _d, _e, _f;
467
- return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === vehicleMakeId &&
468
- ((_d = (_c = fit.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c)) === vehicleModelId &&
469
- ((_f = (_e = fit.Var_Id) === null || _e === void 0 ? void 0 : _e.toString) === null || _f === void 0 ? void 0 : _f.call(_e)) === vehicleVarId;
468
+ return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === equipmentMakeId &&
469
+ ((_d = (_c = fit.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c)) === equipmentModelId &&
470
+ ((_f = (_e = fit.Var_Id) === null || _e === void 0 ? void 0 : _e.toString) === null || _f === void 0 ? void 0 : _f.call(_e)) === equipmentVarId;
470
471
  });
471
472
  });
472
473
  if (match)
473
474
  return match;
474
475
  }
475
476
  // Try Make + Model
476
- if (vehicleMakeId && vehicleModelId) {
477
+ if (equipmentMakeId && equipmentModelId) {
477
478
  const match = fitPriceCosts.find((fpc) => {
478
479
  if (!Array.isArray(fpc.Fit) || fpc.Fit.length === 0)
479
480
  return false;
480
481
  return fpc.Fit.some((fit) => {
481
482
  var _a, _b, _c, _d;
482
- return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === vehicleMakeId &&
483
- ((_d = (_c = fit.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c)) === vehicleModelId &&
483
+ return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === equipmentMakeId &&
484
+ ((_d = (_c = fit.Model_Id) === null || _c === void 0 ? void 0 : _c.toString) === null || _d === void 0 ? void 0 : _d.call(_c)) === equipmentModelId &&
484
485
  !fit.Var_Id;
485
486
  });
486
487
  });
@@ -488,13 +489,13 @@ function findMatchingFitPriceCost(fitPriceCosts, vehicle) {
488
489
  return match;
489
490
  }
490
491
  // Try Make only
491
- if (vehicleMakeId) {
492
+ if (equipmentMakeId) {
492
493
  const match = fitPriceCosts.find((fpc) => {
493
494
  if (!Array.isArray(fpc.Fit) || fpc.Fit.length === 0)
494
495
  return false;
495
496
  return fpc.Fit.some((fit) => {
496
497
  var _a, _b;
497
- return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === vehicleMakeId &&
498
+ return ((_b = (_a = fit.Make_Id) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) === equipmentMakeId &&
498
499
  !fit.Model_Id;
499
500
  });
500
501
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.5.28",
3
+ "version": "1.5.30",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",