@roomwise/calc-engine 0.7.0 → 0.8.0

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/README.md CHANGED
@@ -47,7 +47,7 @@ Lines are produced in this order: base cost, object rules (by `sortOrder`), mate
47
47
  - Base cost: `OBJECT` rules with `baseComponent: true`, one `BASE` line each. Only in `FULL`; a line that is `OK` with a zero amount is left out.
48
48
  - Object rules: the other `OBJECT` level rules, one line each.
49
49
  - Materials: for every room selection with a product, the `MATERIAL_TYPE` rule for the category and the product's material type is used if one exists, otherwise the `CATEGORY` rule. Without either, the line is `NOT_CALCULATED` (`RULE_NOT_FOUND`). Unknown or unavailable products give `UNAVAILABLE`. Each line carries [components](#line-components).
50
- - Engineering and additional: package items marked `includedInBase` become `INCLUDED` lines with a zero amount, and are skipped in `PARTIAL`. Options are priced by unit (`PIECE`, `ROOM_SQM`, `ROOM`, `PROJECT`). An option has exactly one price source: `priceCents` with no `priceCoefficientKeys`, or `priceCents: null` with keys, in which case the unit price is the sum of those coefficients in dollars (`PricingDataSchema` rejects both and neither; read the price from the line's `unitPriceCents`). A missing coefficient gives an `ERROR` line (`UNKNOWN_COEFFICIENT`). An option whose `scopes` do not include the configuration scope is `UNAVAILABLE` with `OPTION_SCOPE_NOT_ALLOWED`.
50
+ - Engineering and additional: package items marked `includedInBase` become `INCLUDED` lines with a zero amount. In `PARTIAL` no package items are priced at all; the section holds only options. Options are priced by unit (`PIECE`, `ROOM_SQM`, `ROOM`, `PROJECT`). An option has exactly one price source: `priceCents` with no `priceCoefficientKeys`, or `priceCents: null` with keys, in which case the unit price is the sum of those coefficients in dollars (`PricingDataSchema` rejects both and neither; read the price from the line's `unitPriceCents`). A missing coefficient gives an `ERROR` line (`UNKNOWN_COEFFICIENT`). An option whose `scopes` do not include the configuration scope is `UNAVAILABLE` with `OPTION_SCOPE_NOT_ALLOWED`.
51
51
 
52
52
  Result fields:
53
53
 
@@ -193,7 +193,7 @@ Every schema is a zod schema with an inferred type of the same name without the
193
193
  | `totalAreaSqm` | required | `null` |
194
194
  | `BASE` section | `OBJECT` rules with `baseComponent: true`, one line each | none |
195
195
  | Material lines | `MATERIAL` component only | `MATERIAL`, `LABOR` and `PREP` components |
196
- | Package items with `includedInBase` | `INCLUDED` lines | skipped |
196
+ | Engineering package items | priced, `INCLUDED` with `includedInBase` | none |
197
197
  | `totalArea` variable | `totalAreaSqm` | `roomsFloorArea` |
198
198
  | Area warnings | `ROOMS_AREA_EXCEEDS_TOTAL`, `ROOMS_AREA_BELOW_TOTAL` | none |
199
199
 
package/dist/index.cjs CHANGED
@@ -322,7 +322,9 @@ function packageLine(configuration, item) {
322
322
  }, item.priceCents / 100 * quantity);
323
323
  }
324
324
  function engineeringLines(configuration, data) {
325
- return [...(configuration.scope === "PARTIAL" ? data.packageItems.filter((item) => !item.includedInBase) : data.packageItems).map((item) => packageLine(configuration, item)), ...optionLines(configuration, data, "ENGINEERING")];
325
+ const options = optionLines(configuration, data, "ENGINEERING");
326
+ if (configuration.scope === "PARTIAL") return options;
327
+ return [...data.packageItems.map((item) => packageLine(configuration, item)), ...options];
326
328
  }
327
329
  //#endregion
328
330
  //#region src/formula/language.ts
package/dist/index.d.cts CHANGED
@@ -29,10 +29,10 @@ export declare const RateSourceSchema: z.ZodEnum<{
29
29
  }>;
30
30
  export type RateSource = z.infer<typeof RateSourceSchema>;
