mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
feat: add currencies (NOK, SEK, DKK) (#128)
This commit is contained in:
parent
592d4eda55
commit
b6b2a2d889
4 changed files with 25 additions and 4 deletions
|
@ -126,6 +126,9 @@ const (
|
|||
CurrencyJpy Currency = "jpy"
|
||||
CurrencyZar Currency = "zar"
|
||||
CurrencyAud Currency = "aud"
|
||||
CurrencyNok Currency = "nok"
|
||||
CurrencySek Currency = "sek"
|
||||
CurrencyDkk Currency = "dkk"
|
||||
)
|
||||
|
||||
func (c Currency) String() string {
|
||||
|
@ -135,7 +138,7 @@ func (c Currency) String() string {
|
|||
// CurrencyValidator is a validator for the "currency" field enum values. It is called by the builders before save.
|
||||
func CurrencyValidator(c Currency) error {
|
||||
switch c {
|
||||
case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud:
|
||||
case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("group: invalid enum value for currency field: %q", c)
|
||||
|
|
|
@ -127,7 +127,7 @@ var (
|
|||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud"}, Default: "usd"},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk"}, Default: "usd"},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
|
|
|
@ -27,7 +27,7 @@ func (Group) Fields() []ent.Field {
|
|||
NotEmpty(),
|
||||
field.Enum("currency").
|
||||
Default("usd").
|
||||
Values("usd", "eur", "gbp", "jpy", "zar", "aud"),
|
||||
Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD";
|
||||
export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD" | "NOK" | "SEK" | "DKK";
|
||||
|
||||
export type Currency = {
|
||||
code: Codes;
|
||||
|
@ -44,4 +44,22 @@ export const currencies: Currency[] = [
|
|||
symbol: "$",
|
||||
name: "Australian Dollar",
|
||||
},
|
||||
{
|
||||
code: "NOK",
|
||||
local: "nb-NO",
|
||||
symbol: "kr",
|
||||
name: "Norwegian Krone",
|
||||
},
|
||||
{
|
||||
code: "SEK",
|
||||
local: "sv-SE",
|
||||
symbol: "kr",
|
||||
name: "Swedish Krona",
|
||||
},
|
||||
{
|
||||
code: "DKK",
|
||||
local: "da-DK",
|
||||
symbol: "kr",
|
||||
name: "Danish Krone",
|
||||
},
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue