Skip to content

Commit

Permalink
Extend the keywords for owner MiTi
Browse files Browse the repository at this point in the history
  • Loading branch information
ursjoss committed Jan 23, 2024
1 parent 44a951d commit 4ddcf19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/export/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/export/export_accounting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down

0 comments on commit 4ddcf19

Please sign in to comment.