asdf
This commit is contained in:
@@ -220,15 +220,27 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
const validSectionId = sections.length > 0 ? sections[0].id : null;
|
||||
const validEquipmentId = planDetails?.equipment?.id;
|
||||
const validProducts = planDetails?.products && planDetails.products.length > 0 ?
|
||||
planDetails.products.map(product => ({
|
||||
productId: product.productId && !isNaN(parseInt(product.productId)) ? parseInt(product.productId) : null,
|
||||
userProductId: product.userProductId && !isNaN(parseInt(product.userProductId)) ? parseInt(product.userProductId) : null,
|
||||
planDetails.products.map(product => {
|
||||
const productData = {
|
||||
rateAmount: product.rateAmount,
|
||||
rateUnit: product.rateUnit,
|
||||
actualProductAmount: product.actualProductAmount || product.productAmount,
|
||||
actualWaterAmount: product.actualWaterAmount || product.waterAmount,
|
||||
actualProductAmount: product.actualProductAmount || product.calculatedProductAmount,
|
||||
actualWaterAmount: product.actualWaterAmount || product.calculatedWaterAmount,
|
||||
actualSpeedMph: Math.max(averageSpeed, 0.1) // Ensure positive speed
|
||||
})).filter(product => product.productId || product.userProductId) : []; // Ensure at least one ID is valid
|
||||
};
|
||||
|
||||
// Only include productId if it's a valid number
|
||||
if (product.productId && !isNaN(parseInt(product.productId))) {
|
||||
productData.productId = parseInt(product.productId);
|
||||
}
|
||||
|
||||
// Only include userProductId if it's a valid number
|
||||
if (product.userProductId && !isNaN(parseInt(product.userProductId))) {
|
||||
productData.userProductId = parseInt(product.userProductId);
|
||||
}
|
||||
|
||||
return productData;
|
||||
}).filter(product => product.productId || product.userProductId) : []; // Ensure at least one ID is valid
|
||||
|
||||
// Validate required fields
|
||||
if (!validSectionId) {
|
||||
@@ -248,7 +260,7 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
planId: application.id,
|
||||
lawnSectionId: validSectionId,
|
||||
equipmentId: validEquipmentId,
|
||||
completedDate: endTime.toISOString(), // Try completedDate instead
|
||||
date: endTime.toISOString(), // Try date field
|
||||
gpsTrack: {
|
||||
points: gpsTrack,
|
||||
totalDistance: totalDistance,
|
||||
|
||||
Reference in New Issue
Block a user