# Custom calculator brief

## Scope

- Visitor decision supported by the result: ...
- Input quantities and units: ...
- Formula source and approval owner: ...
- Limits, exceptions, and rounding rule: ...
- CRM, catalog, API, or form integrations: ...
- Personal data and genuinely necessary analytics events: ...
- No-JavaScript fallback: ...
- Ownership of source, tests, and documentation: ...
- Rule update and repeat acceptance process: ...

## Verified educational example

Each item uses 100 illustrative calculation units. A 10% discount applies starting at 10 items. This is not a commercial price or a development quote. The q > 10 bug was corrected to q >= 10.

```js
function quote(quantity,phase){if(!Number.isSafeInteger(quantity)||quantity<1||quantity>1000)throw Error('QUANTITY_RANGE');const unit=100;return quantity*unit*((phase==='before'?quantity>10:quantity>=10)?90:100)/100;}

const cases = [[9, 900], [10, 900], [11, 990]];
for (const [quantity, expected] of cases) {
  if (quote(quantity, "after") !== expected) throw Error("CALCULATION_FAILED");
}
for (const quantity of [0, -1, 1.5, 1001]) {
  let rejected = false;
  try { quote(quantity, "after"); } catch { rejected = true; }
  if (!rejected) throw Error("INVALID_QUANTITY_ACCEPTED");
}
```

Results: before the fix, two of three cases passed and one failed. After the fix, all three passed. Four invalid values were rejected. The form returned 1000 for quantity 10 before the fix and 900 afterwards.

The Reproleaf HTML audit in the downloadable JSON was run independently. It checks markup, rather than arithmetic. A production calculator additionally needs agreed precision, rounding, data freshness, server validation, and integration checks.
