sales_receipt_edits

When a user contributes the price data, it is stored in the sales_receipt Table. If data validators makes any edit in the data submitted by the contributor then the old data is stored in the sales_rec

Model

This model is exactly same as the sales_receipt modal, the only difference is that it has two additional fields.

FieldTypeNullableConstraints

id

int4

Primary key

sale_receipt_id

int4

Foreign key

(sale receipts)

mandi_id

int4

Foreign Key (mandi)

mandi_name

varchar

mandi_name_hi

varchar

crop_id

int4

Foreign Key (crop)

crop_name

varchar

crop_name_hi

varchar

receipt_date

timestamp

quantity

float8

price

float8

user_id

int4

Foreign Key (person_table)

booklet_number

text

receipt_image_url

varchar

is_approved

bool

created_at

timestamp

updated_at

timestamp

promised_token

int4

token_amount

int4

receipt_owner_id

int4

Foreign Key (person_table)

receipt_owner_phone_number

varchar

validated_by

int4

Foreign Key (person_table)

validated_on

timestamp

rejection_reason_ids

_int4

edited_by

int4

receipt_type

varchar

Default: "handwritten"

Description of fields

This table has same fields as of the sales_receipt table, other than the following two:

sales_receipt_id

this is the primary key of the sales_receipt table and tells us about which entry is edited.

edited_by

the user_id of the team member who edited the receipt.

This field was added in early Jan 2024, and may be empty for rows before that.

How do we make sense of this table?

This table is linked to the sales_receipt table. Whenever a row is edited in the sales_receipt, a new entry is made in this table. On the admin portal, a data validator has an option to edit the details of a sales receipt if the user who uploaded the receipt has not correctly entered the data.

When the data validator clicks on the edit button, a pop-up comes and provides them options to edit any of the following six fields:

  1. mandi

  2. crop

  3. booklet_number

  4. receipt_number

  5. price

  6. quantity

  7. Validation status: approved or rejected

Upon edit, an entry of the older data is made in the the sale_receipt_edits table. The same receipt if edited again, a new entry is made in the sale_receipt_edits table.

The sales_receipt_edit table can have multiple entries for a single sales receipt. If sorted by the created_at timestamp, we can get the different versions of the sales receipt data.

In the Admin Portal, there is a feature to view the different versions of a sale receipt entry that is edited multiple times. It shows the list of all the past versions. It does not show the current version.

Last updated