Fix build in overhead allocation
This commit is contained in:
@@ -4,6 +4,7 @@ use std::{
|
||||
};
|
||||
|
||||
use csv::Reader;
|
||||
use futures::SinkExt;
|
||||
use itertools::Itertools;
|
||||
use nalgebra::{DMatrix, Dynamic, LU};
|
||||
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||
@@ -409,7 +410,8 @@ where
|
||||
summed_department_costs: total_cost,
|
||||
})
|
||||
.collect(),
|
||||
if show_from { Some(output) } else { None },
|
||||
output,
|
||||
show_from,
|
||||
zero_threshold,
|
||||
)?;
|
||||
|
||||
@@ -509,7 +511,8 @@ fn remove_quote_and_padding(s: &str) -> String {
|
||||
fn reciprocal_allocation_impl(
|
||||
allocations: Vec<OverheadAllocationRule>,
|
||||
account_costs: Vec<AccountCost>,
|
||||
movement_writer: Option<&mut impl RecordSerializer>,
|
||||
movement_writer: &mut impl RecordSerializer,
|
||||
show_from: bool,
|
||||
zero_threshold: f64,
|
||||
) -> anyhow::Result<Vec<AccountCost>> {
|
||||
let overhead_department_mappings = get_rules_indexes(&allocations, DepartmentType::Overhead);
|
||||
@@ -546,6 +549,7 @@ fn reciprocal_allocation_impl(
|
||||
overhead_department_mappings,
|
||||
allocations,
|
||||
movement_writer,
|
||||
show_from,
|
||||
zero_threshold,
|
||||
)
|
||||
} else {
|
||||
@@ -555,6 +559,7 @@ fn reciprocal_allocation_impl(
|
||||
overhead_department_mappings,
|
||||
allocations,
|
||||
movement_writer,
|
||||
show_from,
|
||||
zero_threshold,
|
||||
)
|
||||
}
|
||||
@@ -588,7 +593,8 @@ fn do_solve_reciprocal<T: ReciprocalAllocationSolver + Sync + Send>(
|
||||
account_costs: Vec<AccountCost>,
|
||||
overhead_department_mappings: HashMap<String, usize>,
|
||||
allocations: Vec<OverheadAllocationRule>,
|
||||
temp_writer: Option<&mut impl RecordSerializer>,
|
||||
temp_writer: &mut impl RecordSerializer,
|
||||
show_from: bool,
|
||||
zero_threshold: f64,
|
||||
) -> anyhow::Result<Vec<AccountCost>> {
|
||||
let operating_department_mappings = get_rules_indexes(&allocations, DepartmentType::Operating);
|
||||
@@ -611,7 +617,7 @@ fn do_solve_reciprocal<T: ReciprocalAllocationSolver + Sync + Send>(
|
||||
overhead_department_mappings.len(),
|
||||
operating_overhead_mappings,
|
||||
);
|
||||
if let Some(temp_writer) = temp_writer {
|
||||
if show_from {
|
||||
solve_reciprocal_with_from(
|
||||
solver,
|
||||
account_costs,
|
||||
@@ -778,12 +784,12 @@ fn solve_reciprocal_with_from<T: ReciprocalAllocationSolver + Sync + Send>(
|
||||
temp_writer.serialize(moved_amount)?;
|
||||
}
|
||||
}
|
||||
temp_writer.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::reciprocal_allocation;
|
||||
use crate::AccountCost;
|
||||
use crate::DepartmentType;
|
||||
@@ -871,7 +877,8 @@ mod tests {
|
||||
let result = reciprocal_allocation_impl(
|
||||
allocation_rules,
|
||||
initial_totals,
|
||||
Some(&mut movement_writer),
|
||||
&mut movement_writer,
|
||||
false,
|
||||
0.00001,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user