Features / Farming models & harvest

ATM harvest

Logs continuous or whole-crop harvest output for the crops of a synced ATM plot. A whole-crop harvest closes the ATM and removes it from the list.

FactsheetFarming models & harvest
Who uses it
Field staff / CRP (regular cadre)
How you get here
ATM list > ATM card > Harvest (only when HARVEST_ATM_EXTERNAL_SWITCH = 1 and the ATM has a server id).
Tables
farming_model_harvest, farming_model
APIs
1 calls today, 7 App Service operations
Offline
Saved locally in farming_model_harvest and sent through the retrying operation queue (dooWithRetry), not the sync ledger, so it does not appear in Pending Sync and has no dependency on the ATM POST.

Screens

ScreenWhat it doesSource
ATM harvestChoose harvest type, pick crops, enter output per crop, capture photo and location.app/src/main/java/org/platformcommons/urvi/view/atm/harvest/AtmHarvestActivity.kt

What it captures

FieldTypeRequiredValidationOptions from
Harvest typeRadio: Continuous Harvesting (default) / Whole Crop HarvestingYesWhole selects every crop and locks the list; Continuous clears the selection for manual picks.Fixed options
Crop listCheckbox listYesContinuous: at least 1 crop. Whole: all crops.All vegetable and pulse line items of the ATM
Total Output (Quintal)Decimal, per cropYesMust be greater than 0.User input
Surplus Output (Quintal)Decimal, per cropYesMust be less than or equal to total output.User input
Harvest DateDate (dd/MM/yyyy), per cropYesNo future dates. The hidden start date is set to the same value.Date picker
PhotoCameraIf Whole Crop HarvestingOptional for Continuous.Device camera
LocationGPS (auto + Capture Location button)YesDevice GPS

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
ATM has no server idHarvest cannot open: "Please sync ATM before adding harvest data".
Harvest is submittedOne FarmingModelHarvest record per crop with unit UOM.WEIGHT.QUINTAL, harvestType HARVEST_TYPE.CONTINOUS or WHOLE_CROP, geotag "lat,lng".
Harvest type is ContinuousharvestStatus = PENDING.
Harvest type is Whole CropharvestStatus = COMPLETED; every line item becomes COMPLETED so the ATM disappears from the ATM list.
Harvest is saved locallyEvery line item of the ATM (not only the selected crops) gets the new status and type; each crop's harvest date becomes harvestCompleteDateTime.

API contracts

Each call opens to its use case, headers, request and response bodies, and errors.

App Service v2: operationUse
GET /configTyped config bundle (ETag)
GET /farmers/snapshotCursor-paged hydrated farmer snapshot
GET /farmers/{farmerId}/farming-modelsA farmer's ATM plots and DKG answers
POST /sync/batchApply an ordered batch of offline mutations
POST /filesCreate a file upload (resumable or single-shot)
PATCH /files/{fileId}Append a chunk to a resumable upload
HEAD /files/{fileId}Current offset of a resumable upload

Behaviour notes

  • Possible bug · unverified farmingModelLineItemId is set as `if (id == 0) id else null`, so the real line-item id is never sent.
  • Possible bug · unverified the photo (currentPhotoPath) is required for whole crop but never saved or uploaded.
  • Possible bug · unverified a continuous harvest of one crop marks all ATM crops PENDING; only harvested crops should change.
  • Possible bug · unverified bypasses the sync ledger, so failures are invisible to the user.

Improve in the rewrite

  • Share one harvest component with Crop Actual harvest (same units, date rules, photo/location).
  • Route through the sync ledger with a dependency on the ATM POST.
  • Either upload the photo and geotag or stop requiring them.
  • Move hard-coded English labels into string resources.