Features / Planning & tracking

Crop Actual (portfolio)

Monthly record of what is actually growing on each land parcel. Each crop block is a "Portfolio line item" (type SEASON_ACTUAL) with crops and acres, natural-farming (NF) practices, crop type, photo, geofence and harvest; blocks are copied forward month to month.

FactsheetPlanning & tracking
Who uses it
Cadre userUnit login (Unit In-charge / FMT: practices only when PLI edit for FMT is off)HAN user (blocked)
How you get here
Farmer hub, Crop Actual tile. Needs the Crop Actual switch, a category that is not C4/C5, and at least one authenticated land (or no land).
Tables
portfolio, portfolio_portfoliolineitem, portfolio_portfoliolineitem_portfolioproductlineitem, portfolio_question_response, harvest_logs
APIs
13 calls today, 10 App Service operations
Offline
Add/edit work offline and are queued. Month copy falls back to local data. Harvest needs the block to be synced first; available acres use online datasets (PlusOneGetOwnedLandByIEID, PlusOneGetATMNFUsedAcreageByIEID) when available.

Screens

ScreenWhat it doesSource
Crop Actual listOne section "Crop Actual : <current month>" with crop block cards.app/src/main/java/org/platformcommons/urvi/view/portfolio/PortfolioActivity.kt
Crop block cardCrops, practices, PMDS answers, photo, Tile Id, edit/harvest/geofence actions, sync errors.app/src/main/java/org/platformcommons/urvi/view/portfolio/PortfolioBinderAdapter.kt
Add / Edit / Harvest crop blockForm for one block.app/src/main/java/org/platformcommons/urvi/view/portfolio/AddPortfolioActivity.kt
Select land sheetPick an active land parcel.app/src/main/java/org/platformcommons/urvi/view/portfolio/SelectLandBottomSheet.kt

What it captures

FieldTypeRequiredValidationOptions from
PhotoImage pickerNoCompressed and uploaded as a line-item attachment; not editable in harvest mode.Camera / gallery
LandBottom-sheet pickYesNot changeable in Edit. Shows online available acres (owned minus leased minus used) and leased acres. Land with 0 or less available shows "selected land is leased".Farmer's active land
Crop typeDialogYes (before adding crops)Agriculture, Horticulture, Polycropping, PMDS (pre-monsoon dry sowing), RDS (rabi dry sowing), A Grade, No NF CROP. PMDS and RDS only when enabled by config.Fixed list
Crop type change reasonDialogIf crop type changes in EditPMDS: Wrong entry, Soil incorporation, Integration with Kharif. Others: Wrong entry, Crop failed, Harvest complete, Other (free text: letters, digits, "-", "( )" and space).Fixed list
Crops (main)Multi-selectYes (at least 1)A Grade allows one only. PMDS auto-adds the AP_GOV_PMDS crop and hides Add crop. "No NF crop" shows every crop. Dummy crops are removed.Select Crop sheet filtered by crop type
Acres (per crop)DecimalYesGreater than 0; max 99.99 (2 digits before and after point). Locked if harvested, a placeholder or not editable.User input
Major cropStar toggleNoUser input
Seed variety (per crop)Pick or free textNoFree text allows letters, digits, "-", "( )" and space.Seed variety list in code
Expected harvest date (per crop)DateNoEarliest date is today.User input
Edit reason (per crop)DialogIf the crop was edited in Edit modeWrong Entry / Crop Failed / Harvest Completed / Other (text). Error: "Please enter edit reason for crop X".Fixed list
Delete reason (per crop)TextIf deleting a crop that existed beforeDelete is hidden for PMDS, A Grade, compact-block items, harvested crops and harvest mode.User input
Associated cropsMulti-selectIf A Grade (at least 2)Select Crop sheet
Bio-diversity cropsMulti-selectIf A Grade (at least 2)Select Crop sheet
Sowing dateDateNoNeeds crops first. From today minus 6 months to today (in Edit, max = item created date). Applied to all crops; reset when crop type changes.User input
NF practicesMulti-select dialogYes (at least 1)Needs crops first. "No NF crop" auto-selects the No NF crop practice and locks the picker; A Grade auto-adds the A Grade practice.Practice master in local DB, else bundled practice_master.json

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
The farmer has no landAdd shows "no land asset for farmer".
The selected land is disabledSaving is blocked: "cannot add crop against disabled land".
SavingAcres of unharvested crops in this block + acres of all current-season blocks on the same land must not exceed land acres minus ATM land; else "Land limit exceed".
Any crop in the block has been harvestedChanging crop type and adding crops are blocked.
Crop type changesCrops and practices reset (a compact-block-linked item keeps its main crops).
Switching from PMDS with reason "soil incorporation" or "integration with kharif"The PMDS practice is pre-selected.
Logged in as Unit In-charge/FMT and FMT editing is offEverything except practices is frozen.
The line item is linked to a Compact Block, or its land is missing/disabledEdit is hidden on the card.
Harvest is enabled and no crop is a placeholderHarvest is shown; it refuses until the item has a server id ("crop not synced").
Every main crop is fully (WHOLE) harvestedA new block with the same Tile Id is created for the current month with placeholder crops of the same acres, keeping only the A Grade practice.
The current month is empty and the copy config is onLast month's blocks are copied in (from the server if online, the farmer is synced and online copy is not disabled; otherwise from local data, preferring synced items per Tile Id).
There is nothing in the current season but the previous season has itemsThey are carried over with the season renamed, practices cleared (except A Grade), placeholder crops, seed details cleared and associated/bio-diversity crops removed.
Blocks are copiedThey get new ids and first-of-month dates, the "% chemical farming" practice is removed, and photo and geofence are re-posted (falling back to the land geofence).
Land of a copied block is disabled or missingThe block is skipped unless copying disabled Crop Actual is enabled.
Two cards share a Tile IdThey are flagged as duplicates with a coloured border.
Server rejects the block because the land checksum changedThe card shows a "land details changed" banner with the new acres.
Saving in Edit modeA change log (crops added/removed, acres or crop type changed, with reasons) is stored.
Swipe to refresh, the farmer has a server id and the interval has passedCrop Actual is fetched online.

