@robosystems/client 2.20.2 → 2.22.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 +60 -2
- package/artifacts/LedgerClient.js +50 -0
- package/artifacts/LedgerClient.ts +127 -0
- package/artifacts/graphql/generated/graphql.d.ts +295 -0
- package/artifacts/graphql/generated/graphql.js +788 -2
- package/artifacts/graphql/generated/graphql.ts +1073 -0
- 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/index.ts +1 -1
- package/package.json +1 -1
- package/sdk/index.d.ts +1 -1
- package/sdk/index.ts +1 -1
- package/sdk/sdk.gen.d.ts +3 -3
- package/sdk/sdk.gen.js +3 -3
- package/sdk/sdk.gen.ts +3 -3
- package/sdk/types.gen.d.ts +92 -91
- package/sdk/types.gen.ts +93 -91
- package/sdk.gen.d.ts +3 -3
- package/sdk.gen.js +3 -3
- package/sdk.gen.ts +3 -3
- package/types.gen.d.ts +92 -91
- package/types.gen.ts +93 -91
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AcceptSuggestionsRequest, AcceptSuggestionsResponse, AllocationOverrideResponse, AssociationResponse, AutoMapElementsOperation, BindTextBlockRequest, BindTextBlockResponse, BlockedSourceGraphResponse, BlockSourceGraphResult, ComputeMetricsRequest, ComputeMetricsResponse, 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, 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';
|
|
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 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,15 @@ 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
|
+
/** `receivables` (invoices) or `payables` (bills). */
|
|
44
|
+
export type LedgerOpenItemKind = 'receivables' | 'payables';
|
|
36
45
|
export type LedgerStructureList = NonNullable<ListLedgerStructuresQuery['structures']>;
|
|
37
46
|
export type LedgerStructure = LedgerStructureList['structures'][number];
|
|
38
47
|
export type LedgerMappingList = NonNullable<ListLedgerMappingsQuery['mappings']>;
|
|
@@ -393,7 +402,21 @@ export interface CreateJournalEntryOptions {
|
|
|
393
402
|
idempotencyKey?: string | null;
|
|
394
403
|
/** The entity whose books the entry goes into. Omitted: the group parent. */
|
|
395
404
|
entityId?: string | null;
|
|
405
|
+
/**
|
|
406
|
+
* A consolidating entry in the group's consolidation entity: what it
|
|
407
|
+
* adjusts. Only that entity's books take one; the consolidation engine
|
|
408
|
+
* counts a tagged entry toward what it already holds, so an elimination
|
|
409
|
+
* posted by hand is not proposed again.
|
|
410
|
+
*/
|
|
411
|
+
adjustmentKind?: AdjustmentKind | null;
|
|
412
|
+
/**
|
|
413
|
+
* The entity whose figures a consolidating entry adjusts. Required with
|
|
414
|
+
* every `adjustmentKind` but `manual`.
|
|
415
|
+
*/
|
|
416
|
+
adjustsEntityId?: string | null;
|
|
396
417
|
}
|
|
418
|
+
/** What a consolidating entry adjusts. */
|
|
419
|
+
export type AdjustmentKind = ConsolidationProposal['adjustment_kind'];
|
|
397
420
|
interface LedgerClientConfig {
|
|
398
421
|
baseUrl: string;
|
|
399
422
|
credentials?: 'include' | 'same-origin' | 'omit';
|
|
@@ -558,6 +581,41 @@ export declare class LedgerClient {
|
|
|
558
581
|
}): Promise<LedgerAgent[]>;
|
|
559
582
|
/** Get agent detail by id. */
|
|
560
583
|
getAgent(graphId: string, agentId: string): Promise<LedgerAgentDetail | null>;
|
|
584
|
+
/**
|
|
585
|
+
* Receivables or payables aged at a date (`options.asOf`, `YYYY-MM-DD`,
|
|
586
|
+
* default today on the server): totals by days past due, a row per
|
|
587
|
+
* counterparty, and each entity's open items tied out to its receivables
|
|
588
|
+
* or payables account (`differenceCents`, never plugged). `options.scope`
|
|
589
|
+
* is `entity` (one entity's books, `options.entityId` default the group
|
|
590
|
+
* parent) or `group` (the parent and its members consolidated in full,
|
|
591
|
+
* with what they owe each other in `intercompany` and `pairs`). An item
|
|
592
|
+
* with no due date of its own is due on receipt and counted in
|
|
593
|
+
* `defaultedDueDateCount`.
|
|
594
|
+
*/
|
|
595
|
+
getAgedBalances(graphId: string, kind: LedgerOpenItemKind, options?: {
|
|
596
|
+
asOf?: string | null;
|
|
597
|
+
entityId?: string | null;
|
|
598
|
+
scope?: 'entity' | 'group';
|
|
599
|
+
}): Promise<LedgerAgedBalances>;
|
|
600
|
+
/**
|
|
601
|
+
* One counterparty's open invoices (`receivables`) or bills (`payables`)
|
|
602
|
+
* at a date, oldest first, each with its due date, days past due and
|
|
603
|
+
* bucket — the drill from an aged row into its documents.
|
|
604
|
+
*/
|
|
605
|
+
getOpenItemsForAgent(graphId: string, agentId: string, kind: LedgerOpenItemKind, options?: {
|
|
606
|
+
asOf?: string | null;
|
|
607
|
+
entityId?: string | null;
|
|
608
|
+
}): Promise<LedgerOpenItem[]>;
|
|
609
|
+
/**
|
|
610
|
+
* The open invoices or bills a payment or bank line may settle: its own
|
|
611
|
+
* entity's and counterparty's, open at its date, an exact amount match
|
|
612
|
+
* first, then the oldest due date. `classifiedToControl` says the line
|
|
613
|
+
* went to a receivables or payables account — when the inbox offers the
|
|
614
|
+
* pick. Record the choice with `discharge_allocations` on
|
|
615
|
+
* `updateEventBlock`; nothing settles without one. Null when there is no
|
|
616
|
+
* such event.
|
|
617
|
+
*/
|
|
618
|
+
getDischargeCandidates(graphId: string, eventId: string): Promise<LedgerDischargeCandidates | null>;
|
|
561
619
|
/** Trial balance by raw CoA account. */
|
|
562
620
|
getTrialBalance(graphId: string, options?: {
|
|
563
621
|
startDate?: string;
|
|
@@ -201,6 +201,54 @@ 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
|
+
}
|
|
204
252
|
// ── Trial Balance ──────────────────────────────────────────────────
|
|
205
253
|
/** Trial balance by raw CoA account. */
|
|
206
254
|
async getTrialBalance(graphId, options) {
|
|
@@ -942,6 +990,8 @@ class LedgerClient {
|
|
|
942
990
|
type: options.type ?? 'standard',
|
|
943
991
|
status: options.status ?? 'draft',
|
|
944
992
|
transaction_id: options.transactionId ?? null,
|
|
993
|
+
...(options.adjustmentKind ? { adjustment_kind: options.adjustmentKind } : {}),
|
|
994
|
+
...(options.adjustsEntityId ? { adjusts_entity_id: options.adjustsEntityId } : {}),
|
|
945
995
|
},
|
|
946
996
|
};
|
|
947
997
|
const envelope = await this.callOperation('Create journal entry', (o) => (0, sdk_gen_1.createEventBlock)({
|
|
@@ -108,6 +108,7 @@ import type {
|
|
|
108
108
|
ClosePeriodOperation,
|
|
109
109
|
ComputeMetricsRequest,
|
|
110
110
|
ComputeMetricsResponse,
|
|
111
|
+
ConsolidationProposal,
|
|
111
112
|
ConsolidationWorksheetRequest,
|
|
112
113
|
ConsolidationWorksheetResponse,
|
|
113
114
|
CreateAgentRequest,
|
|
@@ -194,7 +195,10 @@ import type {
|
|
|
194
195
|
import type { TokenProvider } from './graphql/client'
|
|
195
196
|
import { GraphQLClientCache, toGraphQLError } from './graphql/client'
|
|
196
197
|
import {
|
|
198
|
+
AgedPayablesDocument,
|
|
199
|
+
AgedReceivablesDocument,
|
|
197
200
|
ClassificationStatsDocument,
|
|
201
|
+
DischargeCandidatesDocument,
|
|
198
202
|
FlowCandidatesDocument,
|
|
199
203
|
GetInformationBlockDocument,
|
|
200
204
|
GetInformationBlockWindowedDocument,
|
|
@@ -240,7 +244,10 @@ import {
|
|
|
240
244
|
ListLedgerTransactionsDocument,
|
|
241
245
|
ListLedgerUnmappedElementsDocument,
|
|
242
246
|
MappingCandidatesDocument,
|
|
247
|
+
OpenItemsForAgentDocument,
|
|
248
|
+
type AgedReceivablesQuery,
|
|
243
249
|
type ClassificationStatsQuery,
|
|
250
|
+
type DischargeCandidatesQuery,
|
|
244
251
|
type FlowCandidatesQuery,
|
|
245
252
|
type GetInformationBlockQuery,
|
|
246
253
|
type GetLedgerAccountRollupsQuery,
|
|
@@ -282,6 +289,7 @@ import {
|
|
|
282
289
|
type ListLedgerTransactionsQuery,
|
|
283
290
|
type ListLedgerUnmappedElementsQuery,
|
|
284
291
|
type MappingCandidatesQuery,
|
|
292
|
+
type OpenItemsForAgentQuery,
|
|
285
293
|
type ReportDownloadFormat,
|
|
286
294
|
type ReportLifecycle,
|
|
287
295
|
} from './graphql/generated/graphql'
|
|
@@ -343,6 +351,16 @@ export type LedgerClassificationStats = NonNullable<ClassificationStatsQuery['cl
|
|
|
343
351
|
export type LedgerClassificationSourceStats = LedgerClassificationStats['bySource'][number]
|
|
344
352
|
export type LedgerUnmappedElement = ListLedgerUnmappedElementsQuery['unmappedElements'][number]
|
|
345
353
|
|
|
354
|
+
export type LedgerAgedBalances = AgedReceivablesQuery['agedReceivables']
|
|
355
|
+
export type LedgerAgingBuckets = LedgerAgedBalances['buckets']
|
|
356
|
+
export type LedgerAgedAgentRow = LedgerAgedBalances['agents'][number]
|
|
357
|
+
export type LedgerControlTieOut = LedgerAgedBalances['tieOuts'][number]
|
|
358
|
+
export type LedgerIntercompanyPair = LedgerAgedBalances['pairs'][number]
|
|
359
|
+
export type LedgerOpenItem = OpenItemsForAgentQuery['openItemsForAgent'][number]
|
|
360
|
+
export type LedgerDischargeCandidates = NonNullable<DischargeCandidatesQuery['dischargeCandidates']>
|
|
361
|
+
/** `receivables` (invoices) or `payables` (bills). */
|
|
362
|
+
export type LedgerOpenItemKind = 'receivables' | 'payables'
|
|
363
|
+
|
|
346
364
|
export type LedgerStructureList = NonNullable<ListLedgerStructuresQuery['structures']>
|
|
347
365
|
export type LedgerStructure = LedgerStructureList['structures'][number]
|
|
348
366
|
|
|
@@ -847,8 +865,23 @@ export interface CreateJournalEntryOptions {
|
|
|
847
865
|
idempotencyKey?: string | null
|
|
848
866
|
/** The entity whose books the entry goes into. Omitted: the group parent. */
|
|
849
867
|
entityId?: string | null
|
|
868
|
+
/**
|
|
869
|
+
* A consolidating entry in the group's consolidation entity: what it
|
|
870
|
+
* adjusts. Only that entity's books take one; the consolidation engine
|
|
871
|
+
* counts a tagged entry toward what it already holds, so an elimination
|
|
872
|
+
* posted by hand is not proposed again.
|
|
873
|
+
*/
|
|
874
|
+
adjustmentKind?: AdjustmentKind | null
|
|
875
|
+
/**
|
|
876
|
+
* The entity whose figures a consolidating entry adjusts. Required with
|
|
877
|
+
* every `adjustmentKind` but `manual`.
|
|
878
|
+
*/
|
|
879
|
+
adjustsEntityId?: string | null
|
|
850
880
|
}
|
|
851
881
|
|
|
882
|
+
/** What a consolidating entry adjusts. */
|
|
883
|
+
export type AdjustmentKind = ConsolidationProposal['adjustment_kind']
|
|
884
|
+
|
|
852
885
|
// ── Client ──────────────────────────────────────────────────────────────
|
|
853
886
|
|
|
854
887
|
interface LedgerClientConfig {
|
|
@@ -1258,6 +1291,98 @@ export class LedgerClient {
|
|
|
1258
1291
|
)
|
|
1259
1292
|
}
|
|
1260
1293
|
|
|
1294
|
+
// ── Receivables and payables ────────────────────────────────────────
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Receivables or payables aged at a date (`options.asOf`, `YYYY-MM-DD`,
|
|
1298
|
+
* default today on the server): totals by days past due, a row per
|
|
1299
|
+
* counterparty, and each entity's open items tied out to its receivables
|
|
1300
|
+
* or payables account (`differenceCents`, never plugged). `options.scope`
|
|
1301
|
+
* is `entity` (one entity's books, `options.entityId` default the group
|
|
1302
|
+
* parent) or `group` (the parent and its members consolidated in full,
|
|
1303
|
+
* with what they owe each other in `intercompany` and `pairs`). An item
|
|
1304
|
+
* with no due date of its own is due on receipt and counted in
|
|
1305
|
+
* `defaultedDueDateCount`.
|
|
1306
|
+
*/
|
|
1307
|
+
async getAgedBalances(
|
|
1308
|
+
graphId: string,
|
|
1309
|
+
kind: LedgerOpenItemKind,
|
|
1310
|
+
options?: {
|
|
1311
|
+
asOf?: string | null
|
|
1312
|
+
entityId?: string | null
|
|
1313
|
+
scope?: 'entity' | 'group'
|
|
1314
|
+
}
|
|
1315
|
+
): Promise<LedgerAgedBalances> {
|
|
1316
|
+
const variables = {
|
|
1317
|
+
asOf: options?.asOf ?? null,
|
|
1318
|
+
entityId: options?.entityId ?? null,
|
|
1319
|
+
scope: options?.scope ?? 'entity',
|
|
1320
|
+
}
|
|
1321
|
+
if (kind === 'receivables') {
|
|
1322
|
+
return this.gqlQuery(
|
|
1323
|
+
graphId,
|
|
1324
|
+
AgedReceivablesDocument,
|
|
1325
|
+
variables,
|
|
1326
|
+
'Aged receivables',
|
|
1327
|
+
(data) => data.agedReceivables
|
|
1328
|
+
)
|
|
1329
|
+
}
|
|
1330
|
+
return this.gqlQuery(
|
|
1331
|
+
graphId,
|
|
1332
|
+
AgedPayablesDocument,
|
|
1333
|
+
variables,
|
|
1334
|
+
'Aged payables',
|
|
1335
|
+
(data) => data.agedPayables
|
|
1336
|
+
)
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* One counterparty's open invoices (`receivables`) or bills (`payables`)
|
|
1341
|
+
* at a date, oldest first, each with its due date, days past due and
|
|
1342
|
+
* bucket — the drill from an aged row into its documents.
|
|
1343
|
+
*/
|
|
1344
|
+
async getOpenItemsForAgent(
|
|
1345
|
+
graphId: string,
|
|
1346
|
+
agentId: string,
|
|
1347
|
+
kind: LedgerOpenItemKind,
|
|
1348
|
+
options?: { asOf?: string | null; entityId?: string | null }
|
|
1349
|
+
): Promise<LedgerOpenItem[]> {
|
|
1350
|
+
return this.gqlQuery(
|
|
1351
|
+
graphId,
|
|
1352
|
+
OpenItemsForAgentDocument,
|
|
1353
|
+
{
|
|
1354
|
+
agentId,
|
|
1355
|
+
kind,
|
|
1356
|
+
asOf: options?.asOf ?? null,
|
|
1357
|
+
entityId: options?.entityId ?? null,
|
|
1358
|
+
},
|
|
1359
|
+
'Open items for agent',
|
|
1360
|
+
(data) => data.openItemsForAgent
|
|
1361
|
+
)
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* The open invoices or bills a payment or bank line may settle: its own
|
|
1366
|
+
* entity's and counterparty's, open at its date, an exact amount match
|
|
1367
|
+
* first, then the oldest due date. `classifiedToControl` says the line
|
|
1368
|
+
* went to a receivables or payables account — when the inbox offers the
|
|
1369
|
+
* pick. Record the choice with `discharge_allocations` on
|
|
1370
|
+
* `updateEventBlock`; nothing settles without one. Null when there is no
|
|
1371
|
+
* such event.
|
|
1372
|
+
*/
|
|
1373
|
+
async getDischargeCandidates(
|
|
1374
|
+
graphId: string,
|
|
1375
|
+
eventId: string
|
|
1376
|
+
): Promise<LedgerDischargeCandidates | null> {
|
|
1377
|
+
return this.gqlQuery(
|
|
1378
|
+
graphId,
|
|
1379
|
+
DischargeCandidatesDocument,
|
|
1380
|
+
{ eventId },
|
|
1381
|
+
'Discharge candidates',
|
|
1382
|
+
(data) => data.dischargeCandidates
|
|
1383
|
+
)
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1261
1386
|
// ── Trial Balance ──────────────────────────────────────────────────
|
|
1262
1387
|
|
|
1263
1388
|
/** Trial balance by raw CoA account. */
|
|
@@ -2483,6 +2608,8 @@ export class LedgerClient {
|
|
|
2483
2608
|
type: options.type ?? 'standard',
|
|
2484
2609
|
status: options.status ?? 'draft',
|
|
2485
2610
|
transaction_id: options.transactionId ?? null,
|
|
2611
|
+
...(options.adjustmentKind ? { adjustment_kind: options.adjustmentKind } : {}),
|
|
2612
|
+
...(options.adjustsEntityId ? { adjusts_entity_id: options.adjustsEntityId } : {}),
|
|
2486
2613
|
},
|
|
2487
2614
|
}
|
|
2488
2615
|
const envelope = await this.callOperation('Create journal entry', (o) =>
|
|
@@ -338,6 +338,294 @@ export type ListLedgerAccountsQuery = {
|
|
|
338
338
|
};
|
|
339
339
|
} | null;
|
|
340
340
|
};
|
|
341
|
+
export type OpenItemFieldsFragment = {
|
|
342
|
+
eventId: string;
|
|
343
|
+
entityId: string;
|
|
344
|
+
agentId: string | null;
|
|
345
|
+
occurredOn: string;
|
|
346
|
+
documentNumber: string | null;
|
|
347
|
+
description: string | null;
|
|
348
|
+
originalCents: number;
|
|
349
|
+
settledCents: number;
|
|
350
|
+
openCents: number;
|
|
351
|
+
currency: string;
|
|
352
|
+
dueDate: string;
|
|
353
|
+
dueDateBasis: string;
|
|
354
|
+
daysPastDue: number;
|
|
355
|
+
bucket: string;
|
|
356
|
+
};
|
|
357
|
+
export type AgedBalancesFieldsFragment = {
|
|
358
|
+
kind: string;
|
|
359
|
+
asOf: string;
|
|
360
|
+
scope: string;
|
|
361
|
+
entityId: string | null;
|
|
362
|
+
memberEntityIds: Array<string>;
|
|
363
|
+
defaultedDueDateCount: number;
|
|
364
|
+
buckets: {
|
|
365
|
+
currentCents: number;
|
|
366
|
+
oneToThirtyCents: number;
|
|
367
|
+
thirtyOneToSixtyCents: number;
|
|
368
|
+
sixtyOneToNinetyCents: number;
|
|
369
|
+
overNinetyCents: number;
|
|
370
|
+
unappliedCreditCents: number;
|
|
371
|
+
totalCents: number;
|
|
372
|
+
};
|
|
373
|
+
agents: Array<{
|
|
374
|
+
agentId: string | null;
|
|
375
|
+
agentName: string | null;
|
|
376
|
+
openItemCount: number;
|
|
377
|
+
oldestDueDate: string | null;
|
|
378
|
+
buckets: {
|
|
379
|
+
currentCents: number;
|
|
380
|
+
oneToThirtyCents: number;
|
|
381
|
+
thirtyOneToSixtyCents: number;
|
|
382
|
+
sixtyOneToNinetyCents: number;
|
|
383
|
+
overNinetyCents: number;
|
|
384
|
+
unappliedCreditCents: number;
|
|
385
|
+
totalCents: number;
|
|
386
|
+
};
|
|
387
|
+
}>;
|
|
388
|
+
intercompany: Array<{
|
|
389
|
+
eventId: string;
|
|
390
|
+
entityId: string;
|
|
391
|
+
agentId: string | null;
|
|
392
|
+
occurredOn: string;
|
|
393
|
+
documentNumber: string | null;
|
|
394
|
+
description: string | null;
|
|
395
|
+
originalCents: number;
|
|
396
|
+
settledCents: number;
|
|
397
|
+
openCents: number;
|
|
398
|
+
currency: string;
|
|
399
|
+
dueDate: string;
|
|
400
|
+
dueDateBasis: string;
|
|
401
|
+
daysPastDue: number;
|
|
402
|
+
bucket: string;
|
|
403
|
+
}>;
|
|
404
|
+
pairs: Array<{
|
|
405
|
+
creditorEntityId: string;
|
|
406
|
+
debtorEntityId: string;
|
|
407
|
+
receivableCents: number;
|
|
408
|
+
payableCents: number;
|
|
409
|
+
differenceCents: number;
|
|
410
|
+
}>;
|
|
411
|
+
tieOuts: Array<{
|
|
412
|
+
entityId: string;
|
|
413
|
+
controlBalanceCents: number | null;
|
|
414
|
+
openItemsCents: number;
|
|
415
|
+
differenceCents: number | null;
|
|
416
|
+
accounts: Array<{
|
|
417
|
+
elementId: string;
|
|
418
|
+
code: string | null;
|
|
419
|
+
name: string;
|
|
420
|
+
}>;
|
|
421
|
+
}>;
|
|
422
|
+
};
|
|
423
|
+
export type AgingBucketsFieldsFragment = {
|
|
424
|
+
currentCents: number;
|
|
425
|
+
oneToThirtyCents: number;
|
|
426
|
+
thirtyOneToSixtyCents: number;
|
|
427
|
+
sixtyOneToNinetyCents: number;
|
|
428
|
+
overNinetyCents: number;
|
|
429
|
+
unappliedCreditCents: number;
|
|
430
|
+
totalCents: number;
|
|
431
|
+
};
|
|
432
|
+
export type AgedReceivablesQueryVariables = Exact<{
|
|
433
|
+
asOf: string | null | undefined;
|
|
434
|
+
entityId: string | null | undefined;
|
|
435
|
+
scope?: string;
|
|
436
|
+
}>;
|
|
437
|
+
export type AgedReceivablesQuery = {
|
|
438
|
+
agedReceivables: {
|
|
439
|
+
kind: string;
|
|
440
|
+
asOf: string;
|
|
441
|
+
scope: string;
|
|
442
|
+
entityId: string | null;
|
|
443
|
+
memberEntityIds: Array<string>;
|
|
444
|
+
defaultedDueDateCount: number;
|
|
445
|
+
buckets: {
|
|
446
|
+
currentCents: number;
|
|
447
|
+
oneToThirtyCents: number;
|
|
448
|
+
thirtyOneToSixtyCents: number;
|
|
449
|
+
sixtyOneToNinetyCents: number;
|
|
450
|
+
overNinetyCents: number;
|
|
451
|
+
unappliedCreditCents: number;
|
|
452
|
+
totalCents: number;
|
|
453
|
+
};
|
|
454
|
+
agents: Array<{
|
|
455
|
+
agentId: string | null;
|
|
456
|
+
agentName: string | null;
|
|
457
|
+
openItemCount: number;
|
|
458
|
+
oldestDueDate: string | null;
|
|
459
|
+
buckets: {
|
|
460
|
+
currentCents: number;
|
|
461
|
+
oneToThirtyCents: number;
|
|
462
|
+
thirtyOneToSixtyCents: number;
|
|
463
|
+
sixtyOneToNinetyCents: number;
|
|
464
|
+
overNinetyCents: number;
|
|
465
|
+
unappliedCreditCents: number;
|
|
466
|
+
totalCents: number;
|
|
467
|
+
};
|
|
468
|
+
}>;
|
|
469
|
+
intercompany: Array<{
|
|
470
|
+
eventId: string;
|
|
471
|
+
entityId: string;
|
|
472
|
+
agentId: string | null;
|
|
473
|
+
occurredOn: string;
|
|
474
|
+
documentNumber: string | null;
|
|
475
|
+
description: string | null;
|
|
476
|
+
originalCents: number;
|
|
477
|
+
settledCents: number;
|
|
478
|
+
openCents: number;
|
|
479
|
+
currency: string;
|
|
480
|
+
dueDate: string;
|
|
481
|
+
dueDateBasis: string;
|
|
482
|
+
daysPastDue: number;
|
|
483
|
+
bucket: string;
|
|
484
|
+
}>;
|
|
485
|
+
pairs: Array<{
|
|
486
|
+
creditorEntityId: string;
|
|
487
|
+
debtorEntityId: string;
|
|
488
|
+
receivableCents: number;
|
|
489
|
+
payableCents: number;
|
|
490
|
+
differenceCents: number;
|
|
491
|
+
}>;
|
|
492
|
+
tieOuts: Array<{
|
|
493
|
+
entityId: string;
|
|
494
|
+
controlBalanceCents: number | null;
|
|
495
|
+
openItemsCents: number;
|
|
496
|
+
differenceCents: number | null;
|
|
497
|
+
accounts: Array<{
|
|
498
|
+
elementId: string;
|
|
499
|
+
code: string | null;
|
|
500
|
+
name: string;
|
|
501
|
+
}>;
|
|
502
|
+
}>;
|
|
503
|
+
};
|
|
504
|
+
};
|
|
505
|
+
export type AgedPayablesQueryVariables = Exact<{
|
|
506
|
+
asOf: string | null | undefined;
|
|
507
|
+
entityId: string | null | undefined;
|
|
508
|
+
scope?: string;
|
|
509
|
+
}>;
|
|
510
|
+
export type AgedPayablesQuery = {
|
|
511
|
+
agedPayables: {
|
|
512
|
+
kind: string;
|
|
513
|
+
asOf: string;
|
|
514
|
+
scope: string;
|
|
515
|
+
entityId: string | null;
|
|
516
|
+
memberEntityIds: Array<string>;
|
|
517
|
+
defaultedDueDateCount: number;
|
|
518
|
+
buckets: {
|
|
519
|
+
currentCents: number;
|
|
520
|
+
oneToThirtyCents: number;
|
|
521
|
+
thirtyOneToSixtyCents: number;
|
|
522
|
+
sixtyOneToNinetyCents: number;
|
|
523
|
+
overNinetyCents: number;
|
|
524
|
+
unappliedCreditCents: number;
|
|
525
|
+
totalCents: number;
|
|
526
|
+
};
|
|
527
|
+
agents: Array<{
|
|
528
|
+
agentId: string | null;
|
|
529
|
+
agentName: string | null;
|
|
530
|
+
openItemCount: number;
|
|
531
|
+
oldestDueDate: string | null;
|
|
532
|
+
buckets: {
|
|
533
|
+
currentCents: number;
|
|
534
|
+
oneToThirtyCents: number;
|
|
535
|
+
thirtyOneToSixtyCents: number;
|
|
536
|
+
sixtyOneToNinetyCents: number;
|
|
537
|
+
overNinetyCents: number;
|
|
538
|
+
unappliedCreditCents: number;
|
|
539
|
+
totalCents: number;
|
|
540
|
+
};
|
|
541
|
+
}>;
|
|
542
|
+
intercompany: Array<{
|
|
543
|
+
eventId: string;
|
|
544
|
+
entityId: string;
|
|
545
|
+
agentId: string | null;
|
|
546
|
+
occurredOn: string;
|
|
547
|
+
documentNumber: string | null;
|
|
548
|
+
description: string | null;
|
|
549
|
+
originalCents: number;
|
|
550
|
+
settledCents: number;
|
|
551
|
+
openCents: number;
|
|
552
|
+
currency: string;
|
|
553
|
+
dueDate: string;
|
|
554
|
+
dueDateBasis: string;
|
|
555
|
+
daysPastDue: number;
|
|
556
|
+
bucket: string;
|
|
557
|
+
}>;
|
|
558
|
+
pairs: Array<{
|
|
559
|
+
creditorEntityId: string;
|
|
560
|
+
debtorEntityId: string;
|
|
561
|
+
receivableCents: number;
|
|
562
|
+
payableCents: number;
|
|
563
|
+
differenceCents: number;
|
|
564
|
+
}>;
|
|
565
|
+
tieOuts: Array<{
|
|
566
|
+
entityId: string;
|
|
567
|
+
controlBalanceCents: number | null;
|
|
568
|
+
openItemsCents: number;
|
|
569
|
+
differenceCents: number | null;
|
|
570
|
+
accounts: Array<{
|
|
571
|
+
elementId: string;
|
|
572
|
+
code: string | null;
|
|
573
|
+
name: string;
|
|
574
|
+
}>;
|
|
575
|
+
}>;
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
export type OpenItemsForAgentQueryVariables = Exact<{
|
|
579
|
+
agentId: string;
|
|
580
|
+
kind: string;
|
|
581
|
+
asOf: string | null | undefined;
|
|
582
|
+
entityId: string | null | undefined;
|
|
583
|
+
}>;
|
|
584
|
+
export type OpenItemsForAgentQuery = {
|
|
585
|
+
openItemsForAgent: Array<{
|
|
586
|
+
eventId: string;
|
|
587
|
+
entityId: string;
|
|
588
|
+
agentId: string | null;
|
|
589
|
+
occurredOn: string;
|
|
590
|
+
documentNumber: string | null;
|
|
591
|
+
description: string | null;
|
|
592
|
+
originalCents: number;
|
|
593
|
+
settledCents: number;
|
|
594
|
+
openCents: number;
|
|
595
|
+
currency: string;
|
|
596
|
+
dueDate: string;
|
|
597
|
+
dueDateBasis: string;
|
|
598
|
+
daysPastDue: number;
|
|
599
|
+
bucket: string;
|
|
600
|
+
}>;
|
|
601
|
+
};
|
|
602
|
+
export type DischargeCandidatesQueryVariables = Exact<{
|
|
603
|
+
eventId: string;
|
|
604
|
+
}>;
|
|
605
|
+
export type DischargeCandidatesQuery = {
|
|
606
|
+
dischargeCandidates: {
|
|
607
|
+
eventId: string;
|
|
608
|
+
kind: string | null;
|
|
609
|
+
amountCents: number;
|
|
610
|
+
classifiedToControl: boolean;
|
|
611
|
+
candidates: Array<{
|
|
612
|
+
eventId: string;
|
|
613
|
+
entityId: string;
|
|
614
|
+
agentId: string | null;
|
|
615
|
+
occurredOn: string;
|
|
616
|
+
documentNumber: string | null;
|
|
617
|
+
description: string | null;
|
|
618
|
+
originalCents: number;
|
|
619
|
+
settledCents: number;
|
|
620
|
+
openCents: number;
|
|
621
|
+
currency: string;
|
|
622
|
+
dueDate: string;
|
|
623
|
+
dueDateBasis: string;
|
|
624
|
+
daysPastDue: number;
|
|
625
|
+
bucket: string;
|
|
626
|
+
}>;
|
|
627
|
+
} | null;
|
|
628
|
+
};
|
|
341
629
|
export type GetLedgerAgentQueryVariables = Exact<{
|
|
342
630
|
id: string;
|
|
343
631
|
}>;
|
|
@@ -2377,6 +2665,9 @@ export type GetLibraryTaxonomyQuery = {
|
|
|
2377
2665
|
elementCount: number | null;
|
|
2378
2666
|
} | null;
|
|
2379
2667
|
};
|
|
2668
|
+
export declare const AgingBucketsFieldsFragmentDoc: DocumentNode<AgingBucketsFieldsFragment, unknown>;
|
|
2669
|
+
export declare const OpenItemFieldsFragmentDoc: DocumentNode<OpenItemFieldsFragment, unknown>;
|
|
2670
|
+
export declare const AgedBalancesFieldsFragmentDoc: DocumentNode<AgedBalancesFieldsFragment, unknown>;
|
|
2380
2671
|
export declare const GetInvestorHoldingsDocument: DocumentNode<GetInvestorHoldingsQuery, GetInvestorHoldingsQueryVariables>;
|
|
2381
2672
|
export declare const GetInvestorPortfolioBlockDocument: DocumentNode<GetInvestorPortfolioBlockQuery, GetInvestorPortfolioBlockQueryVariables>;
|
|
2382
2673
|
export declare const ListInvestorPortfoliosDocument: DocumentNode<ListInvestorPortfoliosQuery, ListInvestorPortfoliosQueryVariables>;
|
|
@@ -2387,6 +2678,10 @@ export declare const GetInvestorSecurityDocument: DocumentNode<GetInvestorSecuri
|
|
|
2387
2678
|
export declare const GetLedgerAccountRollupsDocument: DocumentNode<GetLedgerAccountRollupsQuery, GetLedgerAccountRollupsQueryVariables>;
|
|
2388
2679
|
export declare const GetLedgerAccountTreeDocument: DocumentNode<GetLedgerAccountTreeQuery, GetLedgerAccountTreeQueryVariables>;
|
|
2389
2680
|
export declare const ListLedgerAccountsDocument: DocumentNode<ListLedgerAccountsQuery, ListLedgerAccountsQueryVariables>;
|
|
2681
|
+
export declare const AgedReceivablesDocument: DocumentNode<AgedReceivablesQuery, AgedReceivablesQueryVariables>;
|
|
2682
|
+
export declare const AgedPayablesDocument: DocumentNode<AgedPayablesQuery, AgedPayablesQueryVariables>;
|
|
2683
|
+
export declare const OpenItemsForAgentDocument: DocumentNode<OpenItemsForAgentQuery, OpenItemsForAgentQueryVariables>;
|
|
2684
|
+
export declare const DischargeCandidatesDocument: DocumentNode<DischargeCandidatesQuery, DischargeCandidatesQueryVariables>;
|
|
2390
2685
|
export declare const GetLedgerAgentDocument: DocumentNode<GetLedgerAgentQuery, GetLedgerAgentQueryVariables>;
|
|
2391
2686
|
export declare const ListLedgerAgentsDocument: DocumentNode<ListLedgerAgentsQuery, ListLedgerAgentsQueryVariables>;
|
|
2392
2687
|
export declare const ListLedgerBankAccountsDocument: DocumentNode<ListLedgerBankAccountsQuery, ListLedgerBankAccountsQueryVariables>;
|