@robosystems/client 0.2.43 → 0.2.44
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/extensions/LedgerClient.d.ts +88 -0
- package/extensions/LedgerClient.js +143 -0
- package/extensions/LedgerClient.ts +267 -0
- package/extensions/ReportClient.d.ts +14 -6
- package/extensions/ReportClient.js +19 -15
- package/extensions/ReportClient.ts +37 -21
- package/extensions/hooks.d.ts +1 -40
- package/extensions/hooks.js +0 -134
- package/extensions/hooks.ts +0 -156
- package/extensions/index.d.ts +2 -24
- package/extensions/index.js +1 -65
- package/extensions/index.test.ts +4 -38
- package/extensions/index.ts +0 -78
- package/index.ts +2 -2
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +9 -4
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +31 -1
- package/sdk/sdk.gen.js +65 -2
- package/sdk/sdk.gen.ts +64 -1
- package/sdk/types.gen.d.ts +601 -87
- package/sdk/types.gen.ts +640 -88
- package/sdk-extensions/LedgerClient.d.ts +88 -0
- package/sdk-extensions/LedgerClient.js +143 -0
- package/sdk-extensions/LedgerClient.ts +267 -0
- package/sdk-extensions/ReportClient.d.ts +14 -6
- package/sdk-extensions/ReportClient.js +19 -15
- package/sdk-extensions/ReportClient.ts +37 -21
- package/sdk-extensions/hooks.d.ts +1 -40
- package/sdk-extensions/hooks.js +0 -134
- package/sdk-extensions/hooks.ts +0 -156
- package/sdk-extensions/index.d.ts +2 -24
- package/sdk-extensions/index.js +1 -65
- package/sdk-extensions/index.test.ts +4 -38
- package/sdk-extensions/index.ts +0 -78
- package/sdk.gen.d.ts +31 -1
- package/sdk.gen.js +65 -2
- package/sdk.gen.ts +64 -1
- package/types.gen.d.ts +601 -87
- package/types.gen.ts +640 -88
- package/extensions/DocumentClient.d.ts +0 -102
- package/extensions/DocumentClient.js +0 -176
- package/extensions/DocumentClient.ts +0 -297
- package/extensions/FileClient.d.ts +0 -57
- package/extensions/FileClient.js +0 -246
- package/extensions/FileClient.ts +0 -330
- package/extensions/GraphClient.d.ts +0 -91
- package/extensions/GraphClient.js +0 -244
- package/extensions/GraphClient.test.ts +0 -455
- package/extensions/GraphClient.ts +0 -371
- package/extensions/MaterializationClient.d.ts +0 -61
- package/extensions/MaterializationClient.js +0 -157
- package/extensions/MaterializationClient.ts +0 -223
- package/extensions/TableClient.d.ts +0 -38
- package/extensions/TableClient.js +0 -92
- package/extensions/TableClient.ts +0 -132
- package/sdk-extensions/DocumentClient.d.ts +0 -102
- package/sdk-extensions/DocumentClient.js +0 -176
- package/sdk-extensions/DocumentClient.ts +0 -297
- package/sdk-extensions/FileClient.d.ts +0 -57
- package/sdk-extensions/FileClient.js +0 -246
- package/sdk-extensions/FileClient.ts +0 -330
- package/sdk-extensions/GraphClient.d.ts +0 -91
- package/sdk-extensions/GraphClient.js +0 -244
- package/sdk-extensions/GraphClient.test.ts +0 -455
- package/sdk-extensions/GraphClient.ts +0 -371
- package/sdk-extensions/MaterializationClient.d.ts +0 -61
- package/sdk-extensions/MaterializationClient.js +0 -157
- package/sdk-extensions/MaterializationClient.ts +0 -223
- package/sdk-extensions/TableClient.d.ts +0 -38
- package/sdk-extensions/TableClient.js +0 -92
- package/sdk-extensions/TableClient.ts +0 -132
|
@@ -29,6 +29,74 @@ export interface Structure {
|
|
|
29
29
|
name: string;
|
|
30
30
|
structureType: string;
|
|
31
31
|
}
|
|
32
|
+
export interface Schedule {
|
|
33
|
+
structureId: string;
|
|
34
|
+
name: string;
|
|
35
|
+
taxonomyName: string;
|
|
36
|
+
entryTemplate: Record<string, unknown> | null;
|
|
37
|
+
scheduleMetadata: Record<string, unknown> | null;
|
|
38
|
+
totalPeriods: number;
|
|
39
|
+
periodsWithEntries: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ScheduleCreated {
|
|
42
|
+
structureId: string;
|
|
43
|
+
name: string;
|
|
44
|
+
taxonomyId: string;
|
|
45
|
+
totalPeriods: number;
|
|
46
|
+
totalFacts: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ScheduleFact {
|
|
49
|
+
elementId: string;
|
|
50
|
+
elementName: string;
|
|
51
|
+
value: number;
|
|
52
|
+
periodStart: string;
|
|
53
|
+
periodEnd: string;
|
|
54
|
+
}
|
|
55
|
+
export interface PeriodCloseItem {
|
|
56
|
+
structureId: string;
|
|
57
|
+
structureName: string;
|
|
58
|
+
amount: number;
|
|
59
|
+
status: string;
|
|
60
|
+
entryId: string | null;
|
|
61
|
+
}
|
|
62
|
+
export interface PeriodCloseStatus {
|
|
63
|
+
fiscalPeriodStart: string;
|
|
64
|
+
fiscalPeriodEnd: string;
|
|
65
|
+
periodStatus: string;
|
|
66
|
+
schedules: PeriodCloseItem[];
|
|
67
|
+
totalDraft: number;
|
|
68
|
+
totalPosted: number;
|
|
69
|
+
}
|
|
70
|
+
export interface ClosingEntry {
|
|
71
|
+
entryId: string;
|
|
72
|
+
status: string;
|
|
73
|
+
postingDate: string;
|
|
74
|
+
memo: string;
|
|
75
|
+
debitElementId: string;
|
|
76
|
+
creditElementId: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
}
|
|
79
|
+
export interface CreateScheduleOptions {
|
|
80
|
+
name: string;
|
|
81
|
+
elementIds: string[];
|
|
82
|
+
periodStart: string;
|
|
83
|
+
periodEnd: string;
|
|
84
|
+
monthlyAmount: number;
|
|
85
|
+
entryTemplate: {
|
|
86
|
+
debitElementId: string;
|
|
87
|
+
creditElementId: string;
|
|
88
|
+
entryType?: string;
|
|
89
|
+
memoTemplate?: string;
|
|
90
|
+
};
|
|
91
|
+
taxonomyId?: string;
|
|
92
|
+
scheduleMetadata?: {
|
|
93
|
+
method?: string;
|
|
94
|
+
originalAmount?: number;
|
|
95
|
+
residualValue?: number;
|
|
96
|
+
usefulLifeMonths?: number;
|
|
97
|
+
assetElementId?: string;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
32
100
|
export declare class LedgerClient {
|
|
33
101
|
private config;
|
|
34
102
|
constructor(config: {
|
|
@@ -136,4 +204,24 @@ export declare class LedgerClient {
|
|
|
136
204
|
autoMap(graphId: string, mappingId: string): Promise<{
|
|
137
205
|
operationId?: string;
|
|
138
206
|
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Create a schedule with pre-generated monthly facts.
|
|
209
|
+
*/
|
|
210
|
+
createSchedule(graphId: string, options: CreateScheduleOptions): Promise<ScheduleCreated>;
|
|
211
|
+
/**
|
|
212
|
+
* List all schedules for a graph.
|
|
213
|
+
*/
|
|
214
|
+
listSchedules(graphId: string): Promise<Schedule[]>;
|
|
215
|
+
/**
|
|
216
|
+
* Get facts for a schedule, optionally filtered by period.
|
|
217
|
+
*/
|
|
218
|
+
getScheduleFacts(graphId: string, structureId: string, periodStart?: string, periodEnd?: string): Promise<ScheduleFact[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Get close status for all schedules in a fiscal period.
|
|
221
|
+
*/
|
|
222
|
+
getPeriodCloseStatus(graphId: string, periodStart: string, periodEnd: string): Promise<PeriodCloseStatus>;
|
|
223
|
+
/**
|
|
224
|
+
* Create a draft closing entry from a schedule's facts for a period.
|
|
225
|
+
*/
|
|
226
|
+
createClosingEntry(graphId: string, structureId: string, postingDate: string, periodStart: string, periodEnd: string, memo?: string): Promise<ClosingEntry>;
|
|
139
227
|
}
|
|
@@ -316,5 +316,148 @@ class LedgerClient {
|
|
|
316
316
|
operationId: data?.operation_id,
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
+
// ── Schedules ──────────────────────────────────────────────────────
|
|
320
|
+
/**
|
|
321
|
+
* Create a schedule with pre-generated monthly facts.
|
|
322
|
+
*/
|
|
323
|
+
async createSchedule(graphId, options) {
|
|
324
|
+
const body = {
|
|
325
|
+
name: options.name,
|
|
326
|
+
element_ids: options.elementIds,
|
|
327
|
+
period_start: options.periodStart,
|
|
328
|
+
period_end: options.periodEnd,
|
|
329
|
+
monthly_amount: options.monthlyAmount,
|
|
330
|
+
entry_template: {
|
|
331
|
+
debit_element_id: options.entryTemplate.debitElementId,
|
|
332
|
+
credit_element_id: options.entryTemplate.creditElementId,
|
|
333
|
+
entry_type: options.entryTemplate.entryType,
|
|
334
|
+
memo_template: options.entryTemplate.memoTemplate,
|
|
335
|
+
},
|
|
336
|
+
taxonomy_id: options.taxonomyId,
|
|
337
|
+
schedule_metadata: options.scheduleMetadata
|
|
338
|
+
? {
|
|
339
|
+
method: options.scheduleMetadata.method,
|
|
340
|
+
original_amount: options.scheduleMetadata.originalAmount,
|
|
341
|
+
residual_value: options.scheduleMetadata.residualValue,
|
|
342
|
+
useful_life_months: options.scheduleMetadata.usefulLifeMonths,
|
|
343
|
+
asset_element_id: options.scheduleMetadata.assetElementId,
|
|
344
|
+
}
|
|
345
|
+
: undefined,
|
|
346
|
+
};
|
|
347
|
+
const response = await (0, sdk_gen_1.createSchedule)({
|
|
348
|
+
path: { graph_id: graphId },
|
|
349
|
+
body,
|
|
350
|
+
});
|
|
351
|
+
if (response.error) {
|
|
352
|
+
throw new Error(`Create schedule failed: ${JSON.stringify(response.error)}`);
|
|
353
|
+
}
|
|
354
|
+
const data = response.data;
|
|
355
|
+
return {
|
|
356
|
+
structureId: data.structure_id,
|
|
357
|
+
name: data.name,
|
|
358
|
+
taxonomyId: data.taxonomy_id,
|
|
359
|
+
totalPeriods: data.total_periods,
|
|
360
|
+
totalFacts: data.total_facts,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* List all schedules for a graph.
|
|
365
|
+
*/
|
|
366
|
+
async listSchedules(graphId) {
|
|
367
|
+
const response = await (0, sdk_gen_1.listSchedules)({
|
|
368
|
+
path: { graph_id: graphId },
|
|
369
|
+
});
|
|
370
|
+
if (response.error) {
|
|
371
|
+
throw new Error(`List schedules failed: ${JSON.stringify(response.error)}`);
|
|
372
|
+
}
|
|
373
|
+
const data = response.data;
|
|
374
|
+
return (data.schedules ?? []).map((s) => ({
|
|
375
|
+
structureId: s.structure_id,
|
|
376
|
+
name: s.name,
|
|
377
|
+
taxonomyName: s.taxonomy_name,
|
|
378
|
+
entryTemplate: s.entry_template ?? null,
|
|
379
|
+
scheduleMetadata: s.schedule_metadata ?? null,
|
|
380
|
+
totalPeriods: s.total_periods,
|
|
381
|
+
periodsWithEntries: s.periods_with_entries,
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get facts for a schedule, optionally filtered by period.
|
|
386
|
+
*/
|
|
387
|
+
async getScheduleFacts(graphId, structureId, periodStart, periodEnd) {
|
|
388
|
+
const response = await (0, sdk_gen_1.getScheduleFacts)({
|
|
389
|
+
path: { graph_id: graphId, structure_id: structureId },
|
|
390
|
+
query: {
|
|
391
|
+
period_start: periodStart ?? null,
|
|
392
|
+
period_end: periodEnd ?? null,
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
if (response.error) {
|
|
396
|
+
throw new Error(`Get schedule facts failed: ${JSON.stringify(response.error)}`);
|
|
397
|
+
}
|
|
398
|
+
const data = response.data;
|
|
399
|
+
return (data.facts ?? []).map((f) => ({
|
|
400
|
+
elementId: f.element_id,
|
|
401
|
+
elementName: f.element_name,
|
|
402
|
+
value: f.value,
|
|
403
|
+
periodStart: f.period_start,
|
|
404
|
+
periodEnd: f.period_end,
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get close status for all schedules in a fiscal period.
|
|
409
|
+
*/
|
|
410
|
+
async getPeriodCloseStatus(graphId, periodStart, periodEnd) {
|
|
411
|
+
const response = await (0, sdk_gen_1.getPeriodCloseStatus)({
|
|
412
|
+
path: { graph_id: graphId },
|
|
413
|
+
query: { period_start: periodStart, period_end: periodEnd },
|
|
414
|
+
});
|
|
415
|
+
if (response.error) {
|
|
416
|
+
throw new Error(`Get period close status failed: ${JSON.stringify(response.error)}`);
|
|
417
|
+
}
|
|
418
|
+
const data = response.data;
|
|
419
|
+
return {
|
|
420
|
+
fiscalPeriodStart: data.fiscal_period_start,
|
|
421
|
+
fiscalPeriodEnd: data.fiscal_period_end,
|
|
422
|
+
periodStatus: data.period_status,
|
|
423
|
+
schedules: (data.schedules ?? []).map((s) => ({
|
|
424
|
+
structureId: s.structure_id,
|
|
425
|
+
structureName: s.structure_name,
|
|
426
|
+
amount: s.amount,
|
|
427
|
+
status: s.status,
|
|
428
|
+
entryId: s.entry_id ?? null,
|
|
429
|
+
})),
|
|
430
|
+
totalDraft: data.total_draft,
|
|
431
|
+
totalPosted: data.total_posted,
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Create a draft closing entry from a schedule's facts for a period.
|
|
436
|
+
*/
|
|
437
|
+
async createClosingEntry(graphId, structureId, postingDate, periodStart, periodEnd, memo) {
|
|
438
|
+
const body = {
|
|
439
|
+
posting_date: postingDate,
|
|
440
|
+
period_start: periodStart,
|
|
441
|
+
period_end: periodEnd,
|
|
442
|
+
memo: memo ?? undefined,
|
|
443
|
+
};
|
|
444
|
+
const response = await (0, sdk_gen_1.createClosingEntry)({
|
|
445
|
+
path: { graph_id: graphId, structure_id: structureId },
|
|
446
|
+
body,
|
|
447
|
+
});
|
|
448
|
+
if (response.error) {
|
|
449
|
+
throw new Error(`Create closing entry failed: ${JSON.stringify(response.error)}`);
|
|
450
|
+
}
|
|
451
|
+
const data = response.data;
|
|
452
|
+
return {
|
|
453
|
+
entryId: data.entry_id,
|
|
454
|
+
status: data.status,
|
|
455
|
+
postingDate: data.posting_date,
|
|
456
|
+
memo: data.memo,
|
|
457
|
+
debitElementId: data.debit_element_id,
|
|
458
|
+
creditElementId: data.credit_element_id,
|
|
459
|
+
amount: data.amount,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
319
462
|
}
|
|
320
463
|
exports.LedgerClient = LedgerClient;
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
autoMapElements,
|
|
13
|
+
createClosingEntry,
|
|
13
14
|
createMappingAssociation,
|
|
15
|
+
createSchedule,
|
|
14
16
|
createStructure,
|
|
15
17
|
deleteMappingAssociation,
|
|
16
18
|
getLedgerAccountTree,
|
|
@@ -21,21 +23,34 @@ import {
|
|
|
21
23
|
getMappedTrialBalance,
|
|
22
24
|
getMappingCoverage,
|
|
23
25
|
getMappingDetail,
|
|
26
|
+
getPeriodCloseStatus,
|
|
24
27
|
getReportingTaxonomy,
|
|
28
|
+
getScheduleFacts,
|
|
25
29
|
listElements,
|
|
26
30
|
listLedgerAccounts,
|
|
27
31
|
listLedgerTransactions,
|
|
28
32
|
listMappings,
|
|
33
|
+
listSchedules,
|
|
29
34
|
listStructures,
|
|
30
35
|
} from '../sdk/sdk.gen'
|
|
31
36
|
import type {
|
|
32
37
|
AccountListResponse,
|
|
33
38
|
AccountTreeResponse,
|
|
39
|
+
ClosingEntryResponse,
|
|
40
|
+
CreateClosingEntryRequest,
|
|
41
|
+
CreateScheduleRequest,
|
|
34
42
|
LedgerSummaryResponse,
|
|
35
43
|
LedgerTransactionDetailResponse,
|
|
36
44
|
LedgerTransactionListResponse,
|
|
37
45
|
MappingCoverageResponse,
|
|
38
46
|
MappingDetailResponse,
|
|
47
|
+
PeriodCloseItemResponse,
|
|
48
|
+
PeriodCloseStatusResponse,
|
|
49
|
+
ScheduleCreatedResponse,
|
|
50
|
+
ScheduleFactResponse,
|
|
51
|
+
ScheduleFactsResponse,
|
|
52
|
+
ScheduleListResponse,
|
|
53
|
+
ScheduleSummaryResponse,
|
|
39
54
|
TrialBalanceResponse,
|
|
40
55
|
} from '../sdk/types.gen'
|
|
41
56
|
|
|
@@ -75,6 +90,81 @@ export interface Structure {
|
|
|
75
90
|
structureType: string
|
|
76
91
|
}
|
|
77
92
|
|
|
93
|
+
export interface Schedule {
|
|
94
|
+
structureId: string
|
|
95
|
+
name: string
|
|
96
|
+
taxonomyName: string
|
|
97
|
+
entryTemplate: Record<string, unknown> | null
|
|
98
|
+
scheduleMetadata: Record<string, unknown> | null
|
|
99
|
+
totalPeriods: number
|
|
100
|
+
periodsWithEntries: number
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ScheduleCreated {
|
|
104
|
+
structureId: string
|
|
105
|
+
name: string
|
|
106
|
+
taxonomyId: string
|
|
107
|
+
totalPeriods: number
|
|
108
|
+
totalFacts: number
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ScheduleFact {
|
|
112
|
+
elementId: string
|
|
113
|
+
elementName: string
|
|
114
|
+
value: number
|
|
115
|
+
periodStart: string
|
|
116
|
+
periodEnd: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface PeriodCloseItem {
|
|
120
|
+
structureId: string
|
|
121
|
+
structureName: string
|
|
122
|
+
amount: number
|
|
123
|
+
status: string
|
|
124
|
+
entryId: string | null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface PeriodCloseStatus {
|
|
128
|
+
fiscalPeriodStart: string
|
|
129
|
+
fiscalPeriodEnd: string
|
|
130
|
+
periodStatus: string
|
|
131
|
+
schedules: PeriodCloseItem[]
|
|
132
|
+
totalDraft: number
|
|
133
|
+
totalPosted: number
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ClosingEntry {
|
|
137
|
+
entryId: string
|
|
138
|
+
status: string
|
|
139
|
+
postingDate: string
|
|
140
|
+
memo: string
|
|
141
|
+
debitElementId: string
|
|
142
|
+
creditElementId: string
|
|
143
|
+
amount: number
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface CreateScheduleOptions {
|
|
147
|
+
name: string
|
|
148
|
+
elementIds: string[]
|
|
149
|
+
periodStart: string
|
|
150
|
+
periodEnd: string
|
|
151
|
+
monthlyAmount: number
|
|
152
|
+
entryTemplate: {
|
|
153
|
+
debitElementId: string
|
|
154
|
+
creditElementId: string
|
|
155
|
+
entryType?: string
|
|
156
|
+
memoTemplate?: string
|
|
157
|
+
}
|
|
158
|
+
taxonomyId?: string
|
|
159
|
+
scheduleMetadata?: {
|
|
160
|
+
method?: string
|
|
161
|
+
originalAmount?: number
|
|
162
|
+
residualValue?: number
|
|
163
|
+
usefulLifeMonths?: number
|
|
164
|
+
assetElementId?: string
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
78
168
|
// ── Client ──────────────────────────────────────────────────────────────
|
|
79
169
|
|
|
80
170
|
export class LedgerClient {
|
|
@@ -483,4 +573,181 @@ export class LedgerClient {
|
|
|
483
573
|
operationId: data?.operation_id as string | undefined,
|
|
484
574
|
}
|
|
485
575
|
}
|
|
576
|
+
|
|
577
|
+
// ── Schedules ──────────────────────────────────────────────────────
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Create a schedule with pre-generated monthly facts.
|
|
581
|
+
*/
|
|
582
|
+
async createSchedule(graphId: string, options: CreateScheduleOptions): Promise<ScheduleCreated> {
|
|
583
|
+
const body: CreateScheduleRequest = {
|
|
584
|
+
name: options.name,
|
|
585
|
+
element_ids: options.elementIds,
|
|
586
|
+
period_start: options.periodStart,
|
|
587
|
+
period_end: options.periodEnd,
|
|
588
|
+
monthly_amount: options.monthlyAmount,
|
|
589
|
+
entry_template: {
|
|
590
|
+
debit_element_id: options.entryTemplate.debitElementId,
|
|
591
|
+
credit_element_id: options.entryTemplate.creditElementId,
|
|
592
|
+
entry_type: options.entryTemplate.entryType,
|
|
593
|
+
memo_template: options.entryTemplate.memoTemplate,
|
|
594
|
+
},
|
|
595
|
+
taxonomy_id: options.taxonomyId,
|
|
596
|
+
schedule_metadata: options.scheduleMetadata
|
|
597
|
+
? {
|
|
598
|
+
method: options.scheduleMetadata.method,
|
|
599
|
+
original_amount: options.scheduleMetadata.originalAmount,
|
|
600
|
+
residual_value: options.scheduleMetadata.residualValue,
|
|
601
|
+
useful_life_months: options.scheduleMetadata.usefulLifeMonths,
|
|
602
|
+
asset_element_id: options.scheduleMetadata.assetElementId,
|
|
603
|
+
}
|
|
604
|
+
: undefined,
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const response = await createSchedule({
|
|
608
|
+
path: { graph_id: graphId },
|
|
609
|
+
body,
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
if (response.error) {
|
|
613
|
+
throw new Error(`Create schedule failed: ${JSON.stringify(response.error)}`)
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const data = response.data as ScheduleCreatedResponse
|
|
617
|
+
return {
|
|
618
|
+
structureId: data.structure_id,
|
|
619
|
+
name: data.name,
|
|
620
|
+
taxonomyId: data.taxonomy_id,
|
|
621
|
+
totalPeriods: data.total_periods,
|
|
622
|
+
totalFacts: data.total_facts,
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* List all schedules for a graph.
|
|
628
|
+
*/
|
|
629
|
+
async listSchedules(graphId: string): Promise<Schedule[]> {
|
|
630
|
+
const response = await listSchedules({
|
|
631
|
+
path: { graph_id: graphId },
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
if (response.error) {
|
|
635
|
+
throw new Error(`List schedules failed: ${JSON.stringify(response.error)}`)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const data = response.data as ScheduleListResponse
|
|
639
|
+
return (data.schedules ?? []).map((s: ScheduleSummaryResponse) => ({
|
|
640
|
+
structureId: s.structure_id,
|
|
641
|
+
name: s.name,
|
|
642
|
+
taxonomyName: s.taxonomy_name,
|
|
643
|
+
entryTemplate: s.entry_template ?? null,
|
|
644
|
+
scheduleMetadata: s.schedule_metadata ?? null,
|
|
645
|
+
totalPeriods: s.total_periods,
|
|
646
|
+
periodsWithEntries: s.periods_with_entries,
|
|
647
|
+
}))
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Get facts for a schedule, optionally filtered by period.
|
|
652
|
+
*/
|
|
653
|
+
async getScheduleFacts(
|
|
654
|
+
graphId: string,
|
|
655
|
+
structureId: string,
|
|
656
|
+
periodStart?: string,
|
|
657
|
+
periodEnd?: string
|
|
658
|
+
): Promise<ScheduleFact[]> {
|
|
659
|
+
const response = await getScheduleFacts({
|
|
660
|
+
path: { graph_id: graphId, structure_id: structureId },
|
|
661
|
+
query: {
|
|
662
|
+
period_start: periodStart ?? null,
|
|
663
|
+
period_end: periodEnd ?? null,
|
|
664
|
+
},
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
if (response.error) {
|
|
668
|
+
throw new Error(`Get schedule facts failed: ${JSON.stringify(response.error)}`)
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const data = response.data as ScheduleFactsResponse
|
|
672
|
+
return (data.facts ?? []).map((f: ScheduleFactResponse) => ({
|
|
673
|
+
elementId: f.element_id,
|
|
674
|
+
elementName: f.element_name,
|
|
675
|
+
value: f.value,
|
|
676
|
+
periodStart: f.period_start,
|
|
677
|
+
periodEnd: f.period_end,
|
|
678
|
+
}))
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Get close status for all schedules in a fiscal period.
|
|
683
|
+
*/
|
|
684
|
+
async getPeriodCloseStatus(
|
|
685
|
+
graphId: string,
|
|
686
|
+
periodStart: string,
|
|
687
|
+
periodEnd: string
|
|
688
|
+
): Promise<PeriodCloseStatus> {
|
|
689
|
+
const response = await getPeriodCloseStatus({
|
|
690
|
+
path: { graph_id: graphId },
|
|
691
|
+
query: { period_start: periodStart, period_end: periodEnd },
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
if (response.error) {
|
|
695
|
+
throw new Error(`Get period close status failed: ${JSON.stringify(response.error)}`)
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const data = response.data as PeriodCloseStatusResponse
|
|
699
|
+
return {
|
|
700
|
+
fiscalPeriodStart: data.fiscal_period_start,
|
|
701
|
+
fiscalPeriodEnd: data.fiscal_period_end,
|
|
702
|
+
periodStatus: data.period_status,
|
|
703
|
+
schedules: (data.schedules ?? []).map((s: PeriodCloseItemResponse) => ({
|
|
704
|
+
structureId: s.structure_id,
|
|
705
|
+
structureName: s.structure_name,
|
|
706
|
+
amount: s.amount,
|
|
707
|
+
status: s.status,
|
|
708
|
+
entryId: s.entry_id ?? null,
|
|
709
|
+
})),
|
|
710
|
+
totalDraft: data.total_draft,
|
|
711
|
+
totalPosted: data.total_posted,
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Create a draft closing entry from a schedule's facts for a period.
|
|
717
|
+
*/
|
|
718
|
+
async createClosingEntry(
|
|
719
|
+
graphId: string,
|
|
720
|
+
structureId: string,
|
|
721
|
+
postingDate: string,
|
|
722
|
+
periodStart: string,
|
|
723
|
+
periodEnd: string,
|
|
724
|
+
memo?: string
|
|
725
|
+
): Promise<ClosingEntry> {
|
|
726
|
+
const body: CreateClosingEntryRequest = {
|
|
727
|
+
posting_date: postingDate,
|
|
728
|
+
period_start: periodStart,
|
|
729
|
+
period_end: periodEnd,
|
|
730
|
+
memo: memo ?? undefined,
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const response = await createClosingEntry({
|
|
734
|
+
path: { graph_id: graphId, structure_id: structureId },
|
|
735
|
+
body,
|
|
736
|
+
})
|
|
737
|
+
|
|
738
|
+
if (response.error) {
|
|
739
|
+
throw new Error(`Create closing entry failed: ${JSON.stringify(response.error)}`)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const data = response.data as ClosingEntryResponse
|
|
743
|
+
return {
|
|
744
|
+
entryId: data.entry_id,
|
|
745
|
+
status: data.status,
|
|
746
|
+
postingDate: data.posting_date,
|
|
747
|
+
memo: data.memo,
|
|
748
|
+
debitElementId: data.debit_element_id,
|
|
749
|
+
creditElementId: data.credit_element_id,
|
|
750
|
+
amount: data.amount,
|
|
751
|
+
}
|
|
752
|
+
}
|
|
486
753
|
}
|
|
@@ -21,13 +21,17 @@ export interface Report {
|
|
|
21
21
|
}
|
|
22
22
|
import type { Structure } from './LedgerClient';
|
|
23
23
|
export type { Structure } from './LedgerClient';
|
|
24
|
+
export interface StatementPeriod {
|
|
25
|
+
start: string;
|
|
26
|
+
end: string;
|
|
27
|
+
label: string;
|
|
28
|
+
}
|
|
24
29
|
export interface StatementRow {
|
|
25
30
|
elementId: string;
|
|
26
31
|
elementQname: string;
|
|
27
32
|
elementName: string;
|
|
28
33
|
classification: string;
|
|
29
|
-
|
|
30
|
-
priorValue: number | null;
|
|
34
|
+
values: (number | null)[];
|
|
31
35
|
isSubtotal: boolean;
|
|
32
36
|
depth: number;
|
|
33
37
|
}
|
|
@@ -36,10 +40,7 @@ export interface StatementData {
|
|
|
36
40
|
structureId: string;
|
|
37
41
|
structureName: string;
|
|
38
42
|
structureType: string;
|
|
39
|
-
|
|
40
|
-
periodEnd: string;
|
|
41
|
-
comparativePeriodStart: string | null;
|
|
42
|
-
comparativePeriodEnd: string | null;
|
|
43
|
+
periods: StatementPeriod[];
|
|
43
44
|
rows: StatementRow[];
|
|
44
45
|
validation: {
|
|
45
46
|
passed: boolean;
|
|
@@ -78,6 +79,11 @@ export interface PublishListMember {
|
|
|
78
79
|
addedBy: string;
|
|
79
80
|
addedAt: string;
|
|
80
81
|
}
|
|
82
|
+
export interface PeriodSpecInput {
|
|
83
|
+
start: string;
|
|
84
|
+
end: string;
|
|
85
|
+
label: string;
|
|
86
|
+
}
|
|
81
87
|
export interface CreateReportOptions {
|
|
82
88
|
name: string;
|
|
83
89
|
mappingId: string;
|
|
@@ -86,6 +92,8 @@ export interface CreateReportOptions {
|
|
|
86
92
|
taxonomyId?: string;
|
|
87
93
|
periodType?: string;
|
|
88
94
|
comparative?: boolean;
|
|
95
|
+
/** When set, overrides periodStart/periodEnd/comparative with N explicit periods. */
|
|
96
|
+
periods?: PeriodSpecInput[];
|
|
89
97
|
}
|
|
90
98
|
export declare class ReportClient {
|
|
91
99
|
private config;
|
|
@@ -19,17 +19,21 @@ class ReportClient {
|
|
|
19
19
|
* Create a report — generates facts for all structures in the taxonomy.
|
|
20
20
|
*/
|
|
21
21
|
async create(graphId, options) {
|
|
22
|
+
const body = {
|
|
23
|
+
name: options.name,
|
|
24
|
+
mapping_id: options.mappingId,
|
|
25
|
+
period_start: options.periodStart,
|
|
26
|
+
period_end: options.periodEnd,
|
|
27
|
+
taxonomy_id: options.taxonomyId ?? 'tax_usgaap_reporting',
|
|
28
|
+
period_type: options.periodType ?? 'quarterly',
|
|
29
|
+
comparative: options.comparative ?? true,
|
|
30
|
+
};
|
|
31
|
+
if (options.periods && options.periods.length > 0) {
|
|
32
|
+
body.periods = options.periods;
|
|
33
|
+
}
|
|
22
34
|
const response = await (0, sdk_gen_1.createReport)({
|
|
23
35
|
path: { graph_id: graphId },
|
|
24
|
-
body
|
|
25
|
-
name: options.name,
|
|
26
|
-
mapping_id: options.mappingId,
|
|
27
|
-
period_start: options.periodStart,
|
|
28
|
-
period_end: options.periodEnd,
|
|
29
|
-
taxonomy_id: options.taxonomyId ?? 'tax_usgaap_reporting',
|
|
30
|
-
period_type: options.periodType ?? 'quarterly',
|
|
31
|
-
comparative: options.comparative ?? true,
|
|
32
|
-
},
|
|
36
|
+
body,
|
|
33
37
|
});
|
|
34
38
|
if (response.error) {
|
|
35
39
|
throw new Error(`Create report failed: ${JSON.stringify(response.error)}`);
|
|
@@ -79,17 +83,17 @@ class ReportClient {
|
|
|
79
83
|
structureId: data.structure_id,
|
|
80
84
|
structureName: data.structure_name,
|
|
81
85
|
structureType: data.structure_type,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
periods: (data.periods ?? []).map((p) => ({
|
|
87
|
+
start: p.start,
|
|
88
|
+
end: p.end,
|
|
89
|
+
label: p.label,
|
|
90
|
+
})),
|
|
86
91
|
rows: (data.rows ?? []).map((r) => ({
|
|
87
92
|
elementId: r.element_id,
|
|
88
93
|
elementQname: r.element_qname,
|
|
89
94
|
elementName: r.element_name,
|
|
90
95
|
classification: r.classification,
|
|
91
|
-
|
|
92
|
-
priorValue: r.prior_value ?? null,
|
|
96
|
+
values: r.values ?? [],
|
|
93
97
|
isSubtotal: r.is_subtotal ?? false,
|
|
94
98
|
depth: r.depth ?? 0,
|
|
95
99
|
})),
|