FIx rule import for move money so it moves percentage amounts correctly
This commit is contained in:
@@ -198,7 +198,12 @@ where
|
||||
to_accounts,
|
||||
all_from_accounts: false,
|
||||
all_to_accounts: false,
|
||||
amount: movement_rule.amount.unwrap_or(0.),
|
||||
amount: movement_rule.amount.unwrap_or(0.)
|
||||
* (if movement_rule.is_percent == "%" {
|
||||
0.01
|
||||
} else {
|
||||
1.
|
||||
}),
|
||||
is_percent: movement_rule.is_percent == "%",
|
||||
is_separator: movement_rule.apply == "-DIVIDER-",
|
||||
})
|
||||
@@ -265,6 +270,7 @@ pub fn move_money_1() {}
|
||||
// Note that the movement happens on a line-by-line level. So we can stream the data from disk, and potentially apply this
|
||||
// to every. It's also much more memory efficient than approach 1.
|
||||
// TODO: Time both approaches to seee which is faster depending on the size of the input data/number of rules
|
||||
// Verdict: This is already pretty fast, at least much faster than ppm for BigDataset
|
||||
pub fn move_money_2(
|
||||
initial_totals: HashMap<Unit, f64>,
|
||||
rules: &Vec<MovementRule>,
|
||||
@@ -321,7 +327,7 @@ mod tests {
|
||||
csv::Reader::from_path("reclassrule.csv").unwrap(),
|
||||
csv::Reader::from_path("line.csv").unwrap(),
|
||||
csv::Writer::from_path("output.csv").unwrap(),
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user