generated from OBJNULL/Dockerized-Rust
Fixed bug with abs date change
This commit is contained in:
parent
43cb58cab4
commit
1627998e1e
2 changed files with 9 additions and 12 deletions
|
@ -106,24 +106,18 @@ impl App {
|
||||||
let message = 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.date_str, calculation.change
|
calculation.date_str, calculation.change_abs
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
SharedString::from(format!(
|
SharedString::from(format!(
|
||||||
"Extend the billing date to {} (+{} Days).",
|
"Extend the billing date to {} (+{} Days).",
|
||||||
calculation.date_str, calculation.change
|
calculation.date_str, calculation.change_abs
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returning our CalculationResult
|
// Returning our CalculationResult
|
||||||
println!(
|
|
||||||
"Moving from {} to {}",
|
|
||||||
calculation.date_num,
|
|
||||||
calculation.date_num - calculation.change.round() as i32
|
|
||||||
);
|
|
||||||
|
|
||||||
CalcResult {
|
CalcResult {
|
||||||
start: calculation.date_num - calculation.change.round() as i32,
|
start: calculation.date_num - calculation.change_reg.round() as i32,
|
||||||
end: calculation.date_num,
|
end: calculation.date_num,
|
||||||
message,
|
message,
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ pub struct Backend {
|
||||||
memberships: Vec<String>,
|
memberships: Vec<String>,
|
||||||
}
|
}
|
||||||
pub struct CalculationResult {
|
pub struct CalculationResult {
|
||||||
pub change: f32,
|
pub change_reg: f32,
|
||||||
|
pub change_abs: f32,
|
||||||
pub date_str: String,
|
pub date_str: String,
|
||||||
pub date_num: i32,
|
pub date_num: i32,
|
||||||
pub reversed: bool,
|
pub reversed: bool,
|
||||||
|
@ -145,7 +146,8 @@ impl Backend {
|
||||||
// Stop if there's no price difference
|
// Stop if there's no price difference
|
||||||
if cost_difference == 0.0 {
|
if cost_difference == 0.0 {
|
||||||
return Ok(CalculationResult {
|
return Ok(CalculationResult {
|
||||||
change: 0.0,
|
change_reg: 0.0,
|
||||||
|
change_abs: 0.0,
|
||||||
date_str: String::new(),
|
date_str: String::new(),
|
||||||
date_num: 0,
|
date_num: 0,
|
||||||
reversed: false,
|
reversed: false,
|
||||||
|
@ -189,7 +191,8 @@ impl Backend {
|
||||||
|
|
||||||
// Ok!!
|
// Ok!!
|
||||||
Ok(CalculationResult {
|
Ok(CalculationResult {
|
||||||
change: adjustment_days_f32,
|
change_abs: adjustment_days_f32,
|
||||||
|
change_reg: adjustment_days,
|
||||||
date_str: adjusted_date_string,
|
date_str: adjusted_date_string,
|
||||||
date_num: date_number,
|
date_num: date_number,
|
||||||
reversed: adjustment_days <= 0.0,
|
reversed: adjustment_days <= 0.0,
|
||||||
|
|
Loading…
Reference in a new issue