API contracts

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

Today: callUseReplaced by
GET /ctld/api/product/v1 (generated ProductAPI.getProduct)Load the tenant product (crop/input) master.
GET /ie-registration/assets/json/inventory/crops-list.jsonLoad the static crop list.
GET /gateway/portfolio-service/api/v1/practices/active?direction=ASC&page=1&size=100Load the active farming practices master.
GET /gateway/portfolio-service/api/v1/portfolios/ownerEntities?ownerEntityIdList=&ownerEntityType=ENTITY_TYPE.IEDownload crop plans (portfolios with line items) for a chunk of farmers.
GET /gateway/portfolio-service/api/v1/portfolios/line-items/portfoliosForLineItemIds?portfolioLineItemIds=&returnAllMimeType=trueDownload crop line-item attachments (photos, geofences) in bulk.
GET /gateway/portfolio-service/api/v1/portfolios/portfolioLineItems?portfolioLineItems=Refetch crop line items from the server (overwrite local after a compact-block edit lock, or pick a harvest target).
GET /gateway/portfolio-service/api/v1/portfolios/line-items/ownerEntities/actual/v2?ownerEntityId&ownerEntityType&dateRefresh a farmer's current crop plan.
POST /gateway/portfolio-service/api/v1/portfolios/line-items/v2?logCropActivity=true&actorType&actorIdCreate a crop plan entry (portfolio with one line item).
PATCH /gateway/portfolio-service/api/v1/portfolios/Update crop plans.
PUT /gateway/portfolio-service/api/v1/portfolios/{pid}/portfolioLineItem/v2/crop-activityEdit a crop line item and log the crop activity change.
DELETE /gateway/portfolio-service/api/v1/portfolios/portfolioLineItem/?logCropActivity&portfolioId&portfolioLineItemId&portfolioLineItemUUIDDelete a crop line item.
POST /gateway/portfolio-service/api/v1/portfolios/line-items/attachment/item/customUpload a crop photo, or (with saveFileContent=true, updatePortfolioLineItemWithGeoFenceAttachment=true) a crop KML geofence.
SDK Firebase Storage userId/farmerId/pliId/pliId.extFallback upload for crop photos that keep failing.
App Service v2: operationUse
GET /configTyped config bundle (ETag)
GET /farmers/snapshotCursor-paged hydrated farmer snapshot
GET /farmers/changesDelta sync: upserts and tombstones since a cursor
GET /farmers/{farmerId}/metricsOwned, leased, used and available acres
GET /farmers/{farmerId}/crop-blocksA farmer's Crop Actual blocks for a season / month
POST /sync/batchApply an ordered batch of offline mutations
POST /filesCreate a file upload (resumable or single-shot)
GET /files/{fileId}File metadata and signed download URL
PATCH /files/{fileId}Append a chunk to a resumable upload
HEAD /files/{fileId}Current offset of a resumable upload

Behaviour notes

  • Only blocks in the current season (app config current season code) whose start date is the first of the current month are shown.
  • Harvest entry itself (SelectHarvestBottomSheet) belongs to the harvest feature.

Improve in the rewrite

  • Make month copy an explicit "Copy last month" action with a preview instead of a silent blocking copy on open.
  • Centralise land-availability calculation in one service.
  • Translate hard-coded English strings such as "Cannot add crops after harvest" and "Enter Delete Reason".