From 94ea9d1f7fe2a4b124a3e29bd3e2cb721ab2ab3a Mon Sep 17 00:00:00 2001 From: Priec Date: Wed, 2 Sep 2026 17:12:26 +0200 Subject: [PATCH] currencies in client never drifts from the server from now on --- client | 2 +- client-gui2 | 2 +- common/proto/table_definition.proto | 4 ++++ common/src/money.rs | 18 ++++++++++++++++++ common/src/proto/descriptor.bin | Bin 231876 -> 232118 bytes common/src/proto/komp_ac.table_definition.rs | 4 ++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/client b/client index 474b9761..a46ff110 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 474b9761ce151f7cf0b8e7e1daa931fdfb2e555a +Subproject commit a46ff11093302dfaea766cf09067c9a4011b7501 diff --git a/client-gui2 b/client-gui2 index 7c8d53d4..c4d5a9d2 160000 --- a/client-gui2 +++ b/client-gui2 @@ -1 +1 @@ -Subproject commit 7c8d53d4e952b1a5834bc7fc988798539a4664fd +Subproject commit c4d5a9d22bb669d711971d1cbf84a3389ef61fbe diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 7ce10b52..87573a2c 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -743,4 +743,8 @@ message ListColumnTypesResponse { // Every column type, declarable or not, ordered by name. repeated ColumnType column_types = 1; + + // Every canonical ISO-4217 code accepted by currency-bearing columns and + // profile accounting settings, ordered alphabetically. + repeated string currency_codes = 2; } diff --git a/common/src/money.rs b/common/src/money.rs index dd479191..944931cf 100644 --- a/common/src/money.rs +++ b/common/src/money.rs @@ -18,6 +18,24 @@ pub fn require_iso_currency_code(currency_code: &str) -> Result<&'static iso::Cu iso::find(currency_code).ok_or_else(|| format!("Unknown ISO-4217 currency: {currency_code}")) } +/// Returns every currency accepted by [`require_iso_currency_code`], ordered by +/// its canonical alphabetic code. +pub fn iso_currency_codes() -> Vec<&'static str> { + let mut currencies = Vec::new(); + for first in b'A'..=b'Z' { + for second in b'A'..=b'Z' { + for third in b'A'..=b'Z' { + let bytes = [first, second, third]; + let code = std::str::from_utf8(&bytes).expect("uppercase ASCII currency code"); + if let Some(currency) = iso::find(code) { + currencies.push(currency.iso_alpha_code); + } + } + } + } + currencies +} + #[cfg(test)] mod tests { use super::*; diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 40435b67d20932c396dc9ad9cb657a1afe6903f6..54a97cb0a0ca1f551e3de391de02d615d9330a7d 100644 GIT binary patch delta 319 zcmX>ynQz-vzJ@J~rc0O(KHF}-gmJzi%ThKj@#*p>7{#Z5Jj$4;Dx}KAmt0y@l$w`Z z8K0b=l3Famq`<7f8N>?{bO4)a^0lV#G=f+bfAiy(%igag~YrRE`@@k{Itv*u#WuFyb_RnacT*OF4j@V zFG@)*0-EBJm{X9En3P%qvMQ%ikBf_!ixuP?7O;EZTvia5TM#A-cCC;CjLQs?RaR-Q N4`bS1AI9uz3;=tnU7P>_ delta 76 zcmV-S0JHzLl@7#{4uG@)HKYR1, + /// Every canonical ISO-4217 code accepted by currency-bearing columns and + /// profile accounting settings, ordered alphabetically. + #[prost(string, repeated, tag = "2")] + pub currency_codes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } /// Nested message and enum types in `ListColumnTypesResponse`. pub mod list_column_types_response {