Skip to main content

Period close API

The Close app (close-ui) drives the month-end through 57 whitelisted methods in konsol/close/*_api.py (42 for the close screens and 15 for the Konsol home cards and charts), plus two in konsol/consolidation/doctype/assertion_run/assertion_run.py. This page summarises every one of them, read from the Python on 2026-11-08 (konsol 0cca0242). It is a summary: each function's docstring is the full contract.

Conventions​

Every close method follows three rules. konsol/tests/test_close_api_contract.py parses the source and fails if any method breaks one.

  1. One verb. The decorator is exactly @frappe.whitelist(methods=["GET"]) or @frappe.whitelist(methods=["POST"]). Reads are GET; anything that inserts, saves, submits, cancels, enqueues or commits is POST (Frappe rolls a GET back). A GET-only method answers 403 to a POST.
  2. Role gate first. The first statement is frappe.only_for((...roles...)), written as a literal tuple so the test can read it. A caller outside the tuple gets PermissionError (HTTP 403) before anything else is read.
  3. Entity scope after the gate. What the caller then sees is cut to their entity allow-list (konsol.entity_permissions.allowed_entity_codes): rows for other entities are dropped and counted in a hidden field, or the request is refused by name.

Role tuples used below:

Short nameRoles
All close rolesEPM Admin, EPM Analyst, Entity Accountant, EPM User, System Manager
Group rolesEPM Admin, EPM Analyst, EPM User, System Manager
Analyst or Close LeadEPM Analyst, EPM Admin, System Manager
Close LeadEPM Admin, System Manager

In the product's words, EPM Admin is the Close Lead, EPM Analyst the Group Accountant, Entity Accountant the entity's preparer, EPM User a viewer.

Periods. fiscal_year and fiscal_period name a period declared in EPM Fiscal Year. An undeclared pair is refused with PeriodNotDeclared (a ValidationError, HTTP 417) naming the period. Most methods also need the period to be of type Regular, and writes need it Open.

Errors. Refusals are frappe.throw sentences written for the user (HTTP 417, exc_type: ValidationError). Every write method checks every refusal before it writes anything.

Calling. Arguments map to the function parameters, as Frappe form fields or a JSON body. Paths are /api/method/konsol.close.<module>.<function>.

Period and work​

MethodVerbRolesPurposeKey paramsReturns
period_api.get_contextGETAll close rolesThe signed-in user, every Regular period's state, the landing period and the selected onefiscal_year, fiscal_period (optional; must be a declared Regular period){me, periods, landing, selected}
mywork_api.get_my_workGETAll close rolesThe caller's work items ranked blocking, todo, waiting; a viewer gets none—{items, counts: {blocking, todo, waiting, by_screen}, entities_assigned}
freshness_api.get_freshnessGETAll close rolesWhether the consolidated numbers are current (for the header)—freshness object with as_of
grid_api.get_period_gridGETGroup rolesThe period grid for a Regular periodfiscal_year, fiscal_period{period, rows, counts, rates_error, deadlines, signoff_overdue, ic_overdue, ic_overdue_error, journals_overdue, journals_overdue_error}
grid_api.get_readinessGETGroup rolesThe readiness checklist; reads the same gate the sign-off uses, so the two cannot disagreefiscal_year, fiscal_periodreadiness object

Trial balances​

MethodVerbRolesPurposeKey paramsReturns
tb_api.check_tbPOSTEPM Admin, Entity Accountant, System ManagerCheck a trial-balance CSV for one entity-period; writes nothing. Entity must be in the caller's scope and a non-group Entity.entity, fiscal_year, fiscal_period, amount_basis, content (CSV text or bytes){ok, rows, file_problems, totals, period_problem, replaces}
tb_api.submit_tbPOSTsameRe-check, then submit the CSV as a Trial Balance Submission, cancelling the one it replaces in the same stepas check_tb plus replaces (the name check_tb returned){name, replaced, on_behalf}
tb_read_api.my_tbsGETAll close rolesThe period's entities (cut to scope) with TB status, exception, reminders, deadlinefiscal_year, fiscal_period{period_open, can_upload, can_remind, deadline, entities: [...]}
tb_read_api.tb_compareGETAll close rolesThis period's TB against the previous Regular period's, by accountentity, fiscal_year, fiscal_period{rows, basis_note, previous_note, previous_code, entity, current, previous}
signoff_api.declare_tb_exceptionPOSTClose LeadDeclare that an entity has no trial balance for the period, with a reasonentity, fiscal_year, fiscal_period, reasonthe new TB Exception's name

Bulk upload of many entity-periods from one file is a separate module, konsol/tb_bulk.py (see the inventory).

Checks and sign-off​

MethodVerbRolesPurposeKey paramsReturns
checks_api.get_checksGETAll close rolesThe period's checks: latest run, staleness, failures, warnings, whether the caller may run themfiscal_year, fiscal_period{latest, staleness, staleness_note, as_of, results_run, domains, failures, warnings, can_run, period_status}
checks_api.run_checksPOSTAnalyst or Close LeadStart the close checks: creates an Assertion Run and queues the suite (calls trigger_close_run). Refuses a period that is not Open and a run already Queued or Running.fiscal_year, fiscal_periodthe new Assertion Run's name
signoff_api.get_signoffGETAll close rolesThe period's sign-off summary plus can_sign, can_override, period_status, closed_by, closed_on, and the data-change fieldsfiscal_year, fiscal_periodsummary object
signoff_api.signPOSTClose LeadSign off the period's latest finished run. run must be that run's name, else refused. Green signs; amber needs acknowledgement; red needs override_reason (recorded as Overridden).fiscal_year, fiscal_period, run, acknowledgement, override_reasonresult of sign_off_close
signoff_api.rejectPOSTClose LeadReject the period's signature with a reason; the run goes back to Not signed and the preparer gets a "sent back" work itemfiscal_year, fiscal_period, run, reasonresult of reject_signoff
signoff_api.close_periodPOSTClose Lead (also check_epm_admin)Close the period through its EPM Fiscal Year; the group-rate and sign-off gates are the Fiscal Year'sfiscal_year, fiscal_period, note{status, closed_by, closed_on}
signoff_api.reopen_periodPOSTClose Lead (also check_epm_admin)Reopen the period for a stated reason; later signed periods become Re-sign Neededfiscal_year, fiscal_period, reason{status, closed_by, closed_on}

The two Assertion Run methods the close methods wrap:

MethodVerbRolesPurpose
konsol.consolidation.doctype.assertion_run.assertion_run.trigger_close_runPOSTfrappe.only_for(("EPM Admin", "EPM Analyst", "System Manager"))Create the Assertion Run and enqueue run_close_assertions; refuses a period that is not Open and a run in progress
konsol.consolidation.doctype.assertion_run.assertion_run.sign_off_closePOSTwrite permission on Assertion Run; override needs EPM Admin or System ManagerThe sign-off itself: gates (konsol.close.signoff_gate.assert_can_sign), the amber acknowledgement, the red override, and the refusal of a run that started before the period's last data change (Re-run the checks before signing)

Intercompany​

MethodVerbRolesPurposeKey paramsReturns
ic_api.get_icGETGroup rolesIntercompany pairs, differences and unmatched rows from the last build, cut to scopefiscal_year, fiscal_period{period, state, message, help, published, declared_none, groups, unmatched, counts, hidden, can_send_back, can_remind}
ic_api.send_backPOSTAnalyst or Close LeadSend an over-tolerance pair back to both entities as an ic_sent_back Close Event; Open period onlyfiscal_year, fiscal_period, entity_a, account_a, entity_b, account_b, reason{event, fix_items_for}
ic_balance_api.get_ic_balancesGETGroup rolesThe period's IC Balances and the gap against the IC Elimination Rulesfiscal_year, fiscal_period{period, balances, gap, ambiguous_gap, pending_gap, hidden, entities, can_draft, rules_desk}
ic_balance_api.save_ic_balancePOSTAnalyst or Close LeadDraft a new IC Balance, or edit the named draft's amounts; Open period onlyfiscal_year, fiscal_period, selling_entity, buying_entity, ic_sales_amount, ending_inventory_from_ic, name (edit){name, docstatus}

Journals​

MethodVerbRolesPurposeKey paramsReturns
journal_api.get_journalsGETGroup rolesThe period's Consolidation Journals (draft, approved, cancelled) and what the caller may dofiscal_year, fiscal_periodjournals payload
journal_api.save_journalPOSTEPM Analyst, System ManagerDraft a Consolidation Journal, or edit the named draft; Open period only; adjustment_type must be a journal typefiscal_year, fiscal_period, consolidation_group, adjustment_type, description, lines (list or its JSON), reverse_fiscal_year, reverse_fiscal_period, name (edit)the journal summary: {name, ..., total_debit, total_credit}
journal_api.send_for_approvalPOSTEPM Analyst, System ManagerMove a draft journal to Pending Approval through the installed workflow; refuses an approved, reversed or already-sent journalnamethe journal's name and status

Rates and ownership​

MethodVerbRolesPurposeKey paramsReturns
rates_api.get_ratesGETGroup rolesThe period's group exchange rate grid: required pairs, drafts, approved rates, corrections, move warningsfiscal_year, fiscal_periodgrid payload
rates_api.save_ratePOSTAnalyst or Close LeadDraft a Group Exchange Rate, or a correction of an approved one (supersedes, needs change_reason); Open period onlyfiscal_year, fiscal_period, from_currency, to_currency, rate_type (Closing / Average), quote, quoted_per, change_reason, name, supersedes{name, docstatus, quote_label, source}
rates_api.delete_ratePOSTAnalyst or Close LeadDelete one draft correction; a plain first draft is edited, not deletedname{name, deleted: true}
rates_api.get_pendingGETGroup rolesPending Historical Equity Rate and Ownership Period drafts, cut to scope—pending lists
rates_api.get_ownershipGETGroup rolesOwnership as of the Regular period's first day, per entityfiscal_year, fiscal_periodownership payload with can_record, can_change
rates_api.preview_ownership_changeGETGroup rolesRefusals and structural effect of an ownership change starting on the period's first day; writes nothingfiscal_year, fiscal_period, consolidation_group, entity, ownership_pct, consolidation_method, name (edit){problems, effect, current, pending}
rates_api.save_ownership_changePOSTAnalyst or Close LeadSave the change as a draft Ownership Period superseding the current one; name edits that draftsame as the preview{name, docstatus: 0}

konsol.group_rates.prefill_from_erp (POST, Analyst or Close Lead) drafts Closing and Average rates for a period from the ERP quotes; it lives outside close/.

Statements and commentary​

MethodVerbRolesPurposeKey paramsReturns
statement_api.get_statementGETGroup rolesThe consolidated statement for a root group and periodfiscal_year, fiscal_period, consolidation_groupstatement payload; non-ok states choose_group, no_chart, not_built, error, setup_gap
statement_api.get_drillGETGroup rolesOne heading's drill-downfiscal_year, fiscal_period, consolidation_group, headingdrill rows
statement_api.export_statementGETGroup rolesThe statement and every heading's drill as an .xlsx download; a non-ok statement is refused with its sentence, never an empty filefiscal_year, fiscal_period, consolidation_groupfile download
commentary_api.save_commentaryPOSTAnalyst or Close LeadSave a Statement Commentary for one heading; modified is the value last read, and a stale one is refusedfiscal_year, fiscal_period, consolidation_group, heading, text, modified{name, heading, ...} with the new modified and the editor's full name

Approvals​

MethodVerbRolesPurposeKey paramsReturns
approvals_api.get_queueGETGroup rolesThe caller's approval queue over the approval doctypes (Consolidation Journal, Business Combination, Business Disposal, Group Exchange Rate, Ownership Period, Historical Equity Rate, IC Balance), plus sent-back items—queue payload
approval_api.approve_modeGETAll close rolesWhat the caller may do with a document from its Desk Actions menu: approve, approve with a self-approval reason, not an approver, or sent backdoctype, name{mode, message}
approval_api.approvePOSTClose LeadApprove a document awaiting approval; a self-approval needs reason where Close Settings require itdoctype, name, reason{name, docstatus, self_approved}
approval_api.rejectPOSTClose LeadReject with a reason: back to the workflow's first state, or (no workflow) a Comment and a rejected Close Eventdoctype, name, reason{name, docstatus, status}

Reminders and audit trail​

MethodVerbRolesPurposeKey paramsReturns
remind_api.remindPOSTAnalyst or Close LeadRemind an entity's people about a topic; refused outside an Open period or when there is nothing to remind aboutfiscal_year, fiscal_period, entity, topic (tb or ic){event, recipients}
trail_api.get_trailGETGroup rolesThe period's audit trail of Close Events, cut to scope, then filteredfiscal_year, fiscal_period, kinds, actors, entities (JSON lists), date_from, date_to{period, summary, events, hidden, total, options, filters}
trail_api.export_trail_csvGETGroup rolesThe same filtered trail as a CSV downloadsame as get_trailfile download

Konsol home cards and charts​

Fifteen methods feed the Konsol home workspace and My Work (konsol#407, konsol#419). All but get_board open with frappe.only_for over the Group roles, so an Entity Accountant is refused. The seven card methods and seven chart methods are POST because Frappe's number card and chart widgets call a Custom source with frappe.xcall, which POSTs; they write nothing. Each refuses a non-empty filters argument ("take no filters") rather than ignoring it. The period they read is the current period: the working landing of period_api.get_context, and for charts the current fiscal year up to and including it. A card the readers cannot draw returns a gray "Cannot read: ..." card (a ValueError from a reader or model); a chart that cannot be drawn throws a ValidationError "<chart title> cannot be shown: <reason>", which the widget shows inside the chart.

MethodVerbRolesPurposeKey paramsReturns
overview_api.close_statusPOSTGroup rolesThe current period close status, e.g. "FY2025 P07 · Amber"filters (must be empty)HTML: an indicator pill linked to a Desk route
overview_api.trial_balances_inPOSTGroup rolesTrial balances in / expected, cut to the caller's entity scopesamesame
overview_api.waiting_for_mePOSTGroup rolesHow many documents the caller may approve now (the My work count)samesame
overview_api.ic_over_tolerancePOSTGroup rolesIntercompany pairs over tolerance in the last build (counts, unscoped)samesame
overview_api.tb_exceptionsPOSTGroup rolesSubmitted TB Exceptions for the current period that the caller may readsamesame
overview_api.warehouse_freshnessPOSTGroup rolesWhether the consolidated numbers are currentsamesame
overview_api.get_checklistGETGroup rolesThe current period close checklist: readiness, equity rates awaiting approval, intercompany, draft journals, build, sign-off—{title, reason, lines, done, total}; with no current period, lines is empty and reason says why
charts_api.tb_submission_progressPOSTGroup rolesTrial balances submitted and excepted by period, current fiscal yearfilters (must be empty); the other widget arguments (chart_name, refresh, time_interval, timespan, from_date, to_date, heatmap_year) are accepted and ignored{labels, datasets: [{name, values}]}
charts_api.net_sales_and_resultPOSTGroup rolesNet sales and net result by period for the default root group; net sales is the Close Settings "Net Sales Heading"samesame
charts_api.top_ic_differencesPOSTGroup rolesThe ten largest IC differences by pair, current period (masked to the caller)samesame
charts_api.approvals_backlogPOSTGroup rolesDocuments waiting for approval, by document typesamesame
charts_api.closing_vs_average_ratePOSTGroup rolesClosing and average rate of the three functional currencies held by the most Active entities the caller sees, into the default group's reporting currencysamesame
charts_api.entities_by_statusPOSTGroup rolesEntities (not group nodes) by statussamesame
charts_api.days_to_closePOSTGroup rolesDays from period end to sign-off for the periods whose latest run is signedsamesame
mywork_board_api.get_boardGETAll close rolesmywork_api.get_my_work laid out as cards in Blocking, To do and Waiting columns; reads nothing else—{columns: [{kind, label, cards}], message, list_view}

Example​

# GET: the sign-off summary
curl "http://localhost:8069/api/method/konsol.close.signoff_api.get_signoff?fiscal_year=2026&fiscal_period=10" \
-b "cookies.txt"

# POST: start the checks
curl -X POST "http://localhost:8069/api/method/konsol.close.checks_api.run_checks" \
-H "Content-Type: application/json" -b "cookies.txt" \
-d '{"fiscal_year": 2026, "fiscal_period": 10}'

Where the rules live​

  • Period status and the declared calendar: konsol/period_status.py, konsol/fiscal_calendar.py, doctype EPM Fiscal Year.
  • The sign-off gate: konsol/close/signoff_gate.py.
  • Each screen's pure logic is in a *_model.py next to its *_api.py; the model files import no Frappe and are unit-tested on the host.
  • Per-endpoint tests: konsol/tests/test_close_*_api.py.