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>,
|
memberships: Vec<String>,
|
||||||
}
|
}
|
||||||
pub struct CalculationResult {
|
pub struct CalculationResult {
|
||||||
pub days_pushed: f32,
|
pub change: f32,
|
||||||
pub new_date: String,
|
pub date_str: String,
|
||||||
|
pub date_num: i32,
|
||||||
pub reversed: bool,
|
pub reversed: bool,
|
||||||
pub invalid: bool,
|
pub invalid: bool,
|
||||||
}
|
}
|
||||||
|
@ -144,8 +145,9 @@ 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 {
|
||||||
days_pushed: 0.0,
|
change: 0.0,
|
||||||
new_date: String::new(),
|
date_str: String::new(),
|
||||||
|
date_num: 0,
|
||||||
reversed: false,
|
reversed: false,
|
||||||
invalid: true,
|
invalid: true,
|
||||||
});
|
});
|
||||||
|
@ -179,11 +181,17 @@ impl Backend {
|
||||||
|
|
||||||
// Getting the Adjustment Days String
|
// Getting the Adjustment Days String
|
||||||
let adjusted_date_string = billing_date_adjusted.format("%m/%d/%Y").to_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!!
|
||||||
Ok(CalculationResult {
|
Ok(CalculationResult {
|
||||||
days_pushed: adjustment_days_f32,
|
change: adjustment_days_f32,
|
||||||
new_date: adjusted_date_string,
|
date_str: adjusted_date_string,
|
||||||
|
date_num: date_number,
|
||||||
reversed: adjustment_days <= 0.0,
|
reversed: adjustment_days <= 0.0,
|
||||||
invalid: false,
|
invalid: false,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue