mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: euro currency number format (#3115)
This commit is contained in:
parent
c6401da0b5
commit
fbb1753350
@ -80,6 +80,18 @@ mod tests {
|
||||
assert_number(&type_option, "0.2", "$0.2", &field_type, &field);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn euro_type_option_test() {
|
||||
let field_type = FieldType::Number;
|
||||
let mut type_option = NumberTypeOption::new();
|
||||
type_option.format = NumberFormat::EUR;
|
||||
let field = FieldBuilder::new(field_type.clone(), type_option.clone()).build();
|
||||
|
||||
assert_number(&type_option, "0.2", "€0,2", &field_type, &field);
|
||||
assert_number(&type_option, "1000", "€1.000", &field_type, &field);
|
||||
assert_number(&type_option, "1234.56", "€1.234,56", &field_type, &field);
|
||||
}
|
||||
|
||||
fn assert_number(
|
||||
type_option: &NumberTypeOption,
|
||||
input_str: &str,
|
||||
|
@ -219,7 +219,7 @@ impl CellDataChangeset for NumberTypeOption {
|
||||
NumberCellData::from(formatter.to_string()),
|
||||
)),
|
||||
_ => Ok((
|
||||
NumberCellData::from(formatter.to_string()).into(),
|
||||
NumberCellData::from(formatter.to_unformatted_string()).into(),
|
||||
NumberCellData::from(formatter.to_string()),
|
||||
)),
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use rust_decimal::Decimal;
|
||||
use rusty_money::Money;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct NumberCellFormat {
|
||||
decimal: Option<Decimal>,
|
||||
money: Option<String>,
|
||||
@ -68,6 +68,13 @@ impl NumberCellFormat {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.decimal.is_none()
|
||||
}
|
||||
|
||||
pub fn to_unformatted_string(&self) -> String {
|
||||
match self.decimal {
|
||||
None => String::default(),
|
||||
Some(decimal) => decimal.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn auto_fill_zero_at_start_if_need(num_str: &str) -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user