profit_and_loss
Generate a TallyPrime Profit and Loss statement for a company and date range, derived from the Trial Balance with validation checks and clear not-established reasons.
Instructions
Return the Profit and Loss for a date range, derived from Tally's native Trial Balance: one line per reserved P&L primary group (Sales Accounts, Direct Incomes, Purchase Accounts, Direct Expenses, Indirect Incomes, Indirect Expenses), each the window's signed debit plus credit movement (a debit negative), with gross_result and net_result (a profit positive). The top-level lines is null while net_result is not established, so a derived line is never shown as the statement. Reads the Trial Balance, the group tree, Tally's own Balance Sheet and its Profit and Loss inside one company, mode and book-extent bracket; requires one INR currency master and supported date boundaries. Each line's amount has sum (of the amounts Tally returned), present_count and empty_count. A result is established only if every ledger is classified (a ledger under a user-created primary group, or whose group chain is incomplete, is listed in unclassified, up to 100, with unclassified_total), no Stock-in-Hand ledger carries an amount, and Tally's own Balance Sheet for the window ties line for line to the derived one (balance_sheet_gate). Otherwise it is not_established with a reason (unclassified_ledger_carries_an_amount, closing_stock_not_derivable_from_trial_balance, profit_and_loss_ledger_not_returned, tally_balance_sheet_differs, or for gross and net tally_profit_and_loss_differs); for the two differs reasons, lines names the lines that did not tie. On the one book measured, Tally's own Balance Sheet export left out the Difference in opening balances line its screen showed: when the export's lines do not sum to zero the result carries tally_balance_sheet_sides (the credit and debit totals), the first line says so, and nothing is established (tally_balance_sheet_does_not_balance when no other reason applies). The top-level state is observed only while gross_result and net_result are both established, else not_established with the nested reason. With integrated inventory and no opening stock, Tally's own Less: Closing Stock is used and shown in closing_stock (applied, declined with why, or null), only if that one figure ties Current Assets, the Profit & Loss A/c line and the Cost of Sales heading, and the lines sum to zero (one book seen); Add: Purchase Accounts is then Purchase Accounts. Otherwise a book with stock items refuses. A Tally line with an amount and no derived counterpart (a heading) refuses. Tally's statements name no company; the checks around the read bind them. The gate has been measured over one full year on one book and one month on another; a window spanning more than one financial year is unmeasured. Tally's own Profit and Loss is read too and compared by display name in tie_out (matched, matched_empty_as_zero, differs or not_compared). Gross and net are also refused as tally_profit_and_loss_differs unless it ties: no line differs, no derived line is missing from it, and no line of its with an amount is uncompared, except its Cost of Sales : heading while that equals the derived Purchase Accounts plus Direct Expenses, less any closing stock used, exactly. Each call appends metadata-only receipt lines (tool, company, counts, request and response fingerprints; no book content) to ComplyEaze Bridge's local log on this computer; it writes nothing to Tally.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"company_guid": "<company_guid>",
"from": "<from>",
"to": "<to>"
},
"name": "profit_and_loss"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | The last day of the date range, included (YYYYMMDD or YYYY-MM-DD). | |
| from | Yes | The first day of the date range, included (YYYYMMDD or YYYY-MM-DD). | |
| company_guid | Yes | The company's company_guid, as list_companies returns it. |