Documentation
¶
Overview ¶
Package currency is the currency entity domain: the reference table of the currencies a store accepts, addressable by ISO-4217 Code. It is a global (default-namespace) reference set — the single source the store/settings and product/price currency pickers read, replacing a hardcoded array. The bare value type (usd/eur/…) and its symbol/decimal conventions still live in models/types/currency; this entity carries the editable, seedable rows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Seed ¶
Seed inserts the common currencies into db (which must be the default-namespace reference store). IDEMPOTENT + NON-DESTRUCTIVE: a currency whose code already exists is left untouched (admin edits are never clobbered); only missing codes are created. Returns the number created.
func SeedIfEmpty ¶
SeedIfEmpty seeds the reference currencies only when the table is empty — a cheap count query gates the per-row create, so it is safe to call on every bootstrap (mirrors catalogentry.SeedIfEmpty). Once any currency exists (seeded or admin-created) it never re-runs, so admin edits stay authoritative.
Types ¶
type Currency ¶
type Currency struct {
mixin.Model[Currency]
// Code is the lowercase ISO-4217 code (e.g. "usd"). Unique reference key.
Code string `json:"code"`
// Symbol is the display glyph (e.g. "$", "€", "¥").
Symbol string `json:"symbol"`
// Name is the human-facing currency name (e.g. "US Dollar").
Name string `json:"name"`
// DecimalDigits is the number of minor-unit decimal places (2 for usd, 0 for jpy).
DecimalDigits int `json:"decimalDigits"`
// IncludesTax marks prices in this currency as tax-inclusive.
IncludesTax bool `json:"includesTax"`
}
Currency is one accepted currency, keyed by its lowercase ISO-4217 Code (unique). DecimalDigits is the minor-unit exponent (2 for usd, 0 for jpy); IncludesTax marks currencies whose displayed prices are tax-inclusive.