Merge pull request #601 from hargata/Hargata/div.zero.hotfix

Fix divide by zero error in Cost Per Mile metric
This commit is contained in:
Hargata Softworks
2024-09-01 11:02:42 -06:00
committed by GitHub

View File

@@ -93,7 +93,7 @@ namespace CarCareTracker.Controllers
var maxMileage = _vehicleLogic.GetMaxMileage(vehicleRecords);
var minMileage = _vehicleLogic.GetMinMileage(vehicleRecords);
var totalDistance = maxMileage - minMileage;
vehicleVM.CostPerMile = vehicleTotalCost / totalDistance;
vehicleVM.CostPerMile = totalDistance != default ? vehicleTotalCost / totalDistance : 0.00M;
vehicleVM.DistanceUnit = distanceUnit;
}
if (vehicleVM.DashboardMetrics.Contains(DashboardMetric.TotalCost))