Add main currency code for groups feedback (#329)

Clarify group currency field description

Use default currency code instead of symbol

Hide currency symbol field when using a non-custom Currency

Run prettier

Update currency data

Update package-lock.json
This commit is contained in:
Peter Smit
2025-09-05 12:55:05 +02:00
parent da8473406e
commit 5fee0440c2
8 changed files with 958 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
POSTGRES_PRISMA_URL=postgresql://postgres:1234@localhost POSTGRES_PRISMA_URL=postgresql://postgres:1234@localhost
POSTGRES_URL_NON_POOLING=postgresql://postgres:1234@localhost POSTGRES_URL_NON_POOLING=postgresql://postgres:1234@localhost
NEXT_PUBLIC_DEFAULT_CURRENCY_SYMBOL="" NEXT_PUBLIC_DEFAULT_CURRENCY_CODE=""

View File

@@ -98,7 +98,8 @@
}, },
"CurrencyCodeField": { "CurrencyCodeField": {
"label": "Main currency", "label": "Main currency",
"description": "All amounts and balances will be in this currency. Changing this will NOT convert expenses already entered.", "createDescription": "All amounts and balances will be in this currency.",
"editDescription": "All amounts and balances will be in this currency. Changing this will NOT convert expenses already entered, except when the currency has different \"minor units\" than the current one (e.g. changing from US Dollar to Japanese Yen)",
"customOption": "Custom" "customOption": "Custom"
}, },
"Participants": { "Participants": {

120
package-lock.json generated
View File

@@ -5274,6 +5274,126 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/@next/swc-darwin-arm64": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.28.tgz",
"integrity": "sha512-kzGChl9setxYWpk3H6fTZXXPFFjg7urptLq5o5ZgYezCrqlemKttwMT5iFyx/p1e/JeglTwDFRtb923gTJ3R1w==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.28.tgz",
"integrity": "sha512-z6FXYHDJlFOzVEOiiJ/4NG8aLCeayZdcRSMjPDysW297Up6r22xw6Ea9AOwQqbNsth8JNgIK8EkWz2IDwaLQcw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.28.tgz",
"integrity": "sha512-9ARHLEQXhAilNJ7rgQX8xs9aH3yJSj888ssSjJLeldiZKR4D7N08MfMqljk77fAwZsWwsrp8ohHsMvurvv9liQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.28.tgz",
"integrity": "sha512-p6gvatI1nX41KCizEe6JkF0FS/cEEF0u23vKDpl+WhPe/fCTBeGkEBh7iW2cUM0rvquPVwPWdiUR6Ebr/kQWxQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.28.tgz",
"integrity": "sha512-nsiSnz2wO6GwMAX2o0iucONlVL7dNgKUqt/mDTATGO2NY59EO/ZKnKEr80BJFhuA5UC1KZOMblJHWZoqIJddpA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.28.tgz",
"integrity": "sha512-+IuGQKoI3abrXFqx7GtlvNOpeExUH1mTIqCrh1LGFf8DnlUcTmOOCApEnPJUSLrSbzOdsF2ho2KhnQoO0I1RDw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.28.tgz",
"integrity": "sha512-l61WZ3nevt4BAnGksUVFKy2uJP5DPz2E0Ma/Oklvo3sGj9sw3q7vBWONFRgz+ICiHpW5mV+mBrkB3XEubMrKaA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.28.tgz",
"integrity": "sha512-+Kcp1T3jHZnJ9v9VTJ/yf1t/xmtFAc/Sge4v7mVc1z+NYfYzisi8kJ9AsY8itbgq+WgEwMtOpiLLJsUy2qnXZw==",
"cpu": [
"ia32"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": { "node_modules/@next/swc-win32-x64-msvc": {
"version": "14.2.28", "version": "14.2.28",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.28.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.28.tgz",

View File

@@ -26,7 +26,12 @@ import {
import { ToastAction } from '@/components/ui/toast' import { ToastAction } from '@/components/ui/toast'
import { useToast } from '@/components/ui/use-toast' import { useToast } from '@/components/ui/use-toast'
import { useMediaQuery } from '@/lib/hooks' import { useMediaQuery } from '@/lib/hooks'
import { formatCurrency, formatDate, formatFileSize, getCurrencyFromGroup } from '@/lib/utils' import {
formatCurrency,
formatDate,
formatFileSize,
getCurrencyFromGroup,
} from '@/lib/utils'
import { trpc } from '@/trpc/client' import { trpc } from '@/trpc/client'
import { ChevronRight, FileQuestion, Loader2, Receipt } from 'lucide-react' import { ChevronRight, FileQuestion, Loader2, Receipt } from 'lucide-react'
import { useLocale, useTranslations } from 'next-intl' import { useLocale, useTranslations } from 'next-intl'

View File

@@ -72,7 +72,7 @@ export function GroupForm({
: { : {
name: '', name: '',
information: '', information: '',
currency: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY_SYMBOL || '', currencyCode: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY_CODE || 'USD', // TODO: If NEXT_PUBLIC_DEFAULT_CURRENCY_CODE, is not set, determine the default currency code based on locale
participants: [ participants: [
{ name: t('Participants.John') }, { name: t('Participants.John') },
{ name: t('Participants.Jane') }, { name: t('Participants.Jane') },
@@ -176,7 +176,11 @@ export function GroupForm({
isLoading={false} isLoading={false}
/> />
<FormDescription> <FormDescription>
{t('CurrencyCodeField.description')} {t(
group
? 'CurrencyCodeField.editDescription'
: 'CurrencyCodeField.createDescription',
)}
</FormDescription> </FormDescription>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
@@ -187,13 +191,12 @@ export function GroupForm({
control={form.control} control={form.control}
name="currency" name="currency"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem hidden={!!form.watch('currencyCode')?.length}>
<FormLabel>{t('CurrencyField.label')}</FormLabel> <FormLabel>{t('CurrencyField.label')}</FormLabel>
<FormControl> <FormControl>
<Input <Input
className="text-base" className="text-base"
placeholder={t('CurrencyField.placeholder')} placeholder={t('CurrencyField.placeholder')}
disabled={!!form.watch('currencyCode')?.length}
max={5} max={5}
{...field} {...field}
/> />

View File

@@ -1903,6 +1903,278 @@
"decimal_digits": 2 "decimal_digits": 2
} }
}, },
"ja-JP": {
"USD": {
"name": "米ドル",
"symbol_native": "$",
"symbol": "$",
"code": "USD",
"name_plural": "US dollars",
"rounding": 0,
"decimal_digits": 2
},
"EUR": {
"name": "ユーロ",
"symbol_native": "€",
"symbol": "€",
"code": "EUR",
"name_plural": "euros",
"rounding": 0,
"decimal_digits": 2
},
"JPY": {
"name": "日本円",
"symbol_native": "¥",
"symbol": "¥",
"code": "JPY",
"name_plural": "Japanese yen",
"rounding": 0,
"decimal_digits": 0
},
"BGN": {
"name": "ブルガリア 新レフ",
"symbol_native": "лв.",
"symbol": "BGN",
"code": "BGN",
"name_plural": "Bulgarian leva",
"rounding": 0,
"decimal_digits": 2
},
"CZK": {
"name": "チェコ コルナ",
"symbol_native": "Kč",
"symbol": "Kč",
"code": "CZK",
"name_plural": "Czech Republic korunas",
"rounding": 0,
"decimal_digits": 2
},
"DKK": {
"name": "デンマーク クローネ",
"symbol_native": "kr",
"symbol": "Dkr",
"code": "DKK",
"name_plural": "Danish kroner",
"rounding": 0,
"decimal_digits": 2
},
"GBP": {
"name": "英国ポンド",
"symbol_native": "£",
"symbol": "£",
"code": "GBP",
"name_plural": "British pounds sterling",
"rounding": 0,
"decimal_digits": 2
},
"HUF": {
"name": "ハンガリー フォリント",
"symbol_native": "Ft",
"symbol": "Ft",
"code": "HUF",
"name_plural": "Hungarian forints",
"rounding": 0,
"decimal_digits": 0
},
"PLN": {
"name": "ポーランド ズウォティ",
"symbol_native": "zł",
"symbol": "zł",
"code": "PLN",
"name_plural": "Polish zlotys",
"rounding": 0,
"decimal_digits": 2
},
"RON": {
"name": "ルーマニア レイ",
"symbol_native": "RON",
"symbol": "RON",
"code": "RON",
"name_plural": "Romanian lei",
"rounding": 0,
"decimal_digits": 2
},
"SEK": {
"name": "スウェーデン クローナ",
"symbol_native": "kr",
"symbol": "Skr",
"code": "SEK",
"name_plural": "Swedish kronor",
"rounding": 0,
"decimal_digits": 2
},
"CHF": {
"name": "スイス フラン",
"symbol_native": "CHF",
"symbol": "CHF",
"code": "CHF",
"name_plural": "Swiss francs",
"rounding": 0.05,
"decimal_digits": 2
},
"ISK": {
"name": "アイスランド クローナ",
"symbol_native": "kr",
"symbol": "Ikr",
"code": "ISK",
"name_plural": "Icelandic krónur",
"rounding": 0,
"decimal_digits": 0
},
"NOK": {
"name": "ノルウェー クローネ",
"symbol_native": "kr",
"symbol": "Nkr",
"code": "NOK",
"name_plural": "Norwegian kroner",
"rounding": 0,
"decimal_digits": 2
},
"TRY": {
"name": "新トルコリラ",
"symbol_native": "₺",
"symbol": "TL",
"code": "TRY",
"name_plural": "Turkish Lira",
"rounding": 0,
"decimal_digits": 2
},
"AUD": {
"name": "オーストラリア ドル",
"symbol_native": "$",
"symbol": "AU$",
"code": "AUD",
"name_plural": "Australian dollars",
"rounding": 0,
"decimal_digits": 2
},
"BRL": {
"name": "ブラジル レアル",
"symbol_native": "R$",
"symbol": "R$",
"code": "BRL",
"name_plural": "Brazilian reals",
"rounding": 0,
"decimal_digits": 2
},
"CAD": {
"name": "カナダ ドル",
"symbol_native": "$",
"symbol": "CA$",
"code": "CAD",
"name_plural": "Canadian dollars",
"rounding": 0,
"decimal_digits": 2
},
"CNY": {
"name": "中国人民元",
"symbol_native": "CN¥",
"symbol": "CN¥",
"code": "CNY",
"name_plural": "Chinese yuan",
"rounding": 0,
"decimal_digits": 2
},
"HKD": {
"name": "香港ドル",
"symbol_native": "$",
"symbol": "HK$",
"code": "HKD",
"name_plural": "Hong Kong dollars",
"rounding": 0,
"decimal_digits": 2
},
"IDR": {
"name": "インドネシア ルピア",
"symbol_native": "Rp",
"symbol": "Rp",
"code": "IDR",
"name_plural": "Indonesian rupiahs",
"rounding": 0,
"decimal_digits": 0
},
"ILS": {
"name": "イスラエル新シェケル",
"symbol_native": "₪",
"symbol": "₪",
"code": "ILS",
"name_plural": "Israeli new sheqels",
"rounding": 0,
"decimal_digits": 2
},
"INR": {
"name": "インド ルピー",
"symbol_native": "টকা",
"symbol": "Rs",
"code": "INR",
"name_plural": "Indian rupees",
"rounding": 0,
"decimal_digits": 2
},
"KRW": {
"name": "韓国ウォン",
"symbol_native": "₩",
"symbol": "₩",
"code": "KRW",
"name_plural": "South Korean won",
"rounding": 0,
"decimal_digits": 0
},
"MXN": {
"name": "メキシコ ペソ",
"symbol_native": "$",
"symbol": "MX$",
"code": "MXN",
"name_plural": "Mexican pesos",
"rounding": 0,
"decimal_digits": 2
},
"NZD": {
"name": "ニュージーランド ドル",
"symbol_native": "$",
"symbol": "NZ$",
"code": "NZD",
"name_plural": "New Zealand dollars",
"rounding": 0,
"decimal_digits": 2
},
"PHP": {
"name": "フィリピン ペソ",
"symbol_native": "₱",
"symbol": "₱",
"code": "PHP",
"name_plural": "Philippine pesos",
"rounding": 0,
"decimal_digits": 2
},
"SGD": {
"name": "シンガポール ドル",
"symbol_native": "$",
"symbol": "S$",
"code": "SGD",
"name_plural": "Singapore dollars",
"rounding": 0,
"decimal_digits": 2
},
"THB": {
"name": "タイ バーツ",
"symbol_native": "฿",
"symbol": "฿",
"code": "THB",
"name_plural": "Thai baht",
"rounding": 0,
"decimal_digits": 2
},
"ZAR": {
"name": "南アフリカ ランド",
"symbol_native": "R",
"symbol": "R",
"code": "ZAR",
"name_plural": "South African rand",
"rounding": 0,
"decimal_digits": 2
}
},
"pl-PL": { "pl-PL": {
"USD": { "USD": {
"name": "dolar amerykański", "name": "dolar amerykański",
@@ -4078,5 +4350,549 @@
"rounding": 0, "rounding": 0,
"decimal_digits": 2 "decimal_digits": 2
} }
},
"ca": {
"USD": {
"name": "dòlar dels Estats Units",
"symbol_native": "$",
"symbol": "$",
"code": "USD",
"name_plural": "US dollars",
"rounding": 0,
"decimal_digits": 2
},
"EUR": {
"name": "euro",
"symbol_native": "€",
"symbol": "€",
"code": "EUR",
"name_plural": "euros",
"rounding": 0,
"decimal_digits": 2
},
"JPY": {
"name": "ien japonès",
"symbol_native": "¥",
"symbol": "¥",
"code": "JPY",
"name_plural": "Japanese yen",
"rounding": 0,
"decimal_digits": 0
},
"BGN": {
"name": "lev búlgar",
"symbol_native": "лв.",
"symbol": "BGN",
"code": "BGN",
"name_plural": "Bulgarian leva",
"rounding": 0,
"decimal_digits": 2
},
"CZK": {
"name": "corona txeca",
"symbol_native": "Kč",
"symbol": "Kč",
"code": "CZK",
"name_plural": "Czech Republic korunas",
"rounding": 0,
"decimal_digits": 2
},
"DKK": {
"name": "corona danesa",
"symbol_native": "kr",
"symbol": "Dkr",
"code": "DKK",
"name_plural": "Danish kroner",
"rounding": 0,
"decimal_digits": 2
},
"GBP": {
"name": "lliura esterlina britànica",
"symbol_native": "£",
"symbol": "£",
"code": "GBP",
"name_plural": "British pounds sterling",
"rounding": 0,
"decimal_digits": 2
},
"HUF": {
"name": "fòrint hongarès",
"symbol_native": "Ft",
"symbol": "Ft",
"code": "HUF",
"name_plural": "Hungarian forints",
"rounding": 0,
"decimal_digits": 0
},
"PLN": {
"name": "zloty polonès",
"symbol_native": "zł",
"symbol": "zł",
"code": "PLN",
"name_plural": "Polish zlotys",
"rounding": 0,
"decimal_digits": 2
},
"RON": {
"name": "leu romanès",
"symbol_native": "RON",
"symbol": "RON",
"code": "RON",
"name_plural": "Romanian lei",
"rounding": 0,
"decimal_digits": 2
},
"SEK": {
"name": "corona sueca",
"symbol_native": "kr",
"symbol": "Skr",
"code": "SEK",
"name_plural": "Swedish kronor",
"rounding": 0,
"decimal_digits": 2
},
"CHF": {
"name": "franc suís",
"symbol_native": "CHF",
"symbol": "CHF",
"code": "CHF",
"name_plural": "Swiss francs",
"rounding": 0.05,
"decimal_digits": 2
},
"ISK": {
"name": "corona islandesa",
"symbol_native": "kr",
"symbol": "Ikr",
"code": "ISK",
"name_plural": "Icelandic krónur",
"rounding": 0,
"decimal_digits": 0
},
"NOK": {
"name": "corona noruega",
"symbol_native": "kr",
"symbol": "Nkr",
"code": "NOK",
"name_plural": "Norwegian kroner",
"rounding": 0,
"decimal_digits": 2
},
"TRY": {
"name": "lira turca",
"symbol_native": "₺",
"symbol": "TL",
"code": "TRY",
"name_plural": "Turkish Lira",
"rounding": 0,
"decimal_digits": 2
},
"AUD": {
"name": "dòlar australià",
"symbol_native": "$",
"symbol": "AU$",
"code": "AUD",
"name_plural": "Australian dollars",
"rounding": 0,
"decimal_digits": 2
},
"BRL": {
"name": "real brasiler",
"symbol_native": "R$",
"symbol": "R$",
"code": "BRL",
"name_plural": "Brazilian reals",
"rounding": 0,
"decimal_digits": 2
},
"CAD": {
"name": "dòlar canadenc",
"symbol_native": "$",
"symbol": "CA$",
"code": "CAD",
"name_plural": "Canadian dollars",
"rounding": 0,
"decimal_digits": 2
},
"CNY": {
"name": "iuan xinès",
"symbol_native": "CN¥",
"symbol": "CN¥",
"code": "CNY",
"name_plural": "Chinese yuan",
"rounding": 0,
"decimal_digits": 2
},
"HKD": {
"name": "dòlar de Hong Kong",
"symbol_native": "$",
"symbol": "HK$",
"code": "HKD",
"name_plural": "Hong Kong dollars",
"rounding": 0,
"decimal_digits": 2
},
"IDR": {
"name": "rupia indonèsia",
"symbol_native": "Rp",
"symbol": "Rp",
"code": "IDR",
"name_plural": "Indonesian rupiahs",
"rounding": 0,
"decimal_digits": 0
},
"ILS": {
"name": "nou xéquel israelià",
"symbol_native": "₪",
"symbol": "₪",
"code": "ILS",
"name_plural": "Israeli new sheqels",
"rounding": 0,
"decimal_digits": 2
},
"INR": {
"name": "rupia índia",
"symbol_native": "টকা",
"symbol": "Rs",
"code": "INR",
"name_plural": "Indian rupees",
"rounding": 0,
"decimal_digits": 2
},
"KRW": {
"name": "won sud-coreà",
"symbol_native": "₩",
"symbol": "₩",
"code": "KRW",
"name_plural": "South Korean won",
"rounding": 0,
"decimal_digits": 0
},
"MXN": {
"name": "peso mexicà",
"symbol_native": "$",
"symbol": "MX$",
"code": "MXN",
"name_plural": "Mexican pesos",
"rounding": 0,
"decimal_digits": 2
},
"NZD": {
"name": "dòlar neozelandès",
"symbol_native": "$",
"symbol": "NZ$",
"code": "NZD",
"name_plural": "New Zealand dollars",
"rounding": 0,
"decimal_digits": 2
},
"PHP": {
"name": "peso filipí",
"symbol_native": "₱",
"symbol": "₱",
"code": "PHP",
"name_plural": "Philippine pesos",
"rounding": 0,
"decimal_digits": 2
},
"SGD": {
"name": "dòlar de Singapur",
"symbol_native": "$",
"symbol": "S$",
"code": "SGD",
"name_plural": "Singapore dollars",
"rounding": 0,
"decimal_digits": 2
},
"THB": {
"name": "baht tailandès",
"symbol_native": "฿",
"symbol": "฿",
"code": "THB",
"name_plural": "Thai baht",
"rounding": 0,
"decimal_digits": 2
},
"ZAR": {
"name": "rand sud-africà",
"symbol_native": "R",
"symbol": "R",
"code": "ZAR",
"name_plural": "South African rand",
"rounding": 0,
"decimal_digits": 2
}
},
"cs-CZ": {
"USD": {
"name": "americký dolar",
"symbol_native": "$",
"symbol": "$",
"code": "USD",
"name_plural": "US dollars",
"rounding": 0,
"decimal_digits": 2
},
"EUR": {
"name": "euro",
"symbol_native": "€",
"symbol": "€",
"code": "EUR",
"name_plural": "euros",
"rounding": 0,
"decimal_digits": 2
},
"JPY": {
"name": "japonský jen",
"symbol_native": "¥",
"symbol": "¥",
"code": "JPY",
"name_plural": "Japanese yen",
"rounding": 0,
"decimal_digits": 0
},
"BGN": {
"name": "bulharský lev",
"symbol_native": "лв.",
"symbol": "BGN",
"code": "BGN",
"name_plural": "Bulgarian leva",
"rounding": 0,
"decimal_digits": 2
},
"CZK": {
"name": "česká koruna",
"symbol_native": "Kč",
"symbol": "Kč",
"code": "CZK",
"name_plural": "Czech Republic korunas",
"rounding": 0,
"decimal_digits": 2
},
"DKK": {
"name": "dánská koruna",
"symbol_native": "kr",
"symbol": "Dkr",
"code": "DKK",
"name_plural": "Danish kroner",
"rounding": 0,
"decimal_digits": 2
},
"GBP": {
"name": "britská libra",
"symbol_native": "£",
"symbol": "£",
"code": "GBP",
"name_plural": "British pounds sterling",
"rounding": 0,
"decimal_digits": 2
},
"HUF": {
"name": "maďarský forint",
"symbol_native": "Ft",
"symbol": "Ft",
"code": "HUF",
"name_plural": "Hungarian forints",
"rounding": 0,
"decimal_digits": 0
},
"PLN": {
"name": "polský zlotý",
"symbol_native": "zł",
"symbol": "zł",
"code": "PLN",
"name_plural": "Polish zlotys",
"rounding": 0,
"decimal_digits": 2
},
"RON": {
"name": "rumunský leu",
"symbol_native": "RON",
"symbol": "RON",
"code": "RON",
"name_plural": "Romanian lei",
"rounding": 0,
"decimal_digits": 2
},
"SEK": {
"name": "švédská koruna",
"symbol_native": "kr",
"symbol": "Skr",
"code": "SEK",
"name_plural": "Swedish kronor",
"rounding": 0,
"decimal_digits": 2
},
"CHF": {
"name": "švýcarský frank",
"symbol_native": "CHF",
"symbol": "CHF",
"code": "CHF",
"name_plural": "Swiss francs",
"rounding": 0.05,
"decimal_digits": 2
},
"ISK": {
"name": "islandská koruna",
"symbol_native": "kr",
"symbol": "Ikr",
"code": "ISK",
"name_plural": "Icelandic krónur",
"rounding": 0,
"decimal_digits": 0
},
"NOK": {
"name": "norská koruna",
"symbol_native": "kr",
"symbol": "Nkr",
"code": "NOK",
"name_plural": "Norwegian kroner",
"rounding": 0,
"decimal_digits": 2
},
"TRY": {
"name": "turecká lira",
"symbol_native": "₺",
"symbol": "TL",
"code": "TRY",
"name_plural": "Turkish Lira",
"rounding": 0,
"decimal_digits": 2
},
"AUD": {
"name": "australský dolar",
"symbol_native": "$",
"symbol": "AU$",
"code": "AUD",
"name_plural": "Australian dollars",
"rounding": 0,
"decimal_digits": 2
},
"BRL": {
"name": "brazilský real",
"symbol_native": "R$",
"symbol": "R$",
"code": "BRL",
"name_plural": "Brazilian reals",
"rounding": 0,
"decimal_digits": 2
},
"CAD": {
"name": "kanadský dolar",
"symbol_native": "$",
"symbol": "CA$",
"code": "CAD",
"name_plural": "Canadian dollars",
"rounding": 0,
"decimal_digits": 2
},
"CNY": {
"name": "čínský jüan",
"symbol_native": "CN¥",
"symbol": "CN¥",
"code": "CNY",
"name_plural": "Chinese yuan",
"rounding": 0,
"decimal_digits": 2
},
"HKD": {
"name": "hongkongský dolar",
"symbol_native": "$",
"symbol": "HK$",
"code": "HKD",
"name_plural": "Hong Kong dollars",
"rounding": 0,
"decimal_digits": 2
},
"IDR": {
"name": "indonéská rupie",
"symbol_native": "Rp",
"symbol": "Rp",
"code": "IDR",
"name_plural": "Indonesian rupiahs",
"rounding": 0,
"decimal_digits": 0
},
"ILS": {
"name": "izraelský nový šekel",
"symbol_native": "₪",
"symbol": "₪",
"code": "ILS",
"name_plural": "Israeli new sheqels",
"rounding": 0,
"decimal_digits": 2
},
"INR": {
"name": "indická rupie",
"symbol_native": "টকা",
"symbol": "Rs",
"code": "INR",
"name_plural": "Indian rupees",
"rounding": 0,
"decimal_digits": 2
},
"KRW": {
"name": "jihokorejský won",
"symbol_native": "₩",
"symbol": "₩",
"code": "KRW",
"name_plural": "South Korean won",
"rounding": 0,
"decimal_digits": 0
},
"MXN": {
"name": "mexické peso",
"symbol_native": "$",
"symbol": "MX$",
"code": "MXN",
"name_plural": "Mexican pesos",
"rounding": 0,
"decimal_digits": 2
},
"NZD": {
"name": "novozélandský dolar",
"symbol_native": "$",
"symbol": "NZ$",
"code": "NZD",
"name_plural": "New Zealand dollars",
"rounding": 0,
"decimal_digits": 2
},
"PHP": {
"name": "filipínské peso",
"symbol_native": "₱",
"symbol": "₱",
"code": "PHP",
"name_plural": "Philippine pesos",
"rounding": 0,
"decimal_digits": 2
},
"SGD": {
"name": "singapurský dolar",
"symbol_native": "$",
"symbol": "S$",
"code": "SGD",
"name_plural": "Singapore dollars",
"rounding": 0,
"decimal_digits": 2
},
"THB": {
"name": "thajský baht",
"symbol_native": "฿",
"symbol": "฿",
"code": "THB",
"name_plural": "Thai baht",
"rounding": 0,
"decimal_digits": 2
},
"ZAR": {
"name": "jihoafrický rand",
"symbol_native": "R",
"symbol": "R",
"code": "ZAR",
"name_plural": "South African rand",
"rounding": 0,
"decimal_digits": 2
}
} }
} }

View File

@@ -21,7 +21,7 @@ const envSchema = z
interpretEnvVarAsBool, interpretEnvVarAsBool,
z.boolean().default(false), z.boolean().default(false),
), ),
NEXT_PUBLIC_DEFAULT_CURRENCY_SYMBOL: z.string().optional(), NEXT_PUBLIC_DEFAULT_CURRENCY_CODE: z.string().optional(),
S3_UPLOAD_KEY: z.string().optional(), S3_UPLOAD_KEY: z.string().optional(),
S3_UPLOAD_SECRET: z.string().optional(), S3_UPLOAD_SECRET: z.string().optional(),
S3_UPLOAD_BUCKET: z.string().optional(), S3_UPLOAD_BUCKET: z.string().optional(),

View File

@@ -81,7 +81,11 @@ export function getCurrencyFromGroup(
* @param amount The amount, as the number of minor units of currency (cents for most currencies) * @param amount The amount, as the number of minor units of currency (cents for most currencies)
* @param round Whether to round the amount to the nearest minor unit (e.g.: 1.5612 € => 1.56 €) * @param round Whether to round the amount to the nearest minor unit (e.g.: 1.5612 € => 1.56 €)
*/ */
export function amountAsDecimal(amount: number, currency: Currency, round = false) { export function amountAsDecimal(
amount: number,
currency: Currency,
round = false,
) {
const decimal = amount / 10 ** currency.decimal_digits const decimal = amount / 10 ** currency.decimal_digits
if (round) { if (round) {
return Number(decimal.toFixed(currency.decimal_digits)) return Number(decimal.toFixed(currency.decimal_digits))