# Unit conversions

Define how units convert into each other (1 kg = 1000 g) and use those factors to safely change a referenced material's unit — converting BOM quantities and unit cost instead of silently relabelling them.

import { Aside, Steps } from "@astrojs/starlight/components";
import DocUpdated from "~/components/DocUpdated.astro";

A **unit conversion** is a stored factor between two [units of measure](/features/raw-materials/units/) — `1 kg = 1000 g`, `1 m = 100 cm`. On its own a conversion changes nothing about how a BOM runs. Its job is to let Assemblified do the arithmetic for you the moment a unit genuinely changes, so a physical requirement is _preserved_ rather than mislabelled.

The headline use is **changing a referenced material's unit**. Without conversions, switching a material from `cm` to `m` would relabel `250 cm` as `250 m` — a 100× error that every downstream pick list, shortage list, and work order inherits. With a conversion in place, Assemblified rewrites `250 cm` as `2.5 m` instead.

## On this page

- What a conversion is, and where to manage them
- Linear-only: which conversions can drive quantity/cost math
- Changing a referenced material's unit — the three choices
- When no conversion exists — add one inline, or change unit only
- Bulk and import behavior
- Common gotchas

## Managing conversions

Conversions live under **Settings → Units**, on the **Units & conversions** page, in the **Unit conversions** section beneath the unit list.

<Steps>

1. Go to **Settings → Units**.
2. Scroll to **Unit conversions** and click **Add conversion**.
3. Pick the **from** unit, the **to** unit, and the **factor** (`1 from = factor × to`). For `g → kg` the factor is `0.001`.
4. Save. The conversion is now available everywhere a conversion is needed.

</Steps>

You can also add one without leaving the page you are on: the stock adjustment grid's **More actions** menu has **Units** and **Conversions** entries, and both the stock adjustment grid and the unit-change dialog offer to create the exact missing one inline.

While a conversion is saving, its unit pair and factor are disabled. You can still close the editor;
closing does not undo a save already sent. A failed save lets you correct the same values and retry.

If saving a conversion from the stock adjustment grid or a unit-change dialog fails, a red message stays
beside the form and your unit pair and factor remain. Read the message, adjust the values if needed,
then retry with **Save** or the existing confirmation button. For a connection error, check your
connection first. A successful retry makes the conversion available immediately; closing the editor
clears the message for its next opening.

If the conversion editor cannot open, close its error dialog to keep working. Your unsaved stock
adjustments or material edits remain in place.

Conversions are defined in **one** direction but usable in **both** — Assemblified inverts the factor automatically, so a single `g → kg` row also answers `kg → g`. You don't need to enter the reverse.

When the pair already exists, **Update existing** changes that conversion. If you entered the reverse
pair, the saved conversion keeps its original direction and uses the reciprocal factor. If the pair
can already be calculated through other conversions, **Add anyway** stores the factor you entered
as a direct conversion. **Cancel** on either warning returns to your form with its values intact.

## Linear conversions only

Internally a conversion is an affine map (`value_to = value_from × factor + offset`). But quantity and cost propagation can only use **linear** conversions — ones where `offset = 0`, `factor > 0`, and the factor is finite. A per-unit quantity or cost has no meaningful zero-point shift, so an offset (the kind a `°C → °F` conversion would need) is never applied to BOM math.

In practice every multiplicative conversion you'd define for materials — weight, length, volume, count — is linear and works. The restriction only excludes offset-based temperature-style conversions, which don't belong on a BOM quantity anyway.

## Changing a referenced material's unit

When you change the unit on a material that **isn't** used by any finished good or assembly BOM, the change saves immediately — there are no quantities to keep consistent.

When the material **is** used, the **Change unit of measure?** dialog asks how to apply the change before saving. It lists each affected material with its unit change and the conversion it would use, and offers:

| Choice                        | What it does                                                                                                                                                                                                    | Default |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| **Convert BOM quantities** | Every BOM quantity is recalculated by the conversion factor — `250 cm` becomes `2.5 m`, the physical requirement is preserved.                                                                               | On      |
| **Convert unit cost**         | Recalculates the per-unit cost for the new unit so total cost (`quantity × cost`) stays put. Only offered for materials whose cost you can edit — not Shopify-linked materials, whose cost is owned by Shopify. | Off     |
| **Change unit only**          | The display-only escape hatch: relabels the unit without touching any number.                                                                                                                                   | —       |

The math, for `cm → m` (factor `0.01`):

- **Quantity** — `new = old × factor`, so the amount consumed is unchanged.
- **Unit cost** (opt-in) — `new = old ÷ factor`, so the total cost is unchanged.

**Apply** commits the choice. Converting a unit also recomputes the stored costs of every finished good and assembly BOM that used the material, innermost first, so cost roll-ups stay correct after the change.

## When no conversion exists

If you pick a new unit and **no usable conversion exists** for the old → new pair, Assemblified can't safely convert. The dialog marks that row **Needs a conversion**, shows the warning _There is no conversion for these units_, and the only way forward is one of:

- **Add the conversion inline.** A button reading **Add kg to g** (with your own two units in it) opens the conversion editor locked to exactly that pair. Save it and the dialog re-checks — the convert path unlocks immediately, no need to leave and come back.
- **Change unit only.** Fall back to the display-only relabel, accepting that you'll fix the numbers yourself.

<Aside type="caution">
    **Change unit only** is the one path that can reintroduce the 100×/1000× footgun. If you relabel `kg → g` without also multiplying the
    quantities by 1000, every BOM now reads grams where it means kilograms. Use it only when you genuinely want a cosmetic relabel — for
    a real unit change, add the conversion and convert.
</Aside>

## Bulk and import behavior

- **Bulk edit.** Tick the materials on the list, then **Material settings → Set unit** in the bulk bar. The same dialog opens for the whole selection: it groups the affected materials and shows one **Add … to …** button per distinct unit pair, so you resolve each missing conversion once rather than per material.
- **Import / non-interactive changes.** When a unit change arrives without a dialog choice — a CSV/XLSX import, or any non-interactive path — Assemblified applies **convert-else-fail**: it auto-converts every referenced material that has a usable conversion, and if _any_ referenced material lacks one, it rejects the whole change with no partial writes. A non-interactive path never silently relabels.

## Common gotchas

- **Conversions don't apply at execution time.** They fire only when a referenced material's unit _changes_. A quantity you type into a BOM is always taken at face value in the material's _current_ unit — there's no live conversion while you build a BOM. Keep BOM quantities in the same unit as the material. See [Units → where the symbol shows up](/features/raw-materials/units/#where-the-symbol-shows-up).
- **One direction is enough.** Define `g → kg` _or_ `kg → g`, not both — the inverse is automatic. Defining both is harmless but redundant.
- **Offsets are ignored for BOM math.** A conversion with a non-zero offset is treated as "no usable conversion" for unit changes, so the convert path stays blocked. This only affects offset-style (temperature) conversions.
- **Weight roll-ups use these too.** The [calculated weight](/features/raw-materials/weight/) on a finished good or assembly BOM converts mixed component weight units into one canonical unit using these same conversions. The five seeded weight units (`kg`/`g`/`mg`/`lb`/`oz`) all convert to `kg` out of the box; a custom weight unit needs a conversion before it can roll up.

## Where to next

- [Units of Measurement](/features/raw-materials/units/) — the unit field itself, the built-in list, and adding custom units.
- [Weight](/features/raw-materials/weight/) — the calculated weight roll-up on a finished good or assembly BOM, another consumer of these conversions.
- [Materials overview](/features/raw-materials/overview/) — back to the section root.

<DocUpdated date="2026-10-26" />