generated from OBJNULL/Dockerized-Rust
App now adapts CalcResult & Updated CalculationResult
This commit is contained in:
parent
5e5882d7de
commit
43cb58cab4
1 changed files with 28 additions and 7 deletions
|
@ -75,9 +75,13 @@ impl App {
|
||||||
|| new_membership == "Select One..."
|
|| new_membership == "Select One..."
|
||||||
|| last_billing == "NULL"
|
|| last_billing == "NULL"
|
||||||
{
|
{
|
||||||
return SharedString::from(
|
return CalcResult {
|
||||||
"Please fill out all fields before calculating the Prorate.",
|
message: SharedString::from(
|
||||||
);
|
"Please fill out all fields before calculating the Prorate.",
|
||||||
|
),
|
||||||
|
start: 0,
|
||||||
|
end: 0,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Making the Backend Calculate This
|
// Making the Backend Calculate This
|
||||||
|
@ -91,20 +95,37 @@ impl App {
|
||||||
|
|
||||||
// Is there no cost difference?
|
// Is there no cost difference?
|
||||||
if calculation.invalid {
|
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
|
// Returning the Result
|
||||||
if calculation.reversed {
|
let message = if calculation.reversed {
|
||||||
SharedString::from(format!(
|
SharedString::from(format!(
|
||||||
"Retract the billing date to {} (-{} Days).",
|
"Retract the billing date to {} (-{} Days).",
|
||||||
calculation.new_date, calculation.days_pushed
|
calculation.date_str, calculation.change
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
SharedString::from(format!(
|
SharedString::from(format!(
|
||||||
"Extend the billing date to {} (+{} Days).",
|
"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,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue