generated from OBJNULL/Dockerized-Rust
simplified & expanded CalculationResult
This commit is contained in:
parent
7489515962
commit
5e5882d7de
1 changed files with 14 additions and 6 deletions
|
@ -44,8 +44,9 @@ pub struct Backend {
|
|||
memberships: Vec<String>,
|
||||
}
|
||||
pub struct CalculationResult {
|
||||
pub days_pushed: f32,
|
||||
pub new_date: String,
|
||||
pub change: f32,
|
||||
pub date_str: String,
|
||||
pub date_num: i32,
|
||||
pub reversed: bool,
|
||||
pub invalid: bool,
|
||||
}
|
||||
|
@ -144,8 +145,9 @@ impl Backend {
|
|||
// Stop if there's no price difference
|
||||
if cost_difference == 0.0 {
|
||||
return Ok(CalculationResult {
|
||||
days_pushed: 0.0,
|
||||
new_date: String::new(),
|
||||
change: 0.0,
|
||||
date_str: String::new(),
|
||||
date_num: 0,
|
||||
reversed: false,
|
||||
invalid: true,
|
||||
});
|
||||
|
@ -179,11 +181,17 @@ impl Backend {
|
|||
|
||||
// Getting the Adjustment Days String
|
||||
let adjusted_date_string = billing_date_adjusted.format("%m/%d/%Y").to_string();
|
||||
let date_number = billing_date_adjusted
|
||||
.format("%d")
|
||||
.to_string()
|
||||
.parse::<i32>()
|
||||
.unwrap_or(0);
|
||||
|
||||
// Ok!!
|
||||
Ok(CalculationResult {
|
||||
days_pushed: adjustment_days_f32,
|
||||
new_date: adjusted_date_string,
|
||||
change: adjustment_days_f32,
|
||||
date_str: adjusted_date_string,
|
||||
date_num: date_number,
|
||||
reversed: adjustment_days <= 0.0,
|
||||
invalid: false,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue