TotalApp Docs

Agro-Tech Execution

From scheduled field task through IoT-driven monitoring, harvest scheduling, yield capture, and resource metering — the operational execution pipeline of a growing season.

What this group does

The Agro-Tech Execution group is the field-to-harvest operational pipeline for Agriculture & Agro-Tech Operations. It carries a production cycle from a scheduled field task through IoT-driven monitoring, season and harvest scheduling, yield capture, and resource metering — each screen writing real data forward to the next.

Field/Greenhouse Orders
Season & Harvest Scheduling
IoT Climate & Soil Monitor
Crop Yield Dashboard
Resource Counters

All five screens share one service file, src/services/agroTechExecutionService.ts, so most cross-screen hooks below are real read-modify-write calls against sibling records in the same file rather than simulated hand-offs. A few reach out to harvestSupplyInventoryService.ts and qualityCropHealthService.ts for staging, consumption, WIP, and pre-harvest audit data.

1. Field/Greenhouse Orders

Purpose: Schedule and execute the four core field tasks — plowing, fertigation, pesticide spraying, and pruning — against a specific field or greenhouse, and log what actually happened once the crew is done.

Key features

  • Task typesplowing, fertigation, pesticide_spraying, pruning, each order (FOD-2026-XXXX) targeting a ProductionAreaItem field/greenhouse code.
  • Order lifecycledraft → scheduled → in_progress → completed → qa_on_hold, tracked via FieldOrderStatus badges.
  • Execution log — actual start/end times, fuel/energy consumed, operator observations, materials used (planned vs. actual rate per material), hours worked, and a crop-health-anomaly flag the field crew can raise directly from the execution form.
  • Assignment — links the order to an assigned workforce member (Employee.uid) and, optionally, an assigned equipment asset.

Integration triggers

ActionWhat it does
syncOrderMaterialsToConsumptionOn save when status transitions to completed with materials logged: deducts the matching SKU's on-hand quantity in Agro-Input Staging (deductStagingStock) and writes a consumption record into Agro-Material Consumption for each material used — see Harvest & Supply Inventory.
updateAssetOperatingHoursIntended to roll logged hours worked into the assigned asset's cumulative operating hours to trigger Preventive Maintenance scheduling. Currently a no-op stub — no maintenance screen exists yet in this add-on to receive the update (see Agro-Equipment Maintenance).
flagCropHealthAnomalyIntended to open an alert directly in Pest & Disease Alerts when the crew reports a crop-health anomaly during execution. Currently a no-op stub — kept with the exact call signature the screen already uses, pending wiring to qualityCropHealthService.ts's alert store.

2. Season & Harvest Scheduling

Purpose: Plan a crop's full season — planting through harvest window — against a target harvest and a target field/greenhouse, track milestones, and reserve downstream storage capacity.

Key features

  • Schedule codesHSC-2026-XXXX, each linked to a TargetHarvestItem and a ProductionAreaItem.
  • Status lifecycleplanned → maturing → ready_for_harvest → active_harvesting → completed.
  • Milestones — a checklist of dated milestones (label, target date, completed flag) tracked per schedule.
  • Harvest Readiness Score — computed by computeHarvestReadinessScore() from accumulated Growing Degree Days (GDD) against a maturity target, blended 70/30 with soil moisture health.
  • Silo reservation — a target silo and expected volume can be set on the schedule; reserving capacity calls into the Silo & Storage Management registry.
  • Pre-harvest clearance gatepreHarvestClearanceApproved and harvestLockoutActive flags block harvest authorization until a Crop Health Checklist pre-harvest audit passes and any active PHI (Pre-Harvest Interval) window from Agro-Chemical Analytics has cleared.

Integration triggers

