From Inbox to Books: Automating Invoice Capture & Entry Using AI
AI & Accounting

From Inbox to Books: Automating Invoice Capture & Entry Using AI

Author : CA. JAYPRAKASH M TIWARI

Watch on Youtube

1. Executive Summary

PURCHASE BILL ENTRY AUTOMATION is a desktop-based workflow that automates the movement of purchase invoices from Gmail to accounting software. It downloads PDF invoices from selected senders, extracts invoice fields into an Excel register, prepares Tally-compatible XML masters/vouchers and Zoho Books-ready import output, and imports or prepares posting with user confirmation.

The use case is designed for small and medium CA offices and business accounting teams where repetitive purchase bill entry consumes staff time, creates avoidable errors, and delays ledger posting. The tool keeps documents on the user's system and does not require uploading invoices to a third-party AI platform.

NONE OF THE DOCUMENTS ARE UPLOADED ON ANY AI PLATFORM; THEREFORE CLIENT DATA REMAINS LOCAL AND THE DPDP ACT IS NOT BREACHED.

2. Problem Statement

Purchase bills are commonly received by email as PDF attachments. Accounting staff must download each bill, read invoice details, classify the expense ledger, enter tax fields, create or verify supplier ledgers, and finally post entries in the accounting software.

  1. Manual entry is slow and diverts staff from review, exception handling, and client service.
  2. Invoice fields such as number, date, taxable value, CGST, SGST, IGST and total can be mistyped.
  3. Supplier ledgers may be duplicated when existing ledgers are not checked before voucher posting.
  4. Audit trails become scattered when downloads, working sheets, and import files are not stored systematically.

3. Technology Used

ComponentTechnology
GUI launcherPython tkinter
Email accessGoogle Gmail API with OAuth credentials
PDF extractionPython pdfplumber and extraction logic for multiple invoice formats
Excel outputPython openpyxl
Tally XML generationPython-generated UTF-16 XML in Tally Prime format
Tally integrationPython requests on port 9000 where available, plus pyautogui and clipboard-assisted import
Zoho Books integrationPython-generated structured import file/API-ready data for purchase bill posting in Zoho Books
TriggerShortcut of JMTCO TOOL.vbs for one-click execution of the complete flow

4. Proposed Solution

The proposed solution is an end-to-end Python automation pipeline triggered through the shortcut of JMTCO TOOL.vbs. A graphical launcher collects sender email, bill download location, Tally data path and accounting-system context. The system then downloads invoices, extracts fields, writes a date-wise Excel register, prepares Tally XML files and Zoho Books-ready import output, and guides posting/import into the selected accounting system.

CapabilityDescription
Gmail invoice downloadConnects through Gmail OAuth API, scans today’s emails from the selected sender, creates a date-stamped folder, and downloads PDF attachments.
PDF invoice extractionReads invoices from the date folder and extracts vendor, invoice number, date, taxable amount, GST split and total amount.
Excel registerCreates a detail sheet for line items and a summary sheet for invoice-level review with editable expense ledger classification.
Ledger/contact comparisonReads existing Tally masters where available and supports supplier/contact checking before Tally or Zoho Books import.
Tally / Zoho Books importGenerates separate Tally XML files for missing supplier masters and purchase vouchers, and prepares Zoho Books-ready purchase bill import data with user confirmation.

5. Step-wise Workflow

  1. User runs the shortcut of JMTCO TOOL.vbs, which launches the complete flow and opens the GUI for sender email ID, bill download folder, Tally data path and accounting-system options.
  2. Tool connects to Gmail through OAuth. During first use, the user signs in and a local token is saved for future runs.
  3. The inbox is scanned for today’s emails from the selected sender and PDF attachments are saved in a ddmmyy date folder.
  4. PDF invoices are processed and structured data is written into Invoice_Register_ddmmyy.xlsx, which becomes the common register for Tally and Zoho Books import.
  5. The user reviews the Excel summary sheet and confirms or edits the expense ledger classification before posting to Tally or Zoho Books.
  6. For Tally, the tool opens Tally Prime, assists with the data path and company selection, and exports or receives existing ledger master data; for Zoho Books, the same reviewed register is prepared for Zoho Books import/API-ready posting.
  7. Supplier names are compared against existing Tally ledgers and Zoho Books vendor/contact records where available, helping avoid duplicate masters or contacts.
  8. The tool generates tally_masters.xml for missing Tally suppliers, tally_vouchers.xml for Tally purchase vouchers, and Zoho Books-ready purchase bill import data.
  9. The final data is imported into Tally, first masters where required and then vouchers, or uploaded/posted into Zoho Books as per the selected integration route.

