@tokensapi/dsh-finance 0.1.0-beta.1

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.
@@ -0,0 +1,999 @@
1
+ import type { CompanyWorkspace, FinanceBootstrap, FinanceState, CreateAccountInput, CreateCompanyInput, DeleteCompanyInput, RenameCompanyInput, RevisionedIdInput, SetRetainedEarningsInput, UpdateAccountInput, UpdateOpeningBalanceInput, UpdateOpeningSettingsInput, CompanyMutationInput, PreviewImportInput, ImportPreview, CommitImportInput, ImportCommitResult, CompanyBatchList, BatchDetail, UpdateTransactionInput, TransactionMutationInput, UpdateBatchFundingInput, BatchMutationInput, GenerateReportsInput, FinanceReports, BackupEnvelope, BackupPreview, PreviewBackupInput, RestoreBackupInput } from '../contract.ts';
2
+ export type FinanceErrorCode = 'state-conflict' | 'company-not-found' | 'company-name-required' | 'company-confirmation-mismatch' | 'account-not-found' | 'account-code-conflict' | 'account-name-conflict' | 'account-category-mismatch' | 'account-in-use' | 'account-is-retained-earnings' | 'opening-locked' | 'opening-not-locked' | 'opening-balance-invalid' | 'opening-not-balanced' | 'batch-not-found' | 'transaction-not-found' | 'batch-approved' | 'batch-not-approved' | 'batch-empty' | 'backup-invalid' | 'invalid-request';
3
+ export declare class FinanceError extends Error {
4
+ readonly code: FinanceErrorCode;
5
+ constructor(code: FinanceErrorCode, message: string);
6
+ }
7
+ export interface StateEnvironment {
8
+ id(): string;
9
+ now(): string;
10
+ }
11
+ export declare const defaultStateEnvironment: StateEnvironment;
12
+ export declare function bootstrap(state: FinanceState): FinanceBootstrap;
13
+ export declare function createCompany(state: FinanceState, input: CreateCompanyInput, env?: StateEnvironment): {
14
+ state: FinanceState;
15
+ value: CompanyWorkspace;
16
+ };
17
+ export declare function renameCompany(state: FinanceState, input: RenameCompanyInput, env?: StateEnvironment): {
18
+ state: Readonly<{
19
+ format: "tokens-cowork-finance-state";
20
+ version: 1;
21
+ revision: number;
22
+ companies: Readonly<{
23
+ id: string;
24
+ name: string;
25
+ baseCurrency: string;
26
+ currencyExponent: number;
27
+ openingDate: string;
28
+ openingLocked: boolean;
29
+ retainedEarningsAccountId: string;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ }>[];
33
+ accounts: Readonly<{
34
+ id: string;
35
+ companyId: string;
36
+ code: string;
37
+ name: string;
38
+ category: "asset" | "liability" | "equity" | "income" | "expense";
39
+ reportItem: string;
40
+ openingBalanceMinor: string;
41
+ isContra: boolean;
42
+ isActive: boolean;
43
+ createdAt: string;
44
+ updatedAt: string;
45
+ }>[];
46
+ batches: Readonly<{
47
+ id: string;
48
+ companyId: string;
49
+ fundingAccountId: string;
50
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
51
+ sourceFileName: string | null;
52
+ importedAt: string;
53
+ status: "draft" | "approved";
54
+ approvedAt: string | null;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ }>[];
58
+ transactions: Readonly<{
59
+ id: string;
60
+ companyId: string;
61
+ batchId: string;
62
+ date: string;
63
+ amountMinor: string;
64
+ businessAccountId: string;
65
+ description: string;
66
+ counterparty: string;
67
+ sourceRowNumber: number | null;
68
+ createdAt: string;
69
+ updatedAt: string;
70
+ }>[];
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }>;
74
+ value: Readonly<{
75
+ revision: number;
76
+ company: Readonly<{
77
+ id: string;
78
+ name: string;
79
+ baseCurrency: string;
80
+ currencyExponent: number;
81
+ openingDate: string;
82
+ openingLocked: boolean;
83
+ retainedEarningsAccountId: string;
84
+ createdAt: string;
85
+ updatedAt: string;
86
+ }>;
87
+ accounts: Readonly<{
88
+ id: string;
89
+ companyId: string;
90
+ code: string;
91
+ name: string;
92
+ category: "asset" | "liability" | "equity" | "income" | "expense";
93
+ reportItem: string;
94
+ openingBalanceMinor: string;
95
+ isContra: boolean;
96
+ isActive: boolean;
97
+ createdAt: string;
98
+ updatedAt: string;
99
+ }>[];
100
+ openingSummary: Readonly<{
101
+ assetsMinor: string;
102
+ liabilitiesMinor: string;
103
+ equityMinor: string;
104
+ differenceMinor: string;
105
+ balanced: boolean;
106
+ }>;
107
+ }>;
108
+ };
109
+ export declare function deleteCompany(state: FinanceState, input: DeleteCompanyInput, env?: StateEnvironment): {
110
+ state: Readonly<{
111
+ format: "tokens-cowork-finance-state";
112
+ version: 1;
113
+ revision: number;
114
+ companies: Readonly<{
115
+ id: string;
116
+ name: string;
117
+ baseCurrency: string;
118
+ currencyExponent: number;
119
+ openingDate: string;
120
+ openingLocked: boolean;
121
+ retainedEarningsAccountId: string;
122
+ createdAt: string;
123
+ updatedAt: string;
124
+ }>[];
125
+ accounts: Readonly<{
126
+ id: string;
127
+ companyId: string;
128
+ code: string;
129
+ name: string;
130
+ category: "asset" | "liability" | "equity" | "income" | "expense";
131
+ reportItem: string;
132
+ openingBalanceMinor: string;
133
+ isContra: boolean;
134
+ isActive: boolean;
135
+ createdAt: string;
136
+ updatedAt: string;
137
+ }>[];
138
+ batches: Readonly<{
139
+ id: string;
140
+ companyId: string;
141
+ fundingAccountId: string;
142
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
143
+ sourceFileName: string | null;
144
+ importedAt: string;
145
+ status: "draft" | "approved";
146
+ approvedAt: string | null;
147
+ createdAt: string;
148
+ updatedAt: string;
149
+ }>[];
150
+ transactions: Readonly<{
151
+ id: string;
152
+ companyId: string;
153
+ batchId: string;
154
+ date: string;
155
+ amountMinor: string;
156
+ businessAccountId: string;
157
+ description: string;
158
+ counterparty: string;
159
+ sourceRowNumber: number | null;
160
+ createdAt: string;
161
+ updatedAt: string;
162
+ }>[];
163
+ createdAt: string;
164
+ updatedAt: string;
165
+ }>;
166
+ value: Readonly<{
167
+ revision: number;
168
+ companies: Readonly<{
169
+ id: string;
170
+ name: string;
171
+ baseCurrency: string;
172
+ currencyExponent: number;
173
+ openingDate: string;
174
+ openingLocked: boolean;
175
+ retainedEarningsAccountId: string;
176
+ createdAt: string;
177
+ updatedAt: string;
178
+ }>[];
179
+ limits: Readonly<{
180
+ maxImportFileBytes: number;
181
+ maxImportRows: number;
182
+ }>;
183
+ capabilities: Readonly<{
184
+ companyManagement: boolean;
185
+ accountManagement: boolean;
186
+ transactionImport: boolean;
187
+ reports: boolean;
188
+ backup: boolean;
189
+ }>;
190
+ }>;
191
+ };
192
+ export declare function getCompanyWorkspace(state: FinanceState, companyId: string): Readonly<{
193
+ revision: number;
194
+ company: Readonly<{
195
+ id: string;
196
+ name: string;
197
+ baseCurrency: string;
198
+ currencyExponent: number;
199
+ openingDate: string;
200
+ openingLocked: boolean;
201
+ retainedEarningsAccountId: string;
202
+ createdAt: string;
203
+ updatedAt: string;
204
+ }>;
205
+ accounts: Readonly<{
206
+ id: string;
207
+ companyId: string;
208
+ code: string;
209
+ name: string;
210
+ category: "asset" | "liability" | "equity" | "income" | "expense";
211
+ reportItem: string;
212
+ openingBalanceMinor: string;
213
+ isContra: boolean;
214
+ isActive: boolean;
215
+ createdAt: string;
216
+ updatedAt: string;
217
+ }>[];
218
+ openingSummary: Readonly<{
219
+ assetsMinor: string;
220
+ liabilitiesMinor: string;
221
+ equityMinor: string;
222
+ differenceMinor: string;
223
+ balanced: boolean;
224
+ }>;
225
+ }>;
226
+ export declare function createAccount(state: FinanceState, input: CreateAccountInput, env?: StateEnvironment): {
227
+ state: Readonly<{
228
+ format: "tokens-cowork-finance-state";
229
+ version: 1;
230
+ revision: number;
231
+ companies: Readonly<{
232
+ id: string;
233
+ name: string;
234
+ baseCurrency: string;
235
+ currencyExponent: number;
236
+ openingDate: string;
237
+ openingLocked: boolean;
238
+ retainedEarningsAccountId: string;
239
+ createdAt: string;
240
+ updatedAt: string;
241
+ }>[];
242
+ accounts: Readonly<{
243
+ id: string;
244
+ companyId: string;
245
+ code: string;
246
+ name: string;
247
+ category: "asset" | "liability" | "equity" | "income" | "expense";
248
+ reportItem: string;
249
+ openingBalanceMinor: string;
250
+ isContra: boolean;
251
+ isActive: boolean;
252
+ createdAt: string;
253
+ updatedAt: string;
254
+ }>[];
255
+ batches: Readonly<{
256
+ id: string;
257
+ companyId: string;
258
+ fundingAccountId: string;
259
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
260
+ sourceFileName: string | null;
261
+ importedAt: string;
262
+ status: "draft" | "approved";
263
+ approvedAt: string | null;
264
+ createdAt: string;
265
+ updatedAt: string;
266
+ }>[];
267
+ transactions: Readonly<{
268
+ id: string;
269
+ companyId: string;
270
+ batchId: string;
271
+ date: string;
272
+ amountMinor: string;
273
+ businessAccountId: string;
274
+ description: string;
275
+ counterparty: string;
276
+ sourceRowNumber: number | null;
277
+ createdAt: string;
278
+ updatedAt: string;
279
+ }>[];
280
+ createdAt: string;
281
+ updatedAt: string;
282
+ }>;
283
+ value: Readonly<{
284
+ revision: number;
285
+ company: Readonly<{
286
+ id: string;
287
+ name: string;
288
+ baseCurrency: string;
289
+ currencyExponent: number;
290
+ openingDate: string;
291
+ openingLocked: boolean;
292
+ retainedEarningsAccountId: string;
293
+ createdAt: string;
294
+ updatedAt: string;
295
+ }>;
296
+ accounts: Readonly<{
297
+ id: string;
298
+ companyId: string;
299
+ code: string;
300
+ name: string;
301
+ category: "asset" | "liability" | "equity" | "income" | "expense";
302
+ reportItem: string;
303
+ openingBalanceMinor: string;
304
+ isContra: boolean;
305
+ isActive: boolean;
306
+ createdAt: string;
307
+ updatedAt: string;
308
+ }>[];
309
+ openingSummary: Readonly<{
310
+ assetsMinor: string;
311
+ liabilitiesMinor: string;
312
+ equityMinor: string;
313
+ differenceMinor: string;
314
+ balanced: boolean;
315
+ }>;
316
+ }>;
317
+ };
318
+ export declare function updateAccount(state: FinanceState, input: UpdateAccountInput, env?: StateEnvironment): {
319
+ state: Readonly<{
320
+ format: "tokens-cowork-finance-state";
321
+ version: 1;
322
+ revision: number;
323
+ companies: Readonly<{
324
+ id: string;
325
+ name: string;
326
+ baseCurrency: string;
327
+ currencyExponent: number;
328
+ openingDate: string;
329
+ openingLocked: boolean;
330
+ retainedEarningsAccountId: string;
331
+ createdAt: string;
332
+ updatedAt: string;
333
+ }>[];
334
+ accounts: Readonly<{
335
+ id: string;
336
+ companyId: string;
337
+ code: string;
338
+ name: string;
339
+ category: "asset" | "liability" | "equity" | "income" | "expense";
340
+ reportItem: string;
341
+ openingBalanceMinor: string;
342
+ isContra: boolean;
343
+ isActive: boolean;
344
+ createdAt: string;
345
+ updatedAt: string;
346
+ }>[];
347
+ batches: Readonly<{
348
+ id: string;
349
+ companyId: string;
350
+ fundingAccountId: string;
351
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
352
+ sourceFileName: string | null;
353
+ importedAt: string;
354
+ status: "draft" | "approved";
355
+ approvedAt: string | null;
356
+ createdAt: string;
357
+ updatedAt: string;
358
+ }>[];
359
+ transactions: Readonly<{
360
+ id: string;
361
+ companyId: string;
362
+ batchId: string;
363
+ date: string;
364
+ amountMinor: string;
365
+ businessAccountId: string;
366
+ description: string;
367
+ counterparty: string;
368
+ sourceRowNumber: number | null;
369
+ createdAt: string;
370
+ updatedAt: string;
371
+ }>[];
372
+ createdAt: string;
373
+ updatedAt: string;
374
+ }>;
375
+ value: Readonly<{
376
+ revision: number;
377
+ company: Readonly<{
378
+ id: string;
379
+ name: string;
380
+ baseCurrency: string;
381
+ currencyExponent: number;
382
+ openingDate: string;
383
+ openingLocked: boolean;
384
+ retainedEarningsAccountId: string;
385
+ createdAt: string;
386
+ updatedAt: string;
387
+ }>;
388
+ accounts: Readonly<{
389
+ id: string;
390
+ companyId: string;
391
+ code: string;
392
+ name: string;
393
+ category: "asset" | "liability" | "equity" | "income" | "expense";
394
+ reportItem: string;
395
+ openingBalanceMinor: string;
396
+ isContra: boolean;
397
+ isActive: boolean;
398
+ createdAt: string;
399
+ updatedAt: string;
400
+ }>[];
401
+ openingSummary: Readonly<{
402
+ assetsMinor: string;
403
+ liabilitiesMinor: string;
404
+ equityMinor: string;
405
+ differenceMinor: string;
406
+ balanced: boolean;
407
+ }>;
408
+ }>;
409
+ };
410
+ export declare function deleteAccount(state: FinanceState, input: RevisionedIdInput, env?: StateEnvironment): {
411
+ state: Readonly<{
412
+ format: "tokens-cowork-finance-state";
413
+ version: 1;
414
+ revision: number;
415
+ companies: Readonly<{
416
+ id: string;
417
+ name: string;
418
+ baseCurrency: string;
419
+ currencyExponent: number;
420
+ openingDate: string;
421
+ openingLocked: boolean;
422
+ retainedEarningsAccountId: string;
423
+ createdAt: string;
424
+ updatedAt: string;
425
+ }>[];
426
+ accounts: Readonly<{
427
+ id: string;
428
+ companyId: string;
429
+ code: string;
430
+ name: string;
431
+ category: "asset" | "liability" | "equity" | "income" | "expense";
432
+ reportItem: string;
433
+ openingBalanceMinor: string;
434
+ isContra: boolean;
435
+ isActive: boolean;
436
+ createdAt: string;
437
+ updatedAt: string;
438
+ }>[];
439
+ batches: Readonly<{
440
+ id: string;
441
+ companyId: string;
442
+ fundingAccountId: string;
443
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
444
+ sourceFileName: string | null;
445
+ importedAt: string;
446
+ status: "draft" | "approved";
447
+ approvedAt: string | null;
448
+ createdAt: string;
449
+ updatedAt: string;
450
+ }>[];
451
+ transactions: Readonly<{
452
+ id: string;
453
+ companyId: string;
454
+ batchId: string;
455
+ date: string;
456
+ amountMinor: string;
457
+ businessAccountId: string;
458
+ description: string;
459
+ counterparty: string;
460
+ sourceRowNumber: number | null;
461
+ createdAt: string;
462
+ updatedAt: string;
463
+ }>[];
464
+ createdAt: string;
465
+ updatedAt: string;
466
+ }>;
467
+ value: Readonly<{
468
+ revision: number;
469
+ company: Readonly<{
470
+ id: string;
471
+ name: string;
472
+ baseCurrency: string;
473
+ currencyExponent: number;
474
+ openingDate: string;
475
+ openingLocked: boolean;
476
+ retainedEarningsAccountId: string;
477
+ createdAt: string;
478
+ updatedAt: string;
479
+ }>;
480
+ accounts: Readonly<{
481
+ id: string;
482
+ companyId: string;
483
+ code: string;
484
+ name: string;
485
+ category: "asset" | "liability" | "equity" | "income" | "expense";
486
+ reportItem: string;
487
+ openingBalanceMinor: string;
488
+ isContra: boolean;
489
+ isActive: boolean;
490
+ createdAt: string;
491
+ updatedAt: string;
492
+ }>[];
493
+ openingSummary: Readonly<{
494
+ assetsMinor: string;
495
+ liabilitiesMinor: string;
496
+ equityMinor: string;
497
+ differenceMinor: string;
498
+ balanced: boolean;
499
+ }>;
500
+ }>;
501
+ };
502
+ export declare function updateOpeningBalance(state: FinanceState, input: UpdateOpeningBalanceInput, env?: StateEnvironment): {
503
+ state: Readonly<{
504
+ format: "tokens-cowork-finance-state";
505
+ version: 1;
506
+ revision: number;
507
+ companies: Readonly<{
508
+ id: string;
509
+ name: string;
510
+ baseCurrency: string;
511
+ currencyExponent: number;
512
+ openingDate: string;
513
+ openingLocked: boolean;
514
+ retainedEarningsAccountId: string;
515
+ createdAt: string;
516
+ updatedAt: string;
517
+ }>[];
518
+ accounts: Readonly<{
519
+ id: string;
520
+ companyId: string;
521
+ code: string;
522
+ name: string;
523
+ category: "asset" | "liability" | "equity" | "income" | "expense";
524
+ reportItem: string;
525
+ openingBalanceMinor: string;
526
+ isContra: boolean;
527
+ isActive: boolean;
528
+ createdAt: string;
529
+ updatedAt: string;
530
+ }>[];
531
+ batches: Readonly<{
532
+ id: string;
533
+ companyId: string;
534
+ fundingAccountId: string;
535
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
536
+ sourceFileName: string | null;
537
+ importedAt: string;
538
+ status: "draft" | "approved";
539
+ approvedAt: string | null;
540
+ createdAt: string;
541
+ updatedAt: string;
542
+ }>[];
543
+ transactions: Readonly<{
544
+ id: string;
545
+ companyId: string;
546
+ batchId: string;
547
+ date: string;
548
+ amountMinor: string;
549
+ businessAccountId: string;
550
+ description: string;
551
+ counterparty: string;
552
+ sourceRowNumber: number | null;
553
+ createdAt: string;
554
+ updatedAt: string;
555
+ }>[];
556
+ createdAt: string;
557
+ updatedAt: string;
558
+ }>;
559
+ value: Readonly<{
560
+ revision: number;
561
+ company: Readonly<{
562
+ id: string;
563
+ name: string;
564
+ baseCurrency: string;
565
+ currencyExponent: number;
566
+ openingDate: string;
567
+ openingLocked: boolean;
568
+ retainedEarningsAccountId: string;
569
+ createdAt: string;
570
+ updatedAt: string;
571
+ }>;
572
+ accounts: Readonly<{
573
+ id: string;
574
+ companyId: string;
575
+ code: string;
576
+ name: string;
577
+ category: "asset" | "liability" | "equity" | "income" | "expense";
578
+ reportItem: string;
579
+ openingBalanceMinor: string;
580
+ isContra: boolean;
581
+ isActive: boolean;
582
+ createdAt: string;
583
+ updatedAt: string;
584
+ }>[];
585
+ openingSummary: Readonly<{
586
+ assetsMinor: string;
587
+ liabilitiesMinor: string;
588
+ equityMinor: string;
589
+ differenceMinor: string;
590
+ balanced: boolean;
591
+ }>;
592
+ }>;
593
+ };
594
+ export declare function updateOpeningSettings(state: FinanceState, input: UpdateOpeningSettingsInput, env?: StateEnvironment): {
595
+ state: Readonly<{
596
+ format: "tokens-cowork-finance-state";
597
+ version: 1;
598
+ revision: number;
599
+ companies: Readonly<{
600
+ id: string;
601
+ name: string;
602
+ baseCurrency: string;
603
+ currencyExponent: number;
604
+ openingDate: string;
605
+ openingLocked: boolean;
606
+ retainedEarningsAccountId: string;
607
+ createdAt: string;
608
+ updatedAt: string;
609
+ }>[];
610
+ accounts: Readonly<{
611
+ id: string;
612
+ companyId: string;
613
+ code: string;
614
+ name: string;
615
+ category: "asset" | "liability" | "equity" | "income" | "expense";
616
+ reportItem: string;
617
+ openingBalanceMinor: string;
618
+ isContra: boolean;
619
+ isActive: boolean;
620
+ createdAt: string;
621
+ updatedAt: string;
622
+ }>[];
623
+ batches: Readonly<{
624
+ id: string;
625
+ companyId: string;
626
+ fundingAccountId: string;
627
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
628
+ sourceFileName: string | null;
629
+ importedAt: string;
630
+ status: "draft" | "approved";
631
+ approvedAt: string | null;
632
+ createdAt: string;
633
+ updatedAt: string;
634
+ }>[];
635
+ transactions: Readonly<{
636
+ id: string;
637
+ companyId: string;
638
+ batchId: string;
639
+ date: string;
640
+ amountMinor: string;
641
+ businessAccountId: string;
642
+ description: string;
643
+ counterparty: string;
644
+ sourceRowNumber: number | null;
645
+ createdAt: string;
646
+ updatedAt: string;
647
+ }>[];
648
+ createdAt: string;
649
+ updatedAt: string;
650
+ }>;
651
+ value: Readonly<{
652
+ revision: number;
653
+ company: Readonly<{
654
+ id: string;
655
+ name: string;
656
+ baseCurrency: string;
657
+ currencyExponent: number;
658
+ openingDate: string;
659
+ openingLocked: boolean;
660
+ retainedEarningsAccountId: string;
661
+ createdAt: string;
662
+ updatedAt: string;
663
+ }>;
664
+ accounts: Readonly<{
665
+ id: string;
666
+ companyId: string;
667
+ code: string;
668
+ name: string;
669
+ category: "asset" | "liability" | "equity" | "income" | "expense";
670
+ reportItem: string;
671
+ openingBalanceMinor: string;
672
+ isContra: boolean;
673
+ isActive: boolean;
674
+ createdAt: string;
675
+ updatedAt: string;
676
+ }>[];
677
+ openingSummary: Readonly<{
678
+ assetsMinor: string;
679
+ liabilitiesMinor: string;
680
+ equityMinor: string;
681
+ differenceMinor: string;
682
+ balanced: boolean;
683
+ }>;
684
+ }>;
685
+ };
686
+ export declare function setRetainedEarningsAccount(state: FinanceState, input: SetRetainedEarningsInput, env?: StateEnvironment): {
687
+ state: Readonly<{
688
+ format: "tokens-cowork-finance-state";
689
+ version: 1;
690
+ revision: number;
691
+ companies: Readonly<{
692
+ id: string;
693
+ name: string;
694
+ baseCurrency: string;
695
+ currencyExponent: number;
696
+ openingDate: string;
697
+ openingLocked: boolean;
698
+ retainedEarningsAccountId: string;
699
+ createdAt: string;
700
+ updatedAt: string;
701
+ }>[];
702
+ accounts: Readonly<{
703
+ id: string;
704
+ companyId: string;
705
+ code: string;
706
+ name: string;
707
+ category: "asset" | "liability" | "equity" | "income" | "expense";
708
+ reportItem: string;
709
+ openingBalanceMinor: string;
710
+ isContra: boolean;
711
+ isActive: boolean;
712
+ createdAt: string;
713
+ updatedAt: string;
714
+ }>[];
715
+ batches: Readonly<{
716
+ id: string;
717
+ companyId: string;
718
+ fundingAccountId: string;
719
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
720
+ sourceFileName: string | null;
721
+ importedAt: string;
722
+ status: "draft" | "approved";
723
+ approvedAt: string | null;
724
+ createdAt: string;
725
+ updatedAt: string;
726
+ }>[];
727
+ transactions: Readonly<{
728
+ id: string;
729
+ companyId: string;
730
+ batchId: string;
731
+ date: string;
732
+ amountMinor: string;
733
+ businessAccountId: string;
734
+ description: string;
735
+ counterparty: string;
736
+ sourceRowNumber: number | null;
737
+ createdAt: string;
738
+ updatedAt: string;
739
+ }>[];
740
+ createdAt: string;
741
+ updatedAt: string;
742
+ }>;
743
+ value: Readonly<{
744
+ revision: number;
745
+ company: Readonly<{
746
+ id: string;
747
+ name: string;
748
+ baseCurrency: string;
749
+ currencyExponent: number;
750
+ openingDate: string;
751
+ openingLocked: boolean;
752
+ retainedEarningsAccountId: string;
753
+ createdAt: string;
754
+ updatedAt: string;
755
+ }>;
756
+ accounts: Readonly<{
757
+ id: string;
758
+ companyId: string;
759
+ code: string;
760
+ name: string;
761
+ category: "asset" | "liability" | "equity" | "income" | "expense";
762
+ reportItem: string;
763
+ openingBalanceMinor: string;
764
+ isContra: boolean;
765
+ isActive: boolean;
766
+ createdAt: string;
767
+ updatedAt: string;
768
+ }>[];
769
+ openingSummary: Readonly<{
770
+ assetsMinor: string;
771
+ liabilitiesMinor: string;
772
+ equityMinor: string;
773
+ differenceMinor: string;
774
+ balanced: boolean;
775
+ }>;
776
+ }>;
777
+ };
778
+ export declare function lockOpening(state: FinanceState, input: CompanyMutationInput, env?: StateEnvironment): {
779
+ state: Readonly<{
780
+ format: "tokens-cowork-finance-state";
781
+ version: 1;
782
+ revision: number;
783
+ companies: Readonly<{
784
+ id: string;
785
+ name: string;
786
+ baseCurrency: string;
787
+ currencyExponent: number;
788
+ openingDate: string;
789
+ openingLocked: boolean;
790
+ retainedEarningsAccountId: string;
791
+ createdAt: string;
792
+ updatedAt: string;
793
+ }>[];
794
+ accounts: Readonly<{
795
+ id: string;
796
+ companyId: string;
797
+ code: string;
798
+ name: string;
799
+ category: "asset" | "liability" | "equity" | "income" | "expense";
800
+ reportItem: string;
801
+ openingBalanceMinor: string;
802
+ isContra: boolean;
803
+ isActive: boolean;
804
+ createdAt: string;
805
+ updatedAt: string;
806
+ }>[];
807
+ batches: Readonly<{
808
+ id: string;
809
+ companyId: string;
810
+ fundingAccountId: string;
811
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
812
+ sourceFileName: string | null;
813
+ importedAt: string;
814
+ status: "draft" | "approved";
815
+ approvedAt: string | null;
816
+ createdAt: string;
817
+ updatedAt: string;
818
+ }>[];
819
+ transactions: Readonly<{
820
+ id: string;
821
+ companyId: string;
822
+ batchId: string;
823
+ date: string;
824
+ amountMinor: string;
825
+ businessAccountId: string;
826
+ description: string;
827
+ counterparty: string;
828
+ sourceRowNumber: number | null;
829
+ createdAt: string;
830
+ updatedAt: string;
831
+ }>[];
832
+ createdAt: string;
833
+ updatedAt: string;
834
+ }>;
835
+ value: Readonly<{
836
+ revision: number;
837
+ company: Readonly<{
838
+ id: string;
839
+ name: string;
840
+ baseCurrency: string;
841
+ currencyExponent: number;
842
+ openingDate: string;
843
+ openingLocked: boolean;
844
+ retainedEarningsAccountId: string;
845
+ createdAt: string;
846
+ updatedAt: string;
847
+ }>;
848
+ accounts: Readonly<{
849
+ id: string;
850
+ companyId: string;
851
+ code: string;
852
+ name: string;
853
+ category: "asset" | "liability" | "equity" | "income" | "expense";
854
+ reportItem: string;
855
+ openingBalanceMinor: string;
856
+ isContra: boolean;
857
+ isActive: boolean;
858
+ createdAt: string;
859
+ updatedAt: string;
860
+ }>[];
861
+ openingSummary: Readonly<{
862
+ assetsMinor: string;
863
+ liabilitiesMinor: string;
864
+ equityMinor: string;
865
+ differenceMinor: string;
866
+ balanced: boolean;
867
+ }>;
868
+ }>;
869
+ };
870
+ export declare function unlockOpening(state: FinanceState, input: CompanyMutationInput, env?: StateEnvironment): {
871
+ state: Readonly<{
872
+ format: "tokens-cowork-finance-state";
873
+ version: 1;
874
+ revision: number;
875
+ companies: Readonly<{
876
+ id: string;
877
+ name: string;
878
+ baseCurrency: string;
879
+ currencyExponent: number;
880
+ openingDate: string;
881
+ openingLocked: boolean;
882
+ retainedEarningsAccountId: string;
883
+ createdAt: string;
884
+ updatedAt: string;
885
+ }>[];
886
+ accounts: Readonly<{
887
+ id: string;
888
+ companyId: string;
889
+ code: string;
890
+ name: string;
891
+ category: "asset" | "liability" | "equity" | "income" | "expense";
892
+ reportItem: string;
893
+ openingBalanceMinor: string;
894
+ isContra: boolean;
895
+ isActive: boolean;
896
+ createdAt: string;
897
+ updatedAt: string;
898
+ }>[];
899
+ batches: Readonly<{
900
+ id: string;
901
+ companyId: string;
902
+ fundingAccountId: string;
903
+ sourceType: "csv" | "xlsx" | "paste" | "sample";
904
+ sourceFileName: string | null;
905
+ importedAt: string;
906
+ status: "draft" | "approved";
907
+ approvedAt: string | null;
908
+ createdAt: string;
909
+ updatedAt: string;
910
+ }>[];
911
+ transactions: Readonly<{
912
+ id: string;
913
+ companyId: string;
914
+ batchId: string;
915
+ date: string;
916
+ amountMinor: string;
917
+ businessAccountId: string;
918
+ description: string;
919
+ counterparty: string;
920
+ sourceRowNumber: number | null;
921
+ createdAt: string;
922
+ updatedAt: string;
923
+ }>[];
924
+ createdAt: string;
925
+ updatedAt: string;
926
+ }>;
927
+ value: Readonly<{
928
+ revision: number;
929
+ company: Readonly<{
930
+ id: string;
931
+ name: string;
932
+ baseCurrency: string;
933
+ currencyExponent: number;
934
+ openingDate: string;
935
+ openingLocked: boolean;
936
+ retainedEarningsAccountId: string;
937
+ createdAt: string;
938
+ updatedAt: string;
939
+ }>;
940
+ accounts: Readonly<{
941
+ id: string;
942
+ companyId: string;
943
+ code: string;
944
+ name: string;
945
+ category: "asset" | "liability" | "equity" | "income" | "expense";
946
+ reportItem: string;
947
+ openingBalanceMinor: string;
948
+ isContra: boolean;
949
+ isActive: boolean;
950
+ createdAt: string;
951
+ updatedAt: string;
952
+ }>[];
953
+ openingSummary: Readonly<{
954
+ assetsMinor: string;
955
+ liabilitiesMinor: string;
956
+ equityMinor: string;
957
+ differenceMinor: string;
958
+ balanced: boolean;
959
+ }>;
960
+ }>;
961
+ };
962
+ export declare function previewImport(state: FinanceState, input: PreviewImportInput): ImportPreview;
963
+ export declare function commitImport(state: FinanceState, input: CommitImportInput, env?: StateEnvironment): {
964
+ state: FinanceState;
965
+ value: ImportCommitResult;
966
+ };
967
+ export declare function getCompanyBatches(state: FinanceState, companyId: string): CompanyBatchList;
968
+ export declare function getBatchDetail(state: FinanceState, batchId: string): BatchDetail;
969
+ export declare function updateTransaction(state: FinanceState, input: UpdateTransactionInput, env?: StateEnvironment): {
970
+ state: FinanceState;
971
+ value: BatchDetail;
972
+ };
973
+ export declare function deleteTransaction(state: FinanceState, input: TransactionMutationInput, env?: StateEnvironment): {
974
+ state: FinanceState;
975
+ value: BatchDetail;
976
+ };
977
+ export declare function updateBatchFundingAccount(state: FinanceState, input: UpdateBatchFundingInput, env?: StateEnvironment): {
978
+ state: FinanceState;
979
+ value: BatchDetail;
980
+ };
981
+ export declare function deleteBatch(state: FinanceState, input: BatchMutationInput, env?: StateEnvironment): {
982
+ state: FinanceState;
983
+ value: CompanyBatchList;
984
+ };
985
+ export declare function approveBatch(state: FinanceState, input: BatchMutationInput, env?: StateEnvironment): {
986
+ state: FinanceState;
987
+ value: BatchDetail;
988
+ };
989
+ export declare function unapproveBatch(state: FinanceState, input: BatchMutationInput, env?: StateEnvironment): {
990
+ state: FinanceState;
991
+ value: BatchDetail;
992
+ };
993
+ export declare function generateReports(state: FinanceState, input: GenerateReportsInput): FinanceReports;
994
+ export declare function exportBackup(state: FinanceState, exportedAt?: string): BackupEnvelope;
995
+ export declare function previewBackup(_state: FinanceState, input: PreviewBackupInput): BackupPreview;
996
+ export declare function restoreBackup(state: FinanceState, input: RestoreBackupInput, env?: StateEnvironment): {
997
+ state: FinanceState;
998
+ value: FinanceBootstrap;
999
+ };