Challenge
The business had run its books for years on a FoxPro 2.5 accounting application: dozens of .DBF tables with .IDX indexes, spread across branches, holding ledgers, invoices, payroll and sales-tax records. The software still held the only complete record of that history, but nobody could safely change it, query it in a modern way, or hand it to an auditor in a format current tools understand.
Two things made a straightforward export unsafe. First, the data model did not mean what it appeared to: the FoxPro GROUP field, which looks like an accounting group, actually held geographic areas, so any tool that trusted it would have produced a wrong chart of accounts. Second, opening balances and account names were split across branch-level and master tables, so a naive migration would show “unknown” accounts and balances that did not tie out.
Engineering approach
We treated the migration as an evidence problem, not a copy job.
- Extract everything, then type it. All 72 legacy tables were read with Python, normalised and loaded into an indexed SQLite working copy, then migrated to managed PostgreSQL. Nothing was filtered out at extraction time, so later questions could always be answered from the full record.
- Rebuild, don’t trust, derived numbers. Opening and running balances were recalculated from transactions rather than copied from stored totals. Account-name resolution falls back from branch-party records to the master chart of accounts, so every ledger line resolves to a named account.
- Make imbalance visible. An integrity report groups every voucher by branch, date and document number and lists any whose debits and credits do not net to zero (tolerance ₹0.01). A database checksum is exposed so users can tell whether the dataset has changed since they last looked.
- Map to the accounting system people actually use. For export, ledger accounts were assigned to Tally parent groups by account-code prefix (capital, income, expenses, purchase/trade), with the FoxPro area moved to the address field where it belongs.
- Harden before release. A pre-production audit of the export code found and fixed SQL-injection exposure in branch and date parameters (now whitelisted by pattern), a PostgreSQL date-type crash, a cursor leak and unhandled database errors.
Solution
A hosted, login-protected reporting application over the migrated PostgreSQL database:
- Eleven reports: trial balance, account ledger with running balance, party statement, outstanding with ageing, day book, sales register, product movement, trading account, profit & loss, salary register and CST form tracking — with branch and date filters, search and drill-down from trial balance to ledger.
- Accounting-format output: A4-landscape print layouts for trial balance, ledger and P&L that print the full dataset (not just the visible page), Indian number formatting, and CSV export for every report.
- Tally Prime XML export: ledgers and vouchers for the whole dataset or a filtered branch and date range, with a confirmation step showing exactly what is being exported — so the books can be imported into Tally Prime and checked independently of our software.
Outcome
- 72 legacy FoxPro tables and 110,117 records migrated into PostgreSQL, covering 1,987 accounts, 21,335 transactions, 1,534 invoices and 17 branches.
- An integrity report that lists every voucher whose entries do not balance, so any discrepancy is visible rather than buried.
- In production testing, the Tally Prime export generated 2,830 ledgers and 11,058 vouchers for the full dataset, produced correct filtered exports for a single branch and date range, and rejected a malicious branch parameter with a validation error.
- The historical books are now queryable, printable and exportable to current accounting software without touching the original FoxPro application.