currencies in client never drifts from the server from now on
This commit is contained in:
2
client
2
client
Submodule client updated: 474b9761ce...a46ff11093
Submodule client-gui2 updated: 7c8d53d4e9...c4d5a9d22b
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
Binary file not shown.
@@ -734,6 +734,10 @@ pub struct ListColumnTypesResponse {
|
||||
/// Every column type, declarable or not, ordered by name.
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub column_types: ::prost::alloc::vec::Vec<list_column_types_response::ColumnType>,
|
||||
/// 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 {
|
||||
|
||||
Reference in New Issue
Block a user