Features / Planning & tracking

Compact Block

Groups contiguous S2S natural-farming Crop Actual tiles from several farmers into a compact block of at least 5 acres. Used by Unit-in-charge / FMT staff.

FactsheetPlanning & tracking
Who uses it
Unit-in-charge (unit-incharge)FMT (fmt_l1)
How you get here
VO tab (Unit/FMT home) > Compact Block card. Card visible when PORTFOLIO_APP_CONFIG.FF_COMPACT_BLOCK = 1 (defaults to visible if the key is missing).
Tables
compact_block, compact_block_member, ie_flat_entity
APIs
7 calls today, 7 App Service operations
Offline
Offline-first: compact_block and compact_block_member rows are written locally and synced via CompactBlockWorker and CompactBlockMemberWorker through ledger entries with dependencies.

Screens

ScreenWhat it doesSource
Compact Block listLists active compact blocks with warning chips and search.app/src/main/java/org/platformcommons/urvi/view/compactblock/CompactBlockListFragment.kt
Compact Block containerHeader (name, member count, delete) and Farmer/Crop tabs.app/src/main/java/org/platformcommons/urvi/view/compactblock/CompactBlockContainerFragment.kt
Farmer tabAdd-farmer wizard (VO > SHG > tiles) and review of selected tiles.app/src/main/java/org/platformcommons/urvi/view/compactblock/CompactBlockFarmersFragment.kt
Crop tabRead-only acres per crop and distinct practices across selected tiles.app/src/main/java/org/platformcommons/urvi/view/compactblock/CompactBlockCropsFragment.kt
Searchable multi-select dialogShared VO/SHG picker with an "All" option.app/src/main/java/org/platformcommons/urvi/view/common/SearchableMultiSelectAdapter.kt

What it captures

FieldTypeRequiredValidationOptions from
CB nameText (Edit name dialog)YesDefaults to "CB <number of CBs stored locally>". On rename, must be unique among local CBs (trimmed); otherwise "A compact block with that name already exists."User input
Select VOSearchable multi-select with "All"YesItems show "VO name\nVO id".Distinct VOs in local ie_flat_entity
Select SHGSearchable multi-select with "All"YesItems without an SHG id show just the name (Non-SHG).SHGs of the chosen VOs from ie_flat_entity
TilesCheckbox list grouped by farmerYesCheckbox disabled when the tile has no geofence id. Search matches farmer-name words starting with the query.Eligible Crop Actual tiles of active farmers in the chosen VO/SHG
Removal / delete reasonTextIf removing tiles or deleting the CBSpaces become "_" before sending.User input

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
Showing the CB listOnly active CBs created or updated on or after 2026-09-01 are shown (hard-coded).
Total tile acres of a CB < 5Card chip "< 5 Acres".
Any farmer in the CB is inactiveCard chip "Inactive".
Any farmer is C4 or C5Card chip "Not Farmer".
Any tile's crops lack the S2S practice code (AP-GOV-KAP-100_PERCENT_CHEMICAL_FREE_NATURAL_FARMING)Card chip "Not S2S".
Listing tiles in the wizardA tile is eligible only if it is current season, the latest version for its titleId, has a geofence, sits on land with both survey number and khata (account) number, and is not in another active CB. Only active farmers are included.
Searchable multi-select: "All" is tickedEvery item is ticked, including items hidden by the current search.
Searchable multi-select: any item is unticked"All" is unticked; it re-ticks automatically once every item is ticked.
Searchable multi-select: OK pressed with nothing selectedNothing happens (silently).
Computing total acresTotal = sum of proportion.acre over every crop line of every selected tile (crop acres, not land area).
New CB and total < 5 acresSave blocked: "Please select a total asset of above 5 acres."
New CB and total >= 5 acresSaved; ledger COMPACT_BLOCK POST.
Edit and total < 5 acresThe whole CB is deleted after a "Delete compact block" dialog with required reason; ledger COMPACT_BLOCK DELETE.
Edit, total >= 5 acres, tiles removedAsks "Reason for Farmer Removal" (required); removed tiles are disabled (COMPACT_BLOCK_MEMBER DELETE), then CB saved (COMPACT_BLOCK PUT).
Edit, total >= 5 acres, nothing removedSaved; ledger COMPACT_BLOCK PUT (depends on earlier POST and PUT).
Removing a tile in edit mode would drop the total below 5 acresWarning "Total Land Below 5 Acres" that submitting will disable the compact block.
Tapping a tile on a saved CBOpens the Crop Actual edit screen for that tile; data refreshes on return.
Server refuses a Crop Actual edit because the tile is in a CBError ERR_PLATFORM_PART_OF_COMPACT_BLOCK shown on the portfolio card and in the sync log.

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/changesDelta sync: upserts and tombstones since a cursor
GET /farmers/{farmerId}/crop-blocksA farmer's Crop Actual blocks for a season / month
GET /compact-blocksCompact blocks for VOs
GET /compact-blocks/eligible-tilesTiles eligible for a compact block
POST /sync/batchApply an ordered batch of offline mutations

Behaviour notes

  • Crop tab data is passed between screens through SharedPreferences (PRE_CB_CROPS_DATA).
  • Possible bug · unverified the "< 5 Acres" chip is wrong because totalSelectedLand is never reset per row in CompactBlockListAdapter and accumulates.
  • Possible bug · unverified hard-coded cutoff 2026-09-01 hides all older CBs.
  • Possible bug · unverified default name "CB <count>" can collide after deletions; uniqueness is checked only on rename.
  • Possible bug · unverified saving an edited CB under 5 acres deletes the whole CB via a dialog that looks like the remove-farmer dialog.
  • Possible bug · unverified deleteCompactBlockMember runs database work on the main thread.
  • Possible bug · unverified VO/SHG selection passes display strings ("Name\nId") that the repository splits on newline.
  • Possible bug · unverified Created/Updated dates on the list show raw millisecond numbers.
  • Possible bug · unverified feature flag defaults to enabled when missing, unlike other switches.

Improve in the rewrite

  • Make delete an explicit separate action; never delete as a side effect of saving.
  • Show a live 5-acre progress bar while selecting tiles.
  • Explain why a tile cannot be selected (no geofence, no survey/khata number, already in a CB, wrong season).
  • Move the 5-acre minimum and the date cutoff to config.
  • Pass ids, not display strings, between pickers and queries.
  • Decide whether "All" means all visible items when a search is active.