From 43cb58cab455ec0366052e2492f6c4e2b63a74cd Mon Sep 17 00:00:00 2001 From: Maddox Werts Date: Sat, 2 Aug 2025 15:04:14 -0400 Subject: [PATCH] App now adapts CalcResult & Updated CalculationResult --- project/src/app.rs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/project/src/app.rs b/project/src/app.rs index 2d2a952..4ee3973 100644 --- a/project/src/app.rs +++ b/project/src/app.rs @@ -75,9 +75,13 @@ impl App { || new_membership == "Select One..." || last_billing == "NULL" { - return SharedString::from( - "Please fill out all fields before calculating the Prorate.", - ); + return CalcResult { + message: SharedString::from( + "Please fill out all fields before calculating the Prorate.", + ), + start: 0, + end: 0, + }; } // Making the Backend Calculate This @@ -91,20 +95,37 @@ impl App { // Is there no cost difference? if calculation.invalid { - return SharedString::from("No price difference, don't change anything."); + return CalcResult { + message: SharedString::from("No price difference, don't change anything."), + start: 0, + end: 0, + }; } // Returning the Result - if calculation.reversed { + let message = if calculation.reversed { SharedString::from(format!( "Retract the billing date to {} (-{} Days).", - calculation.new_date, calculation.days_pushed + calculation.date_str, calculation.change )) } else { SharedString::from(format!( "Extend the billing date to {} (+{} Days).", - calculation.new_date, calculation.days_pushed + calculation.date_str, calculation.change )) + }; + + // 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, + end: calculation.date_num, + message, } });