conversions5

This commit is contained in:
Filipriec
2026-08-23 15:50:03 +02:00
parent af7016e4c7
commit 0c33d1fa5c
20 changed files with 1197 additions and 845 deletions

View File

@@ -37,6 +37,10 @@ pub(crate) struct BuilderForm {
#[serde(default)]
pub accounting_currency: String,
#[serde(default)]
pub rate_source_id: String,
#[serde(default)]
pub foreign_currencies: String,
#[serde(default)]
pub global: bool,
#[serde(default)]
pub table_name: String,
@@ -163,6 +167,8 @@ impl BuilderForm {
profile_name_input: self.profile_name_input.clone(),
creating_new_profile,
accounting_currency: self.accounting_currency.clone(),
rate_source_id: self.rate_source_id.clone(),
foreign_currencies: self.foreign_currencies.clone(),
global: self.global,
table_name: self.table_name.clone(),
columns,
@@ -233,7 +239,11 @@ impl AddTablePageState {
tags.push("quantity ledger".to_string());
}
if !column.currency.is_empty() {
tags.push(format!("{}, {}", column.currency, column.money_mode.label()));
tags.push(format!(
"{}, {}",
column.currency,
column.money_mode.label()
));
}
rows.push(ColumnRow {
index: Some(index),
@@ -266,7 +276,11 @@ impl AddTablePageState {
for generated in generated_columns {
let mut tags = vec![format!("generated by {}", column.data_type)];
if generated.inherits_currency {
tags.push(format!("{}, {}", column.currency, column.money_mode.label()));
tags.push(format!(
"{}, {}",
column.currency,
column.money_mode.label()
));
}
rows.push(ColumnRow {
index: None,
@@ -502,15 +516,18 @@ mod tests {
error: None,
};
page.draft.columns.catalog = crate::schema::tests::catalog();
page.draft.columns.added.push(crate::schema::ColumnDefinition {
name: "accounting".to_string(),
data_type: "accounting".to_string(),
indexed: false,
quantity_ledger: false,
required: false,
money_mode: MoneyMode::Exact,
currency: "EUR".to_string(),
});
page.draft
.columns
.added
.push(crate::schema::ColumnDefinition {
name: "accounting".to_string(),
data_type: "accounting".to_string(),
indexed: false,
quantity_ledger: false,
required: false,
money_mode: MoneyMode::Exact,
currency: "EUR".to_string(),
});
let rows = page.column_rows();
assert_eq!(
@@ -537,9 +554,16 @@ mod tests {
);
assert!(row("number").first);
assert!(row("accounting").last);
assert!(!row("accounting").indexable, "a definition row is no column");
assert!(
!row("accounting").indexable,
"a definition row is no column"
);
assert!(row("debit").tags.contains(&"EUR, exact".to_string()));
assert!(row("name").tags.contains(&"generated by accounting".to_string()));
assert!(
row("name")
.tags
.contains(&"generated by accounting".to_string())
);
}
/// The generated columns of an ACCOUNTING row are the user's to alias, and
@@ -586,7 +610,11 @@ mod tests {
assert_eq!(row("account").alias_source.as_deref(), Some("account"));
assert_eq!(row("account").alias, "ucet");
assert!(row("account_id").alias_source.is_none());
assert!(row("account_id").tags.contains(&"written as ucet".to_string()));
assert!(
row("account_id")
.tags
.contains(&"written as ucet".to_string())
);
assert!(
row("accounting").alias_source.is_none(),
"a declared column is named where it is described"