Open-source personal finance manager. Self-hosted, privacy-first.
Feature/adding kzt as currency (#983)
Alatau-AS6535baecac4a
diff --git a/backend/app/api/currencies.py b/backend/app/api/currencies.pyindex 1ffd7173..186cb3ce 100644--- a/backend/app/api/currencies.py+++ b/backend/app/api/currencies.py@@ -32,6 +32,7 @@ CURRENCY_META = {"CRC": {"symbol": "₡", "name": "Costa Rican Colón", "flag": "\U0001F1E8\U0001F1F7"},"IDR": {"symbol": "Rp", "name": "Indonesian Rupiah", "flag": "\U0001F1EE\U0001F1E9"},"DOP": {"symbol": "RD$", "name": "Peso Dominicano", "flag": "\U0001F1E9\U0001F1F4"},+ "KZT": {"symbol": "₸", "name": "Kazakhstani Tenge", "flag": "\U0001F1F0\U0001F1FF"},"RUB": {"symbol": "₽", "name": "Russian Ruble", "flag": "\U0001F1F7\U0001F1FA"},"GTQ": {"symbol": "Q", "name": "Guatemalan Quetzal", "flag": "\U0001F1EC\U0001F1F9"},"PHP": {"symbol": "₱", "name": "Philippine Peso", "flag": "\U0001F1F5\U0001F1ED"},diff --git a/backend/app/core/config.py b/backend/app/core/config.pyindex 7ea369e9..1d4c7c06 100644--- a/backend/app/core/config.py+++ b/backend/app/core/config.py@@ -69,7 +69,7 @@ class Settings(BaseSettings):# FX Ratesopenexchangerates_app_id: str = ""- supported_currencies: str = "USD,EUR,GBP,BRL,CAD,AUD,CHF,ARS,JPY,MXN,INR,SEK,DKK,NOK,PLN,CZK,HUF,RON,CRC,IDR,COP,CLP,DOP,RUB,GTQ,PHP,UAH,NZD,VND,SGD,AZN,TRY,PKR,MDL,AED,THB,EGP,MYR,CNY,SAR,QAR,JMD,RSD" # comma-separated list+ supported_currencies: str = "USD,EUR,GBP,BRL,CAD,AUD,CHF,ARS,JPY,MXN,INR,SEK,DKK,NOK,PLN,CZK,HUF,RON,CRC,IDR,COP,CLP,DOP,KZT,RUB,GTQ,PHP,UAH,NZD,VND,SGD,AZN,TRY,PKR,MDL,AED,THB,EGP,MYR,CNY,SAR,QAR,JMD,RSD" # comma-separated listfx_sync_mode: str = "on_demand" # "on_demand" or "scheduled"# Storagediff --git a/backend/app/fiscal/jurisdictions/kz.toml b/backend/app/fiscal/jurisdictions/kz.tomlnew file mode 100644index 00000000..e559749c--- /dev/null+++ b/backend/app/fiscal/jurisdictions/kz.toml@@ -0,0 +1,6 @@+# Kazakhstan BIN (legal entities) and IIN (individuals) share both the+# length and the check algorithm, so one validator serves both. The two-pass+# weights are the published KZ scheme; a 10 from either pass means the+# number was never issued.+code = "KZ"+kinds = ['kz_biniin']diff --git a/backend/app/fiscal/registry.py b/backend/app/fiscal/registry.pyindex f5c723d2..5c3ab7d0 100644--- a/backend/app/fiscal/registry.py+++ b/backend/app/fiscal/registry.py@@ -91,6 +91,7 @@ class TaxIdKind(str, Enum):RO_CUI = "ro_cui"CH_UID = "ch_uid"INN = "inn"+ KZ_BINIIN = "kz_biniin"EDRPOU = "edrpou"# Latin AmericaCUIT = "cuit"@@ -187,6 +188,7 @@ KIND_SPECS: dict[TaxIdKind, KindSpec] = {# the nine digits were typed.TaxIdKind.CH_UID: _spec(TaxIdKind.CH_UID, "upper_alnum", "ch_uid", "CHE-###.###.###"),TaxIdKind.INN: _spec(TaxIdKind.INN, "digits", "ru_inn"),+ TaxIdKind.KZ_BINIIN: _spec(TaxIdKind.KZ_BINIIN, "digits", "kz_biniin", "### ### ### ###"),TaxIdKind.EDRPOU: _spec(TaxIdKind.EDRPOU, "digits", "ua_edrpou"),# Latin AmericaTaxIdKind.CUIT: _spec(TaxIdKind.CUIT, "digits", "ar_cuit", "##-########-#"),diff --git a/backend/app/fiscal/validators.py b/backend/app/fiscal/validators.pyindex 98fa6487..6309b6d1 100644--- a/backend/app/fiscal/validators.py+++ b/backend/app/fiscal/validators.py@@ -373,6 +373,21 @@ def validate_ru_inn(value: str) -> str | None:return Nonereturn "length"+def validate_kz_biniin(value:str) -> str | None:+ """Kazakhstan BIN/IIN: twelve digits, mod-11 check digit."""+ if not value.isdigit():+ return "invalid"+ if len(value) != 12:+ return "length"+ weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]+ check = _weighted_sum(value[:11], weights) % 11+ if check == 10:+ weights2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2]+ check = _weighted_sum(value[:11], weights2) % 11+ if check == 10:+ return "check_digit"+ return None if value[11] == str(check) else "check_digit"+def validate_ua_edrpou(value: str) -> str | None:"""Eight digits. The check rule differs by registration range, so size@@ -533,6 +548,7 @@ VALIDATORS: dict[str, Callable[[str], str | None]] = {"ro_cui": validate_ro_cui,"ch_uid": validate_ch_uid,"ru_inn": validate_ru_inn,+ "kz_biniin": validate_kz_biniin,"ua_edrpou": validate_ua_edrpou,"ca_bn": validate_ca_bn,"au_abn": validate_au_abn,diff --git a/backend/tests/test_fiscal_packs_intl.py b/backend/tests/test_fiscal_packs_intl.pyindex 670bebc5..3a123fb5 100644--- a/backend/tests/test_fiscal_packs_intl.py+++ b/backend/tests/test_fiscal_packs_intl.py@@ -103,7 +103,7 @@ def test_the_currencies_the_product_supports_have_a_pack():"CHF": "CH", "CNY": "CN", "ARS": "AR", "MXN": "MX", "CLP": "CL","COP": "CO", "PEN": "PE", "UYU": "UY", "INR": "IN", "SEK": "SE","DKK": "DK", "NOK": "NO", "PLN": "PL", "CZK": "CZ", "HUF": "HU",- "RON": "RO", "CRC": "CR", "IDR": "ID", "DOP": "DO", "RUB": "RU",+ "RON": "RO", "CRC": "CR", "IDR": "ID", "DOP": "DO", "KZT": "KZ", "RUB": "RU","GTQ": "GT", "PHP": "PH", "UAH": "UA", "NZD": "NZ", "VND": "VN", "SGD": "SG", "USD": "US",}uncovered = [diff --git a/frontend/src/components/currency-select.tsx b/frontend/src/components/currency-select.tsxindex 3b7c464a..a8452f11 100644--- a/frontend/src/components/currency-select.tsx+++ b/frontend/src/components/currency-select.tsx@@ -34,6 +34,7 @@ export const CURRENCIES = [{ code: 'COP', flag: '\u{1F1E8}\u{1F1F4}', symbol: '$' },{ code: 'CLP', flag: '\u{1F1E8}\u{1F1F1}', symbol: '$' },{ code: 'DOP', flag: '\u{1F1E9}\u{1F1F4}', symbol: 'RD$' },+ { code: 'KZT', flag: '\u{1F1F0}\u{1F1FF}', symbol: '₸' },{ code: 'RUB', flag: '\u{1F1F7}\u{1F1FA}', symbol: '₽' },{ code: 'GTQ', flag: '\u{1F1EC}\u{1F1F9}', symbol: 'Q' },{ code: 'PHP', flag: '\u{1F1F5}\u{1F1ED}', symbol: '₱' },diff --git a/frontend/src/lib/format.ts b/frontend/src/lib/format.tsindex 6201f337..18097df9 100644--- a/frontend/src/lib/format.ts+++ b/frontend/src/lib/format.ts@@ -56,6 +56,7 @@ const CURRENCY_LOCALE: Record<string, string> = {CRC: 'es-CR',IDR: 'id-ID',DOP: 'es-DO',+ KZT: 'ru-KZ',RUB: 'ru-RU',GTQ: 'es-GT',PHP: 'en-PH',