Audits short payments from B2B customers: matches bank credits to invoices, checks every deduction against your documents and drafts disputes.
Short-payment and deduction audit for Indian B2B suppliers.
When a customer pays less than the invoice, the gap is a mix of tax withheld (TDS), fair claims, and deductions you could push back on: rate differences, shortages, scheme claims, display fees, penalties, late cash discounts. Shortfall works out where every rupee went, checks each deduction against your own documents, and drafts the dispute emails. A person reviews and sends them; the agent never sends anything.
For: accounts-receivable teams at mid-size manufacturers, brands and distributors selling to modern trade, quick commerce, distributors and corporates, and the CA firms that keep their books.
demo, or Extra inputs {"demo": true}. It audits a bundled, fictional month for "Demo Foods Pvt Ltd": three customers, three payment advices (one arriving as raw text), five bank credits, delivery documents and trade terms. About 9 LLM calls.open_invoices and evidence in Extra inputs to get invoice matches and verdicts too.{
"$defs": {
"AdviceResult": {
"properties": {
"advice_id": {
"title": "Advice Id",
"type": "string"
},
"customer": {
"title": "Customer",
"type": "string"
},
"date": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Date"
},
"reference": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Reference"
},
"total_net": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Total Net"
},
"source": {
"enum": [
"structured",
"extracted",
"unreadable",
"inferred_from_credit"
],
"title": "Source",
"type": "string"
},
"bank_credit_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Bank Credit Id"
},
"lines": {
"items": {
"$ref": "#/$defs/LineResult"
},
"title": "Lines",
"type": "array"
},
"notes": {
"items": {
"type": "string"
},
"title": "Notes",
"type": "array"
}
},
"required": [
"advice_id",
"customer",
"source"
],
"title": "AdviceResult",
"type": "object"
},
"CreditResult": {
"properties": {
"credit_id": {
"title": "Credit Id",
"type": "string"
},
"date": {
"title": "Date",
"type": "string"
},
"amount": {
"title": "Amount",
"type": "number"
},
"narration": {
"title": "Narration",
"type": "string"
},
"customer": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Customer"
},
"status": {
"enum": [
"matched_to_advice",
"inferred_invoices",
"ambiguous",
"unexplained"
],
"title": "Status",
"type": "string"
},
"advice_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Advice Id"
},
"invoices": {
"items": {
"type": "string"
},
"title": "Invoices",
"type": "array"
},
"inferred_tds": {
"default": 0,
"title": "Inferred Tds",
"type": "number"
},
"alternatives": {
"items": {
"items": {
"type": "string"
},
"type": "array"
},
"title": "Alternatives",
"type": "array"
},
"note": {
"default": "",
"title": "Note",
"type": "string"
}
},
"required": [
"credit_id",
"date",
"amount",
"narration",
"status"
],
"title": "CreditResult",
"type": "object"
},
"CustomerSummary": {
"properties": {
"customer": {
"title": "Customer",
"type": "string"
},
"short_received": {
"title": "Short Received",
"type": "number"
},
"statutory": {
"title": "Statutory",
"type": "number"
},
"statutory_at_risk": {
"title": "Statutory At Risk",
"type": "number"
},
"disputable": {
"title": "Disputable",
"type": "number"
},
"valid": {
"title": "Valid",
"type": "number"
},
"needs_human": {
"title": "Needs Human",
"type": "number"
},
"no_evidence": {
"title": "No Evidence",
"type": "number"
},
"findings": {
"title": "Findings",
"type": "integer"
}
},
"required": [
"customer",
"short_received",
"statutory",
"statutory_at_risk",
"disputable",
"valid",
"needs_human",
"no_evidence",
"findings"
],
"title": "CustomerSummary",
"type": "object"
},
"Draft": {
"properties": {
"kind": {
"enum": [
"dispute",
"advice_request",
"tds_followup"
],
"title": "Kind",
"type": "string"
},
"customer": {
"title": "Customer",
"type": "string"
},
"subject": {
"title": "Subject",
"type": "string"
},
"body": {
"title": "Body",
"type": "string"
},
"amount": {
"title": "Amount",
"type": "number"
},
"finding_ids": {
"items": {
"type": "string"
},
"title": "Finding Ids",
"type": "array"
},
"attachments": {
"items": {
"type": "string"
},
"title": "Attachments",
"type": "array"
}
},
"required": [
"kind",
"customer",
"subject",
"body",
"amount"
],
"title": "Draft",
"type": "object"
},
"EvidenceRef": {
"properties": {
"doc_id": {
"title": "Doc Id",
"type": "string"
},
"quote": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Quote"
}
},
"required": [
"doc_id"
],
"title": "EvidenceRef",
"type": "object"
},
"Finding": {
"properties": {
"finding_id": {
"title": "Finding Id",
"type": "string"
},
"advice_id": {
"title": "Advice Id",
"type": "string"
},
"customer": {
"title": "Customer",
"type": "string"
},
"invoice_no": {
"title": "Invoice No",
"type": "string"
},
"matched_invoice": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Matched Invoice"
},
"label": {
"title": "Label",
"type": "string"
},
"ref": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Ref"
},
"category": {
"title": "Category",
"type": "string"
},
"family": {
"enum": [
"statutory",
"commercial",
"unknown"
],
"title": "Family",
"type": "string"
},
"amount": {
"title": "Amount",
"type": "number"
},
"verdict": {
"enum": [
"disputable",
"partly_disputable",
"valid",
"needs_human",
"no_evidence",
"recoverable_credit",
"credit_mismatch"
],
"title": "Verdict",
"type": "string"
},
"disputable_amount": {
"default": 0,
"title": "Disputable Amount",
"type": "number"
},
"reason": {
"title": "Reason",
"type": "string"
},
"evidence": {
"items": {
"$ref": "#/$defs/EvidenceRef"
},
"title": "Evidence",
"type": "array"
},
"method": {
"default": "rule",
"enum": [
"rule",
"llm+rule",
"none"
],
"title": "Method",
"type": "string"
},
"confidence": {
"default": 1,
"title": "Confidence",
"type": "number"
}
},
"required": [
"finding_id",
"advice_id",
"customer",
"invoice_no",
"label",
"category",
"family",
"amount",
"verdict",
"reason"
],
"title": "Finding",
"type": "object"
},
"LLMUsage": {
"properties": {
"calls": {
"title": "Calls",
"type": "integer"
},
"budget": {
"title": "Budget",
"type": "integer"
},
"skipped": {
"title": "Skipped",
"type": "integer"
},
"failures": {
"items": {
"type": "string"
},
"title": "Failures",
"type": "array"
}
},
"required": [
"calls",
"budget",
"skipped"
],
"title": "LLMUsage",
"type": "object"
},
"LineResult": {
"properties": {
"invoice_no": {
"title": "Invoice No",
"type": "string"
},
"matched_invoice": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Matched Invoice"
},
"match": {
"enum": [
"exact",
"fuzzy",
"gross_mismatch",
"not_found"
],
"title": "Match",
"type": "string"
},
"gross": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Gross"
},
"deductions_total": {
"default": 0,
"title": "Deductions Total",
"type": "number"
},
"net": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Net"
},
"arithmetic": {
"enum": [
"ok",
"mismatch",
"derived"
],
"title": "Arithmetic",
"type": "string"
}
},
"required": [
"invoice_no",
"match",
"arithmetic"
],
"title": "LineResult",
"type": "object"
},
"Totals": {
"properties": {
"short_received": {
"title": "Short Received",
"type": "number"
},
"statutory": {
"title": "Statutory",
"type": "number"
},
"statutory_at_risk": {
"title": "Statutory At Risk",
"type": "number"
},
"commercial": {
"title": "Commercial",
"type": "number"
},
"disputable": {
"title": "Disputable",
"type": "number"
},
"valid": {
"title": "Valid",
"type": "number"
},
"needs_human": {
"title": "Needs Human",
"type": "number"
},
"no_evidence": {
"title": "No Evidence",
"type": "number"
},
"unexplained_credits": {
"title": "Unexplained Credits",
"type": "number"
},
"unexplained_credit_count": {
"title": "Unexplained Credit Count",
"type": "integer"
}
},
"required": [
"short_received",
"statutory",
"statutory_at_risk",
"commercial",
"disputable",
"valid",
"needs_human",
"no_evidence",
"unexplained_credits",
"unexplained_credit_count"
],
"title": "Totals",
"type": "object"
}
},
"properties": {
"company": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Company"
},
"demo": {
"default": false,
"title": "Demo",
"type": "boolean"
},
"totals": {
"$ref": "#/$defs/Totals"
},
"customers": {
"items": {
"$ref": "#/$defs/CustomerSummary"
},
"title": "Customers",
"type": "array"
},
"findings": {
"items": {
"$ref": "#/$defs/Finding"
},
"title": "Findings",
"type": "array"
},
"advices": {
"items": {
"$ref": "#/$defs/AdviceResult"
},
"title": "Advices",
"type": "array"
},
"credits": {
"items": {
"$ref": "#/$defs/CreditResult"
},
"title": "Credits",
"type": "array"
},
"drafts": {
"items": {
"$ref": "#/$defs/Draft"
},
"title": "Drafts",
"type": "array"
},
"warnings": {
"items": {
"type": "string"
},
"title": "Warnings",
"type": "array"
},
"llm": {
"$ref": "#/$defs/LLMUsage"
}
},
"required": [
"totals",
"customers",
"findings",
"advices",
"credits",
"drafts",
"warnings",
"llm"
],
"title": "AuditReport",
"type": "object"
}Scores Shortfall audits against hand-labelled scenarios: each deduction's verdict, the rupees flagged as disputable, tax credit missing from Form 168, and how bank credits were allocated to invoices.
Not evaluated yet.
Run this agent on its own in the Playground; every run shows up here with a replay.
advicesbank_credits| Key | What it holds |
|---|---|
advices | Payment advices: advice_id, customer, date, reference (UTR), total_net, and either lines (invoice_no, gross, net, deductions: [{label, amount, ref}]) or text (the raw advice, read by the LLM). |
bank_credits | Statement rows: credit_id, date, amount, narration. |
open_invoices | invoice_no, customer, date, gross, taxable_value, optional items: [{sku, qty, rate, gst_rate}]. |
rate_contracts | Agreed rates: customer, sku, rate, valid_from, valid_to. |
evidence | Documents as text: doc_id, kind (pod, grn, scheme, agreement, email, other), customer, optional invoice_no, text. |
credit_notes | Credit notes already booked: credit_note_no, customer, invoice_no, ref, amount. |
tds_credits | Rows from Form 168 (formerly 26AS), or GST TDS credit: customer, amount, kind (income_tax or gst). Leave it out and tax credits are reported as not yet verified. |
customer_aliases | Names that differ across documents, e.g. {"Orbit Retail Pvt Ltd": ["ORBIT RETAIL PRIVATE LIMITED"]}. |
company | Your company name, used in the email drafts. |
options | amount_tolerance (₹, default 1), date_window_days (10), tds_rates (fractions, default [0.001, 0.01, 0.02, 0.1]), max_llm_calls (12, at most 30), max_subset_candidates (16), lookback_days (180). |
Files (PDFs, scans, photos, CSV). Attach them in the Playground (Attach files) or upload them with
POST /api/v1/files. Then refer to each by its id in one of three ways:
"advices": [{"advice_id": "...", "file_id": "<id>"}]"evidence": [{"doc_id": "...", "kind": "pod", "customer": "...", "invoice_no": "...", "file_id": "<id>"}]"files": ["<id>", ...]Loose files are sorted automatically. A remittance or payment advice becomes an advice. Anything else becomes evidence, with its kind, customer and invoice numbers guessed from the file name and text.
PDF text is read directly. Images and scanned PDFs are read by the vision model, using at most half of
max_llm_calls (up to 6 calls), and those calls count against the budget.
Amounts accept Indian formatting ("₹1,18,000.50"). Dates accept YYYY-MM-DD or day-first (24/06/2026, 24-Jun-2026).
A minimal run that needs one LLM call:
{
"company": "Your Company Pvt Ltd",
"open_invoices": [{"invoice_no": "T-501", "customer": "Tapti Retail", "taxable_value": 10000, "gross": 10500}],
"advices": [{"advice_id": "TR-9", "customer": "Tapti Retail", "date": "2026-08-20", "lines": [
{"invoice_no": "T-501", "gross": 10500, "net": 9440,
"deductions": [{"label": "TDS", "amount": 10}, {"label": "Shortage 4 units", "amount": 1050}]}]}],
"evidence": [{"doc_id": "POD-T501", "kind": "pod", "customer": "Tapti Retail", "invoice_no": "T-501",
"text": "Delivered 40 units. Received in full, no damage or shortage."}]
}
The text answer says how much came in short, how it splits, and which items are the largest disputes. The structured output, shown in the run viewer, holds:
totals and customers: short-received, disputable, supported, needs review, no evidence, tax credit and tax credit missing.findings: one per deduction, with its category, verdict, disputable amount, the reason, and the quoted document text it rests on.drafts: a dispute email per customer (with the documents to attach), payment-advice requests for credits that couldn't be allocated, and TDS follow-ups. Nothing is sent.credits, advices, warnings: how each bank credit was allocated, notes per advice, and anything that didn't add up.Verdicts are Disputable, Partly disputable, Supported (accept and book it), Needs review, No evidence (nothing on file to contest it with), Tax credit (claim it in your returns) and Credit missing (deducted, but not in Form 168 or on the GST portal).
INV/26-27/0102 is the same as INV-102), then by running number plus amount. Bank credits to advices by amount, UTR, the customer's name in the narration (truncated names included) and date. A credit with no advice goes through a subset-sum search: which of that customer's open invoices, net of TDS at a few candidate rates, add up to it? One answer is reported as inferred, to confirm with the customer; several as ambiguous; none as unexplained.tds_credits per customer.The LLM never decides a verdict on its own and never writes accounting entries. Calls run one at a time and stop at max_llm_calls; anything skipped is marked Needs review and listed in the warnings.
None of its own: it uses the platform's LLM access (aicredits, gpt-4o-mini). Without a working LLM, the rules-only checks (matching, duplicates, rate differences, returns, TDS) still complete, document checks become Needs review, and a run whose only input is a raw advice fails with the LLM error.
options.tds_rates; GST TDS is checked at 2% (CGST Act s.51) and GST TCS at 0.5% or 1% (s.52). Tax credits are matched per customer, not per quarter.evaluation/golden.json holds six hand-labelled cases. Three are settled by rules alone and should always score 1.0: a rate difference plus a claim deducted twice, bank credits without advices, and TDS missing from Form 168. Three exercise the LLM: a proof of delivery against a shortage claim, reading a pasted advice, and the full demo month. Metrics, each from 0 to 1: run_completed, verdict_accuracy, disputable_total, statutory_at_risk and credit_allocation. The offline tests also run every golden case (the LLM ones against a faithful fake), so the dataset can't drift from the code.
ShortfallAgent().audit(data, budget=..., gateway=...) audits exactly the data you pass, as a dict in the Extra
inputs shape or as RunInputs. It never falls back to the demo month and doesn't parse a prompt. It raises
AgentError for invalid inputs or nothing readable, and LLMError the same way a standalone run does.
Pass your own gateway (agent.gateway(budget)) to read its call count even if you cancel the audit on a timeout.
The package's __init__ exports the pieces a workflow may reuse:
AuditReport and RunInputs;LLMGateway with Answer;grounded_doc (quote check);norm_invoice and CustomerBook.workflows/bakaya_v1 uses it to find which deductions stay owed before it
works out MSMED Act interest.
These need a platform design or owner-approved tables, so they are listed rather than built:
shortfall_claims (one row per disputed deduction: customer, invoice, amount, status, amount recovered) and shortfall_claim_events (status changes and email activity).