Gstr 2a - Json To Excel Converter [UPDATED]

b2b_records = [] # Flatten B2B section for fp in data.get('fp', []): # fp = tax period for b2b in fp.get('b2b', []): for inv in b2b.get('inv', []): for item in inv.get('itms', []): itm_det = item.get('itm_det', {}) b2b_records.append( 'Supplier GSTIN': b2b.get('ctin'), 'Invoice No': inv.get('inum'), 'Invoice Date': inv.get('idt'), 'Invoice Value': inv.get('val'), 'Taxable Value': itm_det.get('txval'), 'CGST': itm_det.get('iamt', 0), 'SGST': itm_det.get('samt', 0), 'IGST': itm_det.get('iamt', 0), 'Cess': itm_det.get('csamt', 0), 'Rate': itm_det.get('rt'), 'Place of Supply': inv.get('pos'), 'Reverse Charge': inv.get('rchrg') )

# Write to Excel with formatting with pd.ExcelWriter(output_excel, engine='openpyxl') as writer: df.to_excel(writer, sheet_name='B2B', index=False) # Summary sheet summary = df.groupby('Rate').agg( 'Taxable Value': 'sum', 'CGST': 'sum', 'SGST': 'sum', 'IGST': 'sum' ).reset_index() summary.to_excel(writer, sheet_name='Summary', index=False) GSTR 2A - JSON to Excel Converter

df = pd.DataFrame(b2b_records)

# Apply formatting (freeze panes, auto-filter) wb = load_workbook(output_excel) for sheet in wb.worksheets: sheet.auto_filter.ref = sheet.dimensions sheet.freeze_panes = 'A2' for col in sheet.columns: max_length = 0 col_letter = col[0].column_letter for cell in col: try: if len(str(cell.value)) > max_length: max_length = len(str(cell.value)) except: pass adjusted_width = min(max_length + 2, 30) sheet.column_dimensions[col_letter].width = adjusted_width wb.save(output_excel) b2b_records = [] # Flatten B2B section for fp in data

0

Get *ALL* our FREE Resources

Tackle the trickiest areas of screenwriting with our exclusive eBooks. Get all our FREE resources when you join 60,000 filmmakers on our mailing list!

Success! Thanks for signing up, now please check all your email folders incl junk mail!

Something went wrong.

Send this to a friend