@firela/api-types 0.0.0-canary.2b8fcbd8 → 0.0.0-canary.2fbeefe9

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.
@@ -6,13 +6,7 @@ export const $CreateAccountDto = {
6
6
  path: {
7
7
  type: 'string',
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
- example: 'Assets:CN:Bank:ICBC:Checking'
10
- },
11
- displayName: {
12
- type: 'string',
13
- description:
14
- 'Display name to distinguish accounts at the same path (default: "")',
15
- example: '工资卡'
9
+ example: 'Assets:CN:ICBC:Checking'
16
10
  },
17
11
  openDate: {
18
12
  format: 'date-time',
@@ -45,18 +39,13 @@ export const $CreateAccountDto = {
45
39
  templatePath: {
46
40
  type: 'string',
47
41
  description: 'Reference to account-standards template path',
48
- example: 'Assets:CN:Bank:ICBC:Checking'
42
+ example: 'Assets:CN:Checking'
49
43
  },
50
44
  isCustom: {
51
45
  type: 'boolean',
52
46
  description: 'Whether this is a custom (user-created) account',
53
47
  default: false
54
48
  },
55
- i18nKey: {
56
- type: 'string',
57
- description: 'i18n key for display name (overrides template)',
58
- example: 'account.custom.mybank'
59
- },
60
49
  icon: {
61
50
  type: 'string',
62
51
  description: 'Icon identifier (overrides template)',
@@ -90,13 +79,7 @@ export const $AccountResponseDto = {
90
79
  path: {
91
80
  type: 'string',
92
81
  description: 'Account path (hierarchical, colon-separated)',
93
- example: 'Assets:CN:Bank:ICBC:Checking'
94
- },
95
- displayName: {
96
- type: 'string',
97
- description:
98
- 'Display name distinguishing multiple accounts at the same path',
99
- example: '工资卡'
82
+ example: 'Assets:CN:ICBC:Checking'
100
83
  },
101
84
  type: {
102
85
  type: 'string',
@@ -145,17 +128,17 @@ export const $AccountResponseDto = {
145
128
  templatePath: {
146
129
  type: 'string',
147
130
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
131
+ example: 'Assets:CN:Checking'
149
132
  },
150
133
  isCustom: {
151
134
  type: 'boolean',
152
135
  description: 'Whether this is a custom (user-created) account',
153
136
  example: false
154
137
  },
155
- i18nKey: {
138
+ displayName: {
156
139
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
140
+ description: 'Localized display name (ADR-0114, read-time projection)',
141
+ example: 'Checking'
159
142
  },
160
143
  icon: {
161
144
  type: 'string',
@@ -192,7 +175,6 @@ export const $AccountResponseDto = {
192
175
  required: [
193
176
  'id',
194
177
  'path',
195
- 'displayName',
196
178
  'type',
197
179
  'status',
198
180
  'openDate',
@@ -225,11 +207,6 @@ export const $AccountListResponseDto = {
225
207
  export const $UpdateAccountDto = {
226
208
  type: 'object',
227
209
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
210
  currencies: {
234
211
  description: 'Allowed currencies (null = no restriction)',
235
212
  example: ['CNY', 'USD'],
@@ -251,11 +228,6 @@ export const $UpdateAccountDto = {
251
228
  'NONE'
252
229
  ]
253
230
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
231
  icon: {
260
232
  type: 'string',
261
233
  description: 'Icon identifier',
@@ -316,7 +288,7 @@ export const $AccountStandardResponseDto = {
316
288
  path: {
317
289
  type: 'string',
318
290
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
291
+ example: 'Assets:CN:Checking'
320
292
  },
321
293
  type: {
322
294
  type: 'string',
@@ -324,11 +296,6 @@ export const $AccountStandardResponseDto = {
324
296
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
297
  example: 'Assets'
326
298
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
299
  name: {
333
300
  type: 'string',
334
301
  description: 'Short localized display name',
@@ -353,7 +320,7 @@ export const $AccountStandardResponseDto = {
353
320
  example: 'bank-icbc'
354
321
  }
355
322
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
323
+ required: ['path', 'type', 'description', 'tags', 'icon']
357
324
  } as const;
358
325
 
359
326
  export const $AccountStandardListResponseDto = {
@@ -383,18 +350,13 @@ export const $AccountStandardListResponseDto = {
383
350
  export const $TemplateMetadataDto = {
384
351
  type: 'object',
385
352
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
353
  rootType: {
392
354
  type: 'string',
393
355
  description: 'Root account type',
394
356
  example: 'Assets'
395
357
  }
396
358
  },
397
- required: ['extendable', 'rootType']
359
+ required: ['rootType']
398
360
  } as const;
399
361
 
400
362
  export const $TemplateMetadataResponseDto = {
@@ -533,7 +495,7 @@ export const $CreatePostingDto = {
533
495
  type: 'string',
534
496
  description:
535
497
  'Account name in Beancount format (must start with uppercase, colon-separated)',
536
- example: 'Assets:Bank:Checking'
498
+ example: 'Assets:Checking'
537
499
  },
538
500
  units: {
539
501
  type: 'string',
@@ -692,7 +654,7 @@ export const $PostingResponseDto = {
692
654
  account: {
693
655
  type: 'string',
694
656
  description: 'Account name',
695
- example: 'Assets:Bank:Checking'
657
+ example: 'Assets:Checking'
696
658
  },
697
659
  units: {
698
660
  type: 'string',
@@ -1058,7 +1020,7 @@ export const $PostingDetailDto = {
1058
1020
  account: {
1059
1021
  type: 'string',
1060
1022
  description: 'Fully-qualified Beancount account path',
1061
- example: 'Assets:Bank:Checking'
1023
+ example: 'Assets:Checking'
1062
1024
  },
1063
1025
  units: {
1064
1026
  type: 'string',
@@ -1247,6 +1209,77 @@ export const $TransactionDetailDto = {
1247
1209
  ]
1248
1210
  } as const;
1249
1211
 
1212
+ export const $BalanceByCurrencyDto = {
1213
+ type: 'object',
1214
+ properties: {
1215
+ currency: {
1216
+ type: 'string',
1217
+ description: 'ISO 4217 currency code',
1218
+ example: 'CNY'
1219
+ },
1220
+ balance: {
1221
+ type: 'string',
1222
+ description: 'Balance amount',
1223
+ example: '50000.00'
1224
+ }
1225
+ },
1226
+ required: ['currency', 'balance']
1227
+ } as const;
1228
+
1229
+ export const $ExchangeRateWarningDto = {
1230
+ type: 'object',
1231
+ properties: {
1232
+ type: {
1233
+ type: 'string',
1234
+ description: 'Warning type',
1235
+ example: 'MISSING_EXCHANGE_RATE'
1236
+ },
1237
+ currency: {
1238
+ type: 'string',
1239
+ description: 'Currency without exchange rate',
1240
+ example: 'EUR'
1241
+ },
1242
+ totalAmount: {
1243
+ type: 'string',
1244
+ description: 'Total amount affected',
1245
+ example: '1000.00'
1246
+ }
1247
+ },
1248
+ required: ['type', 'currency', 'totalAmount']
1249
+ } as const;
1250
+
1251
+ export const $TransactionListSummaryDto = {
1252
+ type: 'object',
1253
+ properties: {
1254
+ totalAmount: {
1255
+ type: 'string',
1256
+ description:
1257
+ 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1258
+ example: '-6000.00'
1259
+ },
1260
+ currency: {
1261
+ type: 'string',
1262
+ description: 'Base currency (ISO 4217)',
1263
+ example: 'CNY'
1264
+ },
1265
+ balanceByCurrency: {
1266
+ description: 'Raw (unconverted) balance per currency',
1267
+ type: 'array',
1268
+ items: {
1269
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1270
+ }
1271
+ },
1272
+ warnings: {
1273
+ description: 'Currencies missing an FX rate (omitted when empty)',
1274
+ type: 'array',
1275
+ items: {
1276
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1277
+ }
1278
+ }
1279
+ },
1280
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1281
+ } as const;
1282
+
1250
1283
  export const $TransactionListResponseDto = {
1251
1284
  type: 'object',
1252
1285
  properties: {
@@ -1271,6 +1304,15 @@ export const $TransactionListResponseDto = {
1271
1304
  type: 'number',
1272
1305
  description: 'Number of items skipped',
1273
1306
  example: 0
1307
+ },
1308
+ summary: {
1309
+ description:
1310
+ 'Amount summary for the full filtered set (#514). Present only when the request has a single account OR category viewpoint; omitted for search-only / plain-list / dual-perspective requests.',
1311
+ allOf: [
1312
+ {
1313
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1314
+ }
1315
+ ]
1274
1316
  }
1275
1317
  },
1276
1318
  required: ['data', 'total', 'limit', 'offset']
@@ -1370,7 +1412,7 @@ export const $BalanceResponseDto = {
1370
1412
  account: {
1371
1413
  type: 'string',
1372
1414
  description: 'Account name',
1373
- example: 'Assets:Bank:Checking'
1415
+ example: 'Assets:Checking'
1374
1416
  },
1375
1417
  balance: {
1376
1418
  type: 'string',
@@ -1397,7 +1439,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1397
1439
  account: {
1398
1440
  type: 'string',
1399
1441
  description: 'Account name',
1400
- example: 'Assets:Bank:Checking'
1442
+ example: 'Assets:Checking'
1401
1443
  },
1402
1444
  balances: {
1403
1445
  type: 'object',
@@ -1453,7 +1495,7 @@ export const $TransactionSummaryDto = {
1453
1495
  accountName: {
1454
1496
  type: 'string',
1455
1497
  description: 'Source account name (first posting)',
1456
- example: 'Assets:Bank:Checking'
1498
+ example: 'Assets:Checking'
1457
1499
  },
1458
1500
  sourceType: {
1459
1501
  type: 'string',
@@ -2745,6 +2787,163 @@ export const $UpdateCommodityDto = {
2745
2787
  }
2746
2788
  } as const;
2747
2789
 
2790
+ export const $CreateBeanPriceDto = {
2791
+ type: 'object',
2792
+ properties: {
2793
+ currency: {
2794
+ type: 'string',
2795
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2796
+ example: 'USD'
2797
+ },
2798
+ quoteCurrency: {
2799
+ type: 'string',
2800
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2801
+ example: 'CNY'
2802
+ },
2803
+ amount: {
2804
+ type: 'number',
2805
+ description:
2806
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2807
+ example: 175.5,
2808
+ minimum: 0
2809
+ },
2810
+ date: {
2811
+ type: 'string',
2812
+ description: 'Price date (ISO 8601 format)',
2813
+ example: '2024-11-05'
2814
+ },
2815
+ metadata: {
2816
+ type: 'object',
2817
+ description:
2818
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2819
+ example: {
2820
+ source: 'MANUAL',
2821
+ note: 'Bank valuation report',
2822
+ confidence: 0.95
2823
+ }
2824
+ }
2825
+ },
2826
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2827
+ } as const;
2828
+
2829
+ export const $PriceResponseDto = {
2830
+ type: 'object',
2831
+ properties: {
2832
+ id: {
2833
+ type: 'string',
2834
+ description: 'Unique identifier',
2835
+ example: 'uuid-123-456'
2836
+ },
2837
+ userId: {
2838
+ type: 'string',
2839
+ description: 'User ID (owner of the price)',
2840
+ example: 'user-123'
2841
+ },
2842
+ currency: {
2843
+ type: 'string',
2844
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2845
+ example: 'BTC'
2846
+ },
2847
+ quoteCurrency: {
2848
+ type: 'string',
2849
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2850
+ example: 'USD'
2851
+ },
2852
+ amount: {
2853
+ type: 'number',
2854
+ description:
2855
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2856
+ example: 50000
2857
+ },
2858
+ date: {
2859
+ type: 'string',
2860
+ description:
2861
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2862
+ example: '2024-01-01',
2863
+ format: 'date'
2864
+ },
2865
+ meta: {
2866
+ type: 'object',
2867
+ description:
2868
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2869
+ example: {
2870
+ source: 'MANUAL',
2871
+ note: 'User-defined price',
2872
+ confidence: 1
2873
+ }
2874
+ },
2875
+ createdAt: {
2876
+ format: 'date-time',
2877
+ type: 'string',
2878
+ description: 'Creation timestamp',
2879
+ example: '2024-11-03T10:00:00Z'
2880
+ },
2881
+ updatedAt: {
2882
+ format: 'date-time',
2883
+ type: 'string',
2884
+ description: 'Last update timestamp',
2885
+ example: '2024-11-03T10:00:00Z'
2886
+ }
2887
+ },
2888
+ required: [
2889
+ 'id',
2890
+ 'userId',
2891
+ 'currency',
2892
+ 'quoteCurrency',
2893
+ 'amount',
2894
+ 'date',
2895
+ 'meta',
2896
+ 'createdAt',
2897
+ 'updatedAt'
2898
+ ]
2899
+ } as const;
2900
+
2901
+ export const $PriceListResponseDto = {
2902
+ type: 'object',
2903
+ properties: {
2904
+ items: {
2905
+ description: 'List of prices',
2906
+ type: 'array',
2907
+ items: {
2908
+ $ref: '#/components/schemas/PriceResponseDto'
2909
+ }
2910
+ },
2911
+ total: {
2912
+ type: 'number',
2913
+ description: 'Total number of prices',
2914
+ example: 42
2915
+ }
2916
+ },
2917
+ required: ['items', 'total']
2918
+ } as const;
2919
+
2920
+ export const $UpdateBeanPriceDto = {
2921
+ type: 'object',
2922
+ properties: {
2923
+ currency: {
2924
+ type: 'string',
2925
+ description: 'Currency being priced'
2926
+ },
2927
+ quoteCurrency: {
2928
+ type: 'string',
2929
+ description: 'Quote currency (pricing currency)'
2930
+ },
2931
+ amount: {
2932
+ type: 'number',
2933
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
2934
+ minimum: 0
2935
+ },
2936
+ date: {
2937
+ type: 'string',
2938
+ description: 'Price date (ISO 8601 format)'
2939
+ },
2940
+ metadata: {
2941
+ type: 'object',
2942
+ description: 'Metadata'
2943
+ }
2944
+ }
2945
+ } as const;
2946
+
2748
2947
  export const $CreateRecurringRuleDto = {
2749
2948
  type: 'object',
2750
2949
  properties: {
@@ -4312,10 +4511,399 @@ export const $UpdatePropertyDto = {
4312
4511
  required: ['value']
4313
4512
  } as const;
4314
4513
 
4315
- export const $FileImportDto = {
4514
+ export const $CreateBeanEventDto = {
4316
4515
  type: 'object',
4317
4516
  properties: {
4318
- file: {
4517
+ date: {
4518
+ type: 'string',
4519
+ description: 'Life event date (ISO 8601)',
4520
+ example: '2024-03-15'
4521
+ },
4522
+ type: {
4523
+ type: 'string',
4524
+ description:
4525
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4526
+ example: 'employer'
4527
+ },
4528
+ description: {
4529
+ type: 'string',
4530
+ description:
4531
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4532
+ example: 'Acme Corp'
4533
+ },
4534
+ meta: {
4535
+ type: 'object',
4536
+ description:
4537
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4538
+ example: {
4539
+ note: 'Promotion'
4540
+ }
4541
+ }
4542
+ },
4543
+ required: ['date', 'type', 'description']
4544
+ } as const;
4545
+
4546
+ export const $EventResponseDto = {
4547
+ type: 'object',
4548
+ properties: {
4549
+ id: {
4550
+ type: 'string',
4551
+ description: 'Unique identifier',
4552
+ example: 'uuid-123-456'
4553
+ },
4554
+ userId: {
4555
+ type: 'string',
4556
+ description: 'User ID (owner of the life event)',
4557
+ example: 'user-123'
4558
+ },
4559
+ date: {
4560
+ type: 'string',
4561
+ description: 'Life event date (ISO 8601 format)',
4562
+ example: '2024-03-15',
4563
+ format: 'date'
4564
+ },
4565
+ type: {
4566
+ type: 'string',
4567
+ description:
4568
+ 'Life event type (user-defined, e.g., "employer", "location")',
4569
+ example: 'employer'
4570
+ },
4571
+ description: {
4572
+ type: 'string',
4573
+ description:
4574
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4575
+ example: 'Acme Corp'
4576
+ },
4577
+ meta: {
4578
+ type: 'object',
4579
+ description: 'Product-side metadata (free-form JSON)',
4580
+ example: {
4581
+ note: 'Promotion'
4582
+ }
4583
+ },
4584
+ createdAt: {
4585
+ format: 'date-time',
4586
+ type: 'string',
4587
+ description: 'Creation timestamp',
4588
+ example: '2024-03-15T10:00:00Z'
4589
+ },
4590
+ updatedAt: {
4591
+ format: 'date-time',
4592
+ type: 'string',
4593
+ description:
4594
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4595
+ example: '2024-03-15T10:00:00Z'
4596
+ }
4597
+ },
4598
+ required: [
4599
+ 'id',
4600
+ 'userId',
4601
+ 'date',
4602
+ 'type',
4603
+ 'description',
4604
+ 'meta',
4605
+ 'createdAt',
4606
+ 'updatedAt'
4607
+ ]
4608
+ } as const;
4609
+
4610
+ export const $EventListResponseDto = {
4611
+ type: 'object',
4612
+ properties: {
4613
+ items: {
4614
+ description: 'List of life events',
4615
+ type: 'array',
4616
+ items: {
4617
+ $ref: '#/components/schemas/EventResponseDto'
4618
+ }
4619
+ },
4620
+ total: {
4621
+ type: 'number',
4622
+ description: 'Total number of life events matching the query',
4623
+ example: 42
4624
+ }
4625
+ },
4626
+ required: ['items', 'total']
4627
+ } as const;
4628
+
4629
+ export const $UpdateBeanEventDto = {
4630
+ type: 'object',
4631
+ properties: {
4632
+ date: {
4633
+ type: 'string',
4634
+ description: 'Life event date (ISO 8601)'
4635
+ },
4636
+ type: {
4637
+ type: 'string',
4638
+ description: 'Life event type (user-defined)'
4639
+ },
4640
+ description: {
4641
+ type: 'string',
4642
+ description:
4643
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
4644
+ },
4645
+ meta: {
4646
+ type: 'object',
4647
+ description: 'Product-side metadata (free-form JSON)'
4648
+ }
4649
+ }
4650
+ } as const;
4651
+
4652
+ export const $OnboardingAccountDto = {
4653
+ type: 'object',
4654
+ properties: {
4655
+ path: {
4656
+ type: 'string',
4657
+ description:
4658
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
4659
+ example: 'Assets:Checking'
4660
+ },
4661
+ currency: {
4662
+ type: 'string',
4663
+ description: 'ISO 4217 currency code (3 letters)',
4664
+ example: 'USD'
4665
+ },
4666
+ openingBalance: {
4667
+ type: 'string',
4668
+ description:
4669
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
4670
+ example: '1000.00'
4671
+ },
4672
+ platformId: {
4673
+ type: 'string',
4674
+ description:
4675
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
4676
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
4677
+ }
4678
+ },
4679
+ required: ['path', 'currency']
4680
+ } as const;
4681
+
4682
+ export const $OnboardingDto = {
4683
+ type: 'object',
4684
+ properties: {
4685
+ accounts: {
4686
+ description: 'Asset/Liability accounts to register with opening balances',
4687
+ type: 'array',
4688
+ items: {
4689
+ $ref: '#/components/schemas/OnboardingAccountDto'
4690
+ }
4691
+ },
4692
+ skipAssetRegistration: {
4693
+ type: 'boolean',
4694
+ description:
4695
+ 'Skip asset registration; only bootstrap the core account set',
4696
+ default: false
4697
+ }
4698
+ }
4699
+ } as const;
4700
+
4701
+ export const $ActualBalanceDto = {
4702
+ type: 'object',
4703
+ properties: {
4704
+ amount: {
4705
+ type: 'string',
4706
+ description:
4707
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
4708
+ example: '1234.56'
4709
+ },
4710
+ ccy: {
4711
+ type: 'string',
4712
+ description: 'Currency code (ISO 4217 or commodity ticker).',
4713
+ example: 'CNY'
4714
+ }
4715
+ },
4716
+ required: ['amount', 'ccy']
4717
+ } as const;
4718
+
4719
+ export const $ComputeReconciliationDto = {
4720
+ type: 'object',
4721
+ properties: {
4722
+ accountId: {
4723
+ type: 'string',
4724
+ description: 'BeanAccount id to reconcile.'
4725
+ },
4726
+ asOfDate: {
4727
+ type: 'string',
4728
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4729
+ example: '2026-07-24'
4730
+ },
4731
+ actualBalance: {
4732
+ description: 'Actual balance from the external statement.',
4733
+ allOf: [
4734
+ {
4735
+ $ref: '#/components/schemas/ActualBalanceDto'
4736
+ }
4737
+ ]
4738
+ }
4739
+ },
4740
+ required: ['accountId', 'asOfDate', 'actualBalance']
4741
+ } as const;
4742
+
4743
+ export const $ReconciliationComputeResultDto = {
4744
+ type: 'object',
4745
+ properties: {
4746
+ accountId: {
4747
+ type: 'string'
4748
+ },
4749
+ asOfDate: {
4750
+ type: 'string'
4751
+ },
4752
+ bookBalance: {
4753
+ type: 'string',
4754
+ description: 'System-computed book balance (decimal string).'
4755
+ },
4756
+ actualBalance: {
4757
+ type: 'string',
4758
+ description: 'User-entered actual balance (decimal string).'
4759
+ },
4760
+ currency: {
4761
+ type: 'string'
4762
+ },
4763
+ diff: {
4764
+ type: 'string',
4765
+ description: 'Diff = book − actual (decimal string).'
4766
+ },
4767
+ tolerance: {
4768
+ type: 'string',
4769
+ description: 'Applied tolerance (decimal string).'
4770
+ },
4771
+ withinTolerance: {
4772
+ type: 'boolean',
4773
+ description: 'true when |diff| ≤ tolerance.'
4774
+ },
4775
+ suggestedAction: {
4776
+ type: 'string',
4777
+ enum: ['assert', 'pad'],
4778
+ description:
4779
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
4780
+ }
4781
+ },
4782
+ required: [
4783
+ 'accountId',
4784
+ 'asOfDate',
4785
+ 'bookBalance',
4786
+ 'actualBalance',
4787
+ 'currency',
4788
+ 'diff',
4789
+ 'tolerance',
4790
+ 'withinTolerance',
4791
+ 'suggestedAction'
4792
+ ]
4793
+ } as const;
4794
+
4795
+ export const $AssertReconciliationDto = {
4796
+ type: 'object',
4797
+ properties: {
4798
+ accountId: {
4799
+ type: 'string',
4800
+ description: 'BeanAccount id to reconcile.'
4801
+ },
4802
+ asOfDate: {
4803
+ type: 'string',
4804
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4805
+ example: '2026-07-24'
4806
+ },
4807
+ actualBalance: {
4808
+ description: 'Actual balance from the external statement.',
4809
+ allOf: [
4810
+ {
4811
+ $ref: '#/components/schemas/ActualBalanceDto'
4812
+ }
4813
+ ]
4814
+ },
4815
+ tolerance: {
4816
+ type: 'string',
4817
+ description:
4818
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
4819
+ example: '0.01'
4820
+ }
4821
+ },
4822
+ required: ['accountId', 'asOfDate', 'actualBalance']
4823
+ } as const;
4824
+
4825
+ export const $ReconciliationRecordDto = {
4826
+ type: 'object',
4827
+ properties: {
4828
+ id: {
4829
+ type: 'string'
4830
+ },
4831
+ accountId: {
4832
+ type: 'string'
4833
+ },
4834
+ date: {
4835
+ type: 'string'
4836
+ },
4837
+ amount: {
4838
+ type: 'string',
4839
+ description: 'Asserted (actual) amount.'
4840
+ },
4841
+ currency: {
4842
+ type: 'string'
4843
+ },
4844
+ tolerance: {
4845
+ type: 'string'
4846
+ },
4847
+ diffAmount: {
4848
+ type: 'string',
4849
+ description: 'book − actual.'
4850
+ },
4851
+ diffCurrency: {
4852
+ type: 'string'
4853
+ },
4854
+ createdAt: {
4855
+ type: 'string'
4856
+ }
4857
+ },
4858
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
4859
+ } as const;
4860
+
4861
+ export const $PadReconciliationDto = {
4862
+ type: 'object',
4863
+ properties: {
4864
+ accountId: {
4865
+ type: 'string',
4866
+ description: 'BeanAccount id to reconcile.'
4867
+ },
4868
+ asOfDate: {
4869
+ type: 'string',
4870
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4871
+ example: '2026-07-24'
4872
+ },
4873
+ actualBalance: {
4874
+ description: 'Actual balance from the external statement.',
4875
+ allOf: [
4876
+ {
4877
+ $ref: '#/components/schemas/ActualBalanceDto'
4878
+ }
4879
+ ]
4880
+ },
4881
+ sourceAccount: {
4882
+ type: 'string',
4883
+ description:
4884
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
4885
+ example: 'Equity:Opening-Balances',
4886
+ default: 'Equity:Opening-Balances'
4887
+ }
4888
+ },
4889
+ required: ['accountId', 'asOfDate', 'actualBalance']
4890
+ } as const;
4891
+
4892
+ export const $PadResultDto = {
4893
+ type: 'object',
4894
+ properties: {
4895
+ transactionId: {
4896
+ type: 'string',
4897
+ description: 'Created pad adjusting transaction id.'
4898
+ }
4899
+ },
4900
+ required: ['transactionId']
4901
+ } as const;
4902
+
4903
+ export const $FileImportDto = {
4904
+ type: 'object',
4905
+ properties: {
4906
+ file: {
4319
4907
  type: 'string',
4320
4908
  format: 'binary',
4321
4909
  description: 'Bill file to import (CSV, PDF, OFX, etc.)',
@@ -4478,7 +5066,7 @@ export const $IdentifyResultDto = {
4478
5066
  account: {
4479
5067
  type: 'string',
4480
5068
  description: 'Default account used by this importer',
4481
- example: 'Assets:Alipay:Balance'
5069
+ example: 'Assets:CN:Alipay:Balance'
4482
5070
  },
4483
5071
  message: {
4484
5072
  type: 'string',
@@ -4495,7 +5083,7 @@ export const $MapperDefaultsDto = {
4495
5083
  sourceAccount: {
4496
5084
  type: 'string',
4497
5085
  description: 'Source account for transactions (Beancount format)',
4498
- example: 'Assets:Alipay:Balance'
5086
+ example: 'Assets:CN:Alipay:Balance'
4499
5087
  },
4500
5088
  currency: {
4501
5089
  type: 'string',
@@ -4532,7 +5120,7 @@ export const $MapperDefaultsDto = {
4532
5120
  description:
4533
5121
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4534
5122
  example: {
4535
- HuaBei: 'Liabilities:Alipay:Huabei',
5123
+ HuaBei: 'Liabilities:CN:CreditLine',
4536
5124
  CreditCard: 'Liabilities:CreditCard'
4537
5125
  }
4538
5126
  }
@@ -4664,7 +5252,7 @@ export const $UpdateMapperDefaultsDto = {
4664
5252
  sourceAccount: {
4665
5253
  type: 'string',
4666
5254
  description: 'Source account for transactions (Beancount format)',
4667
- example: 'Assets:Alipay:Balance',
5255
+ example: 'Assets:CN:Alipay:Balance',
4668
5256
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4669
5257
  },
4670
5258
  currency: {
@@ -4692,7 +5280,7 @@ export const $UpdateMapperDefaultsDto = {
4692
5280
  description:
4693
5281
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4694
5282
  example: {
4695
- HuaBei: 'Liabilities:Alipay:Huabei',
5283
+ HuaBei: 'Liabilities:CN:CreditLine',
4696
5284
  CreditCard: 'Liabilities:CreditCard'
4697
5285
  }
4698
5286
  }
@@ -4727,119 +5315,13 @@ export const $UpdateImporterConfigDto = {
4727
5315
  }
4728
5316
  } as const;
4729
5317
 
4730
- export const $CreatePlatformDto = {
4731
- type: 'object',
4732
- properties: {
4733
- name: {
4734
- type: 'string',
4735
- description: 'Platform name',
4736
- example: 'Binance'
4737
- },
4738
- canonical: {
4739
- type: 'string',
4740
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4741
- example: 'binance'
4742
- },
4743
- aliases: {
4744
- description: 'Platform aliases (multi-language names for lookup)',
4745
- example: ['Binance', 'Binance Exchange', 'BNB'],
4746
- type: 'array',
4747
- items: {
4748
- type: 'string'
4749
- }
4750
- },
4751
- url: {
4752
- type: 'string',
4753
- description: 'Platform URL',
4754
- example: 'https://www.binance.com'
4755
- },
4756
- type: {
4757
- type: 'string',
4758
- description: 'Platform type',
4759
- enum: [
4760
- 'BANK',
4761
- 'BROKERAGE',
4762
- 'CRYPTO_EXCHANGE',
4763
- 'PAYMENT',
4764
- 'INVESTMENT',
4765
- 'INSURANCE',
4766
- 'OTHER'
4767
- ],
4768
- example: 'CRYPTO_EXCHANGE'
4769
- },
4770
- logoUrl: {
4771
- type: 'string',
4772
- description: 'Platform logo URL',
4773
- example: 'https://example.com/logos/binance.png'
4774
- },
4775
- isActive: {
4776
- type: 'boolean',
4777
- description: 'Whether the platform is active',
4778
- default: true
4779
- }
4780
- },
4781
- required: ['name', 'canonical', 'aliases', 'url', 'type']
4782
- } as const;
4783
-
4784
- export const $UpdatePlatformDto = {
4785
- type: 'object',
4786
- properties: {
4787
- name: {
4788
- type: 'string',
4789
- description: 'Platform name',
4790
- example: 'Binance'
4791
- },
4792
- canonical: {
4793
- type: 'string',
4794
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4795
- example: 'binance'
4796
- },
4797
- aliases: {
4798
- description: 'Platform aliases (multi-language names for lookup)',
4799
- example: ['Binance', 'Binance Exchange', 'BNB'],
4800
- type: 'array',
4801
- items: {
4802
- type: 'string'
4803
- }
4804
- },
4805
- url: {
4806
- type: 'string',
4807
- description: 'Platform URL',
4808
- example: 'https://www.binance.com'
4809
- },
4810
- type: {
4811
- type: 'string',
4812
- description: 'Platform type',
4813
- enum: [
4814
- 'BANK',
4815
- 'BROKERAGE',
4816
- 'CRYPTO_EXCHANGE',
4817
- 'PAYMENT',
4818
- 'INVESTMENT',
4819
- 'INSURANCE',
4820
- 'OTHER'
4821
- ],
4822
- example: 'CRYPTO_EXCHANGE'
4823
- },
4824
- logoUrl: {
4825
- type: 'string',
4826
- description: 'Platform logo URL',
4827
- example: 'https://example.com/logos/binance.png'
4828
- },
4829
- isActive: {
4830
- type: 'boolean',
4831
- description: 'Whether the platform is active'
4832
- }
4833
- }
4834
- } as const;
4835
-
4836
5318
  export const $ProviderSyncConfigDto = {
4837
5319
  type: 'object',
4838
5320
  properties: {
4839
5321
  sourceAccount: {
4840
5322
  type: 'string',
4841
5323
  description: 'Source account for the first posting',
4842
- example: 'Assets:Bank:Chase'
5324
+ example: 'Assets:US:Chase:Checking'
4843
5325
  },
4844
5326
  defaultCurrency: {
4845
5327
  type: 'string',
@@ -4860,6 +5342,12 @@ export const $ProviderSyncConfigDto = {
4860
5342
  type: 'boolean',
4861
5343
  description: 'Filter pending transactions',
4862
5344
  default: true
5345
+ },
5346
+ externalAccountId: {
5347
+ type: 'string',
5348
+ description:
5349
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5350
+ example: 'acc_gocardless_001'
4863
5351
  }
4864
5352
  },
4865
5353
  required: [
@@ -4979,6 +5467,94 @@ export const $SupportedProvidersResponseDto = {
4979
5467
  required: ['providers']
4980
5468
  } as const;
4981
5469
 
5470
+ export const $CreateExternalAccountLinkDto = {
5471
+ type: 'object',
5472
+ properties: {
5473
+ provider: {
5474
+ type: 'string',
5475
+ enum: [
5476
+ 'plaid',
5477
+ 'teller',
5478
+ 'truelayer',
5479
+ 'gocardless',
5480
+ 'simplefin',
5481
+ 'yodlee',
5482
+ 'beancount-direct',
5483
+ 'parsed-bill'
5484
+ ],
5485
+ example: 'plaid',
5486
+ description: 'Open Banking provider (whitelist)'
5487
+ },
5488
+ externalAccountId: {
5489
+ type: 'string',
5490
+ example: 'acc-plaid-001',
5491
+ description: 'External account ID from the provider'
5492
+ },
5493
+ beanAccountId: {
5494
+ type: 'string',
5495
+ example: '550e8400-e29b-41d4-a716-446655440000',
5496
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5497
+ }
5498
+ },
5499
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5500
+ } as const;
5501
+
5502
+ export const $ExternalAccountLinkResponseDto = {
5503
+ type: 'object',
5504
+ properties: {
5505
+ id: {
5506
+ type: 'string'
5507
+ },
5508
+ provider: {
5509
+ type: 'string'
5510
+ },
5511
+ externalAccountId: {
5512
+ type: 'string'
5513
+ },
5514
+ beanAccountId: {
5515
+ type: 'string'
5516
+ },
5517
+ isActive: {
5518
+ type: 'boolean'
5519
+ },
5520
+ createdAt: {
5521
+ type: 'string'
5522
+ },
5523
+ updatedAt: {
5524
+ type: 'string'
5525
+ }
5526
+ },
5527
+ required: [
5528
+ 'id',
5529
+ 'provider',
5530
+ 'externalAccountId',
5531
+ 'beanAccountId',
5532
+ 'isActive',
5533
+ 'createdAt',
5534
+ 'updatedAt'
5535
+ ]
5536
+ } as const;
5537
+
5538
+ export const $ExternalAccountLinkListResponseDto = {
5539
+ type: 'object',
5540
+ properties: {
5541
+ items: {
5542
+ type: 'array',
5543
+ items: {
5544
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5545
+ }
5546
+ },
5547
+ total: {
5548
+ type: 'number'
5549
+ },
5550
+ provider: {
5551
+ type: 'string',
5552
+ description: 'Filter by provider (query param)'
5553
+ }
5554
+ },
5555
+ required: ['items', 'total']
5556
+ } as const;
5557
+
4982
5558
  export const $ParserTelemetryReportDto = {
4983
5559
  type: 'object',
4984
5560
  properties: {}
@@ -5528,7 +6104,7 @@ export const $NlpSuggestedAccountDto = {
5528
6104
  account: {
5529
6105
  type: 'string',
5530
6106
  description: 'Suggested account path',
5531
- example: 'Assets:Bank:Checking'
6107
+ example: 'Assets:Checking'
5532
6108
  },
5533
6109
  confidence: {
5534
6110
  type: 'number',
@@ -5569,7 +6145,7 @@ export const $NlpDefaultAccountsDto = {
5569
6145
  asset: {
5570
6146
  type: 'string',
5571
6147
  description: 'Default asset account',
5572
- example: 'Assets:Bank:Checking'
6148
+ example: 'Assets:Checking'
5573
6149
  },
5574
6150
  expense: {
5575
6151
  type: 'string',
@@ -5788,24 +6364,113 @@ export const $NlpResponseDto = {
5788
6364
  ]
5789
6365
  }
5790
6366
  },
5791
- required: ['status', 'action']
6367
+ required: ['status', 'action']
6368
+ } as const;
6369
+
6370
+ export const $CreatePlatformDto = {
6371
+ type: 'object',
6372
+ properties: {
6373
+ name: {
6374
+ type: 'string',
6375
+ description: 'Platform name',
6376
+ example: 'Binance'
6377
+ },
6378
+ canonical: {
6379
+ type: 'string',
6380
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6381
+ example: 'binance'
6382
+ },
6383
+ aliases: {
6384
+ description: 'Platform aliases (multi-language names for lookup)',
6385
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6386
+ type: 'array',
6387
+ items: {
6388
+ type: 'string'
6389
+ }
6390
+ },
6391
+ url: {
6392
+ type: 'string',
6393
+ description: 'Platform URL',
6394
+ example: 'https://www.binance.com'
6395
+ },
6396
+ type: {
6397
+ type: 'string',
6398
+ description: 'Platform type',
6399
+ enum: [
6400
+ 'BANK',
6401
+ 'BROKERAGE',
6402
+ 'CRYPTO_EXCHANGE',
6403
+ 'PAYMENT',
6404
+ 'INVESTMENT',
6405
+ 'INSURANCE',
6406
+ 'OTHER'
6407
+ ],
6408
+ example: 'CRYPTO_EXCHANGE'
6409
+ },
6410
+ logoUrl: {
6411
+ type: 'string',
6412
+ description: 'Platform logo URL',
6413
+ example: 'https://example.com/logos/binance.png'
6414
+ },
6415
+ isActive: {
6416
+ type: 'boolean',
6417
+ description: 'Whether the platform is active',
6418
+ default: true
6419
+ }
6420
+ },
6421
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5792
6422
  } as const;
5793
6423
 
5794
- export const $BalanceByCurrencyDto = {
6424
+ export const $UpdatePlatformDto = {
5795
6425
  type: 'object',
5796
6426
  properties: {
5797
- currency: {
6427
+ name: {
5798
6428
  type: 'string',
5799
- description: 'ISO 4217 currency code',
5800
- example: 'CNY'
6429
+ description: 'Platform name',
6430
+ example: 'Binance'
5801
6431
  },
5802
- balance: {
6432
+ canonical: {
5803
6433
  type: 'string',
5804
- description: 'Balance amount',
5805
- example: '50000.00'
6434
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6435
+ example: 'binance'
6436
+ },
6437
+ aliases: {
6438
+ description: 'Platform aliases (multi-language names for lookup)',
6439
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6440
+ type: 'array',
6441
+ items: {
6442
+ type: 'string'
6443
+ }
6444
+ },
6445
+ url: {
6446
+ type: 'string',
6447
+ description: 'Platform URL',
6448
+ example: 'https://www.binance.com'
6449
+ },
6450
+ type: {
6451
+ type: 'string',
6452
+ description: 'Platform type',
6453
+ enum: [
6454
+ 'BANK',
6455
+ 'BROKERAGE',
6456
+ 'CRYPTO_EXCHANGE',
6457
+ 'PAYMENT',
6458
+ 'INVESTMENT',
6459
+ 'INSURANCE',
6460
+ 'OTHER'
6461
+ ],
6462
+ example: 'CRYPTO_EXCHANGE'
6463
+ },
6464
+ logoUrl: {
6465
+ type: 'string',
6466
+ description: 'Platform logo URL',
6467
+ example: 'https://example.com/logos/binance.png'
6468
+ },
6469
+ isActive: {
6470
+ type: 'boolean',
6471
+ description: 'Whether the platform is active'
5806
6472
  }
5807
- },
5808
- required: ['currency', 'balance']
6473
+ }
5809
6474
  } as const;
5810
6475
 
5811
6476
  export const $NetWorthByCurrencyDto = {
@@ -5877,28 +6542,6 @@ export const $ConvertedNetWorthDto = {
5877
6542
  ]
5878
6543
  } as const;
5879
6544
 
5880
- export const $ExchangeRateWarningDto = {
5881
- type: 'object',
5882
- properties: {
5883
- type: {
5884
- type: 'string',
5885
- description: 'Warning type',
5886
- example: 'MISSING_EXCHANGE_RATE'
5887
- },
5888
- currency: {
5889
- type: 'string',
5890
- description: 'Currency without exchange rate',
5891
- example: 'EUR'
5892
- },
5893
- totalAmount: {
5894
- type: 'string',
5895
- description: 'Total amount affected',
5896
- example: '1000.00'
5897
- }
5898
- },
5899
- required: ['type', 'currency', 'totalAmount']
5900
- } as const;
5901
-
5902
6545
  export const $NetWorthResponseDto = {
5903
6546
  type: 'object',
5904
6547
  properties: {
@@ -5984,7 +6627,7 @@ export const $AccountItemDto = {
5984
6627
  name: {
5985
6628
  type: 'string',
5986
6629
  description: 'Full account name',
5987
- example: 'Assets:Bank:CMB:Savings'
6630
+ example: 'Assets:CN:CMB:Savings'
5988
6631
  },
5989
6632
  displayName: {
5990
6633
  type: 'string',
@@ -6000,6 +6643,12 @@ export const $AccountItemDto = {
6000
6643
  type: 'string',
6001
6644
  description: 'Currency code',
6002
6645
  example: 'CNY'
6646
+ },
6647
+ convertedBalance: {
6648
+ type: 'string',
6649
+ description:
6650
+ 'FX-converted balance in base currency; omitted when not convertible',
6651
+ example: '50000.00'
6003
6652
  }
6004
6653
  },
6005
6654
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -6026,11 +6675,66 @@ export const $PlatformGroupDto = {
6026
6675
  },
6027
6676
  totalBalance: {
6028
6677
  type: 'string',
6029
- description: 'Total balance across all accounts in platform',
6678
+ description: 'FX-converted total balance in base currency',
6679
+ example: '100000.00'
6680
+ },
6681
+ balanceByCurrency: {
6682
+ description: 'Raw (unconverted) balances grouped by currency',
6683
+ type: 'array',
6684
+ items: {
6685
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6686
+ }
6687
+ },
6688
+ convertedBalance: {
6689
+ type: 'string',
6690
+ description:
6691
+ 'Converted balance in base currency (omitted when no currency is convertible)',
6030
6692
  example: '100000.00'
6693
+ },
6694
+ sharePct: {
6695
+ type: 'number',
6696
+ description:
6697
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
6698
+ example: 42.5
6699
+ }
6700
+ },
6701
+ required: [
6702
+ 'platformId',
6703
+ 'platformName',
6704
+ 'accounts',
6705
+ 'totalBalance',
6706
+ 'balanceByCurrency',
6707
+ 'sharePct'
6708
+ ]
6709
+ } as const;
6710
+
6711
+ export const $AccountExchangeRateWarningDto = {
6712
+ type: 'object',
6713
+ properties: {
6714
+ type: {
6715
+ type: 'string',
6716
+ description: 'Warning type',
6717
+ example: 'MISSING_EXCHANGE_RATE'
6718
+ },
6719
+ currency: {
6720
+ type: 'string',
6721
+ description: 'Currency without exchange rate',
6722
+ example: 'USD'
6723
+ },
6724
+ accounts: {
6725
+ description: 'Affected account paths',
6726
+ type: 'array',
6727
+ items: {
6728
+ type: 'string'
6729
+ }
6730
+ },
6731
+ totalAmount: {
6732
+ type: 'string',
6733
+ description: 'Total amount in this currency',
6734
+ example: '5000.00'
6031
6735
  }
6032
6736
  },
6033
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
6737
+ required: ['type', 'currency', 'accounts', 'totalAmount']
6034
6738
  } as const;
6035
6739
 
6036
6740
  export const $AccountsSummaryDto = {
@@ -6043,9 +6747,21 @@ export const $AccountsSummaryDto = {
6043
6747
  totalPlatforms: {
6044
6748
  type: 'number',
6045
6749
  description: 'Total number of platforms'
6750
+ },
6751
+ baseCurrency: {
6752
+ type: 'string',
6753
+ description: 'Base currency for conversion',
6754
+ example: 'CNY'
6755
+ },
6756
+ warnings: {
6757
+ description: 'Per-account exchange rate warnings',
6758
+ type: 'array',
6759
+ items: {
6760
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6761
+ }
6046
6762
  }
6047
6763
  },
6048
- required: ['totalAccounts', 'totalPlatforms']
6764
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6049
6765
  } as const;
6050
6766
 
6051
6767
  export const $AccountsResponseDto = {
@@ -6080,7 +6796,7 @@ export const $AccountItemWithAssetClassDto = {
6080
6796
  name: {
6081
6797
  type: 'string',
6082
6798
  description: 'Full account name',
6083
- example: 'Assets:Bank:CMB:Savings'
6799
+ example: 'Assets:CN:CMB:Savings'
6084
6800
  },
6085
6801
  displayName: {
6086
6802
  type: 'string',
@@ -6097,6 +6813,12 @@ export const $AccountItemWithAssetClassDto = {
6097
6813
  description: 'Currency code',
6098
6814
  example: 'CNY'
6099
6815
  },
6816
+ convertedBalance: {
6817
+ type: 'string',
6818
+ description:
6819
+ 'FX-converted balance in base currency; omitted when not convertible',
6820
+ example: '50000.00'
6821
+ },
6100
6822
  assetClass: {
6101
6823
  type: 'string',
6102
6824
  description: 'Asset class',
@@ -6176,35 +6898,6 @@ export const $AssetClassGroupDto = {
6176
6898
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6177
6899
  } as const;
6178
6900
 
6179
- export const $AccountExchangeRateWarningDto = {
6180
- type: 'object',
6181
- properties: {
6182
- type: {
6183
- type: 'string',
6184
- description: 'Warning type',
6185
- example: 'MISSING_EXCHANGE_RATE'
6186
- },
6187
- currency: {
6188
- type: 'string',
6189
- description: 'Currency without exchange rate',
6190
- example: 'USD'
6191
- },
6192
- accounts: {
6193
- description: 'Affected account paths',
6194
- type: 'array',
6195
- items: {
6196
- type: 'string'
6197
- }
6198
- },
6199
- totalAmount: {
6200
- type: 'string',
6201
- description: 'Total amount in this currency',
6202
- example: '5000.00'
6203
- }
6204
- },
6205
- required: ['type', 'currency', 'accounts', 'totalAmount']
6206
- } as const;
6207
-
6208
6901
  export const $AssetClassSummaryDto = {
6209
6902
  type: 'object',
6210
6903
  properties: {
@@ -6278,7 +6971,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6278
6971
  accountPath: {
6279
6972
  type: 'string',
6280
6973
  description: 'Full account path',
6281
- example: 'Assets:US:Investments:Brokerage'
6974
+ example: 'Assets:US:Fidelity:Brokerage'
6282
6975
  },
6283
6976
  accountCurrency: {
6284
6977
  type: 'string',
@@ -6458,30 +7151,125 @@ export const $CashFlowResponseDto = {
6458
7151
  }
6459
7152
  ]
6460
7153
  },
6461
- converted: {
6462
- description: 'Converted values in base currency',
7154
+ converted: {
7155
+ description: 'Converted values in base currency',
7156
+ allOf: [
7157
+ {
7158
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7159
+ }
7160
+ ]
7161
+ },
7162
+ warnings: {
7163
+ description: 'Exchange rate warnings',
7164
+ type: 'array',
7165
+ items: {
7166
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7167
+ }
7168
+ }
7169
+ },
7170
+ required: [
7171
+ 'period',
7172
+ 'income',
7173
+ 'expense',
7174
+ 'netSavings',
7175
+ 'savingsRate',
7176
+ 'currency'
7177
+ ]
7178
+ } as const;
7179
+
7180
+ export const $CategoryGroupDto = {
7181
+ type: 'object',
7182
+ properties: {
7183
+ category: {
7184
+ type: 'string',
7185
+ description:
7186
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7187
+ example: 'Food'
7188
+ },
7189
+ totalExpense: {
7190
+ type: 'string',
7191
+ description:
7192
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7193
+ example: '1200.00'
7194
+ },
7195
+ sharePct: {
7196
+ type: 'number',
7197
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7198
+ example: 42.5
7199
+ },
7200
+ balanceByCurrency: {
7201
+ description: 'Raw (unconverted) expense per currency',
7202
+ type: 'array',
7203
+ items: {
7204
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7205
+ }
7206
+ },
7207
+ convertedBalance: {
7208
+ type: 'string',
7209
+ description:
7210
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7211
+ example: '1200.00'
7212
+ }
7213
+ },
7214
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7215
+ } as const;
7216
+
7217
+ export const $ExpensesByCategorySummaryDto = {
7218
+ type: 'object',
7219
+ properties: {
7220
+ totalExpense: {
7221
+ type: 'string',
7222
+ description:
7223
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7224
+ example: '5000.00'
7225
+ },
7226
+ categoryCount: {
7227
+ type: 'number',
7228
+ description: 'Number of categories',
7229
+ example: 8
7230
+ }
7231
+ },
7232
+ required: ['totalExpense', 'categoryCount']
7233
+ } as const;
7234
+
7235
+ export const $ExpensesByCategoryResponseDto = {
7236
+ type: 'object',
7237
+ properties: {
7238
+ period: {
7239
+ type: 'string',
7240
+ description: 'Period requested',
7241
+ example: '1m'
7242
+ },
7243
+ baseCurrency: {
7244
+ type: 'string',
7245
+ description: 'Base currency for converted values',
7246
+ example: 'CNY'
7247
+ },
7248
+ groups: {
7249
+ description:
7250
+ 'Expense groups by functional category, sorted by converted total desc',
7251
+ type: 'array',
7252
+ items: {
7253
+ $ref: '#/components/schemas/CategoryGroupDto'
7254
+ }
7255
+ },
7256
+ summary: {
7257
+ description: 'Summary statistics',
6463
7258
  allOf: [
6464
7259
  {
6465
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7260
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6466
7261
  }
6467
7262
  ]
6468
7263
  },
6469
7264
  warnings: {
6470
- description: 'Exchange rate warnings',
7265
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6471
7266
  type: 'array',
6472
7267
  items: {
6473
7268
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6474
7269
  }
6475
7270
  }
6476
7271
  },
6477
- required: [
6478
- 'period',
6479
- 'income',
6480
- 'expense',
6481
- 'netSavings',
6482
- 'savingsRate',
6483
- 'currency'
6484
- ]
7272
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6485
7273
  } as const;
6486
7274
 
6487
7275
  export const $MonetaryDto = {
@@ -6773,163 +7561,6 @@ export const $HoldingPnlResponseDto = {
6773
7561
  required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6774
7562
  } as const;
6775
7563
 
6776
- export const $CreateBeanPriceDto = {
6777
- type: 'object',
6778
- properties: {
6779
- currency: {
6780
- type: 'string',
6781
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6782
- example: 'USD'
6783
- },
6784
- quoteCurrency: {
6785
- type: 'string',
6786
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6787
- example: 'CNY'
6788
- },
6789
- amount: {
6790
- type: 'number',
6791
- description:
6792
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6793
- example: 175.5,
6794
- minimum: 0
6795
- },
6796
- date: {
6797
- type: 'string',
6798
- description: 'Price date (ISO 8601 format)',
6799
- example: '2024-11-05'
6800
- },
6801
- metadata: {
6802
- type: 'object',
6803
- description:
6804
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6805
- example: {
6806
- source: 'MANUAL',
6807
- note: 'Bank valuation report',
6808
- confidence: 0.95
6809
- }
6810
- }
6811
- },
6812
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6813
- } as const;
6814
-
6815
- export const $PriceResponseDto = {
6816
- type: 'object',
6817
- properties: {
6818
- id: {
6819
- type: 'string',
6820
- description: 'Unique identifier',
6821
- example: 'uuid-123-456'
6822
- },
6823
- userId: {
6824
- type: 'string',
6825
- description: 'User ID (owner of the price)',
6826
- example: 'user-123'
6827
- },
6828
- currency: {
6829
- type: 'string',
6830
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6831
- example: 'BTC'
6832
- },
6833
- quoteCurrency: {
6834
- type: 'string',
6835
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6836
- example: 'USD'
6837
- },
6838
- amount: {
6839
- type: 'number',
6840
- description:
6841
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6842
- example: 50000
6843
- },
6844
- date: {
6845
- type: 'string',
6846
- description:
6847
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6848
- example: '2024-01-01',
6849
- format: 'date'
6850
- },
6851
- meta: {
6852
- type: 'object',
6853
- description:
6854
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6855
- example: {
6856
- source: 'MANUAL',
6857
- note: 'User-defined price',
6858
- confidence: 1
6859
- }
6860
- },
6861
- createdAt: {
6862
- format: 'date-time',
6863
- type: 'string',
6864
- description: 'Creation timestamp',
6865
- example: '2024-11-03T10:00:00Z'
6866
- },
6867
- updatedAt: {
6868
- format: 'date-time',
6869
- type: 'string',
6870
- description: 'Last update timestamp',
6871
- example: '2024-11-03T10:00:00Z'
6872
- }
6873
- },
6874
- required: [
6875
- 'id',
6876
- 'userId',
6877
- 'currency',
6878
- 'quoteCurrency',
6879
- 'amount',
6880
- 'date',
6881
- 'meta',
6882
- 'createdAt',
6883
- 'updatedAt'
6884
- ]
6885
- } as const;
6886
-
6887
- export const $PriceListResponseDto = {
6888
- type: 'object',
6889
- properties: {
6890
- items: {
6891
- description: 'List of prices',
6892
- type: 'array',
6893
- items: {
6894
- $ref: '#/components/schemas/PriceResponseDto'
6895
- }
6896
- },
6897
- total: {
6898
- type: 'number',
6899
- description: 'Total number of prices',
6900
- example: 42
6901
- }
6902
- },
6903
- required: ['items', 'total']
6904
- } as const;
6905
-
6906
- export const $UpdateBeanPriceDto = {
6907
- type: 'object',
6908
- properties: {
6909
- currency: {
6910
- type: 'string',
6911
- description: 'Currency being priced'
6912
- },
6913
- quoteCurrency: {
6914
- type: 'string',
6915
- description: 'Quote currency (pricing currency)'
6916
- },
6917
- amount: {
6918
- type: 'number',
6919
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
6920
- minimum: 0
6921
- },
6922
- date: {
6923
- type: 'string',
6924
- description: 'Price date (ISO 8601 format)'
6925
- },
6926
- metadata: {
6927
- type: 'object',
6928
- description: 'Metadata'
6929
- }
6930
- }
6931
- } as const;
6932
-
6933
7564
  export const $CurrencyBalanceDto = {
6934
7565
  type: 'object',
6935
7566
  properties: {
@@ -6965,6 +7596,16 @@ export const $TimeSeriesPointDto = {
6965
7596
  description: 'Change from previous point',
6966
7597
  example: '5000.00'
6967
7598
  },
7599
+ assets: {
7600
+ type: 'string',
7601
+ description: 'Total assets at this date (in base currency)',
7602
+ example: '494338.00'
7603
+ },
7604
+ liabilities: {
7605
+ type: 'string',
7606
+ description: 'Total liabilities at this date (in base currency)',
7607
+ example: '310098.00'
7608
+ },
6968
7609
  byCurrency: {
6969
7610
  description: 'Multi-currency breakdown for this point',
6970
7611
  type: 'array',
@@ -7074,6 +7715,111 @@ export const $PortfolioTrendsResponseDto = {
7074
7715
  required: ['series', 'summary', 'period', 'granularity', 'currency']
7075
7716
  } as const;
7076
7717
 
7718
+ export const $CashFlowPointDto = {
7719
+ type: 'object',
7720
+ properties: {
7721
+ month: {
7722
+ type: 'string',
7723
+ description: 'Month key (YYYY-MM)',
7724
+ example: '2024-03'
7725
+ },
7726
+ income: {
7727
+ type: 'string',
7728
+ description: 'Income in base currency (absolute, converted)',
7729
+ example: '10000.00'
7730
+ },
7731
+ expense: {
7732
+ type: 'string',
7733
+ description: 'Expense in base currency (absolute, converted)',
7734
+ example: '5000.00'
7735
+ },
7736
+ netSavings: {
7737
+ type: 'string',
7738
+ description: 'netSavings = income − expense (savings positive)',
7739
+ example: '5000.00'
7740
+ }
7741
+ },
7742
+ required: ['month', 'income', 'expense', 'netSavings']
7743
+ } as const;
7744
+
7745
+ export const $CashFlowTrendSummaryDto = {
7746
+ type: 'object',
7747
+ properties: {
7748
+ totalIncome: {
7749
+ type: 'string',
7750
+ description: 'Total income across the period',
7751
+ example: '60000.00'
7752
+ },
7753
+ totalExpense: {
7754
+ type: 'string',
7755
+ description: 'Total expense across the period',
7756
+ example: '30000.00'
7757
+ },
7758
+ totalNetSavings: {
7759
+ type: 'string',
7760
+ description: 'income − expense across the period',
7761
+ example: '30000.00'
7762
+ },
7763
+ averageMonthlyNetSavings: {
7764
+ type: 'string',
7765
+ description:
7766
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
7767
+ example: '5000.00'
7768
+ }
7769
+ },
7770
+ required: [
7771
+ 'totalIncome',
7772
+ 'totalExpense',
7773
+ 'totalNetSavings',
7774
+ 'averageMonthlyNetSavings'
7775
+ ]
7776
+ } as const;
7777
+
7778
+ export const $CashFlowTrendsResponseDto = {
7779
+ type: 'object',
7780
+ properties: {
7781
+ series: {
7782
+ description:
7783
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
7784
+ type: 'array',
7785
+ items: {
7786
+ $ref: '#/components/schemas/CashFlowPointDto'
7787
+ }
7788
+ },
7789
+ summary: {
7790
+ description: 'Period totals',
7791
+ allOf: [
7792
+ {
7793
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
7794
+ }
7795
+ ]
7796
+ },
7797
+ period: {
7798
+ type: 'string',
7799
+ description: 'Period requested',
7800
+ example: '6m'
7801
+ },
7802
+ granularity: {
7803
+ type: 'string',
7804
+ description: 'Data granularity (v1 returns month buckets)',
7805
+ example: 'month'
7806
+ },
7807
+ currency: {
7808
+ type: 'string',
7809
+ description: 'Base currency for converted values',
7810
+ example: 'CNY'
7811
+ },
7812
+ warnings: {
7813
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
7814
+ type: 'array',
7815
+ items: {
7816
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7817
+ }
7818
+ }
7819
+ },
7820
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
7821
+ } as const;
7822
+
7077
7823
  export const $GenerateSnapshotBody = {
7078
7824
  type: 'object',
7079
7825
  properties: {}