From 97c613b52a1dd0ad414a9c55ec69e03bfae8208d Mon Sep 17 00:00:00 2001 From: "DESKTOP-GENO133\\IvanPlex" Date: Wed, 3 Jan 2024 20:51:14 -0700 Subject: [PATCH] cost makeup report --- Controllers/VehicleController.cs | 12 +++++-- Properties/launchSettings.json | 2 +- Views/Vehicle/Index.cshtml | 8 +++-- Views/Vehicle/_CostMakeUpReport.cshtml | 44 ++++++++++++++------------ Views/Vehicle/_Report.cshtml | 30 ++++++++++++++++++ wwwroot/js/vehicle.js | 18 ++++++----- 6 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 Views/Vehicle/_Report.cshtml diff --git a/Controllers/VehicleController.cs b/Controllers/VehicleController.cs index 975138a..2409534 100644 --- a/Controllers/VehicleController.cs +++ b/Controllers/VehicleController.cs @@ -384,7 +384,7 @@ namespace CarCareTracker.Controllers [HttpGet] public IActionResult GetReportPartialView() { - return PartialView("_CostMakeUpReport"); + return PartialView("_Report"); } [HttpGet] public IActionResult GetCostMakeUpForVehicle(int vehicleId, string startDate = "", string endDate = "") @@ -399,13 +399,21 @@ namespace CarCareTracker.Controllers DateTime.TryParse(endDate, out DateTime parsedEndDate) ) { + parsedEndDate = parsedEndDate.AddDays(1).AddSeconds(-1); //if start and end dates are provided then we need to filter the data down. serviceRecords.RemoveAll(x => x.Date < parsedStartDate || x.Date > parsedEndDate); gasRecords.RemoveAll(x => x.Date < parsedStartDate || x.Date > parsedEndDate); collisionRecords.RemoveAll(x => x.Date < parsedStartDate || x.Date > parsedEndDate); taxRecords.RemoveAll(x => x.Date < parsedStartDate || x.Date > parsedEndDate); } - return Json(true); + var viewModel = new CostMakeUpForVehicle + { + ServiceRecordSum = serviceRecords.Sum(x => x.Cost), + GasRecordSum = gasRecords.Sum(x => x.Cost), + CollisionRecordSum = collisionRecords.Sum(x => x.Cost), + TaxRecordSum = taxRecords.Sum(x => x.Cost) + }; + return PartialView("_CostMakeUpReport", viewModel); } //public IActionResult GetFuelCostByMonthByVehicle(int vehicleId) //{ diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 03a65eb..e699de7 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -7,7 +7,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "dotnetRunMessages": true, - "applicationUrl": "http://10.10.2.60:5011" + "applicationUrl": "http://10.10.2.61:5011" }, "IIS Express": { "commandName": "IISExpress", diff --git a/Views/Vehicle/Index.cshtml b/Views/Vehicle/Index.cshtml index 88647e8..33ac652 100644 --- a/Views/Vehicle/Index.cshtml +++ b/Views/Vehicle/Index.cshtml @@ -8,7 +8,7 @@ - + }
@@ -35,6 +35,9 @@ +