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
| Screen | What it does | Source |
|---|---|---|
| Crop Actual list | One section "Crop Actual : <current month>" with crop block cards. | app/src/main/java/org/platformcommons/urvi/view/portfolio/PortfolioActivity.kt |
| Crop block card | Crops, 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 block | Form for one block. | app/src/main/java/org/platformcommons/urvi/view/portfolio/AddPortfolioActivity.kt |
| Select land sheet | Pick an active land parcel. | app/src/main/java/org/platformcommons/urvi/view/portfolio/SelectLandBottomSheet.kt |
What it captures
| Field | Type | Required | Validation | Options from |
|---|---|---|---|---|
| Photo | Image picker | No | Compressed and uploaded as a line-item attachment; not editable in harvest mode. | Camera / gallery |
| Land | Bottom-sheet pick | Yes | Not 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 type | Dialog | Yes (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 reason | Dialog | If crop type changes in Edit | PMDS: 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-select | Yes (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) | Decimal | Yes | Greater than 0; max 99.99 (2 digits before and after point). Locked if harvested, a placeholder or not editable. | User input |
| Major crop | Star toggle | No | User input | |
| Seed variety (per crop) | Pick or free text | No | Free text allows letters, digits, "-", "( )" and space. | Seed variety list in code |
| Expected harvest date (per crop) | Date | No | Earliest date is today. | User input |
| Edit reason (per crop) | Dialog | If the crop was edited in Edit mode | Wrong Entry / Crop Failed / Harvest Completed / Other (text). Error: "Please enter edit reason for crop X". | Fixed list |
| Delete reason (per crop) | Text | If deleting a crop that existed before | Delete is hidden for PMDS, A Grade, compact-block items, harvested crops and harvest mode. | User input |
| Associated crops | Multi-select | If A Grade (at least 2) | Select Crop sheet | |
| Bio-diversity crops | Multi-select | If A Grade (at least 2) | Select Crop sheet | |
| Sowing date | Date | No | Needs 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 practices | Multi-select dialog | Yes (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.
| When | Then |
|---|---|
| The farmer has no land | Add shows "no land asset for farmer". |
| The selected land is disabled | Saving is blocked: "cannot add crop against disabled land". |
| Saving | Acres 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 harvested | Changing crop type and adding crops are blocked. |
| Crop type changes | Crops 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 off | Everything except practices is frozen. |
| The line item is linked to a Compact Block, or its land is missing/disabled | Edit is hidden on the card. |
| Harvest is enabled and no crop is a placeholder | Harvest is shown; it refuses until the item has a server id ("crop not synced"). |
| Every main crop is fully (WHOLE) harvested | A 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 on | Last 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 items | They 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 copied | They 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 missing | The block is skipped unless copying disabled Crop Actual is enabled. |
| Two cards share a Tile Id | They are flagged as duplicates with a coloured border. |
| Server rejects the block because the land checksum changed | The card shows a "land details changed" banner with the new acres. |
| Saving in Edit mode | A 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 passed | Crop Actual is fetched online. |
API contracts
Each call opens to its use case, headers, request and response bodies, and errors.
| App Service v2: operation | Use |
|---|---|
GET /config | Typed config bundle (ETag) |
GET /farmers/snapshot | Cursor-paged hydrated farmer snapshot |
GET /farmers/changes | Delta sync: upserts and tombstones since a cursor |
GET /farmers/{farmerId}/metrics | Owned, leased, used and available acres |
GET /farmers/{farmerId}/crop-blocks | A farmer's Crop Actual blocks for a season / month |
POST /sync/batch | Apply an ordered batch of offline mutations |
POST /files | Create 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".