efasdf
This commit is contained in:
@@ -20,7 +20,7 @@ const ApplicationPlanModal = ({
|
|||||||
const [selectedNozzleId, setSelectedNozzleId] = useState('');
|
const [selectedNozzleId, setSelectedNozzleId] = useState('');
|
||||||
const [selectedProducts, setSelectedProducts] = useState([]);
|
const [selectedProducts, setSelectedProducts] = useState([]);
|
||||||
const [applicationType, setApplicationType] = useState('');
|
const [applicationType, setApplicationType] = useState('');
|
||||||
const [plannedDate, setPlannedDate] = useState('');
|
const [plannedDate, setPlannedDate] = useState(new Date().toISOString().split('T')[0]);
|
||||||
const [notes, setNotes] = useState('');
|
const [notes, setNotes] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [spreaderSettings, setSpreaderSettings] = useState({});
|
const [spreaderSettings, setSpreaderSettings] = useState({});
|
||||||
@@ -356,45 +356,59 @@ const ApplicationPlanModal = ({
|
|||||||
return total + (area?.area || 0);
|
return total + (area?.area || 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
const totalAreaSquareMeters = totalArea * 0.092903; // Convert sq ft to sq meters
|
||||||
|
|
||||||
|
let waterNeeded = 0;
|
||||||
|
|
||||||
|
// For liquid applications, calculate water needed once for all products
|
||||||
|
if (applicationType === 'liquid' && selectedNozzleId && selectedEquipmentId) {
|
||||||
|
const selectedNozzle = nozzles.find(n => n.id === parseInt(selectedNozzleId));
|
||||||
|
const selectedEquipment = equipment.find(eq => eq.id === parseInt(selectedEquipmentId));
|
||||||
|
|
||||||
|
if (selectedNozzle && selectedEquipment && selectedNozzle.flowRateGpm && selectedEquipment.sprayWidthFeet) {
|
||||||
|
// Convert units
|
||||||
|
const flowRateLPM = selectedNozzle.flowRateGpm * 3.78541; // GPM to L/min
|
||||||
|
const widthMeters = selectedEquipment.sprayWidthFeet * 0.3048; // feet to meters
|
||||||
|
const speedMPM = 107.29; // Assumed speed in meters/minute (4 km/h)
|
||||||
|
|
||||||
|
// Carrier application rate: Rate (L/m²) = flow (L/min) / (width (m) × speed (m/min))
|
||||||
|
const carrierRate = flowRateLPM / (widthMeters * speedMPM);
|
||||||
|
|
||||||
|
// Total water needed = carrier rate × total area
|
||||||
|
const waterNeededLiters = carrierRate * totalAreaSquareMeters;
|
||||||
|
waterNeeded = waterNeededLiters * 0.264172; // Convert liters to gallons
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const calculations = selectedProducts.map(product => {
|
const calculations = selectedProducts.map(product => {
|
||||||
const rateAmount = parseFloat(product.rateAmount) || 0;
|
const rateAmount = parseFloat(product.rateAmount) || 0;
|
||||||
const areaIn1000s = totalArea / 1000;
|
|
||||||
|
|
||||||
if (product.productType === 'granular') {
|
if (product.productType === 'granular') {
|
||||||
// Granular calculations
|
// Granular calculations - total product needed
|
||||||
const totalProductNeeded = rateAmount * areaIn1000s;
|
const totalProductNeeded = (rateAmount * totalArea) / 1000; // Rate is per 1000 sq ft
|
||||||
return {
|
return {
|
||||||
productName: product.productName,
|
productName: product.productName,
|
||||||
totalProductNeeded: totalProductNeeded.toFixed(2),
|
totalProductNeeded: totalProductNeeded.toFixed(2),
|
||||||
unit: product.rateUnit,
|
unit: product.rateUnit?.replace('/1000sqft', '').replace('/1000 sq ft', '') || 'lbs',
|
||||||
waterNeeded: 0 // No water for granular
|
waterNeeded: 0 // No water for granular
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Liquid calculations
|
// Liquid calculations - total product needed
|
||||||
const totalProductNeeded = rateAmount * areaIn1000s;
|
const totalProductNeeded = (rateAmount * totalArea) / 1000; // Rate is per 1000 sq ft
|
||||||
|
|
||||||
// Calculate water needed based on nozzle and equipment settings
|
|
||||||
let waterNeeded = 0;
|
|
||||||
if (selectedNozzleId) {
|
|
||||||
const selectedNozzle = nozzles.find(n => n.id === parseInt(selectedNozzleId));
|
|
||||||
if (selectedNozzle && selectedNozzle.flowRateGpm) {
|
|
||||||
// Basic calculation - this would need equipment speed settings for accuracy
|
|
||||||
waterNeeded = (selectedNozzle.flowRateGpm * 60 * areaIn1000s) / 1000; // Rough estimate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
productName: product.productName,
|
productName: product.productName,
|
||||||
totalProductNeeded: totalProductNeeded.toFixed(2),
|
totalProductNeeded: totalProductNeeded.toFixed(2),
|
||||||
unit: product.rateUnit,
|
unit: product.rateUnit?.replace('/1000sqft', '').replace('/1000 sq ft', '') || 'oz',
|
||||||
waterNeeded: waterNeeded.toFixed(1)
|
waterNeeded: 0 // Water calculated separately for liquid
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalArea: totalArea.toLocaleString(),
|
totalArea: totalArea.toLocaleString(),
|
||||||
calculations
|
calculations,
|
||||||
|
waterNeeded: waterNeeded > 0 ? waterNeeded.toFixed(1) : 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -805,9 +819,13 @@ const ApplicationPlanModal = ({
|
|||||||
<div key={index} className="mb-2">
|
<div key={index} className="mb-2">
|
||||||
<p className="font-medium">{calc.productName}:</p>
|
<p className="font-medium">{calc.productName}:</p>
|
||||||
<p className="ml-2">Product needed: {calc.totalProductNeeded} {calc.unit}</p>
|
<p className="ml-2">Product needed: {calc.totalProductNeeded} {calc.unit}</p>
|
||||||
{calc.waterNeeded > 0 && <p className="ml-2">Water needed: {calc.waterNeeded} gallons</p>}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
{applicationType === 'liquid' && calculations.waterNeeded > 0 && (
|
||||||
|
<div className="mt-2 pt-2 border-t border-blue-200">
|
||||||
|
<p className="font-medium">Water needed: {calculations.waterNeeded} gallons</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null;
|
) : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user