mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 08:35:43 +00:00
feat: more currency support (#520)
* add multiple new currencies * add multiple new currencies * remove duplicate yen
This commit is contained in:
parent
371fc0a6af
commit
c5ae6b17f9
6 changed files with 103 additions and 123 deletions
BIN
backend/api
BIN
backend/api
Binary file not shown.
|
@ -511,6 +511,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
|
|||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
||||
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
|
@ -536,6 +538,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
|
|||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
||||
|
@ -607,7 +611,10 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
|
|||
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
|
||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
|
@ -131,24 +131,36 @@ const DefaultCurrency = CurrencyUsd
|
|||
|
||||
// Currency values.
|
||||
const (
|
||||
CurrencyUsd Currency = "usd"
|
||||
CurrencyAed Currency = "aed"
|
||||
CurrencyAud Currency = "aud"
|
||||
CurrencyBgn Currency = "bgn"
|
||||
CurrencyBrl Currency = "brl"
|
||||
CurrencyCad Currency = "cad"
|
||||
CurrencyChf Currency = "chf"
|
||||
CurrencyCny Currency = "cny"
|
||||
CurrencyCzk Currency = "czk"
|
||||
CurrencyDkk Currency = "dkk"
|
||||
CurrencyEur Currency = "eur"
|
||||
CurrencyGbp Currency = "gbp"
|
||||
CurrencyHkd Currency = "hkd"
|
||||
CurrencyIdr Currency = "idr"
|
||||
CurrencyInr Currency = "inr"
|
||||
CurrencyJpy Currency = "jpy"
|
||||
CurrencyZar Currency = "zar"
|
||||
CurrencyAud Currency = "aud"
|
||||
CurrencyKrw Currency = "krw"
|
||||
CurrencyMxn Currency = "mxn"
|
||||
CurrencyNok Currency = "nok"
|
||||
CurrencyNzd Currency = "nzd"
|
||||
CurrencySek Currency = "sek"
|
||||
CurrencyDkk Currency = "dkk"
|
||||
CurrencyInr Currency = "inr"
|
||||
CurrencyRmb Currency = "rmb"
|
||||
CurrencyBgn Currency = "bgn"
|
||||
CurrencyChf Currency = "chf"
|
||||
CurrencyPln Currency = "pln"
|
||||
CurrencyTry Currency = "try"
|
||||
CurrencyRmb Currency = "rmb"
|
||||
CurrencyRon Currency = "ron"
|
||||
CurrencyCzk Currency = "czk"
|
||||
CurrencyRub Currency = "rub"
|
||||
CurrencySar Currency = "sar"
|
||||
CurrencySek Currency = "sek"
|
||||
CurrencySgd Currency = "sgd"
|
||||
CurrencyThb Currency = "thb"
|
||||
CurrencyTry Currency = "try"
|
||||
CurrencyUsd Currency = "usd"
|
||||
CurrencyZar Currency = "zar"
|
||||
)
|
||||
|
||||
func (c Currency) String() string {
|
||||
|
@ -158,7 +170,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, CurrencyNok, CurrencyNzd, CurrencySek, CurrencyDkk, CurrencyInr, CurrencyRmb, CurrencyBgn, CurrencyChf, CurrencyPln, CurrencyTry, CurrencyRon, CurrencyCzk:
|
||||
case CurrencyAed, CurrencyAud, CurrencyBgn, CurrencyBrl, CurrencyCad, CurrencyChf, CurrencyCny, CurrencyCzk, CurrencyDkk, CurrencyEur, CurrencyGbp, CurrencyHkd, CurrencyIdr, CurrencyInr, CurrencyJpy, CurrencyKrw, CurrencyMxn, CurrencyNok, CurrencyNzd, CurrencyPln, CurrencyRmb, CurrencyRon, CurrencyRub, CurrencySar, CurrencySek, CurrencySgd, CurrencyThb, CurrencyTry, CurrencyUsd, CurrencyZar:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("group: invalid enum value for currency field: %q", c)
|
||||
|
|
|
@ -116,7 +116,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", "nok", "nzd", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"}, Default: "usd"},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"aed", "aud", "bgn", "brl", "cad", "chf", "cny", "czk", "dkk", "eur", "gbp", "hkd", "idr", "inr", "jpy", "krw", "mxn", "nok", "nzd", "pln", "rmb", "ron", "rub", "sar", "sek", "sgd", "thb", "try", "usd", "zar"}, Default: "usd"},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
|
|
|
@ -29,7 +29,37 @@ func (Group) Fields() []ent.Field {
|
|||
NotEmpty(),
|
||||
field.Enum("currency").
|
||||
Default("usd").
|
||||
Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "nzd", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"),
|
||||
Values(
|
||||
"aed",
|
||||
"aud",
|
||||
"bgn",
|
||||
"brl",
|
||||
"cad",
|
||||
"chf",
|
||||
"czk",
|
||||
"dkk",
|
||||
"eur",
|
||||
"gbp",
|
||||
"hkd",
|
||||
"idr",
|
||||
"inr",
|
||||
"jpy",
|
||||
"krw",
|
||||
"mxn",
|
||||
"nok",
|
||||
"nzd",
|
||||
"pln",
|
||||
"rmb",
|
||||
"ron",
|
||||
"rub",
|
||||
"sar",
|
||||
"sek",
|
||||
"sgd",
|
||||
"thb",
|
||||
"try",
|
||||
"usd",
|
||||
"zar",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +100,6 @@ func (g GroupMixin) Fields() []ent.Field {
|
|||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (g GroupMixin) Edges() []ent.Edge {
|
||||
|
|
|
@ -1,19 +1,30 @@
|
|||
export type Codes =
|
||||
| "AED"
|
||||
| "AUD"
|
||||
| "BGN"
|
||||
| "BRL"
|
||||
| "CAD"
|
||||
| "CHF"
|
||||
| "CZK"
|
||||
| "DKK"
|
||||
| "EUR"
|
||||
| "GBP"
|
||||
| "HKD"
|
||||
| "IDR"
|
||||
| "INR"
|
||||
| "JPY"
|
||||
| "KRW"
|
||||
| "MXN"
|
||||
| "NOK"
|
||||
| "NZD"
|
||||
| "PLN"
|
||||
| "RMB"
|
||||
| "RUB"
|
||||
| "RON"
|
||||
| "SAR"
|
||||
| "SEK"
|
||||
| "SGD"
|
||||
| "THB"
|
||||
| "TRY"
|
||||
| "USD"
|
||||
| "ZAR";
|
||||
|
@ -26,112 +37,33 @@ export type Currency = {
|
|||
};
|
||||
|
||||
export const currencies: Currency[] = [
|
||||
{
|
||||
code: "AUD",
|
||||
local: "en-AU",
|
||||
symbol: "$",
|
||||
name: "Australian Dollar",
|
||||
},
|
||||
{
|
||||
code: "GBP",
|
||||
local: "en-GB",
|
||||
symbol: "£",
|
||||
name: "British Pound",
|
||||
},
|
||||
{
|
||||
code: "RMB",
|
||||
local: "zh-CN",
|
||||
symbol: "¥",
|
||||
name: "Chinese Yuan",
|
||||
},
|
||||
{
|
||||
code: "DKK",
|
||||
local: "da-DK",
|
||||
symbol: "kr",
|
||||
name: "Danish Krone",
|
||||
},
|
||||
{
|
||||
code: "EUR",
|
||||
local: "de-DE",
|
||||
symbol: "€",
|
||||
name: "Euro",
|
||||
},
|
||||
{
|
||||
code: "INR",
|
||||
local: "en-IN",
|
||||
symbol: "₹",
|
||||
name: "Indian Rupee",
|
||||
},
|
||||
{
|
||||
code: "JPY",
|
||||
local: "ja-JP",
|
||||
symbol: "¥",
|
||||
name: "Japanese Yen",
|
||||
},
|
||||
{
|
||||
code: "NOK",
|
||||
local: "nb-NO",
|
||||
symbol: "kr",
|
||||
name: "Norwegian Krone",
|
||||
},
|
||||
{
|
||||
code: "NZD",
|
||||
local: "en-NZ",
|
||||
symbol: "NZ$",
|
||||
name: "New Zealand Dollar",
|
||||
},
|
||||
{
|
||||
code: "PLN",
|
||||
local: "pl-PL",
|
||||
symbol: "zł",
|
||||
name: "Polish Zloty",
|
||||
},
|
||||
{
|
||||
code: "RON",
|
||||
local: "ro-RO",
|
||||
symbol: "lei",
|
||||
name: "Romanian Leu",
|
||||
},
|
||||
{
|
||||
code: "ZAR",
|
||||
local: "en-ZA",
|
||||
symbol: "R",
|
||||
name: "South African Rand",
|
||||
},
|
||||
{
|
||||
code: "SEK",
|
||||
local: "sv-SE",
|
||||
symbol: "kr",
|
||||
name: "Swedish Krona",
|
||||
},
|
||||
{
|
||||
code: "TRY",
|
||||
local: "tr-TR",
|
||||
symbol: "₺",
|
||||
name: "Turkish Lira",
|
||||
},
|
||||
{
|
||||
code: "USD",
|
||||
local: "en-US",
|
||||
symbol: "$",
|
||||
name: "US Dollar",
|
||||
},
|
||||
{
|
||||
code: "BGN",
|
||||
local: "bg-BG",
|
||||
symbol: "lv",
|
||||
name: "Bulgarian lev",
|
||||
},
|
||||
{
|
||||
code: "CHF",
|
||||
local: "de-CH",
|
||||
symbol: "chf",
|
||||
name: "Swiss Francs",
|
||||
},
|
||||
{
|
||||
code: "CZK",
|
||||
local: "cs-CZ",
|
||||
symbol: "Kč",
|
||||
name: "Czech Koruna",
|
||||
},
|
||||
{ code: "AED", local: "United Arab Emirates", symbol: "د.إ", name: "United Arab Emirates Dirham" },
|
||||
{ code: "AUD", local: "Australia", symbol: "A$", name: "Australian Dollar" },
|
||||
{ code: "BGN", local: "bg-BG", symbol: "lv", name: "Bulgarian lev" },
|
||||
{ code: "BRL", local: "Brazil", symbol: "R$", name: "Brazilian Real" },
|
||||
{ code: "CAD", local: "Canada", symbol: "C$", name: "Canadian Dollar" },
|
||||
{ code: "CHF", local: "Switzerland", symbol: "CHF", name: "Swiss Franc" },
|
||||
{ code: "CZK", local: "cs-CZ", symbol: "Kč", name: "Czech Koruna" },
|
||||
{ code: "DKK", local: "da-DK", symbol: "kr", name: "Danish Krone" },
|
||||
{ code: "EUR", local: "Eurozone", symbol: "€", name: "Euro" },
|
||||
{ code: "GBP", local: "United Kingdom", symbol: "£", name: "British Pound Sterling" },
|
||||
{ code: "HKD", local: "Hong Kong", symbol: "HK$", name: "Hong Kong Dollar" },
|
||||
{ code: "IDR", local: "Indonesia", symbol: "Rp", name: "Indonesian Rupiah" },
|
||||
{ code: "INR", local: "India", symbol: "₹", name: "Indian Rupee" },
|
||||
{ code: "JPY", local: "Japan", symbol: "¥", name: "Japanese Yen" },
|
||||
{ code: "KRW", local: "South Korea", symbol: "₩", name: "South Korean Won" },
|
||||
{ code: "MXN", local: "Mexico", symbol: "Mex$", name: "Mexican Peso" },
|
||||
{ code: "NOK", local: "Norway", symbol: "kr", name: "Norwegian Krone" },
|
||||
{ code: "NZD", local: "New Zealand", symbol: "NZ$", name: "New Zealand Dollar" },
|
||||
{ code: "PLN", local: "Poland", symbol: "zł", name: "Polish Zloty" },
|
||||
{ code: "RMB", local: "zh-CN", symbol: "¥", name: "Chinese Yuan" },
|
||||
{ code: "RON", local: "ro-RO", symbol: "lei", name: "Romanian Leu" },
|
||||
{ code: "RUB", local: "Russia", symbol: "₽", name: "Russian Ruble" },
|
||||
{ code: "SAR", local: "Saudi Arabia", symbol: "﷼", name: "Saudi Riyal" },
|
||||
{ code: "SEK", local: "Sweden", symbol: "kr", name: "Swedish Krona" },
|
||||
{ code: "SGD", local: "Singapore", symbol: "S$", name: "Singapore Dollar" },
|
||||
{ code: "THB", local: "Thailand", symbol: "฿", name: "Thai Baht" },
|
||||
{ code: "TRY", local: "Turkey", symbol: "₺", name: "Turkish Lira" },
|
||||
{ code: "USD", local: "United States", symbol: "$", name: "United States Dollar" },
|
||||
{ code: "ZAR", local: "South Africa", symbol: "R", name: "South African Rand" },
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue