diff --git a/project/src/app.rs b/project/src/app.rs index 4ee3973..ae16be0 100644 --- a/project/src/app.rs +++ b/project/src/app.rs @@ -106,24 +106,18 @@ impl App { let message = if calculation.reversed { SharedString::from(format!( "Retract the billing date to {} (-{} Days).", - calculation.date_str, calculation.change + calculation.date_str, calculation.change_abs )) } else { SharedString::from(format!( "Extend the billing date to {} (+{} Days).", - calculation.date_str, calculation.change + calculation.date_str, calculation.change_abs )) }; // Returning our CalculationResult - println!( - "Moving from {} to {}", - calculation.date_num, - calculation.date_num - calculation.change.round() as i32 - ); - CalcResult { - start: calculation.date_num - calculation.change.round() as i32, + start: calculation.date_num - calculation.change_reg.round() as i32, end: calculation.date_num, message, } diff --git a/project/src/backend.rs b/project/src/backend.rs index a44d30a..e1b0e71 100644 --- a/project/src/backend.rs +++ b/project/src/backend.rs @@ -44,7 +44,8 @@ pub struct Backend { memberships: Vec, } pub struct CalculationResult { - pub change: f32, + pub change_reg: f32, + pub change_abs: f32, pub date_str: String, pub date_num: i32, pub reversed: bool, @@ -145,7 +146,8 @@ impl Backend { // Stop if there's no price difference if cost_difference == 0.0 { return Ok(CalculationResult { - change: 0.0, + change_reg: 0.0, + change_abs: 0.0, date_str: String::new(), date_num: 0, reversed: false, @@ -189,7 +191,8 @@ impl Backend { // Ok!! Ok(CalculationResult { - change: adjustment_days_f32, + change_abs: adjustment_days_f32, + change_reg: adjustment_days, date_str: adjusted_date_string, date_num: date_number, reversed: adjustment_days <= 0.0,