From ebf638841458de114bf3eb8579f8aa0251e35aec Mon Sep 17 00:00:00 2001 From: "DESKTOP-T0O5CDB\\DESK-555BD" Date: Fri, 24 Jan 2025 10:39:42 -0700 Subject: [PATCH] additional logic taking into account vehicle sold date. --- Controllers/Vehicle/ReportController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Controllers/Vehicle/ReportController.cs b/Controllers/Vehicle/ReportController.cs index 21051d4..f6d1a89 100644 --- a/Controllers/Vehicle/ReportController.cs +++ b/Controllers/Vehicle/ReportController.cs @@ -199,9 +199,17 @@ namespace CarCareTracker.Controllers var totalDays = 0; if (year != default) { - if (year == DateTime.Now.Year) + if (year == DateTime.Now.Year) //current year selected, do math based on how many days have elapsed. { totalDays = DateTime.Now.DayOfYear; + if (!string.IsNullOrWhiteSpace(vehicleData.SoldDate)) //if vehicle is sold in current year, cap the number of days to sold date. + { + var endDate = DateTime.Parse(vehicleData.SoldDate); + if (endDate.Year == DateTime.Now.Year) + { + totalDays = endDate.DayOfYear; + } + } } else { totalDays = DateTime.IsLeapYear(year) ? 366 : 365;