Merge pull request #202 from hargata/Hargata/deltamileage.zero.fix

prevent delta mileage from being 0.
This commit is contained in:
Hargata Softworks 2024-01-31 11:39:33 -07:00 committed by GitHub
commit d198ad9a6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,9 +81,16 @@ namespace CarCareTracker.Helper
else if (currentObject.IsFillToFull)
{
//if user filled to full.
if (convertedConsumption > 0.00M)
if (convertedConsumption > 0.00M && deltaMileage > 0)
{
gasRecordViewModel.MilesPerGallon = useMPG ? (unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption) : 100 / ((unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption));
try
{
gasRecordViewModel.MilesPerGallon = useMPG ? (unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption) : 100 / ((unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption));
}
catch (Exception ex)
{
gasRecordViewModel.MilesPerGallon = 0;
}
}
//reset unFactored vars
unFactoredConsumption = 0;