Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions clients/LedgerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,52 @@ describe('LedgerClient', () => {
})
})

describe('proposeConsolidationEntries', () => {
it('POSTs the period to propose-consolidation-entries and returns the drafts', async () => {
mockFetch.mockResolvedValueOnce(
envelopeResponse('propose-consolidation-entries', {
period: '2026-08',
consolidation_entity_id: 'ent_adj',
closed: false,
entries: [],
replaced: 2,
})
)
const result = await client.proposeConsolidationEntries('graph_42', '2026-08')
const req = mockFetch.mock.calls[0][0] as Request
expect(req.url).toBe(
'http://localhost:8000/extensions/roboledger/graph_42/operations/propose-consolidation-entries'
)
expect(JSON.parse(await req.text())).toEqual({ period: '2026-08' })
expect(result.replaced).toBe(2)
})
})

describe('setAllocationOverride', () => {
it('POSTs the share and basis to set-allocation-override', async () => {
mockFetch.mockResolvedValueOnce(
envelopeResponse('set-allocation-override', {
entity_id: 'ent_cafe',
period: '2026-08',
amount: 250000,
})
)
const result = await client.setAllocationOverride('graph_42', {
entity_id: 'ent_cafe',
period: '2026-08',
amount: 250000,
basis: 'Preferred return first',
})
const req = mockFetch.mock.calls[0][0] as Request
expect(req.url).toBe(
'http://localhost:8000/extensions/roboledger/graph_42/operations/set-allocation-override'
)
const body = JSON.parse(await req.text())
expect(body.basis).toBe('Preferred return first')
expect(result.amount).toBe(250000)
})
})

describe('deleteJournalEntry', () => {
it('returns deleted: true from the envelope', async () => {
mockFetch.mockResolvedValueOnce(envelopeResponse('delete-journal-entry', { deleted: true }))
Expand Down Expand Up @@ -3289,6 +3335,25 @@ describe('LedgerClient', () => {
})
})

describe('previewConsolidationEntries', () => {
it('POSTs the period to preview-consolidation-entries', async () => {
mockFetch.mockResolvedValueOnce(
envelopeResponse('preview-consolidation-entries', {
period: '2026-08',
proposals: [],
up_to_date: true,
})
)
const result = await client.previewConsolidationEntries('graph_42', '2026-08')
const req = mockFetch.mock.calls[0][0] as Request
expect(req.url).toBe(
'http://localhost:8000/extensions/roboledger/graph_42/operations/preview-consolidation-entries'
)
expect(JSON.parse(await req.text())).toEqual({ period: '2026-08' })
expect(result.up_to_date).toBe(true)
})
})

describe('liveFinancialStatement', () => {
it('returns the statement payload', async () => {
mockFetch.mockResolvedValueOnce(
Expand Down
56 changes: 56 additions & 0 deletions clients/LedgerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ import {
linkBankAccount,
linkEntityTaxonomy,
liveFinancialStatement,
previewConsolidationEntries,
previewEventBlock,
previewReconciliations,
previewReconcilingItem,
promoteObligations,
proposeConsolidationEntries,
rebuildSchedule,
recordOpeningBalance,
recordStatementBalance,
Expand All @@ -75,6 +77,7 @@ import {
reopenPeriod,
resolveReconcilingItem,
revokeReportShare,
setAllocationOverride,
setCloseTarget,
setReconciliationPolicy,
shareReport,
Expand All @@ -94,6 +97,7 @@ import type {
AcceptSuggestionsRequest,
AcceptSuggestionsResponse,
AddPublishListMembersOperation,
AllocationOverrideResponse,
AssociationResponse,
AutoMapElementsOperation,
BindTextBlockRequest,
Expand Down Expand Up @@ -145,10 +149,12 @@ import type {
LiveFinancialStatementRequest,
LiveFinancialStatementResponse,
OperationEnvelope,
PreviewConsolidationEntriesResponse,
PreviewEventBlockResponse,
PreviewReconciliationsRequest,
PromoteObligationsRequest,
PromoteObligationsResponse,
ProposeConsolidationEntriesResponse,
PublishListMemberResponse,
PublishListResponse,
RebuildScheduleRequest,
Expand All @@ -168,6 +174,7 @@ import type {
ResolveReconcilingItemRequest,
ResolveReconcilingItemResponse,
RevokeReportShareResponse,
SetAllocationOverrideRequest,
SetCloseTargetOperation,
SetReconciliationPolicyRequest,
ShareReportResponse,
Expand Down Expand Up @@ -2561,6 +2568,39 @@ export class LedgerClient {
return this.requireResult('Record opening balance', envelope.result)
}

/**
* Draft a month's consolidating entries in the group's consolidation
* entity, replacing the drafts the engine wrote for it before; the
* consolidation entity's close posts them. `period` is `YYYY-MM`. A
* residual or a disagreement comes back beside the drafts, never plugged;
* a closed month comes back `closed`, with nothing written.
*/
async proposeConsolidationEntries(
graphId: string,
period: string
): Promise<ProposeConsolidationEntriesResponse> {
const envelope = await this.callOperation('Propose consolidation entries', (o) =>
proposeConsolidationEntries({ ...o, path: { graph_id: graphId }, body: { period } })
)
return this.requireResult('Propose consolidation entries', envelope.result)
}

/**
* Set the outside owners' share of a member's result for one month in
* place of the pro-rata share: `amount` in cents (negative for a share of
* a loss) or `percentage` of the month's result, with the `basis`.
* `clear: true` removes it. Only for a member consolidated in full.
*/
async setAllocationOverride(
graphId: string,
body: SetAllocationOverrideRequest
): Promise<AllocationOverrideResponse> {
const envelope = await this.callOperation('Set allocation override', (o) =>
setAllocationOverride({ ...o, path: { graph_id: graphId }, body })
)
return this.requireResult('Set allocation override', envelope.result)
}

// ── Event blocks (generic preview + status transitions) ──────────────

/**
Expand Down Expand Up @@ -2782,6 +2822,22 @@ export class LedgerClient {
return this.requireResult('Consolidation worksheet', envelope.result)
}

/**
* The consolidating entries a group's month needs, computed from the books
* and posting nothing: each kind and member brought to its month-end
* balance, less what the consolidation entity already holds. `period` is
* `YYYY-MM`.
*/
async previewConsolidationEntries(
graphId: string,
period: string
): Promise<PreviewConsolidationEntriesResponse> {
const envelope = await this.callOperation('Preview consolidation entries', (o) =>
previewConsolidationEntries({ ...o, path: { graph_id: graphId }, body: { period } })
)
return this.requireResult('Preview consolidation entries', envelope.result)
}

/**
* Run a financial statement analysis against an existing report.
* On shared-repo graphs (e.g. SEC), `ticker` is required; on tenant
Expand Down
4 changes: 2 additions & 2 deletions sdk/index.ts

Large diffs are not rendered by default.

Loading
Loading