mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
fix divide by zero.
This commit is contained in:
parent
1b04faad9c
commit
ab720272da
@ -42,7 +42,7 @@ namespace CarCareTracker.Helper
|
|||||||
Gallons = convertedConsumption,
|
Gallons = convertedConsumption,
|
||||||
Cost = currentObject.Cost,
|
Cost = currentObject.Cost,
|
||||||
DeltaMileage = deltaMileage,
|
DeltaMileage = deltaMileage,
|
||||||
CostPerGallon = currentObject.Cost / convertedConsumption,
|
CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0,
|
||||||
IsFillToFull = currentObject.IsFillToFull,
|
IsFillToFull = currentObject.IsFillToFull,
|
||||||
MissedFuelUp = currentObject.MissedFuelUp
|
MissedFuelUp = currentObject.MissedFuelUp
|
||||||
};
|
};
|
||||||
@ -57,7 +57,10 @@ namespace CarCareTracker.Helper
|
|||||||
else if (currentObject.IsFillToFull)
|
else if (currentObject.IsFillToFull)
|
||||||
{
|
{
|
||||||
//if user filled to full.
|
//if user filled to full.
|
||||||
gasRecordViewModel.MilesPerGallon = useMPG ? (unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption) : 100 / ((unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption));
|
if (convertedConsumption > 0.00M)
|
||||||
|
{
|
||||||
|
gasRecordViewModel.MilesPerGallon = useMPG ? (unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption) : 100 / ((unFactoredMileage + deltaMileage) / (unFactoredConsumption + convertedConsumption));
|
||||||
|
}
|
||||||
//reset unFactored vars
|
//reset unFactored vars
|
||||||
unFactoredConsumption = 0;
|
unFactoredConsumption = 0;
|
||||||
unFactoredMileage = 0;
|
unFactoredMileage = 0;
|
||||||
@ -83,7 +86,7 @@ namespace CarCareTracker.Helper
|
|||||||
Cost = currentObject.Cost,
|
Cost = currentObject.Cost,
|
||||||
DeltaMileage = 0,
|
DeltaMileage = 0,
|
||||||
MilesPerGallon = 0,
|
MilesPerGallon = 0,
|
||||||
CostPerGallon = currentObject.Cost / convertedConsumption,
|
CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0,
|
||||||
IsFillToFull = currentObject.IsFillToFull,
|
IsFillToFull = currentObject.IsFillToFull,
|
||||||
MissedFuelUp = currentObject.MissedFuelUp
|
MissedFuelUp = currentObject.MissedFuelUp
|
||||||
});
|
});
|
||||||
|
|||||||
@ -89,7 +89,7 @@ function getAndValidateGasRecordValues() {
|
|||||||
} else {
|
} else {
|
||||||
$("#gasRecordMileage").removeClass("is-invalid");
|
$("#gasRecordMileage").removeClass("is-invalid");
|
||||||
}
|
}
|
||||||
if (gasGallons.trim() == '' || parseInt(gasGallons) < 0) {
|
if (gasGallons.trim() == '' || parseFloat(gasGallons) <= 0) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
$("#gasRecordGallons").addClass("is-invalid");
|
$("#gasRecordGallons").addClass("is-invalid");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user