Skip to content

Add shipping and customs fields to products - #158

Merged
kittendevv merged 4 commits into
kittendevv:mainfrom
Bouni:improve-products
Oct 7, 2026
Merged

kittendevv merged 4 commits into
kittendevv:mainfrom
Bouni:improve-products

Conversation

@Bouni

@Bouni Bouni commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Products can now store the data you need for shipping and customs paperwork: HS code, country of origin, dimensions and weight. Invoice items keep a copy of these values taken when the invoice is saved. That keeps issued invoices stable and lets API users build customs documents or shipping labels from an invoice.

Changes

Products

  • New optional fields:
    • hsCode: HS code
    • countryOfOrigin: ISO 3166-1 alpha-2, stored in uppercase
    • lengthMm, widthMm, heightMm: dimensions in mm
    • weightG: weight in g
  • How input is cleaned up:
    • Empty strings, invalid numbers and negative numbers are stored as NULL.
    • On update, sending null clears a field. Leaving a field out keeps its current value.
  • A new Shipping & Customs section on the product create, edit and detail pages. The products list and the invoice forms are unchanged.
  • New UI labels translated in all locales (de, en, es-ar, es-co, nl, pt-br, tr).

Invoice items

  • Each invoice item stores a copy of its product's shipping and customs values:
    • Creating an invoice or saving a draft copies the product's current values.
    • Editing an issued invoice (protection override) keeps the values the items already had, so issued invoices don't change.
    • Duplicating an invoice uses the current product values. If the product no longer exists, it keeps the original item's values.
  • GET /api/v1/invoices/:id returns all six fields on every item, as do the create, update and duplicate responses. Fields that aren't set are null.
  • Public share links do not include these fields.

Database

  • New nullable columns on products and invoice_items, added with addColumnIfMissing and no default value.
  • Existing products and invoices are not modified; their new fields are just empty or null.
  • Fresh installs get the products columns directly in the CREATE TABLE statements.

Testing

  • Create a product with all shipping fields → the detail page shows them
  • Edit the product and clear a field → the field is removed
  • Country code de is saved as DE, and negative or invalid numbers are ignored
  • Create an invoice with that product → the API returns the copied values on the item
  • Change the product, then edit the issued invoice → the item keeps the old values
  • Duplicate the invoice → the new draft has the current product values
  • An existing database migrates cleanly, and old invoices return null for the new fields

🤖 Generated with Claude Code

Bouni and others added 4 commits October 1, 2026 15:02
Products get optional HS code, country of origin (ISO 3166-1 alpha-2),
length, width and height in mm, and weight in g.

The columns are added with addColumnIfMissing and have no default, so
existing products keep their data and simply have the new fields
empty. Fresh installs get them in the CREATE TABLE statements.

Empty strings, invalid and negative numbers are stored as NULL, and the
country code is uppercased. Passing null on update clears a field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a "Shipping & Customs" section to the create, edit and detail pages
with HS code, country of origin, dimensions and weight. The products
list and invoice forms are unchanged; the fields only appear on the
product pages.

Empty inputs are sent as "" / null, so clearing a field on the edit
page removes the stored value. The country input only accepts two
letters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Invoice items now carry a snapshot of their product's HS code, country
of origin, dimensions and weight, and GET /api/v1/invoices/:id (as well
as the create, update and duplicate responses) always includes all six
fields, null when not set.

- Creating an invoice or saving a draft copies the product's current
  values onto each item
- Editing an issued invoice (protection override) keeps the values
  the items already had, so issued invoices stay unchanged
- Duplicating takes the current product values, falling back to the
  original item's values if the product no longer exists

The invoice_items columns are added with addColumnIfMissing and no
default, so existing invoices are untouched and return null for the
new fields. Public share links do not include them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Bouni

Bouni commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@kittendevv anything I can do for you to get this merged?

@kittendevv

Copy link
Copy Markdown
Owner

Was in the proccess of merging this but i forgor mb

@kittendevv
kittendevv merged commit e6327fe into kittendevv:main Oct 7, 2026
4 of 5 checks passed
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.

2 participants