RCM Auto Invoice Generator: Streamlining GST compliance with PythonRecord inserted or updated successfully.
AI & Audit Automation

RCM Auto Invoice Generator: Streamlining GST compliance with Python

Author : CA Harshit Malviya

Watch on Youtube

Problem Statement:-

We see in most of the cases we handle for GST filings, there is one common problem that is generation of self-invoice under RCM, as we all know there must be a Tax Invoice on the basis of which we can claim GST ITC, which is not present there in case of RCM ITC that we availed from unregistered dealers, so we have a generate a self-invoice.

Generation of self-invoicing under RCM manually, is very time consuming and error prone.

To overcome this situation, I developed a use case for generating self-invoices in PDF from excel summary.

We can export RCM summary for self-invoicing from Tally or any other accounting software in an excel file, and that excel file with some alterations and defined column headings can be used for generating PDF invoices with the help of Chat GPT and Python code.

We all are CA’s not programming expert, so we don’t know how to write code in python and which python libraries are required for doing this task.

So, we can ask ChatGPT to instruct us in doing the same.

You have to take care, that while instructing ChatGPT to write python code, you have to be clear and specific about your inputs and your expectations, here the importance of prompt engineering will come into play.

It is very important that whenever you instruct ChatGPT, you must ask it to act as an expert of the field for you which you are asking questions like now I am doing Python coding, so I will instruct ChatGPT to act as an python coding expert so that I will get my desired results in one shot.

Remember one thing whenever you do python coding with ChatGPT or any other AI tool, it is not necessary that you will get desired result in one go, you have to keep refining your code with the help of ChatGPT or any other AI tool until you get your result.

Steps to develop USE CASE for “RCM Auto Invoice Generator with Python”

Step 1:

Prepare Excel summary which is exported from tally with predefined column headings for the purpose of python coding so that python script will give correct output.

Columns in Excel sheet in Row1 – Starting from A1 to Q1 – Date, Invoice Type, Doc. No., Supplier Name, Supplier GSTIN, Recipient Name, Recipient GSTIN, Recipient Address, Particulars, Place of Supply, HSN/SAC, Taxable Amount, Rate (%), CGST, SGST/UTGST, IGST, Total Invoice Amount.

Important: Make sure there will be no spelling mistakes in column headings in excel sheet.

Step 2:

Save this file in specific folder with file name “InvoicesSummary”.

Step 3:

Install latest version of python in your system with all necessary python libraries.

Python libraries required as under:

  1. pandas – for reading and processing excel data efficiently.
  2. Openpyxl – for handling excel file and compatibility engine.
  3. Reportlab – for PDF generation with table support.

Step 4:

Open ChatGPT (paid version) and give following prompt:

Prompt 1

Please act as a python coding expert and provide me a tested ready to use python code to accomplish my task as per instructions given below:


  1. I have an Excel file “InvoicesSummary”, wherein sheet tab “Sheet1” each row represents one invoice summary.
  2. I want to generate a separate PDF file for each row — one PDF per invoice.
  3. Columns in excel sheet in Row1 – Starting from A1 to Q1 – Date, Invoice Type, Doc. No., Supplier Name, Supplier GSTIN, Recipient Name, Recipient GSTIN, Recipient Address, Particulars, Place of Supply, HSN/SAC, Taxable Amount, Rate (%), CGST, SGST/UTGST, IGST, Total Invoice Amount.
  4. Location of folder where excel is saved - e:\Users\Harshit\Desktop\Python Results\SelfInvoice\02.05.2025 (Change location of folder and give the location where you saved your excel file)
  5. Each PDF should nicely format the invoice data.
  6. Header of generated Invoice will be “Tax Invoice (Self-Invoice under RCM).
  7. Add Signature Placeholder at the bottom of table for authorised signatory, take company name from coloumn “Recipient Name” in excel.
  8. Prefix Rs. for figures and also convert total invoice value in words.
  9. Give PDF invoice in professionally designed table-style layout.


Prompt 2

Also tell me how to use this python code?

Step 5:

Copy and paste the python code given by ChatGpt in a text file and save as that text file as python file with file extension as “.py” and rename it as “generate_invoices”

Step 6:

Run “generate_invoices.py” file by double clicking on it, if the code is correct and excel columns are same as mentioned in prompt and all python libraries are installed correctly, then all excel row which contains invoice summary will get converted in PDF files in a separate folder.