Implement overhead allocation for different account types, add it to binaries
This commit is contained in:
57
src/main.rs
57
src/main.rs
@@ -41,10 +41,19 @@ enum Commands {
|
||||
/// Allocates servicing department amounts to operating departments
|
||||
allocate_overheads {
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
rules: PathBuf,
|
||||
lines: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
lines: PathBuf,
|
||||
accounts: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
allocation_statistics: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
areas: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
cost_centres: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
@@ -63,10 +72,20 @@ fn main() -> anyhow::Result<()> {
|
||||
} => move_money(rules, lines, output, use_numeric_accounts),
|
||||
Commands::smush_rules { rules, output } => smush_rules(rules, output),
|
||||
Commands::allocate_overheads {
|
||||
rules,
|
||||
lines,
|
||||
accounts,
|
||||
allocation_statistics,
|
||||
areas,
|
||||
cost_centres,
|
||||
output,
|
||||
} => allocate_overheads(rules, lines, output),
|
||||
} => allocate_overheads(
|
||||
lines,
|
||||
accounts,
|
||||
allocation_statistics,
|
||||
areas,
|
||||
cost_centres,
|
||||
output,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,23 +108,25 @@ fn smush_rules(rules_path: PathBuf, output: Option<PathBuf>) -> anyhow::Result<(
|
||||
}
|
||||
|
||||
fn allocate_overheads(
|
||||
rules_path: PathBuf,
|
||||
lines: PathBuf,
|
||||
accounts: PathBuf,
|
||||
allocation_statistics: PathBuf,
|
||||
areas: PathBuf,
|
||||
cost_centres: PathBuf,
|
||||
output: Option<PathBuf>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut rdr = csv::Reader::from_path(rules_path)?;
|
||||
|
||||
for result in rdr.deserialize() {
|
||||
let record: CsvOverheadAllocationRule = result?;
|
||||
}
|
||||
|
||||
let mut account_reader = csv::Reader::from_path(lines)?;
|
||||
|
||||
for result in account_reader.deserialize() {
|
||||
let record: CsvCost = result?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
coster_rs::reciprocal_allocation(
|
||||
csv::Reader::from_path(lines)?,
|
||||
csv::Reader::from_path(accounts)?,
|
||||
csv::Reader::from_path(allocation_statistics)?,
|
||||
csv::Reader::from_path(areas)?,
|
||||
csv::Reader::from_path(cost_centres)?,
|
||||
&mut csv::Writer::from_path(output.unwrap_or(PathBuf::from("alloc_output.csv")))?,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
"E".to_owned(),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user