@metron-labs/quote-react 0.1.14 → 0.1.16
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.
- package/LICENSE +31 -31
- package/README.md +222 -222
- package/dist/app/stages/BasketStage.js +78 -9
- package/dist/app/stages/ScheduleResultsStage.d.ts +1 -1
- package/dist/app/stages/ScheduleResultsStage.js +87 -30
- package/dist/embed/quote.js +6719 -6719
- package/dist/lib/boq/toCartItem.js +6 -1
- package/dist/lib/cart/CartContext.js +10 -1
- package/dist/lib/productImage.js +19 -19
- package/dist/styles.css +6708 -6708
- package/dist/util/exportScheduleExcel.js +1 -4
- package/dist/util/pricing.js +5 -17
- package/package.json +53 -53
|
@@ -95,10 +95,7 @@ export async function exportScheduleExcel(rows) {
|
|
|
95
95
|
totalRow[0] = "Estimated total";
|
|
96
96
|
totalRow[TOTAL_COL] = grandTotal;
|
|
97
97
|
wsData.push(totalRow);
|
|
98
|
-
wsData.push([
|
|
99
|
-
"DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",
|
|
100
|
-
...Array(HEADER.length - 1).fill(null),
|
|
101
|
-
]);
|
|
98
|
+
wsData.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.", ...Array(HEADER.length - 1).fill(null)]);
|
|
102
99
|
const ws = XLSX.utils.aoa_to_sheet(wsData);
|
|
103
100
|
ws["!cols"] = [
|
|
104
101
|
{ wch: 12 },
|
package/dist/util/pricing.js
CHANGED
|
@@ -116,9 +116,7 @@ export function getPricingBreakdown(item, options) {
|
|
|
116
116
|
const requestedUnit = canonicalUnit(item.unit) || "-";
|
|
117
117
|
const sellUnit = canonicalUnit(item.saleUnit ?? item.salesUnitSizeUom ?? item.uoi ?? item.salesUomNormalised) || "-";
|
|
118
118
|
const salesUnitSize = item.saleUnitQuantity ?? item.salesUnitSize ?? item.uoiCount ?? 1;
|
|
119
|
-
const wasteFactor = options?.wasteFactorEnabled === false
|
|
120
|
-
? 0
|
|
121
|
-
: (options?.wasteFactorOverride ?? item.wasteFactorOverride ?? item.wasteFactorDefault ?? 0);
|
|
119
|
+
const wasteFactor = options?.wasteFactorEnabled === false ? 0 : (options?.wasteFactorOverride ?? item.wasteFactorOverride ?? item.wasteFactorDefault ?? 0);
|
|
122
120
|
const hasOverride = item.sellUnitsOverride != null && Number.isFinite(item.sellUnitsOverride) && item.sellUnitsOverride > 0;
|
|
123
121
|
const overriddenSellUnits = hasOverride ? (item.sellUnitsOverride ?? null) : null;
|
|
124
122
|
const review = (reason) => ({
|
|
@@ -143,9 +141,7 @@ export function getPricingBreakdown(item, options) {
|
|
|
143
141
|
const wasteMultiplier = 1 + wasteFactor;
|
|
144
142
|
const descriptionCoverage = coverageFromDescription(item, requestedUnit, sellUnit);
|
|
145
143
|
const conversion = item.unitConversions?.find((entry) => sameUnit(entry.requestUom, requestedUnit));
|
|
146
|
-
const hasStructuredRoute = !!item.saleUnit && (sameUnit(requestedUnit, sellUnit) ||
|
|
147
|
-
!!conversion ||
|
|
148
|
-
(sameUnit(requestedUnit, "each") && !packUnits.has(sellUnit)));
|
|
144
|
+
const hasStructuredRoute = !!item.saleUnit && (sameUnit(requestedUnit, sellUnit) || !!conversion || (sameUnit(requestedUnit, "each") && !packUnits.has(sellUnit)));
|
|
149
145
|
// A partial structured conversion must not hide a valid legacy/LLM conversion.
|
|
150
146
|
if (hasStructuredRoute) {
|
|
151
147
|
if (sameUnit(requestedUnit, sellUnit)) {
|
|
@@ -161,9 +157,7 @@ export function getPricingBreakdown(item, options) {
|
|
|
161
157
|
// that reciprocal relationship in the form a merchant expects to read.
|
|
162
158
|
const itemsPerRequestedUnit = 1 / conversion.quantityPerSaleUnit;
|
|
163
159
|
const roundedItemsPerRequestedUnit = Math.round(itemsPerRequestedUnit);
|
|
164
|
-
const isWholePackRelationship = sameUnit(sellUnit, "each") &&
|
|
165
|
-
conversion.quantityPerSaleUnit < 1 &&
|
|
166
|
-
Math.abs(itemsPerRequestedUnit - roundedItemsPerRequestedUnit) < 1e-9;
|
|
160
|
+
const isWholePackRelationship = sameUnit(sellUnit, "each") && conversion.quantityPerSaleUnit < 1 && Math.abs(itemsPerRequestedUnit - roundedItemsPerRequestedUnit) < 1e-9;
|
|
167
161
|
calculation = isWholePackRelationship
|
|
168
162
|
? `${requestedAmount} ${requestedUnit}${wasteFactor > 0 ? ` x ${wasteMultiplier}` : ""} x ${roundedItemsPerRequestedUnit} per ${requestedUnit}`
|
|
169
163
|
: `${requestedAmount} ${requestedUnit}${wasteFactor > 0 ? ` x ${wasteMultiplier}` : ""} / ${conversion.quantityPerSaleUnit} ${requestedUnit} per ${sellUnit}`;
|
|
@@ -177,18 +171,12 @@ export function getPricingBreakdown(item, options) {
|
|
|
177
171
|
else if (sameUnit(requestedUnit, sellUnit) && salesUnitSize > 0) {
|
|
178
172
|
rawSellUnits = (requestedAmount * wasteMultiplier) / salesUnitSize;
|
|
179
173
|
costingMode = "direct";
|
|
180
|
-
calculation =
|
|
181
|
-
wasteFactor > 0
|
|
182
|
-
? `${requestedAmount} ${requestedUnit} x ${wasteMultiplier} / ${salesUnitSize} ${sellUnit} per sell unit`
|
|
183
|
-
: `${requestedAmount} ${requestedUnit} / ${salesUnitSize} ${sellUnit} per sell unit`;
|
|
174
|
+
calculation = wasteFactor > 0 ? `${requestedAmount} ${requestedUnit} x ${wasteMultiplier} / ${salesUnitSize} ${sellUnit} per sell unit` : `${requestedAmount} ${requestedUnit} / ${salesUnitSize} ${sellUnit} per sell unit`;
|
|
184
175
|
}
|
|
185
176
|
else if (sameUnit(requestedUnit, "each") && salesUnitSize > 0 && discreteSellUnits.has(sellUnit)) {
|
|
186
177
|
rawSellUnits = (requestedAmount * wasteMultiplier) / salesUnitSize;
|
|
187
178
|
costingMode = "derived";
|
|
188
|
-
calculation =
|
|
189
|
-
wasteFactor > 0
|
|
190
|
-
? `${requestedAmount} each x ${wasteMultiplier} / ${salesUnitSize} each per ${sellUnit}`
|
|
191
|
-
: `${requestedAmount} each / ${salesUnitSize} each per ${sellUnit}`;
|
|
179
|
+
calculation = wasteFactor > 0 ? `${requestedAmount} each x ${wasteMultiplier} / ${salesUnitSize} each per ${sellUnit}` : `${requestedAmount} each / ${salesUnitSize} each per ${sellUnit}`;
|
|
192
180
|
}
|
|
193
181
|
else if (packItemsForRequestedUnit(item, requestedUnit) != null && salesUnitSize > 0) {
|
|
194
182
|
const itemsPerRequestedPack = packItemsForRequestedUnit(item, requestedUnit) ?? 0;
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@metron-labs/quote-react",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Metron Labs quote and estimating calculator components for React",
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"*.css"
|
|
8
|
-
],
|
|
9
|
-
"main": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./styles.css": "./dist/styles.css",
|
|
17
|
-
"./*": {
|
|
18
|
-
"types": "./dist/*.d.ts",
|
|
19
|
-
"default": "./dist/*.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
|
-
"publishConfig": {
|
|
26
|
-
"access": "restricted"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "
|
|
30
|
-
"typecheck": "tsc --noEmit",
|
|
31
|
-
"test": "vitest run",
|
|
32
|
-
"prepublishOnly": "npm run typecheck && npm run build",
|
|
33
|
-
"check:embed": "node scripts/checkEmbed.mjs"
|
|
34
|
-
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"react": "^18.3.0 || ^19.0.0",
|
|
37
|
-
"react-dom": "^18.3.0 || ^19.0.0"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"xlsx": "^0.18.5"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@types/node": "^20",
|
|
44
|
-
"@types/react": "^19",
|
|
45
|
-
"@types/react-dom": "^19",
|
|
46
|
-
"esbuild": "^0.28.2",
|
|
47
|
-
"react": "19.2.3",
|
|
48
|
-
"react-dom": "19.2.3",
|
|
49
|
-
"tsx": "^4",
|
|
50
|
-
"typescript": "^5",
|
|
51
|
-
"vitest": "^3"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@metron-labs/quote-react",
|
|
3
|
+
"version": "0.1.16",
|
|
4
|
+
"description": "Metron Labs quote and estimating calculator components for React",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.css"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./styles.css": "./dist/styles.css",
|
|
17
|
+
"./*": {
|
|
18
|
+
"types": "./dist/*.d.ts",
|
|
19
|
+
"default": "./dist/*.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "restricted"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && node scripts/copyStatic.mjs && node scripts/buildEmbed.mjs",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"prepublishOnly": "npm run typecheck && npm run build",
|
|
33
|
+
"check:embed": "node scripts/checkEmbed.mjs"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
37
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"xlsx": "^0.18.5"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20",
|
|
44
|
+
"@types/react": "^19",
|
|
45
|
+
"@types/react-dom": "^19",
|
|
46
|
+
"esbuild": "^0.28.2",
|
|
47
|
+
"react": "19.2.3",
|
|
48
|
+
"react-dom": "19.2.3",
|
|
49
|
+
"tsx": "^4",
|
|
50
|
+
"typescript": "^5",
|
|
51
|
+
"vitest": "^3"
|
|
52
|
+
}
|
|
53
|
+
}
|