Skip to content

Allow Unit to be set to empty - #163

Open
Bouni wants to merge 2 commits into
kittendevv:mainfrom
Bouni:fix-154
Open

Bouni wants to merge 2 commits into
kittendevv:mainfrom
Bouni:fix-154

Conversation

@Bouni

@Bouni Bouni commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Allow products without a unit

Closes #154

Problem

A product's unit couldn't be cleared:

  • The backend replaced an empty unit with "piece" when creating, updating and reading products.
  • The edit form sent undefined when the unit was cleared, so the backend kept the old value.

Changes

  • backend/src/controllers/products.ts: removed the "piece" fallback. An empty unit is stored as NULL and returned as undefined.
  • frontend/src/routes/products/[id]/edit/+page.server.ts: the form now sends the empty unit so the backend clears it.
  • frontend/src/lib/components/InvoiceEditor.svelte: picking a product with no unit for an invoice line now clears that line's unit instead of keeping the previous one.

Behaviour change

New products with no unit selected now have no unit; they no longer default to piece. Existing products are not changed.

Testing

  • Clear the unit of an existing product → it's saved as empty and shown as -
  • Create a product without a unit → no unit is stored
  • Add a product without a unit to an invoice → the line's unit is empty and the PDF has no unit column (unless another line has a unit)

🤖 Generated with Claude Code

Bouni and others added 2 commits October 9, 2026 09:28
Stop defaulting an empty unit to 'piece' in the products controller,
send the cleared unit from the edit form so it actually gets removed,
and don't carry over a stale unit when selecting a product without one
in the invoice editor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add default empty unit in product form

1 participant