@metron-labs/quote-react 0.1.70 → 0.1.71

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.
@@ -12,7 +12,9 @@ export interface PricingBreakdown {
12
12
  costingMode: "direct" | "derived" | "review";
13
13
  }
14
14
  export declare function getCartSubtotal(items: CartItem[], options?: Parameters<typeof getPricingBreakdown>[1]): number | null;
15
- export declare function getPricingBreakdown(item: CartItem, options?: {
15
+ export declare function getPricingBreakdown(item: CartItem, options?: Parameters<typeof calculateBreakdown>[1]): PricingBreakdown;
16
+ declare function calculateBreakdown(item: CartItem, options?: {
16
17
  wasteFactorEnabled?: boolean;
17
18
  wasteFactorOverride?: number | null;
18
19
  }): PricingBreakdown;
20
+ export {};
@@ -136,6 +136,14 @@ export function getCartSubtotal(items, options) {
136
136
  return totals.some((total) => total == null) ? null : totals.reduce((sum, total) => sum + (total ?? 0), 0);
137
137
  }
138
138
  export function getPricingBreakdown(item, options) {
139
+ const pricing = calculateBreakdown(item, options);
140
+ // An aggregate "Bulk Bag (800kg)" is sold per bag, but "10 tonnes -> 13 bags" reads like small
141
+ // bags. Label only; a request already in bags keeps "bag" so it still matches the sell unit.
142
+ return pricing.sellUnit === "bag" && pricing.requestedUnit !== "bag" && /\bbulk bag\b/i.test(item.description)
143
+ ? { ...pricing, sellUnit: "bulk bag" }
144
+ : pricing;
145
+ }
146
+ function calculateBreakdown(item, options) {
139
147
  const requestedAmount = item.qty;
140
148
  const sellUnit = canonicalUnit(item.saleUnit ?? item.salesUnitSizeUom ?? item.uoi ?? item.salesUomNormalised) || "-";
141
149
  // A counted request such as "100 concrete blocks" may have a missing source
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "@metron-labs/quote-react",
3
- "version": "0.1.70",
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
- }
1
+ {
2
+ "name": "@metron-labs/quote-react",
3
+ "version": "0.1.71",
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
+ }