Database / Endorsement

endorsement_entity

Endorsement (VO/SHG approval) record for a VO, SHG or farmer, including review and abstract PDF.

Table factsheetagri_db
Written by
  • FetchEndorsementDataWorker, FetchEndorsementForVoDataWorker
  • SetupIeFlatSchemaData
  • EndorsementRepositoryImpl
  • Endorse / review / upload abstract (createEndorsement, updateEndorsement, uploadEndorsementAbstract)
Read by
  • Endorsement screens
  • Farmer detail (getEntityForIeId)
Filled from
GET rtld/api/dataset/v1/execute (endorsement datasets)
Sync
No BaseEntity flags. Local changes are queued in sync_ledger as ENDORSEMENT and ENDORSEMENT_ATTACHMENT.
Source
data/src/main/java/org/mindtree/app/agricultor/data/sync/entity/EndorsementEntity.kt

Columns

ColumnTypeNullKeyMeaning
idINTEGERYesServer id. Null or 0 until the row is synced.
entityTypeTEXTYesENTITY.TYPE.VO | SHG | FARMER.
entityIdTEXTYesFK → ie_flat_entity.iEOLTPIdId of the endorsed VO, SHG or farmer. Link by convention only, no FK constraint.
entityCodeTEXTYesFor farmer rows: farmer alias (ie_flat_entity.uuid); otherwise entity_code from the server.
endorsedByTEXTYesWho endorsed or flagged: "firstName--loginName" of the logged-in user, or endorsed_by from the server.
nameTEXTYesDisplay name: VO name, SHG name or farmer full name.
statusTEXTYesPENDING | ENDORSED | FLAGGED | FOR_REVIEW.
districtNameTEXTYesDistrict name of the VO/SHG/farmer.
unitNameTEXTYesunit_name from the server. For locally built farmer rows the app puts the farmer's phone number here.
timestampINTEGERYesEndorsed time (epoch millis).
endorsedUserIdINTEGERYesUser id of the person who endorsed or flagged.
mandalCodeTEXTYesMandal code: mandal_code from the server, or ie_flat_entity.mandalCode for locally built rows.
mandalNameTEXTYesMandal name of the VO/SHG/farmer.
voCodeTEXTYesVO id (= ie_flat_entity.vOId).
voNameTEXTYesName of the VO.
shgCodeTEXTYesSHG id (= ie_flat_entity.sHGID).
shgNameTEXTYesName of the SHG.
reviewdByTEXTYesReviewer (column name typo).
reviewByUserIdINTEGERYesUser id of the person who marked the record "for review" (resolved).
reviewedTimestampINTEGERYesNo description in code.
abstractFileTEXTYesPath or URL of the generated abstract PDF.
hasNpmShopINTEGERYes1 if the VO has an NPM shop.
endorsementTypeTEXTYesnull = regular endorsement, else a survey type.
created_atINTEGERYesCreated time; added in migration 39 to 40 with typo type INTERGER.
uuidTEXTNoPKPrimary key (business UUID).

Notes

  • saveEndorsements clears the whole table, then inserts, so unsynced local rows can be lost on refresh.
  • getEntityForIeId: latest non-null-status endorsement of a farmer by created_at DESC.
  • getCountOfEndorsedSHGForVo: distinct ENDORSED SHGs of a VO.
  • Possible bug · unverified clear-and-insert on refresh may wipe local endorsements that are not yet synced.
  • Missing index on entityId.