diff --git a/src/PowderCoating.Web/Helpers/HelpKnowledgeBase.cs b/src/PowderCoating.Web/Helpers/HelpKnowledgeBase.cs index 03f722d..2dc8421 100644 --- a/src/PowderCoating.Web/Helpers/HelpKnowledgeBase.cs +++ b/src/PowderCoating.Web/Helpers/HelpKnowledgeBase.cs @@ -1401,7 +1401,11 @@ public static class HelpKnowledgeBase Using in wizard: item wizard shows "Custom Formula Item" card if active templates exist → choose template → template diagram shown for reference → enter measurements → Calculate → verify result → continue to coatings/prep steps Formula variable names: snake_case, letters/digits/underscores only. Reserved variable: "rate" (pre-populated from Default Rate). NCalc syntax: +, -, *, /, %, Pow(b,e), Abs(x), Round(x,d), Max(a,b), Min(a,b), Sqrt(x) - Example formula (box, inches): 2*(l*w + l*h + w*h) / 144 * rate + Common formula patterns (all Fixed Rate, divide inches by 144 to get sqft): + - 6-sided box: fields l_in/w_in/h_in → 2*(l_in*w_in + l_in*h_in + w_in*h_in) / 144 * rate + - Cylinder: fields d_in/h_in → (3.14159 * d_in * h_in + 2 * 3.14159 * Pow(d_in/2, 2)) / 144 * rate + - Flat panel: fields l_in/w_in → l_in * w_in / 144 * rate + Walkthrough: first time opening Custom Formulas tab with no templates triggers a 7-step guided tour automatically; also accessible via "How it works" button Help article: Help → Custom Formula Item Templates """; diff --git a/src/PowderCoating.Web/Views/CompanySettings/Index.cshtml b/src/PowderCoating.Web/Views/CompanySettings/Index.cshtml index f9e02e1..92a32ce 100644 --- a/src/PowderCoating.Web/Views/CompanySettings/Index.cshtml +++ b/src/PowderCoating.Web/Views/CompanySettings/Index.cshtml @@ -2064,9 +2064,14 @@
@@ -2097,6 +2102,34 @@
No fields yet.
'; return; } + cfRenderVariablePills(); el.innerHTML = cfFields.map((f, i) => `Some items — roof curbs, electrical enclosures, welded frames — have prices that depend on + exact measurements rather than estimated surface area.
+A Formula Template lets you define a reusable calculation once in Company Settings. + When a staff member adds that item to a quote or job, they just fill in the measurements and the price + calculates automatically — no mental math, no spreadsheets.
+When you create a template, you choose how the formula result is used:
+| Mode | Formula produces… | How it’s priced |
|---|---|---|
| Fixed Rate | +A dollar amount | +Used directly as the item’s unit price. Best for items priced by a custom rate (e.g. $/sqft of surface). | +
| Surface Area | +Square footage | +Fed into the standard coating engine and priced using your operating cost rates — just like any other coated item. | +
Fields are the measurements your staff will fill in when they use the template. + Each field becomes an input box in the item wizard.
+| Variable name | length_in |
|---|---|
| Label | Length (inches) |
| Default | 24 |
| Variable name | width_in |
|---|---|
| Label | Width (inches) |
| Default | 12 |
length_in Bad: length in or 1length
+ The formula is a math expression using your field variable names plus the reserved
+ variable rate (pre-filled from the template’s Default Rate).
Example — flat panel price (inches → sqft → dollars):
+length_in * width_in / 144 * rate+
Supported operations:
++ - * / — basic mathPow(base, exp) — exponentsSqrt(x) — square rootRound(x, digits) — roundingAbs(x) — absolute valueMax(a,b) Min(a,b)rate is always available — you set it as the Default Rate on the template
+ and staff can override it per-use. Don’t create a field called rate.
+ Before saving, use the Run button to verify your formula evaluates correctly + using each field’s default value.
+If the formula has an error (typo, missing variable, bad syntax) the result will + show in red with a description of the problem. Fix it before saving.
` + }, + { + title: 'Example — 6-Sided Box', + icon: 'bi-box text-secondary', + html: ` +A roof curb or electrical enclosure can be priced by calculating its outer surface area.
+| Variable | Label | Default |
|---|---|---|
l_in | Length (in) | 24 |
w_in | Width (in) | 24 |
h_in | Height (in) | 12 |
2*(l_in*w_in + l_in*h_in + w_in*h_in) / 144 * rate+ What it does: Calculates total outer surface area of all 6 faces + in square inches, converts to square feet (÷144), multiplies by rate. +
+ + You can add a diagram image to the template — staff will see it in the wizard as a reference + while entering measurements. +
` + }, + { + title: 'Example — Cylinder', + icon: 'bi-vinyl text-secondary', + html: ` +Round parts like pipe ends or cylindrical housings use a slightly different formula.
+| Variable | Label | Default |
|---|---|---|
d_in | Diameter (in) | 12 |
h_in | Height (in) | 18 |
(3.14159 * d_in * h_in + 2 * 3.14159 * Pow(d_in/2, 2)) / 144 * rate+ What it does: Lateral surface area (circumference × height) + plus two circular end caps, converted to sqft, multiplied by rate. +