6. Solution / Key Features

  1. One-click workflow from Gmail to Tally-ready and Zoho Books-ready import, reducing repetitive operational effort.
  2. Zero manual typing for standard invoice fields once extraction is completed.
  3. GST-aware processing for IGST, CGST and SGST across common purchase bill formats.
  4. Built-in ledger checking before creating new suppliers, reducing duplicate masters.
  5. Date-stamped folders and Excel registers create a clear audit trail for review and later reference.
  6. Usable by non-accounting staff for the mechanical download and extraction stage, while the accountant retains review control.
  7. Flexible accounting destination: the same invoice register can feed Tally Prime as well as Zoho Books.

7. Data Security and Control Features

Control AreaImplementation
Local processingInvoices are processed on the user's computer. There is no requirement to upload invoices to an external AI service.
DPDP assuranceNONE OF THE DOCUMENTS ARE UPLOADED ON ANY AI PLATFORM; THEREFORE CLIENT DATA REMAINS LOCAL AND THE DPDP ACT IS NOT BREACHED.
Gmail accessOAuth is used through Google Cloud credentials. The first-run token is saved locally for subsequent authorized runs.
Human reviewThe Excel summary register allows review and correction of expense ledger classification before Tally XML import or Zoho Books posting.
Master/contact validationExisting Tally ledger names and Zoho Books vendor/contact records can be compared before creating missing suppliers.
TraceabilityPDFs, Excel register, Tally XML files and Zoho Books import data remain in date-stamped folders for future checking.

8. One-time Setup Requirements

RequirementWhere RequiredRemarks
Python and librariesEach PCRequired for running the automation scripts and GUI.
credentials.jsonOnce per Google account/projectCreated from Google Cloud Console after enabling Gmail API.
token.pickleCreated automatically on first runStores the user’s authorized Gmail session locally.
Tally Prime / Zoho Books accessEach accounting PC or Zoho Books organisationRequired for final import/posting and company/organisation selection.

Google Cloud setup involves creating or selecting a project, enabling Gmail API, creating OAuth Desktop App credentials, downloading credentials.json, and adding the Gmail address as a test user where applicable.

9. Expected Impact

AreaExpected Improvement
Time savingSignificant reduction in manual downloading, reading, typing and posting of purchase bills.
AccuracyLower chance of mistakes in invoice number, dates, taxable values and GST components.
Compliance readinessBetter supporting records through preserved PDFs and structured Excel registers.
ScalabilityMultiple invoices from a sender can be handled in one run and routed to Tally Prime or Zoho Books.
Office productivityStaff can focus on exception review, ledger classification and client-facing work.

10. Limitations and Future Scope

  1. Scanned or low-quality invoices may require OCR enhancement or manual review.
  2. Different vendor formats may require continuous improvement of extraction rules.
  3. Future versions can add stronger duplicate invoice detection, vendor-wise extraction templates, and exception dashboards.
  4. Zoho Books integration can be further enhanced with direct API posting, status logging and vendor/contact auto-matching.
  5. A formal validation report can be added for each run, showing total invoices processed, exceptions, missing ledgers, and imported vouchers.

11. Conclusion

PURCHASE BILL ENTRY AUTOMATION is a practical CA-office use case that applies automation to a daily accounting pain point. It reduces repetitive manual work, improves consistency, protects data by keeping processing local, and preserves accountant control through review checkpoints before Tally or Zoho Books import.

The use case is suitable for ICAI AI Hackathon submission because it demonstrates a working, affordable and practice-oriented application of AI-assisted automation for Chartered Accountants and small business accounting teams.