# Calculation

> A reference to a calculation, picked from the calculations of the relevant product.

Source: CBX documentation, version 3.x (released). Canonical page: https://docs.configbox.at/docs/technical/property-types/calculation. Last updated 2026-07-27.

---
A reference to a calculation, picked from the calculations of the relevant product.

**Storage kind:** `column` · **Column:** `int unsigned`, **nullable by default**

Use it for any field that points at a calculation — an answer's price calculation, a question's
maximum-value calculation, a shipping rule's cost. It extends [`join`](https://docs.configbox.at/docs/technical/property-types/join), so it is a join
with the extras this one case needs: a "no calculation" placeholder, product grouping, a link
through to the referenced calculation, and copy semantics that follow the calculation.

## Settings

| Setting | Meaning |
|---|---|
| `modelClass` / `modelMethod` | Where the pickable calculations come from |
| `propNameKey` / `propNameDisplay` | Key and label fields, as for a [`join`](https://docs.configbox.at/docs/technical/property-types/join) |
| `defaultlabel` | Placeholder — conventionally "No Calculation" |
| `groupby` | Group the options, typically by product |
| `dropdownOrdering` | Order of the option list |
| `showLinks` | Render a link through to the referenced calculation |
| `isPseudoJoin` | Suppress the SQL join |

It inherits everything else `join` accepts.

## Nullable by default

"No calculation assigned" is the normal state for most fields carrying one, so this type declares
`getDefaultNullable()` as `true` — the only type besides [`datetime`](https://docs.configbox.at/docs/technical/property-types/datetime) that defaults
nullable.

Several of these columns also have `ON DELETE SET NULL` foreign keys — `answers.calcmodel`,
`questions.calcmodel_id_max_val` — which makes NOT NULL impossible regardless of preference: the
database will write NULL into them when a calculation is deleted. Treat NULL as the normal absent
value and read it as "no calculation", never as an error.

## Copying follows the calculation

`copyCalculation()` runs during a record copy, so a copied record points at a **copy of** the
calculation rather than sharing the original. That is what keeps a duplicated product's pricing
independent — edit the copy's calculation and the original is untouched.

It is the same shape as `rule`'s `copyRule()` and `calculationOverride`'s `copyOverrides()`: a
reference that would otherwise alias shared state across a copy.

`copyCalculation()` honours `storeExternally`, writing the new reference to the foreign table when
the property lives there.

## Notes

It behaves as a `join` for query building — it extends the join type — but exists separately because
a calculation reference is a distinct thing to pick, order and link to. `showLinks` in particular
only makes sense here: it renders a link from the referencing form straight into the calculation
editor, which is how an operator gets from "this answer is priced somehow" to the formula.

@see join.md
@see calculationoverride.md — per-customer-group overrides of a reference like this
@see ../com_configbox_calculation_engine.md
@see ../../admin-guide/pricing/build-a-calculation.md — what the operator sees