ActionWhat it does
syncScheduleToWIPWhen a schedule is locked in, instantiates an active crop-cycle batch (GrowingCropWIPRecord, status germination) in Growing Crop Tracking WIP — see Harvest & Supply Inventory.
reserveStorageCapacityAdds the schedule's expected harvest volume to the target silo's reservedTons in the Silo & Storage Management registry (owned by harvestSupplyInventoryService.ts, re-exported here — see the implementation note in Harvest & Supply Inventory).
schedulePreHarvestQualityAuditDispatches a mandatory pre_harvest_audit inspection request into Crop Health Checklist, status requires_attention, linked back to this schedule — see Quality & Crop Health Operations.

3. IoT Climate & Soil Monitor

Purpose: Monitor live telemetry from field/greenhouse sensor nodes — temperature, humidity, soil moisture, EC, pH, VPD — and automatically respond when readings cross configured thresholds.

Key features

  • Node codesIOT-2026-XXXX, each targeting a ProductionAreaItem and optionally an AgronomicSopItem.
  • Sensor statusoptimal, warning_dry_soil, critical_high_temp, sensor_offline.
  • Telemetry fields — ambient temp (°C), relative humidity (%), soil moisture (%), soil EC, soil pH, VPD (kPa), battery (%), signal strength (%), last ping timestamp.
  • Microclimate Health Score — computed by computeMicroclimateHealthScore(), comparing ambient temp/humidity/pH against the crop recipe's target growth-stage parameters.
  • Configurable thresholds — per-node min/max bounds for temp, humidity, and soil moisture (IoTThresholdConfig) drive the automated triggers below.

Integration triggers

ActionWhat it does
triggerAutomatedFieldOrderWhen soil moisture drops below the node's configured threshold, generates an emergency fertigation field order (status scheduled) directly into Field/Greenhouse Orders' ledger — both screens share this same service file.
createMaintenanceWorkOrderWhen a node pings offline or reports corrupt values, dispatches a hardware maintenance work order via maintenanceWorkOrderService (the domain-agnostic engine already used elsewhere in TotalApp).

4. Crop Yield Dashboard

Purpose: Capture the actual harvest outcome per batch — yield per hectare, quality grade, weighbridge reading, defects — and compare it against the target baseline.

Key features

  • Yield recordsYLD-2026-XXXX, linked to a harvest batch code, an optional harvest schedule, and a TargetHarvestItem.
  • Quality gradesgrade_a_premium, grade_b_industrial, grade_c_waste.
  • Yield variancecomputeYieldVariancePercent() compares actualYieldPerHa against targetYieldBaselinePerHa; positive means the harvest outperformed baseline.
  • Defect tracking — a list of defect entries (reason, percent of loss) plus an overall percent loss/waste figure.
  • Weighbridge reading & silo receipt — actual tonnage from the weighbridge and a silo receipt certificate URL for the batch.

Integration triggers

ActionWhat it does
publishYieldToTraceabilityOnce a yield record is validated, generates a serialized lot (LOT-2026-XXXX) directly in the Farm-to-Fork Traceability store, carrying origin field, harvest batch code, and a link back to this yield record — see Quality & Crop Health Operations.
syncYieldVarianceToTargetHarvestsFolds the actual yield into Target Harvests' running ML baseline average for that crop product (updateMlBaselineYield in targetHarvestService).
logInboundStorageBatchCreates an unverified intake lot directly in the Silo & Storage Management registry when a harvest batch is reconciled — see Harvest & Supply Inventory.

5. Resource Counters

Purpose: Meter utility consumption — irrigation water, electricity, diesel, natural gas — per field/greenhouse zone against a daily quota, and post the observed cost downstream.

Key features

  • Counter codesCTR-2026-XXXX, resource types irrigation_water_m3, electricity_kwh, diesel_liters, natural_gas_m3.
  • Counter statusnormal, threshold_exceeded, possible_leak_overuse, uncalibrated.
  • Net usage & quotacomputeNetUsage() clamps previous-vs-current reading to a non-negative delta (so a meter rollover never reports negative usage); computeDailyQuotaPercent() shows percent of the daily limit allowance consumed.
  • Leak/surge flagsleakFlagged and powerSurgeFlagged booleans, plus a photo-proof URL and last calibration date per counter.
  • SOP cost attribution — each counter can be linked to an AgronomicSopItem so its usage cost rolls into that SOP's running cost basis.

