Merge pull request #827 from hargata/Hargata/824
Fix number of days used when calculating cost per day.
This commit is contained in:
@@ -196,7 +196,20 @@ namespace CarCareTracker.Controllers
|
||||
var vehicleData = _dataAccess.GetVehicleById(vehicleId);
|
||||
var userConfig = _config.GetUserConfig(User);
|
||||
var totalDistanceTraveled = maxMileage - minMileage;
|
||||
var totalDays = _vehicleLogic.GetOwnershipDays(vehicleData.PurchaseDate, vehicleData.SoldDate, serviceRecords, collisionRecords, gasRecords, upgradeRecords, odometerRecords, taxRecords);
|
||||
var totalDays = 0;
|
||||
if (year != default)
|
||||
{
|
||||
if (year == DateTime.Now.Year)
|
||||
{
|
||||
totalDays = DateTime.Now.DayOfYear;
|
||||
} else
|
||||
{
|
||||
totalDays = DateTime.IsLeapYear(year) ? 366 : 365;
|
||||
}
|
||||
} else
|
||||
{
|
||||
totalDays = _vehicleLogic.GetOwnershipDays(vehicleData.PurchaseDate, vehicleData.SoldDate, serviceRecords, collisionRecords, gasRecords, upgradeRecords, odometerRecords, taxRecords);
|
||||
}
|
||||
var viewModel = new CostTableForVehicle
|
||||
{
|
||||
ServiceRecordSum = serviceRecords.Sum(x => x.Cost),
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
<thead class="sticky-top">
|
||||
<tr class="d-flex">
|
||||
<th scope="col" class="col-3 flex-grow-1">@translator.Translate(userLanguage, "Type")</th>
|
||||
<th scope="col" class="col-3 flex-grow-1">@translator.Translate(userLanguage, "Cost Per Day")</th>
|
||||
<th scope="col" class="col-3 flex-grow-1">@translator.Translate(userLanguage, Model.DistanceUnit)</th>
|
||||
<th scope="col" style="cursor:pointer;" onclick="toggleCostTableHint()" class="col-3 flex-grow-1">@translator.Translate(userLanguage, "Cost Per Day")<span class="cost-table-hint d-none">@($"({Model.NumberOfDays.ToString("N0")})")</span></th>
|
||||
<th scope="col" style="cursor:pointer;" onclick="toggleCostTableHint()" class="col-3 flex-grow-1">@translator.Translate(userLanguage, Model.DistanceUnit)<span class="cost-table-hint d-none">@($"({Model.TotalDistance.ToString("N0")})")</span></th>
|
||||
<th scope="col" class="col-3 flex-grow-1">@translator.Translate(userLanguage, "Total")</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -275,6 +275,13 @@ function toggleBarChartTableData() {
|
||||
$('[report-data="cost"]').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
function toggleCostTableHint() {
|
||||
if ($(".cost-table-hint").hasClass("d-none")) {
|
||||
$(".cost-table-hint").removeClass("d-none");
|
||||
} else {
|
||||
$(".cost-table-hint").addClass("d-none");
|
||||
}
|
||||
}
|
||||
function updateReminderPie() {
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
var daysToAdd = $("#reminderOption").val();
|
||||
|
||||
Reference in New Issue
Block a user