From 4ddcf1973d95e7dc9447d562b93b70aaf65bb553 Mon Sep 17 00:00:00 2001 From: Urs Joss Date: Tue, 23 Jan 2024 16:12:17 +0100 Subject: [PATCH] Extend the keywords for owner MiTi --- src/export/constraint.rs | 4 ++-- src/export/export_accounting.rs | 2 +- src/prepare.rs | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/export/constraint.rs b/src/export/constraint.rs index 2e0c233..89b1608 100644 --- a/src/export/constraint.rs +++ b/src/export/constraint.rs @@ -68,7 +68,7 @@ fn validate_field( .select(columns) .collect()?; if df.shape().0 > 0 { - Err(Box::try_from(error(df)).unwrap()) + Err(Box::from(error(df))) } else { Ok(()) } @@ -169,7 +169,7 @@ fn topic_owner_constraint( .select(columns) .collect()?; if df.shape().0 > 0 { - Err(Box::try_from(error(df)).unwrap()) + Err(Box::from(error(df))) } else { Ok(()) } diff --git a/src/export/export_accounting.rs b/src/export/export_accounting.rs index c2cadcd..248e851 100644 --- a/src/export/export_accounting.rs +++ b/src/export/export_accounting.rs @@ -104,7 +104,7 @@ fn validate_constraint( .collect()?; Ok(if violations.shape().0 > 0 { let row_vec = violations.get_row(0).unwrap().0; - let date = row_vec.get(0).unwrap().clone(); + let date = row_vec.first().unwrap().clone(); let net = row_vec.last().unwrap().clone(); Err(format!("Constraint violation for accounting export on {date}: net value of account {account} is {net} instead of 0.0").into()) } else { diff --git a/src/prepare.rs b/src/prepare.rs index 441e6b0..e10e82f 100644 --- a/src/prepare.rs +++ b/src/prepare.rs @@ -258,7 +258,7 @@ fn infer_topic(time_options: StrptimeOptions) -> Expr { /// Otherwise the owner is `LoLa`. fn infer_owner() -> Expr { when(col("Topic").neq(lit(Topic::MiTi.to_string()))) - .then(Expr::Literal(LiteralValue::Null)) + .then(Expr::Literal(Null)) .when( col("Description") .str() @@ -269,6 +269,9 @@ fn infer_owner() -> Expr { .or(col("Description").str().contains(lit("Dessert"), true)) .or(col("Description").str().contains(lit("Praktik"), true)) .or(col("Description").str().contains(lit("Vorspeise"), true)) + .or(col("Description") + .str() + .contains(lit("Vorsp\\. \\+ Hauptsp\\."), true)) .or(col("Description").str().contains(lit("Hauptspeise"), true)) .or(col("Description").str().contains(lit("Trinkgeld"), true)) .or(col("Description")