31
31
  export declare const SurfaceKindSchema: z.ZodEnum<{
32
- NONE: "NONE";
33
32
  FLOOR: "FLOOR";
34
33
  WALLS: "WALLS";
35
34
  CEILING: "CEILING";
35
+ NONE: "NONE";
36
36
  }>;
37
37
  export type SurfaceKind = z.infer<typeof SurfaceKindSchema>;
38
38
  export declare const ProductUnitSchema: z.ZodEnum<{
@@ -488,10 +488,10 @@ export declare const PricingCategorySchema: z.ZodObject<{
488
488
  id: z.ZodString;
489
489
  wastePercent: z.ZodNumber;
490
490
  surface: z.ZodEnum<{
491
- NONE: "NONE";
492
491
  FLOOR: "FLOOR";
493
492
  WALLS: "WALLS";
494
493
  CEILING: "CEILING";
494
+ NONE: "NONE";
495
495
  }>;
496
496
  requiresPutty: z.ZodDefault<z.ZodBoolean>;
497
497
  }, z.core.$strip>;
@@ -622,10 +622,10 @@ export declare const PricingDataSchema: z.ZodObject<{
622
622
  id: z.ZodString;
623
623
  wastePercent: z.ZodNumber;
624
624
  surface: z.ZodEnum<{
625
- NONE: "NONE";
626
625
  FLOOR: "FLOOR";
627
626
  WALLS: "WALLS";
628
627
  CEILING: "CEILING";
628
+ NONE: "NONE";
629
629
  }>;
630
630
  requiresPutty: z.ZodDefault<z.ZodBoolean>;
631
631
  }, z.core.$strip>>;
package/dist/index.d.ts CHANGED
@@ -29,10 +29,10 @@ export declare const RateSourceSchema: z.ZodEnum<{
29
29
  }>;
30
30
  export type RateSource = z.infer<typeof RateSourceSchema>;
31
31
  export declare const SurfaceKindSchema: z.ZodEnum<{
32
- NONE: "NONE";
33
32
  FLOOR: "FLOOR";
34
33
  WALLS: "WALLS";
35
34
  CEILING: "CEILING";
35
+ NONE: "NONE";
36
36
  }>;
37
37
  export type SurfaceKind = z.infer<typeof SurfaceKindSchema>;
38
38
  export declare const ProductUnitSchema: z.ZodEnum<{
@@ -488,10 +488,10 @@ export declare const PricingCategorySchema: z.ZodObject<{
488
488
  id: z.ZodString;
489
489
  wastePercent: z.ZodNumber;
490
490
  surface: z.ZodEnum<{
491
- NONE: "NONE";
492
491
  FLOOR: "FLOOR";
493
492
  WALLS: "WALLS";
494
493
  CEILING: "CEILING";
494
+ NONE: "NONE";
495
495
  }>;
496
496
  requiresPutty: z.ZodDefault<z.ZodBoolean>;
497
497
  }, z.core.$strip>;
@@ -622,10 +622,10 @@ export declare const PricingDataSchema: z.ZodObject<{
622
622
  id: z.ZodString;
623
623
  wastePercent: z.ZodNumber;
624
624
  surface: z.ZodEnum<{
625
- NONE: "NONE";
626
625
  FLOOR: "FLOOR";
627
626
  WALLS: "WALLS";
628
627
  CEILING: "CEILING";
628
+ NONE: "NONE";
629
629
  }>;
630
630
  requiresPutty: z.ZodDefault<z.ZodBoolean>;
631
631
  }, z.core.$strip>>;
package/dist/index.js CHANGED
@@ -297,7 +297,9 @@ function packageLine(configuration, item) {
297
297
  }, item.priceCents / 100 * quantity);
298
298
  }
299
299
  function engineeringLines(configuration, data) {
300
- return [...(configuration.scope === "PARTIAL" ? data.packageItems.filter((item) => !item.includedInBase) : data.packageItems).map((item) => packageLine(configuration, item)), ...optionLines(configuration, data, "ENGINEERING")];
300
+ const options = optionLines(configuration, data, "ENGINEERING");
301
+ if (configuration.scope === "PARTIAL") return options;
302
+ return [...data.packageItems.map((item) => packageLine(configuration, item)), ...options];
301
303
  }
302
304
  //#endregion
303
305
  //#region src/formula/language.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomwise/calc-engine",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",