@metron-labs/quote-react 0.1.72 → 0.1.74

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.
@@ -148,7 +148,11 @@ function calculateBreakdown(item, options) {
148
148
  const sellUnit = canonicalUnit(item.saleUnit ?? item.salesUnitSizeUom ?? item.uoi ?? item.salesUomNormalised) || "-";
149
149
  // A counted request such as "100 concrete blocks" may have a missing source
150
150
  // unit even though the selected product is sold as a discrete unit.
151
- const requestedUnit = canonicalUnit(item.unit) || (requestedAmount > 0 && discreteSellUnits.has(sellUnit) ? sellUnit : "-");
151
+ // "2000x Beaverscrews" has no unit either, but for a box, pack or tub with a known count, a
152
+ // pack's worth or more means items (2,000 screws), not 2,000 tubs.
153
+ const eachPerPack = item.unitConversions?.find((entry) => sameUnit(entry.requestUom, "each"))?.quantityPerSaleUnit;
154
+ const bareCountOfItems = !canonicalUnit(item.unit) && packUnits.has(sellUnit) && eachPerPack != null && eachPerPack > 1 && requestedAmount >= eachPerPack;
155
+ const requestedUnit = canonicalUnit(item.unit) || (bareCountOfItems ? "each" : requestedAmount > 0 && discreteSellUnits.has(sellUnit) ? sellUnit : "-");
152
156
  const salesUnitSize = item.saleUnitQuantity ?? item.salesUnitSize ?? item.uoiCount ?? 1;
153
157
  const wasteFactor = options?.wasteFactorEnabled === false ? 0 : (options?.wasteFactorOverride ?? item.wasteFactorOverride ?? item.wasteFactorDefault ?? 0);
154
158
  const hasOverride = item.sellUnitsOverride != null && Number.isFinite(item.sellUnitsOverride) && item.sellUnitsOverride > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metron-labs/quote-react",
3
- "version": "0.1.72",
3
+ "version": "0.1.74",
4
4
  "description": "Metron Labs quote and estimating calculator components for React",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": [