1 Invoice checksum calculation. To uniquely identify each invoice a checksum is calculated at the invoice level. The logic for calculating checksum for invoice is given below. 1. Concatenate the attribute names and values for invoice headers into a checksum string. The attributes are to be arranged in the following order. - inum, idt, val, pos, rchrg, prs, od_num, od_dt, etin 2. Sort the item level details based on item number. 3. Append the item level attribute names and values to the checksum string. (Please find the code snippet at reference section) The item level attributes are to be arranged in the following order - num, item_det:ty, hsn_sc, txval, irt, iamt, crt, camt, srt, samt, csrt, csamt 4. The final checksum is found by calculating the SHA-256 hash of the checksum string. For e.g below shows sample concatenated string of an invoice with singe item details. inum=27686,idt=16-04-2016,val=142244.71,pos=01,rchrg=N,prs=N,etin=XYZ, itms:num=1,itm_det:ty=S,hsn_sc=S84,txval=247.25,irt=0.0,iamt=0.0,csrt= 0.2,csamt=15.0,itms:num=2,itm_det:ty=S,hsn_sc=S90, txval=500.25, irt=0.0,iamt=0.0,crt=4.48,camt=93.11,srt=2.01,samt=58.5 The SHA-256 of the above string will be the checksum of the invoice.
2 R1 Summary Checksum calculation. The checksum of GSTR1 summary payload is provided at different levels. -
Counter party wise checksum different sections of GSTR1 summary payload (if applicable) Section wise checksum for each sections of GSTR1 Summary payload. Complete GSTR1 Summary Payload Checksum.
2.1 Counter Party Wise Checksum For sections B2B, B2BA, CDN & CDNA of GSTR1, the counter party is the receiver GSTIN whereas B2CL/B2CLA the counter party is state code. The checksum calculation logic for counter party wise summary is given below. 1) Step 1: Fetch metadata all section invoices for a particular Supplier GSTIN – Receiver GSTIN relationship for the current return period. The list consists of supplier uploaded and auto populated invoices. The metadata contains the invoice number, invoice date, invoice checksum, provider and the action taken by the supplier. 2) For each counter party invoices are sorted in this order : a) Receiver provider invoices will take precedence over supplier provided invoices. b) The invoices in each provider group are sorted by financial year in ascending order. c) The invoices with same provider and financial year are sorted by invoice number in ascending order. 3) Concatenate the checksum of sorted invoices and supplier action into a string.. Only for section B2B,B2BA, CDN & CDNA where receiver GSTN is the counter party, the invoice action is included in
the checksum. For other sections like B2CL/B2CLA, the action will not be part of checksum. The valid acronyms of supplier action are given below. Supplier Action Acronym Accepted A Rejected R Modified M Keep Pending P e.g. Concatenated String of counter party checksum = chksum(invoice1)+A+checksum(invoice2)+R 4) Calculate the SHA256 hash of the concatenated checksum string and use this as the counter party wise checksum.
2.2 Section Wise Checksum if counter party summary is applicable For the sections such as B2B/B2BA/CDN/CDNA/B2CL/B2CLA, the summary checksum will be created based on the counter party checksum. The steps for calculating checksum is given below. 1. For the particular section, fetch all counter parties. If there is no counter party available, list will be empty. 2. Counter Party list is sorted in the alphabetical order. 3. Combine the checksum of all counter parties in the sorted order. 4. Calculate the SHA256 hash of the concatenated checksum string and use this as the counter party wise checksum.
2.3 Section Wise Checksum if counter party summary is not applicable For the sections such as EXP/EXPA/TXPD/AT/ATA/B2CS/B2CSA/HSN/NIL, the counter party summary is not calculated. The steps for calculating checksum for these sections is given below. 1. Fetch all records of each sections. 2. For EXP/EXPA/TXPD sort the records based on invoice number. Invoices are first sorted based on the financial year and then the invoice number in alphabetical order. Concatenate checksum of the sorted invoices and take SHA-256 hash of the concatenated string. 3. For AT/ATA, sort the records based on the document number. Documents are first sorted based on the financial year and then the document number in alphabetical order.If a document contains multiple item details, the item data are sorted with HSN codes. Concatenate checksum of the sorted documents and take SHA-256 hash of the concatenated string. 4. For B2CS/B2CSA records, the following steps are done for calculating checksum a. Group B2CS records with state code as the primary key. b. For each state code, sort B2CS records according to the hsn code. c. In case of B2CS records, the sorting is done based on the Month (tax period) and HSN codes. d. For each state code, concatenate checksum of the sorted records and take SHA-256 hash of it. e. Sort state code level checksums according to the state code in lexicographical order. f. Concatenate checksum of each state code and take SHA-256 Hash of it.
5. For HSN Summary, the records are sorted with serial number. The sorted records are concatenated and SHA-256 hash is calculated for checksum. 6. For NIL Summary records, the records are grouped based on the type (goods/services) and then based on the supply type (INTRB2B/ INTRB2C/ INTRAB2B/ INTRAB2C). The sorted records are concatenated and SHA-256 hash is calculated for checksum.
2.4 GSTR1 Summary payload checksum The GSTR1 summary payload checksum is the combined checksum of all sections. The checksum is calculated based on the following process 1) Sections are sorted in the following order: a) B2B b) B2BA c) B2CL d) B2CLA e) B2CS f) B2CSA g) CDN h) CDNA i) EXP j) EXPA k) AT l) ATA m) TXPD n) HSN o) NIL 2) For each of the section from the sorted list fetch the section level checksum and concatenate them in to a string 3) SHA-256 hash of the string is the summary checksum