The problem
Indian companies raise debt through non-convertible debentures (NCDs), a kind of corporate bond. Each month, an accounting practice whose clients hold NCDs receives one Excel workbook from each issuer. Every workbook has a sheet per month, and each sheet lists every investor’s interest, tax deducted at source (TDS) and principal repayments.
The practice’s books, kept in Lekhavo, import NCD schedules one entity at a time, filtered to that entity’s tax ID (its PAN). Imported as they arrive, the issuer files would have to be uploaded to every entity, and a client’s position would still be split across several unrelated statements. In the practice’s real data, more than a third of clients hold paper from more than one issuer. So this is a genuine pivot, not a simple split.
Lekhavo’s NCD import also rejects the whole file if one row fails its checks, so one bad row costs the client’s entire import.
What we built
NCD (ncd.lekhavo.com) turns the data around. It takes in issuer workbooks, keeps one normalized payment history, and produces one workbook per client covering every issuer, ready to upload into Lekhavo as a single import.
Upload, stage, review, commit
Each issuer workbook moves through explicit steps:
- Receive: the file is hashed and the original kept. A byte-identical re-upload is refused and the earlier filename is named. A database uniqueness rule backs this up, so two simultaneous uploads of one file can’t both get in.
- Stage: every sheet is read, every row checked and compared with the stored payments, and the whole proposal saved. A page refresh mustn’t lose a long review.
- Review: the practice sees what is new, what changed and what conflicts.
- Commit: staged rows are written into the payment history in one transaction.
Two rules protect the history. A partial file is not an instruction to delete: one real workbook skips two months entirely. A missing payment is marked stale only when the newer file covers an overlapping period for the same client and series, and nothing in the commit path deletes a payment. Hand corrections survive the next month’s file: the old value goes to an append-only history, and a file that disagrees is recorded, not applied.
The tie-out checks
Every row passes five checks, the same ones Lekhavo’s importer runs, because the whole point is a file that importer accepts:
| Check | Rule |
|---|---|
| Series ID (ISIN) | INE followed by 9 letters or digits |
| PAN | 5 letters, 4 digits, 1 letter |
| Days | days printed = period end minus period start |
| Interest | gross interest minus TDS equals net interest, within ₹1.50 |
| Total | net interest plus principal equals the printed total, within ₹1.50 |
The ₹1.50 tolerance isn’t padding. Issuers round interest and TDS separately on each line, so the printed parts can miss their own total by about a rupee. Requiring exact equality would quarantine correct rows.
Measured against the real workbooks, about 2% of rows fail, all on the total check. The checks report every failure in a row, not just the first, and each one points to the file, sheet and row number the practice will actually open.
There is deliberately no overlapping-period check. One client legitimately holds several payments over overlapping dates, each on a different principal tranche, and flagging them would quarantine correct data.
Money is stored as numeric(20,6) and added in BigInt micro-units, never as floating point, because the source carries sub-paise precision and one drifted paisa could fail a client’s whole import.
Failing rows are held, not dropped
A failing row is stored and flagged, and its validity is recomputed in the database from the row’s own figures. It blocks that client’s export and becomes valid as soon as someone corrects it. Dropping it would understate a client’s position by an amount the software never mentions.
The export
The export uses the same query as the screen the practice reviewed, so the workbook holds exactly the rows they saw. Any rows excluded by hand are recorded on the export.
If any row would fail Lekhavo’s import, the export is refused. The refusal is a value that lists the blocking payments, so the screen can show them and the practice can correct or exclude each one. The workbook writer repeats the checks itself, at a layer no caller can skip. It also writes the file for the importer, not for Excel:
- Column headers spelled correctly, even though every source workbook misspells one of them
- Dates as real date cells, so day-first versus month-first is never guessed
- A total row with no series ID, so the importer skips it instead of failing on it
Why there is no database link to Lekhavo
NCD has its own database, its own sign-in and its own deployment. There’s no connection between NCD and Lekhavo’s database in either direction. Nothing in Lekhavo reads NCD, and NCD can’t write to Lekhavo. In production, the two databases sit in separate projects.
The handoff is a file a person downloads from NCD and uploads into Lekhavo. That’s deliberate:
- The upload is the review step. Someone looks at a client’s workbook before it reaches their books. A direct database read that “saved” that step would remove a safety check, not just a manual chore.
- Lekhavo checks again. Its importer runs the same tie-out rules on the file, so a mistake on one side gets caught on the other.
- Each system fails alone. A bad deploy in NCD can’t corrupt the books.
An earlier version read Lekhavo’s session tables through a read-only role. It could recognize a session but never issue or end one, so NCD had no login screen of its own. Giving NCD its own identity tables fixed that and removed the last link between the databases.
How it was built
NCD was built in Tembrant’s AI software factory: agents work in parallel, held to fixed gates. Every change starts from a written spec and gets tests first. The tests are asserted against facts measured from the real issuer workbooks: row counts, client counts and the exact list of failing rows. Each change ships through one pull request with an independent code review and green CI, and only the merged revision is deployed.
If your firm reconciles third-party schedules before they reach the books, read about our reconciliation software development work or contact us.