Integration triggers

ActionWhat it does
postResourceToMaterialConsumptionPosts the counter's net usage and total cost into Agro-Material Consumption's ledger, mapped to the matching source category (water_utilities, power_electricity, or fuel) — see Harvest & Supply Inventory.
flagEquipmentPipeLeakDispatches an emergency maintenance work order ("Abnormal Utility Surge / Leak") via the same createMaintenanceWorkOrder helper used by IoT Climate & Soil Monitor.
recalculateSopCostBasisFolds the counter's observed utility cost into the linked SOP's running cost-basis average (updateUtilityCostBasis in agronomicSopService).

End-to-end data flow

Source screen / functionWritesTarget screen / record
Field/Greenhouse Orders — syncOrderMaterialsToConsumptionDeducts staging stock; new consumption recordAgro-Input Staging + Agro-Material Consumption
Season & Harvest Scheduling — syncScheduleToWIPNew GrowingCropWIPRecord (germination stage)Growing Crop Tracking WIP
Season & Harvest Scheduling — reserveStorageCapacityIncrements reservedTons on target siloSilo & Storage Management registry
Season & Harvest Scheduling — schedulePreHarvestQualityAuditNew pre_harvest_audit checklistCrop Health Checklist
IoT Climate & Soil Monitor — triggerAutomatedFieldOrderNew fertigation field orderField/Greenhouse Orders
IoT Climate & Soil Monitor — createMaintenanceWorkOrderNew maintenance work ordermaintenanceWorkOrderService (domain-agnostic)
Crop Yield Dashboard — publishYieldToTraceabilityNew serialized lot (LOT-2026-XXXX)Farm-to-Fork Traceability
Crop Yield Dashboard — syncYieldVarianceToTargetHarvestsUpdates ML baseline yield averageTarget Harvests
Crop Yield Dashboard — logInboundStorageBatchNew unverified intake lotSilo & Storage Management registry
Resource Counters — postResourceToMaterialConsumptionNew consumption record (utility category)Agro-Material Consumption
Resource Counters — flagEquipmentPipeLeakNew maintenance work ordermaintenanceWorkOrderService (domain-agnostic)
Resource Counters — recalculateSopCostBasisUpdates SOP running cost basisAgronomic SOPs

Frequently Asked Questions

Why does an emergency field order created by IoT Climate & Soil Monitor have no assigned workforce?
triggerAutomatedFieldOrder creates the order with empty assignedWorkforceId/assignedWorkforceCode fields — it's a scheduling placeholder that still needs a human to assign a crew from Field/Greenhouse Orders before it can move past scheduled.
Why doesn't logging a crop-health anomaly during field execution create an alert yet?
flagCropHealthAnomaly is currently a no-op stub in agroTechExecutionService.ts — the anomaly flag is saved on the order's execution log, but the automatic escalation into Pest & Disease Alerts is not yet wired.
What is the Harvest Readiness Score based on?
A weighted blend: 70% from accumulated Growing Degree Days versus the crop's target GDD, and 30% from how close soil moisture sits to a 50% midpoint. It's computed live by computeHarvestReadinessScore() whenever the schedule's telemetry-fed fields change.
Can a harvest schedule be moved to active_harvesting while a PHI window is still active?
No — harvestLockoutActive is set by Agro-Chemical Analytics whenever a Pre-Harvest Interval is still counting down on that field, and it blocks harvest authorization until the interval clears. See Quality & Crop Health Operations for the PHI mechanics.
Why does a resource counter reading never go negative even after a meter reset?
computeNetUsage() clamps the previous-vs-current delta at zero, so a counter rollover or hardware reset is reported as zero usage for that reading rather than a nonsensical negative number.
Where does the material consumption cost logged from a field order actually get priced?
syncOrderMaterialsToConsumption writes the consumption record with unitCost/totalCost at zero — pricing is applied afterward in Agro-Material Consumption itself, which owns the ledger. See Harvest & Supply Inventory.