Fix move money to correctly move between accounts/ccs with ranges and and consider cost output correctly, speed up process by using hashset for rule accounts/departments

This commit is contained in:
piv
2023-03-08 12:56:39 +10:30
parent e1bb6e65d3
commit 1e36bc68e4
4 changed files with 152 additions and 88 deletions

View File

@@ -27,6 +27,9 @@ enum Commands {
#[arg(short = 'a', long, value_name = "FILE")]
accounts: PathBuf,
#[arg(short = 'c', long, value_name = "FILE")]
cost_centres: PathBuf,
#[arg(short, long, value_name = "FILE")]
output: Option<PathBuf>,
@@ -80,6 +83,7 @@ fn main() -> anyhow::Result<()> {
rules,
lines,
accounts,
cost_centres,
output,
use_numeric_accounts,
flush_pass,
@@ -87,6 +91,7 @@ fn main() -> anyhow::Result<()> {
rules,
lines,
accounts,
cost_centres,
output,
use_numeric_accounts,
flush_pass,
@@ -118,14 +123,16 @@ fn move_money(
rules: PathBuf,
lines: PathBuf,
accounts: PathBuf,
cost_centres: PathBuf,
output: Option<PathBuf>,
use_numeric_accounts: bool,
flush_pass: bool,
) -> anyhow::Result<()> {
coster_rs::move_money(
csv::Reader::from_path(rules)?,
csv::Reader::from_path(lines)?,
csv::Reader::from_path(accounts)?,
&mut csv::Reader::from_path(rules)?,
&mut csv::Reader::from_path(lines)?,
&mut csv::Reader::from_path(accounts)?,
&mut csv::Reader::from_path(cost_centres)?,
&mut csv::Writer::from_path(output.unwrap_or(PathBuf::from("output.csv")))?,
use_numeric_accounts,
flush_pass,