Reduce the epsilon value format to 5 decimal places
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct CsvMovementRule {
|
||||
@@ -86,9 +86,17 @@ pub struct CsvCost {
|
||||
pub account: String,
|
||||
#[serde(rename = "COSTCENTRE")]
|
||||
pub department: String,
|
||||
#[serde(serialize_with = "round_serialize")]
|
||||
pub value: f64,
|
||||
}
|
||||
|
||||
fn round_serialize<S>(x: &f64, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
s.serialize_f64((x * 100000.).round() / 100000.)
|
||||
}
|
||||
|
||||
pub fn move_money<R, L, O>(
|
||||
rules_reader: csv::Reader<R>,
|
||||
lines_reader: csv::Reader<L>,
|
||||
|
||||
@@ -388,7 +388,7 @@ where
|
||||
for cost in results {
|
||||
for department in cost.summed_department_costs {
|
||||
// Any consumers should assume missing cc/account value was 0 (we already ignore overhead, as they all 0 out)
|
||||
if department.value != 0. {
|
||||
if department.value > 0.00001 || department.value < -0.00001 {
|
||||
output.serialize(CsvCost {
|
||||
account: cost.account.clone(),
|
||||
department: department.department,
|
||||
|
||||
Reference in New Issue
Block a user