Resolve year calculation issues.

This commit is contained in:
Patrick Fic
2021-11-08 06:23:43 -08:00
parent 41ff382067
commit e043d6cbaf
2 changed files with 8 additions and 6 deletions

View File

@@ -73,5 +73,10 @@
"title": "Release Notes for 1.0.23",
"date": "10/13/2021",
"notes": "New Features: \n- Improved detection of glass and glass related lines.\n- Improved detection of manual part changes."
},
"1.0.24": {
"title": "Release Notes for 1.0.24",
"date": "11/08/2021",
"notes": "New Features: \n- Resolved age calculation issue for model year 2022 vehicles."
}
}

View File

@@ -20,14 +20,11 @@ export function CalculateVehicleAge(job) {
const parsedYr = parseInt(job.v_model_yr);
const vehicleYr =
moment().year() - 2000 >= parsedYr ? 2000 + parsedYr : 1900 + parsedYr;
moment().year() + 1 - 2000 >= parsedYr ? 2000 + parsedYr : 1900 + parsedYr;
let ret =
moment().year() - 2000 < parsedYr
? 0
: moment(job.close_date || new Date()).year() - vehicleYr;
let ret;
if (ret < 0) ret = 0;
ret = Math.max(0, moment(job.close_date || new Date()).year() - vehicleYr);
return ret;
}