ZunekoLabs
ZUNEKOLABS
Zuneko Labs
Zuneko Labsby Emdee Digitronics
Get Started
Back to HomeERPsystemmiddlewareTallybooks

How to Integrate a Purchase System With Tally

A large share of Indian businesses run their buying in one system and their books in Tally, and want the two connected. The integration is well-trodden and the failure modes are specific, predictable and expensive, because the thing being written into is the accounting record.

Covered below: the available interfaces, the patterns that work, and the design constraint that shapes everything. Tally versions differ, so confirm the settings against the installation in front of you.

The constraint everything else follows from

Tally is a desktop application that can act as a server. That sentence carries the whole architecture.

With connectivity enabled, Tally listens for XML over HTTP, conventionally on port 9000, and a company must be loaded for requests to resolve. Which means the integration's availability depends on a particular machine being switched on, with Tally running, with the right company open, and with somebody not having closed it to go home.

That is not a criticism of Tally, which was designed as accounting software rather than as a service. It is a constraint, and integrations that ignore it fail on a Friday evening and lose whatever they were trying to send.

Never design a Tally integration as fire and forget. Every write must be queued, acknowledged and retryable, because the receiving end is a desktop application that will be unavailable regularly and unpredictably.

The interfaces available

XML over HTTP is the closest thing to a conventional interface. A request is posted to the listener and Tally returns XML. The envelope nests as an outer element containing a header and body, with the body carrying a message element wrapping the object being read or written, such as a ledger or a voucher. It supports both reads and writes: reads across ledgers, stock items, cost centres, godowns and stock groups, and writes across the common voucher types including purchase, payment, journal, credit note and debit note.

ODBC exposes Tally data to SQL queries and is read-optimised, typically on the same port. It suits reporting and extraction and is not the route for writing.

Two mechanical details cause a disproportionate share of first-attempt failures. Dates are expected in year-month-day form without separators. Errors come back as Tally-formatted XML rather than as conventional status codes, so error handling has to parse the response rather than check a code, and the import log on the Tally machine is where the real diagnosis lives.

Masters before transactions, always

A voucher referencing a ledger that does not exist fails. So does one referencing a stock item that does not exist. The ordering is absolute: groups, ledgers and stock items are created first, then transactions.

That produces the design question every Tally integration has to answer, which is what happens when a purchase system creates a supplier that Tally has never seen.

Three patterns are available.

  1. Master sync first, one direction. The purchase system is the master for suppliers and items, and creates them in Tally before any voucher references them. Clean, and it requires the purchase system's naming to be acceptable to the accounts team, who have usually been naming ledgers their own way for a decade.
  2. Mapping table. Both systems keep their own records and a mapping connects them. More work to maintain and it respects both parties' conventions, which is frequently what makes the project politically possible.
  3. Fail and queue. The voucher is attempted, the reference error is caught, the master is created and the voucher retried. Simple to build and it generates support traffic on every new supplier.

The second is usually right for an established business and the first for a new implementation. The third should be a fallback rather than a design.

FailureCauseWhere it surfaces
Voucher rejected on unknown ledgerMaster not created firstImport response, then the log
Duplicate vouchers in the booksRetry without idempotencyReconciliation, weeks later
Debit and credit mismatchRounding or a missing tax lineImport response, immediately
Wrong voucher typeMapping decided per developer rather than per policyAccounts, at period close
Silent non-deliveryTally closed, no queue, no acknowledgementNowhere, until somebody notices a gap

The last row is the dangerous one. An integration that posts and assumes success loses entries whenever Tally is unavailable, and the loss is invisible because nothing errored on the sending side.

When to build it and when to buy a connector

A judgement worth making explicitly, since both answers are defensible and the wrong one is expensive in different ways.

Building is reasonable where the scope is genuinely narrow: one voucher type, one direction, with ledger and tax mappings that already exist and are stable. A purchase invoice posting into Tally with a fixed supplier mapping is a contained problem, and a competent developer will have it working in days.

The scope grows non-linearly from there. Adding master synchronisation introduces conflict handling. Adding bank and payment entries introduces reconciliation. Adding tax statement reconciliation introduces an entirely separate data source. Each addition is individually modest and the combination is a product rather than a script, maintained by whoever wrote it, for as long as the business runs.

The honest test is whether the integration will stay at one voucher type in one direction. If the answer is probably not, the maintenance burden should be priced into the build decision at the start rather than discovered in year two when the original developer has moved on and the mapping table is in somebody's head.

Either way, the pattern below applies. A bought connector that posts unvalidated entries has the same problem as a built one.

The pattern that protects the books

The house position, developed on this specific problem, is that nothing should reach Tally unvalidated.

A middleware layer between the purchase system and Tally performs the checks that Tally will not: that the invoice matches its order and receipt within tolerance, that the supplier's registration is valid, that the document is not a duplicate of one already posted, that the tax lines compute. Entries passing every check post automatically. Entries failing any of them are held as exceptions with a reason.

The argument for this is not that Tally is unreliable. It is that Tally is authoritative. Once an entry is in the books it is a correction rather than a fix, corrections attract attention at audit, and a period that has been closed is considerably harder to amend. The cheapest place to catch a bad entry is before it becomes an accounting record.

Worked example, illustrative rather than measured. A business posts around 400 supplier invoices a month. Suppose two per cent carry a defect that would require correction after posting: a mismatched amount, a duplicate, a wrong ledger. That is eight corrections a month, each needing a journal entry, an approval and an explanation at close, at perhaps forty minutes each including the chase. Roughly five hours a month of accounting time, plus a corrections trail an auditor will ask about. Validating before posting moves those eight into an exception queue where the fix is a field edit taking two minutes. The arithmetic is unremarkable and the audit consequence is the part that matters. The figures are constructed to show the shape of the trade.

Idempotency, which is the one thing not to skip

Retry logic and duplicate prevention are the same problem, and getting them wrong produces duplicated entries in the accounting record, which is the worst available outcome.

Every write should carry an identifier the sending system controls and can check. Before posting, query whether a voucher with that reference already exists. After posting, record the acknowledgement against the source document. A retry then checks before it writes rather than writing again hopefully.

This matters more here than in most integrations because the receiving end becomes unavailable routinely. An integration that never retries loses data and one that retries without checking duplicates it, and duplicate vouchers are typically found weeks later during reconciliation, by which point the period may be closed.

Four decisions that belong to accounts, not to the developer

Four decisions belong to accounts rather than to whoever builds the integration, and deferring them is the most common cause of rework.

Which voucher type each transaction posts as. Purchase invoices, debit notes, payments and advances each need a decision, and the decision has to be the same every time. Inconsistent voucher types produce books that reconcile badly and reports that disagree.

How ledgers are named and who may create them. If the purchase system creates ledgers, its naming convention becomes the accounts team's convention, which they may reasonably refuse. Settling this before the build determines whether the design is master sync or a mapping table.

What happens at period close. Whether the integration may post into a closed period, what it does with entries arriving after close, and who decides. Left unsettled, the answer becomes whatever the code happens to do.

Who owns exceptions. Entries held by validation need somebody to resolve them, and that person is usually in accounts rather than in purchase. An exception queue with no owner fills up and then gets bypassed, which returns the arrangement to posting unvalidated entries.

None of the four is technical and all four shape the build. A project that starts with the XML and works backwards to these questions rewrites something.

Questions worth asking