-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix[AGRI-NMP-721]: Fertigation Calculation Fixes #722
Changes from all commits
b420349
3573859
a886949
6161861
4cd427a
c3f463a
33465ae
b446b71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -817,5 +817,12 @@ | |
"Text": "Enter the volume of fertilizer mixture to be applied; do not enter the fertigation system's total output volume.", | ||
"UserPromptPage": "Calculate", | ||
"UserJourney": "Mixed" | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New tooltip for solubilty |
||
{ | ||
"Id": 123, | ||
"Name": "solubilityinfomessage", | ||
"Text": "Determines if the fertilizer will fully dissolve based on its solubility, the total volume to apply, and the amount of fertilizer.", | ||
"UserPromptPage": "Calculate", | ||
"UserJourney": "Mixed" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,7 @@ public IActionResult FertigationDetails(string fldName, int? id, string? groupID | |
ExplainApplicationRate = _sd.GetUserPrompt("applicationinfomessage"), | ||
ExplainTime = _sd.GetUserPrompt("timeinfomessage"), | ||
ExplainTankVolume = _sd.GetUserPrompt("tankvolumeinfomessage"), | ||
ExplainSolubility = _sd.GetUserPrompt("solubilityinfomessage"), | ||
}; | ||
if(id == null){ | ||
ModelState.AddModelError("start", "invalid"); | ||
|
@@ -308,6 +309,9 @@ public IActionResult FertigationDetails(string fldName, int? id, string? groupID | |
fgvm.nutrientConcentrationN = nf.nutrientConcentrationN.ToString("#.##"); | ||
fgvm.nutrientConcentrationP205 = nf.nutrientConcentrationP205.ToString("#.##"); | ||
fgvm.nutrientConcentrationK2O = nf.nutrientConcentrationK2O.ToString("#.##"); | ||
fgvm.kglNutrientConcentrationN = (nf.nutrientConcentrationN * 0.119826m).ToString("#.##"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kg/l nutrient concentration in stock to be displayed |
||
fgvm.kglNutrientConcentrationP205 = (nf.nutrientConcentrationP205 * 0.119826m).ToString("#.##"); | ||
fgvm.kglNutrientConcentrationK2O = (nf.nutrientConcentrationK2O * 0.119826m).ToString("#.##"); | ||
if (!ft.Custom && ft.DryLiquid == "liquid") | ||
{ | ||
if (fgvm.density != _fg.GetLiquidFertilizerDensity(nf.fertilizerId, nf.liquidDensityUnitId).Value.ToString("#.##")) | ||
|
@@ -386,6 +390,10 @@ private void FertigationDetail_Reset(ref FertigationDetailsViewModel fgvm) | |
fgvm.nutrientConcentrationP205 = "0"; | ||
fgvm.nutrientConcentrationK2O = "0"; | ||
|
||
fgvm.kglNutrientConcentrationN = "0"; | ||
fgvm.kglNutrientConcentrationP205 = "0"; | ||
fgvm.kglNutrientConcentrationK2O = "0"; | ||
|
||
fgvm.totN = "0"; | ||
fgvm.totP2o5 = "0"; | ||
fgvm.totK2o = "0"; | ||
|
@@ -797,15 +805,36 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm) | |
fgvm.manualEntry); | ||
|
||
Field field = _ud.GetFieldDetails(fgvm.fieldName); | ||
// Get the selected unit's conversion factor | ||
FertilizerUnit _fU = _sd.GetFertilizerUnit(Convert.ToInt32(fgvm.selProductRateUnitOption)); | ||
// Convert the rate to imp gal | ||
decimal convertedProductRate = Convert.ToDecimal(fgvm.productRate) * _fU.ConversionToImperialGallonsPerAcre; | ||
|
||
// Method to get conversion factor based on user's selected unit for product rate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change total product units and conversion factor based on users application rate units |
||
decimal conversionFactor = 1m; | ||
switch(fgvm.selProductRateUnitOption) { | ||
case "5": // imp gal to US gallon/ac | ||
conversionFactor = 1.2m; | ||
break; | ||
case "3": // imp gal to L/ac | ||
conversionFactor = 4.546m; | ||
break; | ||
case "4": // Imp. gallon/ac | ||
break; | ||
case "6": // imp gal to L/ha | ||
conversionFactor = 2.471m; | ||
break; | ||
} | ||
|
||
// Convert the rate based on the selected unit | ||
decimal selectedProductRate = convertedProductRate * conversionFactor; | ||
|
||
//Total Product Volume per fertigation | ||
fgvm.totProductVolPerFert = Math.Round((field.Area * convertedProductRate), 1); // convert to int/string? Error messages? | ||
fgvm.totProductVolPerFert = Math.Round(field.Area * selectedProductRate, 1); // convert to int/string? Error messages? | ||
|
||
// Total product volume per growing season calc | ||
// Product Rate x Fertigation area x fert per season | ||
fgvm.totProductVolPerSeason = Math.Round((field.Area * convertedProductRate * fgvm.eventsPerSeason), 1); // convert to int/string? Error messages? | ||
fgvm.totProductVolPerSeason = Math.Round(field.Area * selectedProductRate, 1) * fgvm.eventsPerSeason; // convert to int/string? Error messages? | ||
|
||
decimal injectionRateConversion = 0; | ||
switch (fgvm.selInjectionRateUnitOption) | ||
|
@@ -833,14 +862,14 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm) | |
fgvm.fertigationTime = Math.Round(fertTimeVal, 0); | ||
|
||
//Applied nutrients per fertigation | ||
fgvm.calcN = Convert.ToInt32(fertilizerNutrients.fertilizer_N).ToString(); | ||
fgvm.calcP2o5 = Convert.ToInt32(fertilizerNutrients.fertilizer_P2O5).ToString(); | ||
fgvm.calcK2o = Convert.ToInt32(fertilizerNutrients.fertilizer_K2O).ToString(); | ||
fgvm.calcN = (Convert.ToInt32(fertilizerNutrients.fertilizer_N)/100).ToString(); | ||
fgvm.calcP2o5 = (Convert.ToInt32(fertilizerNutrients.fertilizer_P2O5)/100).ToString(); | ||
fgvm.calcK2o = (Convert.ToInt32(fertilizerNutrients.fertilizer_K2O)/100).ToString(); | ||
|
||
//Total Applied Nutrients | ||
fgvm.calcTotalN = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_N) * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
fgvm.calcTotalK2o = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_P2O5) * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
fgvm.calcTotalP2o5 = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_K2O) * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
fgvm.calcTotalN = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_N)/100 * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction to Applied Nutrients calculation, was N * tank vol / fert area now N/100 * amount to dissolve / fert area |
||
fgvm.calcTotalK2o = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_P2O5)/100 * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
fgvm.calcTotalP2o5 = Convert.ToString(Convert.ToInt32(fertilizerNutrients.fertilizer_K2O)/100 * Convert.ToInt32(fgvm.eventsPerSeason)); | ||
|
||
fgvm.btnText = fgvm.id == null ? "Add to Field" : "Update Field"; | ||
} | ||
|
@@ -1031,25 +1060,36 @@ private void SolidFertigationCalculation(FertigationDetailsViewModel fgvm){ | |
|
||
fertArea = Convert.ToDecimal(fgvm.fieldArea); | ||
|
||
//Need in lb/us gallon | ||
fgvm.nutrientConcentrationN = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valN) / 100 / (tankVolume * 1.20095m), 2)); | ||
fgvm.nutrientConcentrationK2O = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valK2o) / 100 / (tankVolume * 1.20095m), 2)); | ||
fgvm.nutrientConcentrationP205 = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valP2o5) / 100 / (tankVolume * 1.20095m), 2)); | ||
|
||
|
||
fgvm.fertigationTime = Math.Round(tankVolume / convertedInjectionRate, 0); | ||
|
||
|
||
if (amountToDissolve <= tankVolume * solInWater/1000){ | ||
//convert tankVolume from imp gal to litres | ||
//convert amountToDissolve from lbs to kgs | ||
if ((amountToDissolve * 0.45359237m) <= (tankVolume * 4.54609m * solInWater / 1000)) | ||
{ | ||
fgvm.dryAction = "Soluble"; | ||
} | ||
else{ | ||
//Need in lb/us gallon | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if soluble then calculate nutrient concentration in stock in imperial and metric |
||
fgvm.nutrientConcentrationN = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valN) / 100 / (tankVolume * 1.20095m), 2)); | ||
fgvm.nutrientConcentrationK2O = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valK2o) / 100 / (tankVolume * 1.20095m), 2)); | ||
fgvm.nutrientConcentrationP205 = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valP2o5) / 100 / (tankVolume * 1.20095m), 2)); | ||
fgvm.kglNutrientConcentrationN = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valN) / 100 / (tankVolume * 1.20095m)/8.3454043m, 2)); | ||
fgvm.kglNutrientConcentrationK2O = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valK2o) / 100 / (tankVolume * 1.20095m) * 0.119826m, 2)); | ||
fgvm.kglNutrientConcentrationP205 = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valP2o5) / 100 / (tankVolume * 1.20095m) * 0.119826m, 2)); | ||
} | ||
else | ||
{ | ||
fgvm.dryAction = "Reduce the amount to dissolve"; | ||
} | ||
|
||
fgvm.calcN = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationN) * tankVolume / fertArea, 2)); | ||
fgvm.calcK2o = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationK2O) * tankVolume / fertArea, 2)); | ||
fgvm.calcP2o5 = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationP205) * tankVolume / fertArea, 2)); | ||
// dont show nutrient concentration calculations if need to reduce amount to dissolve | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changes to 0 if user needs to reduce amount to dissolve. |
||
fgvm.nutrientConcentrationN = "0"; | ||
fgvm.nutrientConcentrationK2O = "0"; | ||
fgvm.nutrientConcentrationP205 = "0"; | ||
fgvm.kglNutrientConcentrationN = "0"; | ||
fgvm.kglNutrientConcentrationK2O = "0"; | ||
fgvm.kglNutrientConcentrationP205 = "0"; | ||
} | ||
|
||
fgvm.calcN = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationN) * amountToDissolve / fertArea, 2)); | ||
fgvm.calcK2o = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationK2O) * amountToDissolve / fertArea, 2)); | ||
fgvm.calcP2o5 = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.nutrientConcentrationP205) * amountToDissolve / fertArea, 2)); | ||
|
||
fgvm.totN = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.calcN) * fgvm.eventsPerSeason, 2)); | ||
fgvm.totK2o = Convert.ToString(Math.Round(Convert.ToDecimal(fgvm.calcK2o) * fgvm.eventsPerSeason, 2)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,11 +106,13 @@ | |
</div> | ||
</div> | ||
</div> | ||
<div class="form-group col-sm-4" style="display:flex; align-items: center; width: 160px; margin-top: 8px;"> | ||
<div class="form-group col-sm-4" style="display:flex; align-items: center; margin-right: 300px; margin-bottom: 50px;"> | ||
<div> | ||
<label > | ||
Solubility Assessment | ||
</label> | ||
<a href="#" data-toggle="tooltip" title="@Model.ExplainSolubility" id="toolTipExplainSolubility"> | ||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" title="Explanation of Solubility" style="font-size:20px;"></span> | ||
<div class="cell" style="text-align:center"> | ||
@if (Model.dryAction == "Soluble") | ||
{ | ||
|
@@ -127,33 +129,62 @@ | |
</div> | ||
</div> | ||
<div class="form-group col-sm-4" style="display:flex; align-items: center;"> | ||
<div class="Table"> | ||
<div class="Title"> | ||
<p>Nutrient Concentration In Stock Solution(lb/US gallon)</p> | ||
</div> | ||
<div class="Heading"> | ||
<div class="Cell"> | ||
<p>N</p> | ||
</div> | ||
<div class="Cell"> | ||
<p>P<sub>2</sub>O<sub>5</sub></p> | ||
</div> | ||
<div class="Cell"> | ||
<p>K<sub>2</sub>O</p> | ||
<div class="Table"> | ||
<div class="Title"> | ||
<p>Nutrient Concentration In Stock Solution(lb/US gallon)</p> | ||
</div> | ||
<div class="Heading"> | ||
<div class="Cell"> | ||
<p>N</p> | ||
</div> | ||
<div class="Cell"> | ||
<p>P<sub>2</sub>O<sub>5</sub></p> | ||
</div> | ||
<div class="Cell"> | ||
<p>K<sub>2</sub>O</p> | ||
</div> | ||
</div> | ||
<div class="Row"> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationN | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationP205 | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationK2O | ||
</div> | ||
</div> | ||
</div> | ||
<div class="Row"> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationN | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationP205 | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.nutrientConcentrationK2O | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group col-sm-4" style="display:flex; align-items: center;"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New nutrient concentration in stock table in kg/l |
||
<div class="Table"> | ||
<div class="Title"> | ||
<p>Nutrient Concentration In Stock Solution(kg/L)</p> | ||
</div> | ||
<div class="Heading"> | ||
<div class="Cell"> | ||
<p>N</p> | ||
</div> | ||
<div class="Cell"> | ||
<p>P<sub>2</sub>O<sub>5</sub></p> | ||
</div> | ||
<div class="Cell"> | ||
<p>K<sub>2</sub>O</p> | ||
</div> | ||
</div> | ||
<div class="Row"> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.kglNutrientConcentrationN | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.kglNutrientConcentrationP205 | ||
</div> | ||
<div class="Cell" style="text-align:center"> | ||
@Model.kglNutrientConcentrationK2O | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
} else { | ||
<div class="form-group col-sm-2" style="margin-right:0px; padding-right:0px; width:150px"> | ||
|
@@ -465,6 +496,9 @@ | |
@Html.HiddenFor(x => x.nutrientConcentrationN) | ||
@Html.HiddenFor(x => x.nutrientConcentrationK2O) | ||
@Html.HiddenFor(x => x.nutrientConcentrationP205) | ||
@Html.HiddenFor(x => x.kglNutrientConcentrationN) | ||
@Html.HiddenFor(x => x.kglNutrientConcentrationK2O) | ||
@Html.HiddenFor(x => x.kglNutrientConcentrationP205) | ||
|
||
</form> | ||
</div> | ||
|
@@ -509,6 +543,15 @@ $(document).ready(function () { | |
$('#toolTipExplainTankVolume').click(function () { | ||
triggerToolTip($('#toolTipExplainTankVolume')); | ||
}); | ||
//tooltip for solubility | ||
$('#toolTipExplainSolubility').tooltip({ | ||
template: toolTipClickableInnerHtml, | ||
html: true, | ||
trigger: 'manual', | ||
}); | ||
$('#toolTipExplainSolubility').click(function () { | ||
triggerToolTip($('#toolTipExplainSolubility')); | ||
}); | ||
} | ||
|
||
initializeToolTips() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to the solubility of Ammonium nitrate to 19.02 as per Ahmed's correction in the fert ppt