Sheet WRK-01

Rescuing a FoxPro 2.5 accounting system — every voucher checked before anyone relied on it

72 FoxPro 2.5 tables and 110,117 records rebuilt in PostgreSQL, with voucher-balance checks and a Tally Prime export for independent verification.

Record WRK-01
Client
Trading & distribution organisation
Industry
Trading & distribution
Year
2026
Capability
Build, Advise
Stack
  • FoxPro 2.5 (.dbf)
  • Python
  • SQLite
  • PostgreSQL
  • FastAPI
  • SQLAlchemy
  • Docker
  • Railway
  • Tally Prime XML

Opening brief

At a glance

Client engagement

Problem / risk
Years of books locked in FoxPro 2.5 — unsafe to change, hard to query, awkward for auditors.
Scope
Full extraction of 72 tables into PostgreSQL, integrity checks, eleven reports and Tally Prime export.
Constraints
FoxPro fields did not mean what they appeared to; balances had to be rebuilt, not copied.
Timeframe
2026

Outcomes

  • Measured72 tables and 110,117 records migrated with voucher-balance integrity reporting
  • MeasuredTally Prime export produced for independent reconciliation
  • QualitativeHistorical books queryable without touching the original FoxPro app
Architecture of Rescuing a FoxPro 2.5 accounting system — every voucher checked before anyone relied on it10 components in 6 columns (Legacy, Build, Data, Protect, Output, External) joined by 9 numbered connections, listed in the notes below the figure.FoxPro 2.5 .DBF /.IDX files (72tables)Python extraction &normalisationSQLite working copyFastAPI reportingservice (11 reports)Access-controlled webdashboardPostgreSQL (managed)Integrity checks(voucher balance,checksum)Tally Prime XMLexportA4 accounting print &CSV exportIndependentverification in Tally123456789
  1. LegacyFoxPro 2.5 .DBF / .IDX files (72 tables)
  2. BuildPython extraction & normalisation; SQLite working copy; FastAPI reporting service (11 reports); Access-controlled web dashboard
  3. DataPostgreSQL (managed)
  4. ProtectIntegrity checks (voucher balance, checksum)
  5. OutputTally Prime XML export; A4 accounting print & CSV export
  6. ExternalIndependent verification in Tally
Fig. 1Architecture. Dashed outlines sit outside the system boundary.
  1. FoxPro 2.5 .DBF / .IDX files (72 tables) to Python extraction & normalisation: read all tables
  2. Python extraction & normalisation to SQLite working copy: typed, indexed
  3. SQLite working copy to PostgreSQL (managed): migrate
  4. PostgreSQL (managed) to FastAPI reporting service (11 reports): SQL views
  5. PostgreSQL (managed) to Integrity checks (voucher balance, checksum): per-voucher sums
  6. FastAPI reporting service (11 reports) to Access-controlled web dashboard: authenticated
  7. Access-controlled web dashboard to A4 accounting print & CSV export: full-dataset print
  8. FastAPI reporting service (11 reports) to Tally Prime XML export: branch / date filtered
  9. Tally Prime XML export to Independent verification in Tally: import & reconcile

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.

Related insights

Tell us what you run. We’ll tell you what we’d do first.

Tell us what you run and what keeps breaking. We will map it, tell you plainly what we would change, and quote it in writing.

support@kamyab.co.inWhatsApp +91 99877 77250