@luca-financial/luca-schema 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,34 +11,25 @@ npm install @luca-financial/luca-schema
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { lucaValidator, enums, schemas } from '@luca-financial/luca-schema';
14
+ import { validate } from '@luca-financial/luca-schema';
15
15
 
16
- // Validate a transaction
17
- const validateTransaction = lucaValidator.getSchema('transaction');
18
16
  const transactionData = {
19
17
  id: '123e4567-e89b-12d3-a456-426614174000',
20
- payorId: '123e4567-e89b-12d3-a456-426614174001',
21
- payeeId: '123e4567-e89b-12d3-a456-426614174002',
22
- categoryId: '123e4567-e89b-12d3-a456-426614174003',
23
- amount: 100.5,
18
+ accountId: '123e4567-e89b-12d3-a456-426614174001',
19
+ categoryId: null,
20
+ statementId: null,
21
+ amount: -2599,
24
22
  date: '2024-01-01',
25
23
  description: 'Test transaction',
26
- transactionState: enums.TransactionStateEnum.COMPLETED,
24
+ transactionState: 'COMPLETED',
27
25
  createdAt: '2024-01-01T00:00:00Z',
28
26
  updatedAt: null
29
27
  };
30
28
 
31
- const isValid = validateTransaction(transactionData);
32
-
33
- if (!isValid) {
34
- console.error('Validation errors:', validateTransaction.errors);
29
+ const result = validate('transaction', transactionData);
30
+ if (!result.valid) {
31
+ console.error('Validation errors:', result.errors);
35
32
  }
36
-
37
- // Alternative: Use schemas directly with the validate method
38
- const isValidDirect = lucaValidator.validate(
39
- schemas.transaction,
40
- transactionData
41
- );
42
33
  ```
43
34
 
44
35
  ## Available Schemas
@@ -50,9 +41,9 @@ Validates financial transactions with properties like amount, date, and state.
50
41
  ```typescript
51
42
  const transaction = {
52
43
  id: string;
53
- payorId: string;
54
- payeeId: string;
44
+ accountId: string;
55
45
  categoryId: string | null;
46
+ statementId: string | null;
56
47
  amount: number;
57
48
  date: string;
58
49
  description: string;
@@ -69,8 +60,7 @@ Validates recurring transaction templates with frequency and interval settings.
69
60
  ```typescript
70
61
  const recurringTransaction = {
71
62
  id: string;
72
- payorId: string;
73
- payeeId: string;
63
+ accountId: string;
74
64
  categoryId: string | null;
75
65
  amount: number;
76
66
  description: string;
@@ -85,22 +75,6 @@ const recurringTransaction = {
85
75
  };
86
76
  ```
87
77
 
88
- ### Entity
89
-
90
- Validates financial entities like accounts, retailers, or individuals.
91
-
92
- ```typescript
93
- const entity = {
94
- id: string;
95
- name: string;
96
- description: string | null;
97
- entityType: 'ACCOUNT' | 'RETAILER' | 'SERVICE' | 'INDIVIDUAL' | 'UTILITY' | 'GOVERNMENT';
98
- entityStatus: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'DELETED' | 'CLOSED';
99
- createdAt: string;
100
- updatedAt: string | null;
101
- };
102
- ```
103
-
104
78
  ### Category
105
79
 
106
80
  Validates transaction categories with optional parent relationships.
@@ -108,11 +82,10 @@ Validates transaction categories with optional parent relationships.
108
82
  ```typescript
109
83
  const category = {
110
84
  id: string;
85
+ slug: string;
111
86
  name: string;
112
87
  description: string | null;
113
88
  parentId: string | null;
114
- defaultCategoryId: string | null;
115
- categoryType: 'DEFAULT' | 'MODIFIED' | 'CUSTOM';
116
89
  createdAt: string;
117
90
  updatedAt: string | null;
118
91
  };
@@ -134,6 +107,26 @@ const recurringTransactionEvent = {
134
107
  };
135
108
  ```
136
109
 
110
+ ### Statement
111
+
112
+ Validates credit card statements with balances in integer minor units.
113
+
114
+ ```typescript
115
+ const statement = {
116
+ id: string;
117
+ accountId: string;
118
+ startDate: string;
119
+ endDate: string;
120
+ startingBalance: number;
121
+ endingBalance: number;
122
+ totalCharges: number;
123
+ totalPayments: number;
124
+ status: 'draft' | 'current' | 'past' | 'locked';
125
+ createdAt: string;
126
+ updatedAt: string | null;
127
+ };
128
+ ```
129
+
137
130
  ## Development
138
131
 
139
132
  ```bash
@@ -213,6 +213,13 @@ export type RecurringTransactionState = 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CAN
213
213
  * via the `definition` "RecurringTransactionEventStatus".
214
214
  */
215
215
  export type RecurringTransactionEventStatus = 'MODIFIED' | 'DELETED';
216
+ /**
217
+ * Allowed statuses for statements
218
+ *
219
+ * This interface was referenced by `LucaSchemaEnums`'s JSON-Schema
220
+ * via the `definition` "StatementStatus".
221
+ */
222
+ export type StatementStatus = 'draft' | 'current' | 'past' | 'locked';
216
223
 
217
224
  /**
218
225
  * Shared enumerations for Luca Schema objects
@@ -336,10 +343,74 @@ export type APR = number | null;
336
343
  */
337
344
  export type ClosedAt = string | null;
338
345
  /**
339
- * Defines recurring financial transactions within the application.
346
+ * Defines the schema for credit card statements.
340
347
  */
341
- export type RecurringTransaction = Common2 & {
348
+ export type Statement = Common2 & {
342
349
  accountId: AccountID;
350
+ startDate: StartDate;
351
+ endDate: EndDate;
352
+ startingBalance: StartingBalance;
353
+ endingBalance: EndingBalance;
354
+ totalCharges: TotalCharges;
355
+ totalPayments: TotalPayments;
356
+ /**
357
+ * Allowed statuses for statements
358
+ */
359
+ status: 'draft' | 'current' | 'past' | 'locked';
360
+ };
361
+ /**
362
+ * UUID for the item
363
+ */
364
+ export type ID2 = string;
365
+ /**
366
+ * The timestamp of the creation of the item
367
+ */
368
+ export type DateCreated2 = string;
369
+ /**
370
+ * The timestamp of the last update or null if the item has not been updated yet
371
+ */
372
+ export type LastUpdated2 = string | null;
373
+ /**
374
+ * The timestamp of when the item was soft-deleted
375
+ */
376
+ export type DateDeleted2 = string | null;
377
+ /**
378
+ * Version number for optimistic concurrency control
379
+ */
380
+ export type Version2 = number;
381
+ /**
382
+ * ID of the account this statement belongs to
383
+ */
384
+ export type AccountID = string;
385
+ /**
386
+ * Statement start date (inclusive) in YYYY-MM-DD format
387
+ */
388
+ export type StartDate = string;
389
+ /**
390
+ * Statement end date (inclusive) in YYYY-MM-DD format
391
+ */
392
+ export type EndDate = string;
393
+ /**
394
+ * Balance carried into this statement period in integer minor units
395
+ */
396
+ export type StartingBalance = number;
397
+ /**
398
+ * Balance at the end of this statement period in integer minor units
399
+ */
400
+ export type EndingBalance = number;
401
+ /**
402
+ * Sum of all charges during the statement period in integer minor units
403
+ */
404
+ export type TotalCharges = number;
405
+ /**
406
+ * Sum of all payments/credits during the statement period in integer minor units
407
+ */
408
+ export type TotalPayments = number;
409
+ /**
410
+ * Defines recurring financial transactions within the application.
411
+ */
412
+ export type RecurringTransaction = Common3 & {
413
+ accountId: AccountID1;
343
414
  categoryId?: CategoryID;
344
415
  amount: Amount;
345
416
  description: Description1;
@@ -349,8 +420,8 @@ export type RecurringTransaction = Common2 & {
349
420
  frequency: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
350
421
  interval: FrequencyInterval;
351
422
  occurrences?: TotalOccurrences;
352
- startOn: StartDate;
353
- endOn?: EndDate;
423
+ startOn: StartDate1;
424
+ endOn?: EndDate1;
354
425
  /**
355
426
  * Allowed states for recurring transactions
356
427
  */
@@ -359,33 +430,33 @@ export type RecurringTransaction = Common2 & {
359
430
  /**
360
431
  * UUID for the item
361
432
  */
362
- export type ID2 = string;
433
+ export type ID3 = string;
363
434
  /**
364
435
  * The timestamp of the creation of the item
365
436
  */
366
- export type DateCreated2 = string;
437
+ export type DateCreated3 = string;
367
438
  /**
368
439
  * The timestamp of the last update or null if the item has not been updated yet
369
440
  */
370
- export type LastUpdated2 = string | null;
441
+ export type LastUpdated3 = string | null;
371
442
  /**
372
443
  * The timestamp of when the item was soft-deleted
373
444
  */
374
- export type DateDeleted2 = string | null;
445
+ export type DateDeleted3 = string | null;
375
446
  /**
376
447
  * Version number for optimistic concurrency control
377
448
  */
378
- export type Version2 = number;
449
+ export type Version3 = number;
379
450
  /**
380
451
  * ID of the account this transaction belongs to
381
452
  */
382
- export type AccountID = string;
453
+ export type AccountID1 = string;
383
454
  /**
384
455
  * Category identifier for organizing the transaction. Can be null if not categorized.
385
456
  */
386
457
  export type CategoryID = string | null;
387
458
  /**
388
- * The monetary value of the transaction.
459
+ * The monetary value in integer minor units. Can be positive or negative.
389
460
  */
390
461
  export type Amount = number;
391
462
  /**
@@ -403,15 +474,15 @@ export type TotalOccurrences = number | null;
403
474
  /**
404
475
  * The date on which the recurring transaction series should begin.
405
476
  */
406
- export type StartDate = string;
477
+ export type StartDate1 = string;
407
478
  /**
408
479
  * The date on which the recurring transaction series should end. Can be null.
409
480
  */
410
- export type EndDate = string | null;
481
+ export type EndDate1 = string | null;
411
482
  /**
412
483
  * Manages occurrences of recurring transactions, including tracking their modifications or logical deletions. 'transactionId' is required when an occurrence is modified to link it to an actual transaction.
413
484
  */
414
- export type RecurringTransactionEvent = Common3 & {
485
+ export type RecurringTransactionEvent = Common4 & {
415
486
  transactionId?: AssociatedTransactionID;
416
487
  recurringTransactionId?: RecurringTransactionID;
417
488
  expectedDate?: ExpectedDate;
@@ -432,23 +503,23 @@ export type RecurringTransactionEvent = Common3 & {
432
503
  /**
433
504
  * UUID for the item
434
505
  */
435
- export type ID3 = string;
506
+ export type ID4 = string;
436
507
  /**
437
508
  * The timestamp of the creation of the item
438
509
  */
439
- export type DateCreated3 = string;
510
+ export type DateCreated4 = string;
440
511
  /**
441
512
  * The timestamp of the last update or null if the item has not been updated yet
442
513
  */
443
- export type LastUpdated3 = string | null;
514
+ export type LastUpdated4 = string | null;
444
515
  /**
445
516
  * The timestamp of when the item was soft-deleted
446
517
  */
447
- export type DateDeleted3 = string | null;
518
+ export type DateDeleted4 = string | null;
448
519
  /**
449
520
  * Version number for optimistic concurrency control
450
521
  */
451
- export type Version3 = number;
522
+ export type Version4 = number;
452
523
  /**
453
524
  * Identifier of the actual transaction when the occurrence is modified; must be null when deleted.
454
525
  */
@@ -461,8 +532,8 @@ export type RecurringTransactionID = string;
461
532
  * The date when the occurrence is expected.
462
533
  */
463
534
  export type ExpectedDate = string;
464
- export type Transaction = Common4 & {
465
- accountId: AccountID1;
535
+ export type Transaction = Common5 & {
536
+ accountId: AccountID2;
466
537
  date: Date;
467
538
  authorizedAt?: AuthorizedAt;
468
539
  postedAt?: PostedAt;
@@ -472,6 +543,7 @@ export type Transaction = Common4 & {
472
543
  memo?: Memo;
473
544
  counterparty?: Counterparty;
474
545
  categoryId?: CategoryID1;
546
+ statementId?: StatementID;
475
547
  aggregationServiceId?: AggregationServiceID1;
476
548
  /**
477
549
  * Allowed transaction lifecycle states
@@ -492,27 +564,27 @@ export type Transaction = Common4 & {
492
564
  /**
493
565
  * UUID for the item
494
566
  */
495
- export type ID4 = string;
567
+ export type ID5 = string;
496
568
  /**
497
569
  * The timestamp of the creation of the item
498
570
  */
499
- export type DateCreated4 = string;
571
+ export type DateCreated5 = string;
500
572
  /**
501
573
  * The timestamp of the last update or null if the item has not been updated yet
502
574
  */
503
- export type LastUpdated4 = string | null;
575
+ export type LastUpdated5 = string | null;
504
576
  /**
505
577
  * The timestamp of when the item was soft-deleted
506
578
  */
507
- export type DateDeleted4 = string | null;
579
+ export type DateDeleted5 = string | null;
508
580
  /**
509
581
  * Version number for optimistic concurrency control
510
582
  */
511
- export type Version4 = number;
583
+ export type Version5 = number;
512
584
  /**
513
585
  * ID of the account this transaction belongs to
514
586
  */
515
- export type AccountID1 = string;
587
+ export type AccountID2 = string;
516
588
  /**
517
589
  * Date of the transaction in YYYY-MM-DD format
518
590
  */
@@ -530,7 +602,7 @@ export type PostedAt = string | null;
530
602
  */
531
603
  export type Currency = string | null;
532
604
  /**
533
- * Transaction amount (can be positive or negative)
605
+ * Transaction amount in integer minor units. Can be positive or negative.
534
606
  */
535
607
  export type Amount1 = number;
536
608
  /**
@@ -549,6 +621,10 @@ export type Counterparty = string | null;
549
621
  * Category UUID for this transaction
550
622
  */
551
623
  export type CategoryID1 = string | null;
624
+ /**
625
+ * Statement UUID for this transaction
626
+ */
627
+ export type StatementID = string | null;
552
628
  /**
553
629
  * Identifier for this transaction in a financial data aggregation service.
554
630
  */
@@ -560,7 +636,7 @@ export type DeletedAt = string | null;
560
636
  /**
561
637
  * Defines a split within a transaction.
562
638
  */
563
- export type TransactionSplit = Common5 & {
639
+ export type TransactionSplit = Common6 & {
564
640
  transactionId: TransactionID;
565
641
  amount: Amount2;
566
642
  categoryId: CategoryID2;
@@ -570,29 +646,29 @@ export type TransactionSplit = Common5 & {
570
646
  /**
571
647
  * UUID for the item
572
648
  */
573
- export type ID5 = string;
649
+ export type ID6 = string;
574
650
  /**
575
651
  * The timestamp of the creation of the item
576
652
  */
577
- export type DateCreated5 = string;
653
+ export type DateCreated6 = string;
578
654
  /**
579
655
  * The timestamp of the last update or null if the item has not been updated yet
580
656
  */
581
- export type LastUpdated5 = string | null;
657
+ export type LastUpdated6 = string | null;
582
658
  /**
583
659
  * The timestamp of when the item was soft-deleted
584
660
  */
585
- export type DateDeleted5 = string | null;
661
+ export type DateDeleted6 = string | null;
586
662
  /**
587
663
  * Version number for optimistic concurrency control
588
664
  */
589
- export type Version5 = number;
665
+ export type Version6 = number;
590
666
  /**
591
667
  * The identifier of the parent transaction.
592
668
  */
593
669
  export type TransactionID = string;
594
670
  /**
595
- * The amount allocated to this split (must be non-zero; can be positive or negative).
671
+ * The amount allocated to this split in integer minor units. Must be greater than 0.
596
672
  */
597
673
  export type Amount2 = number;
598
674
  /**
@@ -624,6 +700,10 @@ export interface LucaSchema {
624
700
  * List of accounts
625
701
  */
626
702
  accounts: Account[];
703
+ /**
704
+ * List of statements
705
+ */
706
+ statements: Statement[];
627
707
  /**
628
708
  * List of recurring transactions
629
709
  */
@@ -701,6 +781,16 @@ export interface Common5 {
701
781
  deletedAt?: DateDeleted5;
702
782
  version?: Version5;
703
783
  }
784
+ /**
785
+ * Common properties for all schemas
786
+ */
787
+ export interface Common6 {
788
+ id: ID6;
789
+ createdAt: DateCreated6;
790
+ updatedAt: LastUpdated6;
791
+ deletedAt?: DateDeleted6;
792
+ version?: Version6;
793
+ }
704
794
 
705
795
  /**
706
796
  * Defines recurring financial transactions within the application.
@@ -752,7 +842,7 @@ export type AccountID = string;
752
842
  */
753
843
  export type CategoryID = string | null;
754
844
  /**
755
- * The monetary value of the transaction.
845
+ * The monetary value in integer minor units. Can be positive or negative.
756
846
  */
757
847
  export type Amount = number;
758
848
  /**
@@ -852,6 +942,82 @@ export interface Common {
852
942
  version?: Version;
853
943
  }
854
944
 
945
+ /**
946
+ * Defines the schema for credit card statements.
947
+ */
948
+ export type Statement = Common & {
949
+ accountId: AccountID;
950
+ startDate: StartDate;
951
+ endDate: EndDate;
952
+ startingBalance: StartingBalance;
953
+ endingBalance: EndingBalance;
954
+ totalCharges: TotalCharges;
955
+ totalPayments: TotalPayments;
956
+ /**
957
+ * Allowed statuses for statements
958
+ */
959
+ status: 'draft' | 'current' | 'past' | 'locked';
960
+ };
961
+ /**
962
+ * UUID for the item
963
+ */
964
+ export type ID = string;
965
+ /**
966
+ * The timestamp of the creation of the item
967
+ */
968
+ export type DateCreated = string;
969
+ /**
970
+ * The timestamp of the last update or null if the item has not been updated yet
971
+ */
972
+ export type LastUpdated = string | null;
973
+ /**
974
+ * The timestamp of when the item was soft-deleted
975
+ */
976
+ export type DateDeleted = string | null;
977
+ /**
978
+ * Version number for optimistic concurrency control
979
+ */
980
+ export type Version = number;
981
+ /**
982
+ * ID of the account this statement belongs to
983
+ */
984
+ export type AccountID = string;
985
+ /**
986
+ * Statement start date (inclusive) in YYYY-MM-DD format
987
+ */
988
+ export type StartDate = string;
989
+ /**
990
+ * Statement end date (inclusive) in YYYY-MM-DD format
991
+ */
992
+ export type EndDate = string;
993
+ /**
994
+ * Balance carried into this statement period in integer minor units
995
+ */
996
+ export type StartingBalance = number;
997
+ /**
998
+ * Balance at the end of this statement period in integer minor units
999
+ */
1000
+ export type EndingBalance = number;
1001
+ /**
1002
+ * Sum of all charges during the statement period in integer minor units
1003
+ */
1004
+ export type TotalCharges = number;
1005
+ /**
1006
+ * Sum of all payments/credits during the statement period in integer minor units
1007
+ */
1008
+ export type TotalPayments = number;
1009
+
1010
+ /**
1011
+ * Common properties for all schemas
1012
+ */
1013
+ export interface Common {
1014
+ id: ID;
1015
+ createdAt: DateCreated;
1016
+ updatedAt: LastUpdated;
1017
+ deletedAt?: DateDeleted;
1018
+ version?: Version;
1019
+ }
1020
+
855
1021
  export type Transaction = Common & {
856
1022
  accountId: AccountID;
857
1023
  date: Date;
@@ -863,6 +1029,7 @@ export type Transaction = Common & {
863
1029
  memo?: Memo;
864
1030
  counterparty?: Counterparty;
865
1031
  categoryId?: CategoryID;
1032
+ statementId?: StatementID;
866
1033
  aggregationServiceId?: AggregationServiceID;
867
1034
  /**
868
1035
  * Allowed transaction lifecycle states
@@ -921,7 +1088,7 @@ export type PostedAt = string | null;
921
1088
  */
922
1089
  export type Currency = string | null;
923
1090
  /**
924
- * Transaction amount (can be positive or negative)
1091
+ * Transaction amount in integer minor units. Can be positive or negative.
925
1092
  */
926
1093
  export type Amount = number;
927
1094
  /**
@@ -940,6 +1107,10 @@ export type Counterparty = string | null;
940
1107
  * Category UUID for this transaction
941
1108
  */
942
1109
  export type CategoryID = string | null;
1110
+ /**
1111
+ * Statement UUID for this transaction
1112
+ */
1113
+ export type StatementID = string | null;
943
1114
  /**
944
1115
  * Identifier for this transaction in a financial data aggregation service.
945
1116
  */
@@ -995,7 +1166,7 @@ export type Version = number;
995
1166
  */
996
1167
  export type TransactionID = string;
997
1168
  /**
998
- * The amount allocated to this split (must be non-zero; can be positive or negative).
1169
+ * The amount allocated to this split in integer minor units. Must be greater than 0.
999
1170
  */
1000
1171
  export type Amount = number;
1001
1172
  /**
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ const schemas = { ...schemaIndex, enums: schemaIndex.enums };
7
7
  export const accountSchema = schemas.account;
8
8
  export const categorySchema = schemas.category;
9
9
  export const lucaSchema = schemas.lucaSchema;
10
+ export const statementSchema = schemas.statement;
10
11
  export const recurringTransactionSchema = schemas.recurringTransaction;
11
12
  export const recurringTransactionEventSchema =
12
13
  schemas.recurringTransactionEvent;
@@ -5,6 +5,7 @@ import categorySchemaJson from './schemas/category.json' with { type: 'json' };
5
5
  import commonSchemaJson from './schemas/common.json' with { type: 'json' };
6
6
  import enumsSchemaJson from './schemas/enums.json' with { type: 'json' };
7
7
  import lucaSchemaJson from './schemas/lucaSchema.json' with { type: 'json' };
8
+ import statementSchemaJson from './schemas/statement.json' with { type: 'json' };
8
9
  import recurringTransactionSchemaJson from './schemas/recurringTransaction.json' with { type: 'json' };
9
10
  import recurringTransactionEventSchemaJson from './schemas/recurringTransactionEvent.json' with { type: 'json' };
10
11
  import transactionSchemaJson from './schemas/transaction.json' with { type: 'json' };
@@ -14,6 +15,7 @@ const schemas = {
14
15
  account: accountSchemaJson,
15
16
  category: categorySchemaJson,
16
17
  lucaSchema: lucaSchemaJson,
18
+ statement: statementSchemaJson,
17
19
  recurringTransaction: recurringTransactionSchemaJson,
18
20
  recurringTransactionEvent: recurringTransactionEventSchemaJson,
19
21
  transaction: transactionSchemaJson,
@@ -7,6 +7,7 @@
7
7
  "ACCOUNT": "account",
8
8
  "CATEGORY": "category",
9
9
  "LUCASCHEMA": "lucaSchema",
10
+ "STATEMENT": "statement",
10
11
  "RECURRING_TRANSACTION": "recurringTransaction",
11
12
  "RECURRING_TRANSACTION_EVENT": "recurringTransactionEvent",
12
13
  "TRANSACTION": "transaction",
@@ -48,6 +49,11 @@
48
49
  "type": "string",
49
50
  "enum": ["MODIFIED", "DELETED"],
50
51
  "description": "Allowed statuses for recurring transaction events"
52
+ },
53
+ "StatementStatus": {
54
+ "type": "string",
55
+ "enum": ["draft", "current", "past", "locked"],
56
+ "description": "Allowed statuses for statements"
51
57
  }
52
58
  }
53
59
  }
@@ -2,6 +2,7 @@ import account from './account.json' with { type: 'json' };
2
2
  import category from './category.json' with { type: 'json' };
3
3
  import common from './common.json' with { type: 'json' };
4
4
  import lucaSchema from './lucaSchema.json' with { type: 'json' };
5
+ import statement from './statement.json' with { type: 'json' };
5
6
  import recurringTransaction from './recurringTransaction.json' with { type: 'json' };
6
7
  import recurringTransactionEvent from './recurringTransactionEvent.json' with { type: 'json' };
7
8
  import transaction from './transaction.json' with { type: 'json' };
@@ -13,6 +14,7 @@ export {
13
14
  category,
14
15
  common,
15
16
  lucaSchema,
17
+ statement,
16
18
  recurringTransaction,
17
19
  recurringTransactionEvent,
18
20
  transaction,
@@ -25,6 +27,7 @@ export default {
25
27
  category,
26
28
  common,
27
29
  lucaSchema,
30
+ statement,
28
31
  recurringTransaction,
29
32
  recurringTransactionEvent,
30
33
  transaction,
@@ -8,6 +8,7 @@
8
8
  "schemaVersion",
9
9
  "categories",
10
10
  "accounts",
11
+ "statements",
11
12
  "recurringTransactions",
12
13
  "recurringTransactionEvents",
13
14
  "transactions",
@@ -34,6 +35,14 @@
34
35
  "$ref": "./account.json"
35
36
  }
36
37
  },
38
+ "statements": {
39
+ "type": "array",
40
+ "description": "List of statements",
41
+ "uniqueItems": true,
42
+ "items": {
43
+ "$ref": "./statement.json"
44
+ }
45
+ },
37
46
  "recurringTransactions": {
38
47
  "type": "array",
39
48
  "description": "List of recurring transactions",
@@ -23,9 +23,9 @@
23
23
  "description": "Category identifier for organizing the transaction. Can be null if not categorized."
24
24
  },
25
25
  "amount": {
26
- "type": "number",
26
+ "type": "integer",
27
27
  "title": "Amount",
28
- "description": "The monetary value of the transaction."
28
+ "description": "The monetary value in integer minor units. Can be positive or negative."
29
29
  },
30
30
  "description": {
31
31
  "type": "string",
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/statement.json",
4
+ "title": "Statement",
5
+ "description": "Defines the schema for credit card statements.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "./common.json"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "accountId": {
14
+ "type": "string",
15
+ "title": "Account ID",
16
+ "format": "uuid",
17
+ "description": "ID of the account this statement belongs to"
18
+ },
19
+ "startDate": {
20
+ "type": "string",
21
+ "title": "Start Date",
22
+ "format": "date",
23
+ "description": "Statement start date (inclusive) in YYYY-MM-DD format"
24
+ },
25
+ "endDate": {
26
+ "type": "string",
27
+ "title": "End Date",
28
+ "format": "date",
29
+ "description": "Statement end date (inclusive) in YYYY-MM-DD format"
30
+ },
31
+ "startingBalance": {
32
+ "type": "integer",
33
+ "title": "Starting Balance",
34
+ "description": "Balance carried into this statement period in integer minor units"
35
+ },
36
+ "endingBalance": {
37
+ "type": "integer",
38
+ "title": "Ending Balance",
39
+ "description": "Balance at the end of this statement period in integer minor units"
40
+ },
41
+ "totalCharges": {
42
+ "type": "integer",
43
+ "title": "Total Charges",
44
+ "minimum": 0,
45
+ "description": "Sum of all charges during the statement period in integer minor units"
46
+ },
47
+ "totalPayments": {
48
+ "type": "integer",
49
+ "title": "Total Payments",
50
+ "minimum": 0,
51
+ "description": "Sum of all payments/credits during the statement period in integer minor units"
52
+ },
53
+ "status": {
54
+ "type": "string",
55
+ "title": "Statement Status",
56
+ "$ref": "./enums.json#/$defs/StatementStatus",
57
+ "description": "Current status of the statement"
58
+ }
59
+ },
60
+ "required": [
61
+ "accountId",
62
+ "startDate",
63
+ "endDate",
64
+ "startingBalance",
65
+ "endingBalance",
66
+ "totalCharges",
67
+ "totalPayments",
68
+ "status"
69
+ ]
70
+ }
@@ -42,9 +42,9 @@
42
42
  "description": "ISO 4217 currency code for the transaction."
43
43
  },
44
44
  "amount": {
45
- "type": "number",
45
+ "type": "integer",
46
46
  "title": "Amount",
47
- "description": "Transaction amount (can be positive or negative)"
47
+ "description": "Transaction amount in integer minor units. Can be positive or negative."
48
48
  },
49
49
  "description": {
50
50
  "type": "string",
@@ -68,6 +68,12 @@
68
68
  "format": "uuid",
69
69
  "description": "Category UUID for this transaction"
70
70
  },
71
+ "statementId": {
72
+ "type": ["string", "null"],
73
+ "title": "Statement ID",
74
+ "format": "uuid",
75
+ "description": "Statement UUID for this transaction"
76
+ },
71
77
  "aggregationServiceId": {
72
78
  "type": ["string", "null"],
73
79
  "title": "Aggregation Service ID",
@@ -17,10 +17,10 @@
17
17
  "description": "The identifier of the parent transaction."
18
18
  },
19
19
  "amount": {
20
- "type": "number",
20
+ "type": "integer",
21
21
  "title": "Amount",
22
- "exclusiveMinimum": 0,
23
- "description": "The amount allocated to this split (must be non-zero; can be positive or negative)."
22
+ "minimum": 1,
23
+ "description": "The amount allocated to this split in integer minor units. Must be greater than 0."
24
24
  },
25
25
  "categoryId": {
26
26
  "type": ["string", "null"],
package/dist/index.d.ts CHANGED
@@ -213,6 +213,13 @@ export type RecurringTransactionState = 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CAN
213
213
  * via the `definition` "RecurringTransactionEventStatus".
214
214
  */
215
215
  export type RecurringTransactionEventStatus = 'MODIFIED' | 'DELETED';
216
+ /**
217
+ * Allowed statuses for statements
218
+ *
219
+ * This interface was referenced by `LucaSchemaEnums`'s JSON-Schema
220
+ * via the `definition` "StatementStatus".
221
+ */
222
+ export type StatementStatus = 'draft' | 'current' | 'past' | 'locked';
216
223
 
217
224
  /**
218
225
  * Shared enumerations for Luca Schema objects
@@ -336,10 +343,74 @@ export type APR = number | null;
336
343
  */
337
344
  export type ClosedAt = string | null;
338
345
  /**
339
- * Defines recurring financial transactions within the application.
346
+ * Defines the schema for credit card statements.
340
347
  */
341
- export type RecurringTransaction = Common2 & {
348
+ export type Statement = Common2 & {
342
349
  accountId: AccountID;
350
+ startDate: StartDate;
351
+ endDate: EndDate;
352
+ startingBalance: StartingBalance;
353
+ endingBalance: EndingBalance;
354
+ totalCharges: TotalCharges;
355
+ totalPayments: TotalPayments;
356
+ /**
357
+ * Allowed statuses for statements
358
+ */
359
+ status: 'draft' | 'current' | 'past' | 'locked';
360
+ };
361
+ /**
362
+ * UUID for the item
363
+ */
364
+ export type ID2 = string;
365
+ /**
366
+ * The timestamp of the creation of the item
367
+ */
368
+ export type DateCreated2 = string;
369
+ /**
370
+ * The timestamp of the last update or null if the item has not been updated yet
371
+ */
372
+ export type LastUpdated2 = string | null;
373
+ /**
374
+ * The timestamp of when the item was soft-deleted
375
+ */
376
+ export type DateDeleted2 = string | null;
377
+ /**
378
+ * Version number for optimistic concurrency control
379
+ */
380
+ export type Version2 = number;
381
+ /**
382
+ * ID of the account this statement belongs to
383
+ */
384
+ export type AccountID = string;
385
+ /**
386
+ * Statement start date (inclusive) in YYYY-MM-DD format
387
+ */
388
+ export type StartDate = string;
389
+ /**
390
+ * Statement end date (inclusive) in YYYY-MM-DD format
391
+ */
392
+ export type EndDate = string;
393
+ /**
394
+ * Balance carried into this statement period in integer minor units
395
+ */
396
+ export type StartingBalance = number;
397
+ /**
398
+ * Balance at the end of this statement period in integer minor units
399
+ */
400
+ export type EndingBalance = number;
401
+ /**
402
+ * Sum of all charges during the statement period in integer minor units
403
+ */
404
+ export type TotalCharges = number;
405
+ /**
406
+ * Sum of all payments/credits during the statement period in integer minor units
407
+ */
408
+ export type TotalPayments = number;
409
+ /**
410
+ * Defines recurring financial transactions within the application.
411
+ */
412
+ export type RecurringTransaction = Common3 & {
413
+ accountId: AccountID1;
343
414
  categoryId?: CategoryID;
344
415
  amount: Amount;
345
416
  description: Description1;
@@ -349,8 +420,8 @@ export type RecurringTransaction = Common2 & {
349
420
  frequency: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
350
421
  interval: FrequencyInterval;
351
422
  occurrences?: TotalOccurrences;
352
- startOn: StartDate;
353
- endOn?: EndDate;
423
+ startOn: StartDate1;
424
+ endOn?: EndDate1;
354
425
  /**
355
426
  * Allowed states for recurring transactions
356
427
  */
@@ -359,33 +430,33 @@ export type RecurringTransaction = Common2 & {
359
430
  /**
360
431
  * UUID for the item
361
432
  */
362
- export type ID2 = string;
433
+ export type ID3 = string;
363
434
  /**
364
435
  * The timestamp of the creation of the item
365
436
  */
366
- export type DateCreated2 = string;
437
+ export type DateCreated3 = string;
367
438
  /**
368
439
  * The timestamp of the last update or null if the item has not been updated yet
369
440
  */
370
- export type LastUpdated2 = string | null;
441
+ export type LastUpdated3 = string | null;
371
442
  /**
372
443
  * The timestamp of when the item was soft-deleted
373
444
  */
374
- export type DateDeleted2 = string | null;
445
+ export type DateDeleted3 = string | null;
375
446
  /**
376
447
  * Version number for optimistic concurrency control
377
448
  */
378
- export type Version2 = number;
449
+ export type Version3 = number;
379
450
  /**
380
451
  * ID of the account this transaction belongs to
381
452
  */
382
- export type AccountID = string;
453
+ export type AccountID1 = string;
383
454
  /**
384
455
  * Category identifier for organizing the transaction. Can be null if not categorized.
385
456
  */
386
457
  export type CategoryID = string | null;
387
458
  /**
388
- * The monetary value of the transaction.
459
+ * The monetary value in integer minor units. Can be positive or negative.
389
460
  */
390
461
  export type Amount = number;
391
462
  /**
@@ -403,15 +474,15 @@ export type TotalOccurrences = number | null;
403
474
  /**
404
475
  * The date on which the recurring transaction series should begin.
405
476
  */
406
- export type StartDate = string;
477
+ export type StartDate1 = string;
407
478
  /**
408
479
  * The date on which the recurring transaction series should end. Can be null.
409
480
  */
410
- export type EndDate = string | null;
481
+ export type EndDate1 = string | null;
411
482
  /**
412
483
  * Manages occurrences of recurring transactions, including tracking their modifications or logical deletions. 'transactionId' is required when an occurrence is modified to link it to an actual transaction.
413
484
  */
414
- export type RecurringTransactionEvent = Common3 & {
485
+ export type RecurringTransactionEvent = Common4 & {
415
486
  transactionId?: AssociatedTransactionID;
416
487
  recurringTransactionId?: RecurringTransactionID;
417
488
  expectedDate?: ExpectedDate;
@@ -432,23 +503,23 @@ export type RecurringTransactionEvent = Common3 & {
432
503
  /**
433
504
  * UUID for the item
434
505
  */
435
- export type ID3 = string;
506
+ export type ID4 = string;
436
507
  /**
437
508
  * The timestamp of the creation of the item
438
509
  */
439
- export type DateCreated3 = string;
510
+ export type DateCreated4 = string;
440
511
  /**
441
512
  * The timestamp of the last update or null if the item has not been updated yet
442
513
  */
443
- export type LastUpdated3 = string | null;
514
+ export type LastUpdated4 = string | null;
444
515
  /**
445
516
  * The timestamp of when the item was soft-deleted
446
517
  */
447
- export type DateDeleted3 = string | null;
518
+ export type DateDeleted4 = string | null;
448
519
  /**
449
520
  * Version number for optimistic concurrency control
450
521
  */
451
- export type Version3 = number;
522
+ export type Version4 = number;
452
523
  /**
453
524
  * Identifier of the actual transaction when the occurrence is modified; must be null when deleted.
454
525
  */
@@ -461,8 +532,8 @@ export type RecurringTransactionID = string;
461
532
  * The date when the occurrence is expected.
462
533
  */
463
534
  export type ExpectedDate = string;
464
- export type Transaction = Common4 & {
465
- accountId: AccountID1;
535
+ export type Transaction = Common5 & {
536
+ accountId: AccountID2;
466
537
  date: Date;
467
538
  authorizedAt?: AuthorizedAt;
468
539
  postedAt?: PostedAt;
@@ -472,6 +543,7 @@ export type Transaction = Common4 & {
472
543
  memo?: Memo;
473
544
  counterparty?: Counterparty;
474
545
  categoryId?: CategoryID1;
546
+ statementId?: StatementID;
475
547
  aggregationServiceId?: AggregationServiceID1;
476
548
  /**
477
549
  * Allowed transaction lifecycle states
@@ -492,27 +564,27 @@ export type Transaction = Common4 & {
492
564
  /**
493
565
  * UUID for the item
494
566
  */
495
- export type ID4 = string;
567
+ export type ID5 = string;
496
568
  /**
497
569
  * The timestamp of the creation of the item
498
570
  */
499
- export type DateCreated4 = string;
571
+ export type DateCreated5 = string;
500
572
  /**
501
573
  * The timestamp of the last update or null if the item has not been updated yet
502
574
  */
503
- export type LastUpdated4 = string | null;
575
+ export type LastUpdated5 = string | null;
504
576
  /**
505
577
  * The timestamp of when the item was soft-deleted
506
578
  */
507
- export type DateDeleted4 = string | null;
579
+ export type DateDeleted5 = string | null;
508
580
  /**
509
581
  * Version number for optimistic concurrency control
510
582
  */
511
- export type Version4 = number;
583
+ export type Version5 = number;
512
584
  /**
513
585
  * ID of the account this transaction belongs to
514
586
  */
515
- export type AccountID1 = string;
587
+ export type AccountID2 = string;
516
588
  /**
517
589
  * Date of the transaction in YYYY-MM-DD format
518
590
  */
@@ -530,7 +602,7 @@ export type PostedAt = string | null;
530
602
  */
531
603
  export type Currency = string | null;
532
604
  /**
533
- * Transaction amount (can be positive or negative)
605
+ * Transaction amount in integer minor units. Can be positive or negative.
534
606
  */
535
607
  export type Amount1 = number;
536
608
  /**
@@ -549,6 +621,10 @@ export type Counterparty = string | null;
549
621
  * Category UUID for this transaction
550
622
  */
551
623
  export type CategoryID1 = string | null;
624
+ /**
625
+ * Statement UUID for this transaction
626
+ */
627
+ export type StatementID = string | null;
552
628
  /**
553
629
  * Identifier for this transaction in a financial data aggregation service.
554
630
  */
@@ -560,7 +636,7 @@ export type DeletedAt = string | null;
560
636
  /**
561
637
  * Defines a split within a transaction.
562
638
  */
563
- export type TransactionSplit = Common5 & {
639
+ export type TransactionSplit = Common6 & {
564
640
  transactionId: TransactionID;
565
641
  amount: Amount2;
566
642
  categoryId: CategoryID2;
@@ -570,29 +646,29 @@ export type TransactionSplit = Common5 & {
570
646
  /**
571
647
  * UUID for the item
572
648
  */
573
- export type ID5 = string;
649
+ export type ID6 = string;
574
650
  /**
575
651
  * The timestamp of the creation of the item
576
652
  */
577
- export type DateCreated5 = string;
653
+ export type DateCreated6 = string;
578
654
  /**
579
655
  * The timestamp of the last update or null if the item has not been updated yet
580
656
  */
581
- export type LastUpdated5 = string | null;
657
+ export type LastUpdated6 = string | null;
582
658
  /**
583
659
  * The timestamp of when the item was soft-deleted
584
660
  */
585
- export type DateDeleted5 = string | null;
661
+ export type DateDeleted6 = string | null;
586
662
  /**
587
663
  * Version number for optimistic concurrency control
588
664
  */
589
- export type Version5 = number;
665
+ export type Version6 = number;
590
666
  /**
591
667
  * The identifier of the parent transaction.
592
668
  */
593
669
  export type TransactionID = string;
594
670
  /**
595
- * The amount allocated to this split (must be non-zero; can be positive or negative).
671
+ * The amount allocated to this split in integer minor units. Must be greater than 0.
596
672
  */
597
673
  export type Amount2 = number;
598
674
  /**
@@ -624,6 +700,10 @@ export interface LucaSchema {
624
700
  * List of accounts
625
701
  */
626
702
  accounts: Account[];
703
+ /**
704
+ * List of statements
705
+ */
706
+ statements: Statement[];
627
707
  /**
628
708
  * List of recurring transactions
629
709
  */
@@ -701,6 +781,16 @@ export interface Common5 {
701
781
  deletedAt?: DateDeleted5;
702
782
  version?: Version5;
703
783
  }
784
+ /**
785
+ * Common properties for all schemas
786
+ */
787
+ export interface Common6 {
788
+ id: ID6;
789
+ createdAt: DateCreated6;
790
+ updatedAt: LastUpdated6;
791
+ deletedAt?: DateDeleted6;
792
+ version?: Version6;
793
+ }
704
794
 
705
795
  /**
706
796
  * Defines recurring financial transactions within the application.
@@ -752,7 +842,7 @@ export type AccountID = string;
752
842
  */
753
843
  export type CategoryID = string | null;
754
844
  /**
755
- * The monetary value of the transaction.
845
+ * The monetary value in integer minor units. Can be positive or negative.
756
846
  */
757
847
  export type Amount = number;
758
848
  /**
@@ -852,6 +942,82 @@ export interface Common {
852
942
  version?: Version;
853
943
  }
854
944
 
945
+ /**
946
+ * Defines the schema for credit card statements.
947
+ */
948
+ export type Statement = Common & {
949
+ accountId: AccountID;
950
+ startDate: StartDate;
951
+ endDate: EndDate;
952
+ startingBalance: StartingBalance;
953
+ endingBalance: EndingBalance;
954
+ totalCharges: TotalCharges;
955
+ totalPayments: TotalPayments;
956
+ /**
957
+ * Allowed statuses for statements
958
+ */
959
+ status: 'draft' | 'current' | 'past' | 'locked';
960
+ };
961
+ /**
962
+ * UUID for the item
963
+ */
964
+ export type ID = string;
965
+ /**
966
+ * The timestamp of the creation of the item
967
+ */
968
+ export type DateCreated = string;
969
+ /**
970
+ * The timestamp of the last update or null if the item has not been updated yet
971
+ */
972
+ export type LastUpdated = string | null;
973
+ /**
974
+ * The timestamp of when the item was soft-deleted
975
+ */
976
+ export type DateDeleted = string | null;
977
+ /**
978
+ * Version number for optimistic concurrency control
979
+ */
980
+ export type Version = number;
981
+ /**
982
+ * ID of the account this statement belongs to
983
+ */
984
+ export type AccountID = string;
985
+ /**
986
+ * Statement start date (inclusive) in YYYY-MM-DD format
987
+ */
988
+ export type StartDate = string;
989
+ /**
990
+ * Statement end date (inclusive) in YYYY-MM-DD format
991
+ */
992
+ export type EndDate = string;
993
+ /**
994
+ * Balance carried into this statement period in integer minor units
995
+ */
996
+ export type StartingBalance = number;
997
+ /**
998
+ * Balance at the end of this statement period in integer minor units
999
+ */
1000
+ export type EndingBalance = number;
1001
+ /**
1002
+ * Sum of all charges during the statement period in integer minor units
1003
+ */
1004
+ export type TotalCharges = number;
1005
+ /**
1006
+ * Sum of all payments/credits during the statement period in integer minor units
1007
+ */
1008
+ export type TotalPayments = number;
1009
+
1010
+ /**
1011
+ * Common properties for all schemas
1012
+ */
1013
+ export interface Common {
1014
+ id: ID;
1015
+ createdAt: DateCreated;
1016
+ updatedAt: LastUpdated;
1017
+ deletedAt?: DateDeleted;
1018
+ version?: Version;
1019
+ }
1020
+
855
1021
  export type Transaction = Common & {
856
1022
  accountId: AccountID;
857
1023
  date: Date;
@@ -863,6 +1029,7 @@ export type Transaction = Common & {
863
1029
  memo?: Memo;
864
1030
  counterparty?: Counterparty;
865
1031
  categoryId?: CategoryID;
1032
+ statementId?: StatementID;
866
1033
  aggregationServiceId?: AggregationServiceID;
867
1034
  /**
868
1035
  * Allowed transaction lifecycle states
@@ -921,7 +1088,7 @@ export type PostedAt = string | null;
921
1088
  */
922
1089
  export type Currency = string | null;
923
1090
  /**
924
- * Transaction amount (can be positive or negative)
1091
+ * Transaction amount in integer minor units. Can be positive or negative.
925
1092
  */
926
1093
  export type Amount = number;
927
1094
  /**
@@ -940,6 +1107,10 @@ export type Counterparty = string | null;
940
1107
  * Category UUID for this transaction
941
1108
  */
942
1109
  export type CategoryID = string | null;
1110
+ /**
1111
+ * Statement UUID for this transaction
1112
+ */
1113
+ export type StatementID = string | null;
943
1114
  /**
944
1115
  * Identifier for this transaction in a financial data aggregation service.
945
1116
  */
@@ -995,7 +1166,7 @@ export type Version = number;
995
1166
  */
996
1167
  export type TransactionID = string;
997
1168
  /**
998
- * The amount allocated to this split (must be non-zero; can be positive or negative).
1169
+ * The amount allocated to this split in integer minor units. Must be greater than 0.
999
1170
  */
1000
1171
  export type Amount = number;
1001
1172
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luca-financial/luca-schema",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Schemas for the Luca Ledger application",
5
5
  "author": "Johnathan Aspinwall",
6
6
  "main": "dist/esm/index.js",