@robosystems/client 2.21.0 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/LedgerClient.d.ts +81 -3
- package/artifacts/LedgerClient.js +92 -1
- package/artifacts/LedgerClient.ts +190 -2
- package/artifacts/graphql/generated/graphql.d.ts +329 -0
- package/artifacts/graphql/generated/graphql.js +961 -59
- package/artifacts/graphql/generated/graphql.ts +1275 -59
- package/artifacts/graphql/queries/ledger/agedBalances.d.ts +27 -0
- package/artifacts/graphql/queries/ledger/agedBalances.js +136 -0
- package/artifacts/graphql/queries/ledger/agedBalances.ts +139 -0
- package/artifacts/graphql/queries/ledger/dimensions.d.ts +7 -0
- package/artifacts/graphql/queries/ledger/dimensions.js +27 -0
- package/artifacts/graphql/queries/ledger/dimensions.ts +25 -0
- package/artifacts/graphql/queries/ledger/journalEntries.js +5 -0
- package/artifacts/graphql/queries/ledger/journalEntries.ts +5 -0
- package/artifacts/graphql/queries/ledger/transaction.js +6 -0
- package/artifacts/graphql/queries/ledger/transaction.ts +6 -0
- package/artifacts/graphql/queries/ledger/trialBalance.d.ts +4 -1
- package/artifacts/graphql/queries/ledger/trialBalance.js +19 -3
- package/artifacts/graphql/queries/ledger/trialBalance.ts +19 -3
- package/index.ts +2 -2
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +7 -5
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +21 -5
- package/sdk/sdk.gen.js +40 -6
- package/sdk/sdk.gen.ts +39 -5
- package/sdk/types.gen.d.ts +449 -5
- package/sdk/types.gen.ts +468 -5
- package/sdk.gen.d.ts +21 -5
- package/sdk.gen.js +40 -6
- package/sdk.gen.ts +39 -5
- package/types.gen.d.ts +449 -5
- package/types.gen.ts +468 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AcceptSuggestionsRequest, AcceptSuggestionsResponse, AllocationOverrideResponse, AssociationResponse, AutoMapElementsOperation, BindTextBlockRequest, BindTextBlockResponse, BlockedSourceGraphResponse, BlockSourceGraphResult, ComputeMetricsRequest, ComputeMetricsResponse, ConsolidationProposal, ConsolidationWorksheetRequest, ConsolidationWorksheetResponse, CreateAgentRequest, CreateEntityRequest, CreateEventBlockRequest, CreateEventHandlerRequest, CreateInformationBlockRequest, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteInformationBlockRequest, DeleteInformationBlockResponse, DeleteMappingAssociationOperation, DeleteResult, DeleteTaxonomyBlockRequest, DeleteTaxonomyBlockResponse, EntityTaxonomyResponse, EvaluateRulesRequest, EvaluateRulesResponse, EventBlockEnvelope, EventHandlerResponse, FinancialStatementAnalysisRequest, FinancialStatementAnalysisResponse, InformationBlockEnvelope, InitializeChartOfAccountsRequest, JournalEntryResponse, LearnClassificationDefaultsResponse, LedgerAgentResponse, LinkBankAccountRequest, LinkBankAccountResponse, LinkEntityTaxonomyRequest, LiveFinancialStatementRequest, LiveFinancialStatementResponse, OperationEnvelope, PreviewConsolidationEntriesResponse, PreviewEventBlockResponse, PreviewReconciliationsRequest, PromoteObligationsRequest, PromoteObligationsResponse, ProposeConsolidationEntriesResponse, PublishListMemberResponse, PublishListResponse, ReconcilingItemPlan, RecordOpeningBalanceRequest, ReportResponse, ResolveReconcilingItemRequest, ResolveReconcilingItemResponse, RevokeReportShareResponse, SetAllocationOverrideRequest, ShareReportResponse, TaxonomyBlockEnvelope, UpdateAgentRequest, UpdateEntityRequest, UpdateEventBlockRequest, UpdateEventHandlerRequest, UpdateInformationBlockRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest, ViewResponse } from '../types.gen';
|
|
1
|
+
import type { AcceptSuggestionsRequest, AcceptSuggestionsResponse, AllocationOverrideResponse, AssociationResponse, AutoMapElementsOperation, BindTextBlockRequest, BindTextBlockResponse, BlockedSourceGraphResponse, BlockSourceGraphResult, ComputeMetricsRequest, ComputeMetricsResponse, ConsolidationProposal, ConsolidationWorksheetRequest, ConsolidationWorksheetResponse, CreateAgentRequest, CreateDimensionRequest, CreateEntityRequest, CreateEventBlockRequest, CreateEventHandlerRequest, CreateInformationBlockRequest, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteInformationBlockRequest, DeleteInformationBlockResponse, DeleteMappingAssociationOperation, DeleteResult, DeleteTaxonomyBlockRequest, DeleteTaxonomyBlockResponse, DimensionResponse, EntityTaxonomyResponse, EvaluateRulesRequest, EvaluateRulesResponse, EventBlockEnvelope, EventHandlerResponse, FinancialStatementAnalysisRequest, FinancialStatementAnalysisResponse, InformationBlockEnvelope, InitializeChartOfAccountsRequest, JournalEntryResponse, LearnClassificationDefaultsResponse, LedgerAgentResponse, LinkBankAccountRequest, LinkBankAccountResponse, LinkEntityTaxonomyRequest, LiveFinancialStatementRequest, LiveFinancialStatementResponse, OperationEnvelope, PreviewConsolidationEntriesResponse, PreviewEventBlockResponse, PreviewReconciliationsRequest, PromoteObligationsRequest, PromoteObligationsResponse, ProposeConsolidationEntriesResponse, PublishListMemberResponse, PublishListResponse, ReconcilingItemPlan, RecordOpeningBalanceRequest, ReportResponse, ResolveReconcilingItemRequest, ResolveReconcilingItemResponse, RevokeReportShareResponse, SetAllocationOverrideRequest, ShareReportResponse, TaxonomyBlockEnvelope, UpdateAgentRequest, UpdateDimensionRequest, UpdateEntityRequest, UpdateEventBlockRequest, UpdateEventHandlerRequest, UpdateInformationBlockRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest, ViewResponse } from '../types.gen';
|
|
2
2
|
import type { TokenProvider } from './graphql/client';
|
|
3
|
-
import { ListLedgerBankAccountsQuery, type ClassificationStatsQuery, type FlowCandidatesQuery, type GetInformationBlockQuery, type GetLedgerAccountRollupsQuery, type GetLedgerAccountTreeQuery, type GetLedgerAgentQuery, type GetLedgerClosingBookStructuresQuery, type GetLedgerEntityQuery, type GetLedgerEventBlockQuery, type GetLedgerFiscalCalendarQuery, type GetLedgerMappedTrialBalanceQuery, type GetLedgerMappingCoverageQuery, type GetLedgerMappingQuery, type GetLedgerPeriodCloseStatusQuery, type GetLedgerPeriodDraftsQuery, type GetLedgerPublishListQuery, type GetLedgerReportingTaxonomyQuery, type GetLedgerReportPackageQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type GetLedgerSummaryQuery, type GetLedgerTransactionQuery, type GetLedgerTrialBalanceQuery, type ListChartTemplatesQuery, type ListInformationBlocksQuery, type ListInformationBlockSummariesQuery, type ListLedgerAccountsQuery, type ListLedgerAgentsQuery, type ListLedgerBlockedSourceGraphsQuery, type ListLedgerElementsQuery, type ListLedgerEntitiesQuery, type ListLedgerEventBlocksQuery, type ListLedgerJournalEntriesQuery, type ListLedgerMappingsQuery, type ListLedgerPublishListsQuery, type ListLedgerReconciliationsQuery, type ListLedgerReportsQuery, type ListLedgerStructuresQuery, type ListLedgerTaxonomiesQuery, type ListLedgerTransactionsQuery, type ListLedgerUnmappedElementsQuery, type MappingCandidatesQuery, type ReportDownloadFormat, type ReportLifecycle } from './graphql/generated/graphql';
|
|
3
|
+
import { ListLedgerBankAccountsQuery, type AgedReceivablesQuery, type ClassificationStatsQuery, type DischargeCandidatesQuery, type FlowCandidatesQuery, type GetInformationBlockQuery, type GetLedgerAccountRollupsQuery, type GetLedgerAccountTreeQuery, type GetLedgerAgentQuery, type GetLedgerClosingBookStructuresQuery, type GetLedgerEntityQuery, type GetLedgerEventBlockQuery, type GetLedgerFiscalCalendarQuery, type GetLedgerMappedTrialBalanceQuery, type GetLedgerMappingCoverageQuery, type GetLedgerMappingQuery, type GetLedgerPeriodCloseStatusQuery, type GetLedgerPeriodDraftsQuery, type GetLedgerPublishListQuery, type GetLedgerReportingTaxonomyQuery, type GetLedgerReportPackageQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type GetLedgerSummaryQuery, type GetLedgerTransactionQuery, type GetLedgerTrialBalanceQuery, type ListChartTemplatesQuery, type ListInformationBlocksQuery, type ListInformationBlockSummariesQuery, type ListLedgerAccountsQuery, type ListLedgerAgentsQuery, type ListLedgerBlockedSourceGraphsQuery, type ListLedgerDimensionsQuery, type ListLedgerElementsQuery, type ListLedgerEntitiesQuery, type ListLedgerEventBlocksQuery, type ListLedgerJournalEntriesQuery, type ListLedgerMappingsQuery, type ListLedgerPublishListsQuery, type ListLedgerReconciliationsQuery, type ListLedgerReportsQuery, type ListLedgerStructuresQuery, type ListLedgerTaxonomiesQuery, type ListLedgerTransactionsQuery, type ListLedgerUnmappedElementsQuery, type MappingCandidatesQuery, type OpenItemsForAgentQuery, type ReportDownloadFormat, type ReportLifecycle } from './graphql/generated/graphql';
|
|
4
4
|
export { GraphQLError } from './graphql/client';
|
|
5
5
|
export type { ReportLifecycle };
|
|
6
6
|
export type LedgerEntity = NonNullable<GetLedgerEntityQuery['entity']>;
|
|
@@ -33,6 +33,17 @@ export type LedgerFlowCandidate = FlowCandidatesQuery['flowCandidates'][number];
|
|
|
33
33
|
export type LedgerClassificationStats = NonNullable<ClassificationStatsQuery['classificationStats']>;
|
|
34
34
|
export type LedgerClassificationSourceStats = LedgerClassificationStats['bySource'][number];
|
|
35
35
|
export type LedgerUnmappedElement = ListLedgerUnmappedElementsQuery['unmappedElements'][number];
|
|
36
|
+
export type LedgerAgedBalances = AgedReceivablesQuery['agedReceivables'];
|
|
37
|
+
export type LedgerAgingBuckets = LedgerAgedBalances['buckets'];
|
|
38
|
+
export type LedgerAgedAgentRow = LedgerAgedBalances['agents'][number];
|
|
39
|
+
export type LedgerControlTieOut = LedgerAgedBalances['tieOuts'][number];
|
|
40
|
+
export type LedgerIntercompanyPair = LedgerAgedBalances['pairs'][number];
|
|
41
|
+
export type LedgerOpenItem = OpenItemsForAgentQuery['openItemsForAgent'][number];
|
|
42
|
+
export type LedgerDischargeCandidates = NonNullable<DischargeCandidatesQuery['dischargeCandidates']>;
|
|
43
|
+
export type LedgerDimensionList = NonNullable<ListLedgerDimensionsQuery['dimensions']>;
|
|
44
|
+
export type LedgerDimension = LedgerDimensionList['dimensions'][number];
|
|
45
|
+
/** `receivables` (invoices) or `payables` (bills). */
|
|
46
|
+
export type LedgerOpenItemKind = 'receivables' | 'payables';
|
|
36
47
|
export type LedgerStructureList = NonNullable<ListLedgerStructuresQuery['structures']>;
|
|
37
48
|
export type LedgerStructure = LedgerStructureList['structures'][number];
|
|
38
49
|
export type LedgerMappingList = NonNullable<ListLedgerMappingsQuery['mappings']>;
|
|
@@ -572,11 +583,78 @@ export declare class LedgerClient {
|
|
|
572
583
|
}): Promise<LedgerAgent[]>;
|
|
573
584
|
/** Get agent detail by id. */
|
|
574
585
|
getAgent(graphId: string, agentId: string): Promise<LedgerAgentDetail | null>;
|
|
575
|
-
/**
|
|
586
|
+
/**
|
|
587
|
+
* Receivables or payables aged at a date (`options.asOf`, `YYYY-MM-DD`,
|
|
588
|
+
* default today on the server): totals by days past due, a row per
|
|
589
|
+
* counterparty, and each entity's open items tied out to its receivables
|
|
590
|
+
* or payables account (`differenceCents`, never plugged). `options.scope`
|
|
591
|
+
* is `entity` (one entity's books, `options.entityId` default the group
|
|
592
|
+
* parent) or `group` (the parent and its members consolidated in full,
|
|
593
|
+
* with what they owe each other in `intercompany` and `pairs`). An item
|
|
594
|
+
* with no due date of its own is due on receipt and counted in
|
|
595
|
+
* `defaultedDueDateCount`.
|
|
596
|
+
*/
|
|
597
|
+
getAgedBalances(graphId: string, kind: LedgerOpenItemKind, options?: {
|
|
598
|
+
asOf?: string | null;
|
|
599
|
+
entityId?: string | null;
|
|
600
|
+
scope?: 'entity' | 'group';
|
|
601
|
+
}): Promise<LedgerAgedBalances>;
|
|
602
|
+
/**
|
|
603
|
+
* One counterparty's open invoices (`receivables`) or bills (`payables`)
|
|
604
|
+
* at a date, oldest first, each with its due date, days past due and
|
|
605
|
+
* bucket — the drill from an aged row into its documents.
|
|
606
|
+
*/
|
|
607
|
+
getOpenItemsForAgent(graphId: string, agentId: string, kind: LedgerOpenItemKind, options?: {
|
|
608
|
+
asOf?: string | null;
|
|
609
|
+
entityId?: string | null;
|
|
610
|
+
}): Promise<LedgerOpenItem[]>;
|
|
611
|
+
/**
|
|
612
|
+
* The open invoices or bills a payment or bank line may settle: its own
|
|
613
|
+
* entity's and counterparty's, open at its date, an exact amount match
|
|
614
|
+
* first, then the oldest due date. `classifiedToControl` says the line
|
|
615
|
+
* went to a receivables or payables account — when the inbox offers the
|
|
616
|
+
* pick. Record the choice with `discharge_allocations` on
|
|
617
|
+
* `updateEventBlock`; nothing settles without one. Null when there is no
|
|
618
|
+
* such event.
|
|
619
|
+
*/
|
|
620
|
+
getDischargeCandidates(graphId: string, eventId: string): Promise<LedgerDischargeCandidates | null>;
|
|
621
|
+
/**
|
|
622
|
+
* The graph's management dimension members — departments, classes,
|
|
623
|
+
* locations, projects — by axis then name, each with how many lines carry
|
|
624
|
+
* it. `types` lists the axes the graph has members on. Retired members
|
|
625
|
+
* are left out unless `options.includeInactive`.
|
|
626
|
+
*/
|
|
627
|
+
getDimensions(graphId: string, options?: {
|
|
628
|
+
dimensionType?: string | null;
|
|
629
|
+
includeInactive?: boolean;
|
|
630
|
+
}): Promise<LedgerDimensionList | null>;
|
|
631
|
+
/**
|
|
632
|
+
* Add a member to a management dimension (`dimension_type`: department,
|
|
633
|
+
* class, location, project, or an axis of your own). `value`, the
|
|
634
|
+
* member's key within its axis, defaults to a slug of the name; a
|
|
635
|
+
* duplicate key is refused (409).
|
|
636
|
+
*/
|
|
637
|
+
createDimension(graphId: string, body: CreateDimensionRequest, idempotencyKey?: string): Promise<DimensionResponse>;
|
|
638
|
+
/**
|
|
639
|
+
* Rename a member, or retire it with `is_active: false`: it stays on the
|
|
640
|
+
* lines that carry it and goes on no new ones. A member synced from
|
|
641
|
+
* QuickBooks keeps QuickBooks's name.
|
|
642
|
+
*/
|
|
643
|
+
updateDimension(graphId: string, body: UpdateDimensionRequest): Promise<DimensionResponse>;
|
|
644
|
+
/**
|
|
645
|
+
* Trial balance by raw CoA account. `options.dimension` sums one
|
|
646
|
+
* management dimension member's lines (`memberId: 'unallocated'` for the
|
|
647
|
+
* lines no member of the axis tags); such a balance need not foot, and
|
|
648
|
+
* says so in `sliced`.
|
|
649
|
+
*/
|
|
576
650
|
getTrialBalance(graphId: string, options?: {
|
|
577
651
|
startDate?: string;
|
|
578
652
|
endDate?: string;
|
|
579
653
|
entityId?: string | null;
|
|
654
|
+
dimension?: {
|
|
655
|
+
type: string;
|
|
656
|
+
memberId: string;
|
|
657
|
+
} | null;
|
|
580
658
|
}): Promise<LedgerTrialBalance | null>;
|
|
581
659
|
/** Trial balance rolled up to GAAP reporting concepts via a mapping. */
|
|
582
660
|
getMappedTrialBalance(graphId: string, mappingId: string, options?: {
|
|
@@ -201,13 +201,104 @@ class LedgerClient {
|
|
|
201
201
|
async getAgent(graphId, agentId) {
|
|
202
202
|
return this.gqlQuery(graphId, graphql_1.GetLedgerAgentDocument, { id: agentId }, 'Get agent', (data) => data.agent);
|
|
203
203
|
}
|
|
204
|
+
// ── Receivables and payables ────────────────────────────────────────
|
|
205
|
+
/**
|
|
206
|
+
* Receivables or payables aged at a date (`options.asOf`, `YYYY-MM-DD`,
|
|
207
|
+
* default today on the server): totals by days past due, a row per
|
|
208
|
+
* counterparty, and each entity's open items tied out to its receivables
|
|
209
|
+
* or payables account (`differenceCents`, never plugged). `options.scope`
|
|
210
|
+
* is `entity` (one entity's books, `options.entityId` default the group
|
|
211
|
+
* parent) or `group` (the parent and its members consolidated in full,
|
|
212
|
+
* with what they owe each other in `intercompany` and `pairs`). An item
|
|
213
|
+
* with no due date of its own is due on receipt and counted in
|
|
214
|
+
* `defaultedDueDateCount`.
|
|
215
|
+
*/
|
|
216
|
+
async getAgedBalances(graphId, kind, options) {
|
|
217
|
+
const variables = {
|
|
218
|
+
asOf: options?.asOf ?? null,
|
|
219
|
+
entityId: options?.entityId ?? null,
|
|
220
|
+
scope: options?.scope ?? 'entity',
|
|
221
|
+
};
|
|
222
|
+
if (kind === 'receivables') {
|
|
223
|
+
return this.gqlQuery(graphId, graphql_1.AgedReceivablesDocument, variables, 'Aged receivables', (data) => data.agedReceivables);
|
|
224
|
+
}
|
|
225
|
+
return this.gqlQuery(graphId, graphql_1.AgedPayablesDocument, variables, 'Aged payables', (data) => data.agedPayables);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* One counterparty's open invoices (`receivables`) or bills (`payables`)
|
|
229
|
+
* at a date, oldest first, each with its due date, days past due and
|
|
230
|
+
* bucket — the drill from an aged row into its documents.
|
|
231
|
+
*/
|
|
232
|
+
async getOpenItemsForAgent(graphId, agentId, kind, options) {
|
|
233
|
+
return this.gqlQuery(graphId, graphql_1.OpenItemsForAgentDocument, {
|
|
234
|
+
agentId,
|
|
235
|
+
kind,
|
|
236
|
+
asOf: options?.asOf ?? null,
|
|
237
|
+
entityId: options?.entityId ?? null,
|
|
238
|
+
}, 'Open items for agent', (data) => data.openItemsForAgent);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The open invoices or bills a payment or bank line may settle: its own
|
|
242
|
+
* entity's and counterparty's, open at its date, an exact amount match
|
|
243
|
+
* first, then the oldest due date. `classifiedToControl` says the line
|
|
244
|
+
* went to a receivables or payables account — when the inbox offers the
|
|
245
|
+
* pick. Record the choice with `discharge_allocations` on
|
|
246
|
+
* `updateEventBlock`; nothing settles without one. Null when there is no
|
|
247
|
+
* such event.
|
|
248
|
+
*/
|
|
249
|
+
async getDischargeCandidates(graphId, eventId) {
|
|
250
|
+
return this.gqlQuery(graphId, graphql_1.DischargeCandidatesDocument, { eventId }, 'Discharge candidates', (data) => data.dischargeCandidates);
|
|
251
|
+
}
|
|
252
|
+
// ── Management dimensions ─────────────────────────────────────────
|
|
253
|
+
/**
|
|
254
|
+
* The graph's management dimension members — departments, classes,
|
|
255
|
+
* locations, projects — by axis then name, each with how many lines carry
|
|
256
|
+
* it. `types` lists the axes the graph has members on. Retired members
|
|
257
|
+
* are left out unless `options.includeInactive`.
|
|
258
|
+
*/
|
|
259
|
+
async getDimensions(graphId, options) {
|
|
260
|
+
return this.gqlQuery(graphId, graphql_1.ListLedgerDimensionsDocument, {
|
|
261
|
+
dimensionType: options?.dimensionType ?? null,
|
|
262
|
+
includeInactive: options?.includeInactive ?? false,
|
|
263
|
+
}, 'List dimensions', (data) => data.dimensions);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Add a member to a management dimension (`dimension_type`: department,
|
|
267
|
+
* class, location, project, or an axis of your own). `value`, the
|
|
268
|
+
* member's key within its axis, defaults to a slug of the name; a
|
|
269
|
+
* duplicate key is refused (409).
|
|
270
|
+
*/
|
|
271
|
+
async createDimension(graphId, body, idempotencyKey) {
|
|
272
|
+
const envelope = await this.callOperation('Create dimension', (o) => (0, sdk_gen_1.createDimension)({
|
|
273
|
+
...(0, rest_1.withIdempotencyKey)(o, idempotencyKey),
|
|
274
|
+
path: { graph_id: graphId },
|
|
275
|
+
body,
|
|
276
|
+
}));
|
|
277
|
+
return this.requireResult('Create dimension', envelope.result);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Rename a member, or retire it with `is_active: false`: it stays on the
|
|
281
|
+
* lines that carry it and goes on no new ones. A member synced from
|
|
282
|
+
* QuickBooks keeps QuickBooks's name.
|
|
283
|
+
*/
|
|
284
|
+
async updateDimension(graphId, body) {
|
|
285
|
+
const envelope = await this.callOperation('Update dimension', (o) => (0, sdk_gen_1.updateDimension)({ ...o, path: { graph_id: graphId }, body }));
|
|
286
|
+
return this.requireResult('Update dimension', envelope.result);
|
|
287
|
+
}
|
|
204
288
|
// ── Trial Balance ──────────────────────────────────────────────────
|
|
205
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* Trial balance by raw CoA account. `options.dimension` sums one
|
|
291
|
+
* management dimension member's lines (`memberId: 'unallocated'` for the
|
|
292
|
+
* lines no member of the axis tags); such a balance need not foot, and
|
|
293
|
+
* says so in `sliced`.
|
|
294
|
+
*/
|
|
206
295
|
async getTrialBalance(graphId, options) {
|
|
207
296
|
return this.gqlQuery(graphId, graphql_1.GetLedgerTrialBalanceDocument, {
|
|
208
297
|
startDate: options?.startDate ?? null,
|
|
209
298
|
endDate: options?.endDate ?? null,
|
|
210
299
|
entityId: options?.entityId ?? null,
|
|
300
|
+
dimensionType: options?.dimension?.type ?? null,
|
|
301
|
+
dimensionMemberId: options?.dimension?.memberId ?? null,
|
|
211
302
|
}, 'Get trial balance', (data) => data.trialBalance);
|
|
212
303
|
}
|
|
213
304
|
/** Trial balance rolled up to GAAP reporting concepts via a mapping. */
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
computeMetrics,
|
|
40
40
|
consolidationWorksheet,
|
|
41
41
|
createAgent,
|
|
42
|
+
createDimension,
|
|
42
43
|
createEntity,
|
|
43
44
|
createEventBlock,
|
|
44
45
|
createEventHandler,
|
|
@@ -85,6 +86,7 @@ import {
|
|
|
85
86
|
transitionFilingStatus,
|
|
86
87
|
unblockSourceGraph,
|
|
87
88
|
updateAgent,
|
|
89
|
+
updateDimension,
|
|
88
90
|
updateEntity,
|
|
89
91
|
updateEventBlock,
|
|
90
92
|
updateEventHandler,
|
|
@@ -112,6 +114,7 @@ import type {
|
|
|
112
114
|
ConsolidationWorksheetRequest,
|
|
113
115
|
ConsolidationWorksheetResponse,
|
|
114
116
|
CreateAgentRequest,
|
|
117
|
+
CreateDimensionRequest,
|
|
115
118
|
CreateEntityRequest,
|
|
116
119
|
CreateEventBlockRequest,
|
|
117
120
|
CreateEventHandlerRequest,
|
|
@@ -128,6 +131,7 @@ import type {
|
|
|
128
131
|
DeleteResult,
|
|
129
132
|
DeleteTaxonomyBlockRequest,
|
|
130
133
|
DeleteTaxonomyBlockResponse,
|
|
134
|
+
DimensionResponse,
|
|
131
135
|
EntityTaxonomyResponse,
|
|
132
136
|
EvaluateRulesRequest,
|
|
133
137
|
EvaluateRulesResponse,
|
|
@@ -183,6 +187,7 @@ import type {
|
|
|
183
187
|
TaxonomyBlockEnvelope,
|
|
184
188
|
TransitionFilingStatusRequest,
|
|
185
189
|
UpdateAgentRequest,
|
|
190
|
+
UpdateDimensionRequest,
|
|
186
191
|
UpdateEntityRequest,
|
|
187
192
|
UpdateEventBlockRequest,
|
|
188
193
|
UpdateEventHandlerRequest,
|
|
@@ -195,7 +200,10 @@ import type {
|
|
|
195
200
|
import type { TokenProvider } from './graphql/client'
|
|
196
201
|
import { GraphQLClientCache, toGraphQLError } from './graphql/client'
|
|
197
202
|
import {
|
|
203
|
+
AgedPayablesDocument,
|
|
204
|
+
AgedReceivablesDocument,
|
|
198
205
|
ClassificationStatsDocument,
|
|
206
|
+
DischargeCandidatesDocument,
|
|
199
207
|
FlowCandidatesDocument,
|
|
200
208
|
GetInformationBlockDocument,
|
|
201
209
|
GetInformationBlockWindowedDocument,
|
|
@@ -228,6 +236,7 @@ import {
|
|
|
228
236
|
ListLedgerBankAccountsDocument,
|
|
229
237
|
ListLedgerBankAccountsQuery,
|
|
230
238
|
ListLedgerBlockedSourceGraphsDocument,
|
|
239
|
+
ListLedgerDimensionsDocument,
|
|
231
240
|
ListLedgerElementsDocument,
|
|
232
241
|
ListLedgerEntitiesDocument,
|
|
233
242
|
ListLedgerEventBlocksDocument,
|
|
@@ -241,7 +250,10 @@ import {
|
|
|
241
250
|
ListLedgerTransactionsDocument,
|
|
242
251
|
ListLedgerUnmappedElementsDocument,
|
|
243
252
|
MappingCandidatesDocument,
|
|
253
|
+
OpenItemsForAgentDocument,
|
|
254
|
+
type AgedReceivablesQuery,
|
|
244
255
|
type ClassificationStatsQuery,
|
|
256
|
+
type DischargeCandidatesQuery,
|
|
245
257
|
type FlowCandidatesQuery,
|
|
246
258
|
type GetInformationBlockQuery,
|
|
247
259
|
type GetLedgerAccountRollupsQuery,
|
|
@@ -270,6 +282,7 @@ import {
|
|
|
270
282
|
type ListLedgerAccountsQuery,
|
|
271
283
|
type ListLedgerAgentsQuery,
|
|
272
284
|
type ListLedgerBlockedSourceGraphsQuery,
|
|
285
|
+
type ListLedgerDimensionsQuery,
|
|
273
286
|
type ListLedgerElementsQuery,
|
|
274
287
|
type ListLedgerEntitiesQuery,
|
|
275
288
|
type ListLedgerEventBlocksQuery,
|
|
@@ -283,6 +296,7 @@ import {
|
|
|
283
296
|
type ListLedgerTransactionsQuery,
|
|
284
297
|
type ListLedgerUnmappedElementsQuery,
|
|
285
298
|
type MappingCandidatesQuery,
|
|
299
|
+
type OpenItemsForAgentQuery,
|
|
286
300
|
type ReportDownloadFormat,
|
|
287
301
|
type ReportLifecycle,
|
|
288
302
|
} from './graphql/generated/graphql'
|
|
@@ -344,6 +358,19 @@ export type LedgerClassificationStats = NonNullable<ClassificationStatsQuery['cl
|
|
|
344
358
|
export type LedgerClassificationSourceStats = LedgerClassificationStats['bySource'][number]
|
|
345
359
|
export type LedgerUnmappedElement = ListLedgerUnmappedElementsQuery['unmappedElements'][number]
|
|
346
360
|
|
|
361
|
+
export type LedgerAgedBalances = AgedReceivablesQuery['agedReceivables']
|
|
362
|
+
export type LedgerAgingBuckets = LedgerAgedBalances['buckets']
|
|
363
|
+
export type LedgerAgedAgentRow = LedgerAgedBalances['agents'][number]
|
|
364
|
+
export type LedgerControlTieOut = LedgerAgedBalances['tieOuts'][number]
|
|
365
|
+
export type LedgerIntercompanyPair = LedgerAgedBalances['pairs'][number]
|
|
366
|
+
export type LedgerOpenItem = OpenItemsForAgentQuery['openItemsForAgent'][number]
|
|
367
|
+
export type LedgerDischargeCandidates = NonNullable<DischargeCandidatesQuery['dischargeCandidates']>
|
|
368
|
+
|
|
369
|
+
export type LedgerDimensionList = NonNullable<ListLedgerDimensionsQuery['dimensions']>
|
|
370
|
+
export type LedgerDimension = LedgerDimensionList['dimensions'][number]
|
|
371
|
+
/** `receivables` (invoices) or `payables` (bills). */
|
|
372
|
+
export type LedgerOpenItemKind = 'receivables' | 'payables'
|
|
373
|
+
|
|
347
374
|
export type LedgerStructureList = NonNullable<ListLedgerStructuresQuery['structures']>
|
|
348
375
|
export type LedgerStructure = LedgerStructureList['structures'][number]
|
|
349
376
|
|
|
@@ -1274,12 +1301,171 @@ export class LedgerClient {
|
|
|
1274
1301
|
)
|
|
1275
1302
|
}
|
|
1276
1303
|
|
|
1304
|
+
// ── Receivables and payables ────────────────────────────────────────
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* Receivables or payables aged at a date (`options.asOf`, `YYYY-MM-DD`,
|
|
1308
|
+
* default today on the server): totals by days past due, a row per
|
|
1309
|
+
* counterparty, and each entity's open items tied out to its receivables
|
|
1310
|
+
* or payables account (`differenceCents`, never plugged). `options.scope`
|
|
1311
|
+
* is `entity` (one entity's books, `options.entityId` default the group
|
|
1312
|
+
* parent) or `group` (the parent and its members consolidated in full,
|
|
1313
|
+
* with what they owe each other in `intercompany` and `pairs`). An item
|
|
1314
|
+
* with no due date of its own is due on receipt and counted in
|
|
1315
|
+
* `defaultedDueDateCount`.
|
|
1316
|
+
*/
|
|
1317
|
+
async getAgedBalances(
|
|
1318
|
+
graphId: string,
|
|
1319
|
+
kind: LedgerOpenItemKind,
|
|
1320
|
+
options?: {
|
|
1321
|
+
asOf?: string | null
|
|
1322
|
+
entityId?: string | null
|
|
1323
|
+
scope?: 'entity' | 'group'
|
|
1324
|
+
}
|
|
1325
|
+
): Promise<LedgerAgedBalances> {
|
|
1326
|
+
const variables = {
|
|
1327
|
+
asOf: options?.asOf ?? null,
|
|
1328
|
+
entityId: options?.entityId ?? null,
|
|
1329
|
+
scope: options?.scope ?? 'entity',
|
|
1330
|
+
}
|
|
1331
|
+
if (kind === 'receivables') {
|
|
1332
|
+
return this.gqlQuery(
|
|
1333
|
+
graphId,
|
|
1334
|
+
AgedReceivablesDocument,
|
|
1335
|
+
variables,
|
|
1336
|
+
'Aged receivables',
|
|
1337
|
+
(data) => data.agedReceivables
|
|
1338
|
+
)
|
|
1339
|
+
}
|
|
1340
|
+
return this.gqlQuery(
|
|
1341
|
+
graphId,
|
|
1342
|
+
AgedPayablesDocument,
|
|
1343
|
+
variables,
|
|
1344
|
+
'Aged payables',
|
|
1345
|
+
(data) => data.agedPayables
|
|
1346
|
+
)
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* One counterparty's open invoices (`receivables`) or bills (`payables`)
|
|
1351
|
+
* at a date, oldest first, each with its due date, days past due and
|
|
1352
|
+
* bucket — the drill from an aged row into its documents.
|
|
1353
|
+
*/
|
|
1354
|
+
async getOpenItemsForAgent(
|
|
1355
|
+
graphId: string,
|
|
1356
|
+
agentId: string,
|
|
1357
|
+
kind: LedgerOpenItemKind,
|
|
1358
|
+
options?: { asOf?: string | null; entityId?: string | null }
|
|
1359
|
+
): Promise<LedgerOpenItem[]> {
|
|
1360
|
+
return this.gqlQuery(
|
|
1361
|
+
graphId,
|
|
1362
|
+
OpenItemsForAgentDocument,
|
|
1363
|
+
{
|
|
1364
|
+
agentId,
|
|
1365
|
+
kind,
|
|
1366
|
+
asOf: options?.asOf ?? null,
|
|
1367
|
+
entityId: options?.entityId ?? null,
|
|
1368
|
+
},
|
|
1369
|
+
'Open items for agent',
|
|
1370
|
+
(data) => data.openItemsForAgent
|
|
1371
|
+
)
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* The open invoices or bills a payment or bank line may settle: its own
|
|
1376
|
+
* entity's and counterparty's, open at its date, an exact amount match
|
|
1377
|
+
* first, then the oldest due date. `classifiedToControl` says the line
|
|
1378
|
+
* went to a receivables or payables account — when the inbox offers the
|
|
1379
|
+
* pick. Record the choice with `discharge_allocations` on
|
|
1380
|
+
* `updateEventBlock`; nothing settles without one. Null when there is no
|
|
1381
|
+
* such event.
|
|
1382
|
+
*/
|
|
1383
|
+
async getDischargeCandidates(
|
|
1384
|
+
graphId: string,
|
|
1385
|
+
eventId: string
|
|
1386
|
+
): Promise<LedgerDischargeCandidates | null> {
|
|
1387
|
+
return this.gqlQuery(
|
|
1388
|
+
graphId,
|
|
1389
|
+
DischargeCandidatesDocument,
|
|
1390
|
+
{ eventId },
|
|
1391
|
+
'Discharge candidates',
|
|
1392
|
+
(data) => data.dischargeCandidates
|
|
1393
|
+
)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// ── Management dimensions ─────────────────────────────────────────
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* The graph's management dimension members — departments, classes,
|
|
1400
|
+
* locations, projects — by axis then name, each with how many lines carry
|
|
1401
|
+
* it. `types` lists the axes the graph has members on. Retired members
|
|
1402
|
+
* are left out unless `options.includeInactive`.
|
|
1403
|
+
*/
|
|
1404
|
+
async getDimensions(
|
|
1405
|
+
graphId: string,
|
|
1406
|
+
options?: { dimensionType?: string | null; includeInactive?: boolean }
|
|
1407
|
+
): Promise<LedgerDimensionList | null> {
|
|
1408
|
+
return this.gqlQuery(
|
|
1409
|
+
graphId,
|
|
1410
|
+
ListLedgerDimensionsDocument,
|
|
1411
|
+
{
|
|
1412
|
+
dimensionType: options?.dimensionType ?? null,
|
|
1413
|
+
includeInactive: options?.includeInactive ?? false,
|
|
1414
|
+
},
|
|
1415
|
+
'List dimensions',
|
|
1416
|
+
(data) => data.dimensions
|
|
1417
|
+
)
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Add a member to a management dimension (`dimension_type`: department,
|
|
1422
|
+
* class, location, project, or an axis of your own). `value`, the
|
|
1423
|
+
* member's key within its axis, defaults to a slug of the name; a
|
|
1424
|
+
* duplicate key is refused (409).
|
|
1425
|
+
*/
|
|
1426
|
+
async createDimension(
|
|
1427
|
+
graphId: string,
|
|
1428
|
+
body: CreateDimensionRequest,
|
|
1429
|
+
idempotencyKey?: string
|
|
1430
|
+
): Promise<DimensionResponse> {
|
|
1431
|
+
const envelope = await this.callOperation('Create dimension', (o) =>
|
|
1432
|
+
createDimension({
|
|
1433
|
+
...withIdempotencyKey(o, idempotencyKey),
|
|
1434
|
+
path: { graph_id: graphId },
|
|
1435
|
+
body,
|
|
1436
|
+
})
|
|
1437
|
+
)
|
|
1438
|
+
return this.requireResult('Create dimension', envelope.result)
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Rename a member, or retire it with `is_active: false`: it stays on the
|
|
1443
|
+
* lines that carry it and goes on no new ones. A member synced from
|
|
1444
|
+
* QuickBooks keeps QuickBooks's name.
|
|
1445
|
+
*/
|
|
1446
|
+
async updateDimension(graphId: string, body: UpdateDimensionRequest): Promise<DimensionResponse> {
|
|
1447
|
+
const envelope = await this.callOperation('Update dimension', (o) =>
|
|
1448
|
+
updateDimension({ ...o, path: { graph_id: graphId }, body })
|
|
1449
|
+
)
|
|
1450
|
+
return this.requireResult('Update dimension', envelope.result)
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1277
1453
|
// ── Trial Balance ──────────────────────────────────────────────────
|
|
1278
1454
|
|
|
1279
|
-
/**
|
|
1455
|
+
/**
|
|
1456
|
+
* Trial balance by raw CoA account. `options.dimension` sums one
|
|
1457
|
+
* management dimension member's lines (`memberId: 'unallocated'` for the
|
|
1458
|
+
* lines no member of the axis tags); such a balance need not foot, and
|
|
1459
|
+
* says so in `sliced`.
|
|
1460
|
+
*/
|
|
1280
1461
|
async getTrialBalance(
|
|
1281
1462
|
graphId: string,
|
|
1282
|
-
options?: {
|
|
1463
|
+
options?: {
|
|
1464
|
+
startDate?: string
|
|
1465
|
+
endDate?: string
|
|
1466
|
+
entityId?: string | null
|
|
1467
|
+
dimension?: { type: string; memberId: string } | null
|
|
1468
|
+
}
|
|
1283
1469
|
): Promise<LedgerTrialBalance | null> {
|
|
1284
1470
|
return this.gqlQuery(
|
|
1285
1471
|
graphId,
|
|
@@ -1288,6 +1474,8 @@ export class LedgerClient {
|
|
|
1288
1474
|
startDate: options?.startDate ?? null,
|
|
1289
1475
|
endDate: options?.endDate ?? null,
|
|
1290
1476
|
entityId: options?.entityId ?? null,
|
|
1477
|
+
dimensionType: options?.dimension?.type ?? null,
|
|
1478
|
+
dimensionMemberId: options?.dimension?.memberId ?? null,
|
|
1291
1479
|
},
|
|
1292
1480
|
'Get trial balance',
|
|
1293
1481
|
(data) => data.trialBalance
|