fix: corrigir relacao matematica de % eficiencia no calculo de consumo

This commit is contained in:
2026-08-27 16:47:35 +00:00
parent 796d81b1cd
commit 190fd3afdc
+11 -8
View File
@@ -298,11 +298,12 @@ export const YieldStudyDashboard: React.FC = () => {
const weightInTons = Number(cat.weight) || 0;
const yieldPerTon = Number(cat.historicalYield) || 0;
const rawVal = Number(cat.efficiency);
const val = !isNaN(rawVal) ? rawVal : 20;
const effVal = !isNaN(rawVal) && rawVal > 0 ? rawVal : 80;
const isLegacyEfficiency = val > 60;
const efficiencyDecimal = isLegacyEfficiency ? val / 100 : (100 - val) / 100;
const lossFactor = efficiencyDecimal > 0 ? 1 / efficiencyDecimal : 1;
// Eficiência de Aplicação (%): 100% = sem perda (lossFactor = 1.0), 80% = 20% perda (lossFactor = 1.25), etc.
const effPercent = Math.min(Math.max(effVal, 1), 100);
const efficiencyDecimal = effPercent / 100;
const lossFactor = 1 / efficiencyDecimal;
// Cálculo por PESO (L/t) - Não usa mais o fator de eficiência/perda
const litrosPeso = weightInTons * yieldPerTon;
@@ -706,10 +707,10 @@ export const YieldStudyDashboard: React.FC = () => {
onChange={e => {
const selectedName = e.target.value;
const geoType = geometryTypes.find(g => g.name === selectedName);
// Update name and auto-set efficiency (loss) if found
// Update name and auto-set efficiency if found (100% - loss%)
updateCategory(cat.id, {
name: selectedName,
...(geoType && { efficiency: geoType.efficiencyLoss || 20 })
...(geoType && { efficiency: Math.max(10, 100 - (geoType.efficiencyLoss || 20)) })
});
}}
>
@@ -788,11 +789,13 @@ export const YieldStudyDashboard: React.FC = () => {
<Ruler size={12} className="absolute left-3 top-1/2 -translate-y-1/2 text-text-muted" />
<input
type="number"
min="1"
max="100"
className="w-full h-11 bg-surface border border-border/40 rounded-xl pl-9 pr-4 text-sm font-black outline-none focus:border-primary transition-all text-blue-600"
value={cat.efficiency}
onChange={e => updateCategory(cat.id, { efficiency: Number(e.target.value) })}
title="Percentual de Eficiência/Perda (Aplica-se apenas ao cálculo por Área)"
placeholder="20"
title="Eficiência de Aplicação (%) - 100% representa zero perda"
placeholder="80"
/>
</div>
</div>