backbone-accounting 0.18.0

GL, journals, ledger, reconciliation (extracted from bersihir)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
//! Public types for Accounting module
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! These DTOs are the ONLY types other modules should use.
//! They are decoupled from internal domain entities.

use serde::{Deserialize, Serialize};
use uuid::Uuid;
use chrono::{DateTime, Utc, NaiveDate};
use rust_decimal::Decimal;
use crate::domain::entity::*;

// ============================================================================
// ACCOUNT TYPES
// ============================================================================

/// Type-safe ID for Account
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct AccountId(pub Uuid);

impl AccountId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for AccountId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<AccountId> for Uuid {
    fn from(id: AccountId) -> Self {
        id.0
    }
}

/// Data transfer object for Account
///
/// This is the public representation of Account for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountDto {
    pub id: AccountId,
    pub account_number: String,
    pub account_code: String,
    pub name: String,
    pub description: Option<String>,
    pub account_type: AccountType,
    pub account_subtype: AccountSubtype,
    pub normal_balance: NormalBalance,
    pub parent_id: Option<Uuid>,
    pub level: i32,
    pub path: Option<String>,
    pub is_header: bool,
    pub is_detail: bool,
    pub currency: String,
    pub opening_balance: Decimal,
    pub opening_balance_date: Option<NaiveDate>,
    pub current_balance: Decimal,
    pub is_reconcilable: bool,
    pub has_budget: bool,
    pub budget_amount: Option<Decimal>,
    pub sort_order: i32,
    pub show_in_reports: bool,
    pub status: AccountStatus,
    pub is_system: bool,
    pub notes: Option<String>,
    pub source_id: Option<Uuid>,
    pub is_cloned: bool,
    pub chart_code: Option<String>,
    pub chart_version: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of Account for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountSummary {
    pub id: AccountId,
    pub name: String,
    pub status: AccountStatus,
}

/// Reference to Account for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountRef {
    pub id: AccountId,
}

// ============================================================================
// ACCOUNTINGPOST TYPES
// ============================================================================

/// Type-safe ID for AccountingPost
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct AccountingPostId(pub Uuid);

impl AccountingPostId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for AccountingPostId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<AccountingPostId> for Uuid {
    fn from(id: AccountingPostId) -> Self {
        id.0
    }
}

/// Data transfer object for AccountingPost
///
/// This is the public representation of AccountingPost for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountingPostDto {
    pub id: AccountingPostId,
    pub branch_id: Option<Uuid>,
    pub source_type: PostingSourceType,
    pub source_id: Uuid,
    pub source_reference: Option<String>,
    pub journal_id: Option<Uuid>,
    pub posting_type: PostingType,
    pub posting_status: PostingStatus,
    pub currency: String,
    pub total_debit: Decimal,
    pub total_credit: Decimal,
    pub scheduled_at: Option<DateTime<Utc>>,
    pub posted_at: Option<DateTime<Utc>>,
    pub failed_at: Option<DateTime<Utc>>,
    pub retry_count: i32,
    pub max_retries: i32,
    pub next_retry_at: Option<DateTime<Utc>>,
    pub error_code: Option<String>,
    pub error_message: Option<String>,
    pub reverses_post_id: Option<Uuid>,
    pub reversed_by_post_id: Option<Uuid>,
    pub posted_by: Option<Uuid>,
    pub notes: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of AccountingPost for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountingPostSummary {
    pub id: AccountingPostId,
}

/// Reference to AccountingPost for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountingPostRef {
    pub id: AccountingPostId,
}

// ============================================================================
// COSTCENTER TYPES
// ============================================================================

/// Type-safe ID for CostCenter
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct CostCenterId(pub Uuid);

impl CostCenterId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for CostCenterId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<CostCenterId> for Uuid {
    fn from(id: CostCenterId) -> Self {
        id.0
    }
}

/// Data transfer object for CostCenter
///
/// This is the public representation of CostCenter for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostCenterDto {
    pub id: CostCenterId,
    pub code: String,
    pub name: String,
    pub description: Option<String>,
    pub parent_id: Option<Uuid>,
    pub level: i32,
    pub is_group: bool,
    pub branch_id: Option<Uuid>,
    pub status: CostCenterStatus,
    pub sort_order: i32,
    pub metadata: serde_json::Value,
}

/// Summary view of CostCenter for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostCenterSummary {
    pub id: CostCenterId,
    pub name: String,
    pub status: CostCenterStatus,
}

/// Reference to CostCenter for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostCenterRef {
    pub id: CostCenterId,
}

// ============================================================================
// EMVQRCONFIG TYPES
// ============================================================================

/// Type-safe ID for EmvQrConfig
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct EmvQrConfigId(pub Uuid);

impl EmvQrConfigId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for EmvQrConfigId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<EmvQrConfigId> for Uuid {
    fn from(id: EmvQrConfigId) -> Self {
        id.0
    }
}

/// Data transfer object for EmvQrConfig
///
/// This is the public representation of EmvQrConfig for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmvQrConfigDto {
    pub id: EmvQrConfigId,
    pub merchant_name: String,
    pub merchant_city: String,
    pub country_code: String,
    pub mcc: String,
    pub gui: String,
    pub merchant_identifier: String,
    pub currency: String,
    pub initiation_method: String,
    pub bank_account_id: Option<Uuid>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: serde_json::Value,
}

/// Summary view of EmvQrConfig for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmvQrConfigSummary {
    pub id: EmvQrConfigId,
    pub merchant_name: String,
    pub created_at: DateTime<Utc>,
}

/// Reference to EmvQrConfig for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmvQrConfigRef {
    pub id: EmvQrConfigId,
}

// ============================================================================
// BANKCHECKSEQUENCE TYPES
// ============================================================================

/// Type-safe ID for BankCheckSequence
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BankCheckSequenceId(pub Uuid);

impl BankCheckSequenceId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for BankCheckSequenceId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<BankCheckSequenceId> for Uuid {
    fn from(id: BankCheckSequenceId) -> Self {
        id.0
    }
}

/// Data transfer object for BankCheckSequence
///
/// This is the public representation of BankCheckSequence for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BankCheckSequenceDto {
    pub id: BankCheckSequenceId,
    pub bank_account_id: Uuid,
    pub numbering_mode: String,
    pub next_number: i64,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: serde_json::Value,
}

/// Summary view of BankCheckSequence for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BankCheckSequenceSummary {
    pub id: BankCheckSequenceId,
    pub created_at: DateTime<Utc>,
}

/// Reference to BankCheckSequence for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BankCheckSequenceRef {
    pub id: BankCheckSequenceId,
}

// ============================================================================
// PRINTEDCHECK TYPES
// ============================================================================

/// Type-safe ID for PrintedCheck
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PrintedCheckId(pub Uuid);

impl PrintedCheckId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PrintedCheckId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PrintedCheckId> for Uuid {
    fn from(id: PrintedCheckId) -> Self {
        id.0
    }
}

/// Data transfer object for PrintedCheck
///
/// This is the public representation of PrintedCheck for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrintedCheckDto {
    pub id: PrintedCheckId,
    pub bank_account_id: Uuid,
    pub payment_id: Uuid,
    pub payment_number: Option<String>,
    pub check_number: String,
    pub amount: Decimal,
    pub payee_name: Option<String>,
    pub status: String,
    pub printed_at: DateTime<Utc>,
    pub printed_by: Option<Uuid>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: serde_json::Value,
}

/// Summary view of PrintedCheck for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrintedCheckSummary {
    pub id: PrintedCheckId,
    pub payee_name: Option<String>,
    pub status: String,
    pub created_at: DateTime<Utc>,
}

/// Reference to PrintedCheck for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrintedCheckRef {
    pub id: PrintedCheckId,
}

// ============================================================================
// TAXTAGREPAIRRUN TYPES
// ============================================================================

/// Type-safe ID for TaxTagRepairRun
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TaxTagRepairRunId(pub Uuid);

impl TaxTagRepairRunId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for TaxTagRepairRunId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<TaxTagRepairRunId> for Uuid {
    fn from(id: TaxTagRepairRunId) -> Self {
        id.0
    }
}

/// Data transfer object for TaxTagRepairRun
///
/// This is the public representation of TaxTagRepairRun for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaxTagRepairRunDto {
    pub id: TaxTagRepairRunId,
    pub date_from: NaiveDate,
    pub date_to: NaiveDate,
    pub rules: serde_json::Value,
    pub lines_examined: i64,
    pub lines_retagged: i64,
    pub dry_run: bool,
    pub overridden_closed_periods: serde_json::Value,
    pub actor: Option<Uuid>,
    pub reason: String,
    pub ran_at: DateTime<Utc>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: serde_json::Value,
}

/// Summary view of TaxTagRepairRun for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaxTagRepairRunSummary {
    pub id: TaxTagRepairRunId,
    pub created_at: DateTime<Utc>,
}

/// Reference to TaxTagRepairRun for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaxTagRepairRunRef {
    pub id: TaxTagRepairRunId,
}

// ============================================================================
// FINANCIALSTATEMENT TYPES
// ============================================================================

/// Type-safe ID for FinancialStatement
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FinancialStatementId(pub Uuid);

impl FinancialStatementId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for FinancialStatementId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<FinancialStatementId> for Uuid {
    fn from(id: FinancialStatementId) -> Self {
        id.0
    }
}

/// Data transfer object for FinancialStatement
///
/// This is the public representation of FinancialStatement for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialStatementDto {
    pub id: FinancialStatementId,
    pub statement_number: String,
    pub statement_type: StatementType,
    pub name: String,
    pub fiscal_period_id: Option<Uuid>,
    pub fiscal_year: i32,
    pub fiscal_month: Option<i32>,
    pub as_of_date: NaiveDate,
    pub period_start: Option<NaiveDate>,
    pub period_end: Option<NaiveDate>,
    pub is_comparative: bool,
    pub comparative_period_id: Option<Uuid>,
    pub comparative_as_of_date: Option<NaiveDate>,
    pub status: StatementStatus,
    pub total_current_assets: Option<Decimal>,
    pub total_non_current_assets: Option<Decimal>,
    pub total_assets: Option<Decimal>,
    pub total_current_liabilities: Option<Decimal>,
    pub total_non_current_liabilities: Option<Decimal>,
    pub total_liabilities: Option<Decimal>,
    pub total_equity: Option<Decimal>,
    pub balance_check: bool,
    pub balance_difference: Option<Decimal>,
    pub total_revenue: Option<Decimal>,
    pub total_cogs: Option<Decimal>,
    pub gross_profit: Option<Decimal>,
    pub gross_profit_margin: Option<Decimal>,
    pub total_operating_expenses: Option<Decimal>,
    pub operating_income: Option<Decimal>,
    pub operating_margin: Option<Decimal>,
    pub total_other_income: Option<Decimal>,
    pub total_other_expenses: Option<Decimal>,
    pub income_before_tax: Option<Decimal>,
    pub tax_expense: Option<Decimal>,
    pub net_income: Option<Decimal>,
    pub net_profit_margin: Option<Decimal>,
    pub cash_from_operations: Option<Decimal>,
    pub cash_from_investing: Option<Decimal>,
    pub cash_from_financing: Option<Decimal>,
    pub net_cash_change: Option<Decimal>,
    pub beginning_cash: Option<Decimal>,
    pub ending_cash: Option<Decimal>,
    pub total_debits: Option<Decimal>,
    pub total_credits: Option<Decimal>,
    pub trial_balance_check: bool,
    pub line_items: serde_json::Value,
    pub comparative_data: serde_json::Value,
    pub variance_data: serde_json::Value,
    pub notes: serde_json::Value,
    pub management_notes: Option<String>,
    pub generated_at: Option<DateTime<Utc>>,
    pub generated_by: Option<Uuid>,
    pub generation_parameters: serde_json::Value,
    pub reviewed_at: Option<DateTime<Utc>>,
    pub reviewed_by: Option<Uuid>,
    pub approved_at: Option<DateTime<Utc>>,
    pub approved_by: Option<Uuid>,
    pub published_at: Option<DateTime<Utc>>,
    pub pdf_url: Option<String>,
    pub excel_url: Option<String>,
    pub currency: String,
    pub metadata: serde_json::Value,
}

/// Summary view of FinancialStatement for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialStatementSummary {
    pub id: FinancialStatementId,
    pub name: String,
    pub status: StatementStatus,
}

/// Reference to FinancialStatement for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialStatementRef {
    pub id: FinancialStatementId,
}

// ============================================================================
// FISCALPERIOD TYPES
// ============================================================================

/// Type-safe ID for FiscalPeriod
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FiscalPeriodId(pub Uuid);

impl FiscalPeriodId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for FiscalPeriodId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<FiscalPeriodId> for Uuid {
    fn from(id: FiscalPeriodId) -> Self {
        id.0
    }
}

/// Data transfer object for FiscalPeriod
///
/// This is the public representation of FiscalPeriod for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FiscalPeriodDto {
    pub id: FiscalPeriodId,
    pub period_code: String,
    pub name: String,
    pub period_type: PeriodType,
    pub start_date: NaiveDate,
    pub end_date: NaiveDate,
    pub fiscal_year: i32,
    pub fiscal_quarter: Option<i32>,
    pub fiscal_month: Option<i32>,
    pub parent_id: Option<Uuid>,
    pub level: i32,
    pub status: PeriodStatus,
    pub is_current: bool,
    pub opening_balance_set: bool,
    pub opening_balance_date: Option<DateTime<Utc>>,
    pub opening_balance_by: Option<Uuid>,
    pub closing_started_at: Option<DateTime<Utc>>,
    pub closing_started_by: Option<Uuid>,
    pub closed_at: Option<DateTime<Utc>>,
    pub closed_by: Option<Uuid>,
    pub locked_at: Option<DateTime<Utc>>,
    pub locked_by: Option<Uuid>,
    pub lock_reason: Option<String>,
    pub reopened_at: Option<DateTime<Utc>>,
    pub reopened_by: Option<Uuid>,
    pub reopen_reason: Option<String>,
    pub allow_adjustments: bool,
    pub adjustment_deadline: Option<NaiveDate>,
    pub total_debits: Decimal,
    pub total_credits: Decimal,
    pub journal_count: i32,
    pub total_revenue: Decimal,
    pub total_expenses: Decimal,
    pub net_income: Decimal,
    pub total_assets: Decimal,
    pub total_liabilities: Decimal,
    pub total_equity: Decimal,
    pub balance_sheet_generated: bool,
    pub income_statement_generated: bool,
    pub statements_generated_at: Option<DateTime<Utc>>,
    pub notes: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of FiscalPeriod for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FiscalPeriodSummary {
    pub id: FiscalPeriodId,
    pub name: String,
    pub status: PeriodStatus,
}

/// Reference to FiscalPeriod for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FiscalPeriodRef {
    pub id: FiscalPeriodId,
}

// ============================================================================
// JOURNAL TYPES
// ============================================================================

/// Type-safe ID for Journal
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct JournalId(pub Uuid);

impl JournalId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for JournalId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<JournalId> for Uuid {
    fn from(id: JournalId) -> Self {
        id.0
    }
}

/// Data transfer object for Journal
///
/// This is the public representation of Journal for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalDto {
    pub id: JournalId,
    pub journal_number: String,
    pub reference_number: Option<String>,
    pub journal_type: JournalType,
    pub branch_id: Option<Uuid>,
    pub transaction_date: NaiveDate,
    pub posting_date: Option<NaiveDate>,
    pub fiscal_period_id: Option<Uuid>,
    pub fiscal_year: Option<i32>,
    pub fiscal_month: Option<i32>,
    pub description: String,
    pub notes: Option<String>,
    pub currency: String,
    pub total_debit: Decimal,
    pub total_credit: Decimal,
    pub line_count: i32,
    pub source: JournalSource,
    pub source_type: Option<String>,
    pub source_id: Option<Uuid>,
    pub source_reference: Option<String>,
    pub is_reversed: bool,
    pub reversed_by_id: Option<Uuid>,
    pub reversed_at: Option<DateTime<Utc>>,
    pub reversal_reason: Option<String>,
    pub reverses_id: Option<Uuid>,
    pub is_reversing: bool,
    pub auto_reverse: bool,
    pub auto_reverse_date: Option<NaiveDate>,
    pub status: JournalStatus,
    pub requires_approval: bool,
    pub approval_threshold: Option<Decimal>,
    pub submitted_at: Option<DateTime<Utc>>,
    pub submitted_by: Option<Uuid>,
    pub approved_at: Option<DateTime<Utc>>,
    pub approved_by: Option<Uuid>,
    pub rejected_at: Option<DateTime<Utc>>,
    pub rejected_by: Option<Uuid>,
    pub rejection_reason: Option<String>,
    pub posted_at: Option<DateTime<Utc>>,
    pub posted_by: Option<Uuid>,
    pub is_voided: bool,
    pub voided_at: Option<DateTime<Utc>>,
    pub voided_by: Option<Uuid>,
    pub void_reason: Option<String>,
    pub attachments: serde_json::Value,
    pub metadata: serde_json::Value,
}

/// Summary view of Journal for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalSummary {
    pub id: JournalId,
    pub status: JournalStatus,
}

/// Reference to Journal for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalRef {
    pub id: JournalId,
}

// ============================================================================
// JOURNALLINE TYPES
// ============================================================================

/// Type-safe ID for JournalLine
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct JournalLineId(pub Uuid);

impl JournalLineId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for JournalLineId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<JournalLineId> for Uuid {
    fn from(id: JournalLineId) -> Self {
        id.0
    }
}

/// Data transfer object for JournalLine
///
/// This is the public representation of JournalLine for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalLineDto {
    pub id: JournalLineId,
    pub journal_id: Uuid,
    pub branch_id: Option<Uuid>,
    pub party_type: Option<PartyType>,
    pub party_id: Option<Uuid>,
    pub line_number: i32,
    pub account_id: Uuid,
    pub account_number: String,
    pub account_name: String,
    pub debit_amount: Decimal,
    pub credit_amount: Decimal,
    pub currency: String,
    pub exchange_rate: Decimal,
    pub base_debit_amount: Decimal,
    pub base_credit_amount: Decimal,
    pub description: Option<String>,
    pub cost_center_id: Option<Uuid>,
    pub project_id: Option<Uuid>,
    pub department_id: Option<Uuid>,
    pub dimensions: Option<serde_json::Value>,
    pub source_type: Option<String>,
    pub source_id: Option<Uuid>,
    pub source_reference: Option<String>,
    pub is_tax_line: bool,
    pub tax_rate: Option<Decimal>,
    pub tax_base_amount: Option<Decimal>,
    pub related_line_id: Option<Uuid>,
    pub has_quantity: bool,
    pub quantity: Option<Decimal>,
    pub unit: Option<String>,
    pub unit_price: Option<Decimal>,
    pub is_reconciled: bool,
    pub reconciliation_id: Option<Uuid>,
    pub reconciled_at: Option<DateTime<Utc>>,
    pub full_reconcile_id: Option<Uuid>,
    pub is_posted: bool,
    pub ledger_id: Option<Uuid>,
    pub posted_at: Option<DateTime<Utc>>,
    pub tags: serde_json::Value,
    pub data: serde_json::Value,
}

/// Summary view of JournalLine for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalLineSummary {
    pub id: JournalLineId,
    pub account_name: String,
}

/// Reference to JournalLine for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JournalLineRef {
    pub id: JournalLineId,
}

// ============================================================================
// LEDGER TYPES
// ============================================================================

/// Type-safe ID for Ledger
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct LedgerId(pub Uuid);

impl LedgerId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for LedgerId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<LedgerId> for Uuid {
    fn from(id: LedgerId) -> Self {
        id.0
    }
}

/// Data transfer object for Ledger
///
/// This is the public representation of Ledger for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LedgerDto {
    pub id: LedgerId,
    pub account_id: Uuid,
    pub account_number: String,
    pub account_name: String,
    pub account_type: AccountType,
    pub normal_balance: NormalBalance,
    pub journal_id: Uuid,
    pub journal_number: String,
    pub journal_line_id: Uuid,
    pub transaction_date: NaiveDate,
    pub posting_date: NaiveDate,
    pub fiscal_period_id: Option<Uuid>,
    pub fiscal_year: i32,
    pub fiscal_month: i32,
    pub description: String,
    pub reference: Option<String>,
    pub currency: String,
    pub debit_amount: Decimal,
    pub credit_amount: Decimal,
    pub balance_before: Decimal,
    pub balance_after: Decimal,
    pub balance_change: Decimal,
    pub sequence_number: i32,
    pub branch_id: Option<Uuid>,
    pub party_type: Option<PartyType>,
    pub party_id: Option<Uuid>,
    pub cost_center_id: Option<Uuid>,
    pub project_id: Option<Uuid>,
    pub department_id: Option<Uuid>,
    pub dimensions: Option<serde_json::Value>,
    pub source_type: Option<String>,
    pub source_id: Option<Uuid>,
    pub source_reference: Option<String>,
    pub is_reconciled: bool,
    pub reconciliation_id: Option<Uuid>,
    pub reconciled_at: Option<DateTime<Utc>>,
    pub is_opening_balance: bool,
    pub is_closing_entry: bool,
    pub is_adjustment: bool,
    pub is_reversed: bool,
    pub reversed_by_id: Option<Uuid>,
    pub reverses_id: Option<Uuid>,
    pub metadata: serde_json::Value,
}

/// Summary view of Ledger for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LedgerSummary {
    pub id: LedgerId,
    pub account_name: String,
}

/// Reference to Ledger for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LedgerRef {
    pub id: LedgerId,
}

// ============================================================================
// RECONCILIATION TYPES
// ============================================================================

/// Type-safe ID for Reconciliation
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ReconciliationId(pub Uuid);

impl ReconciliationId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for ReconciliationId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<ReconciliationId> for Uuid {
    fn from(id: ReconciliationId) -> Self {
        id.0
    }
}

/// Data transfer object for Reconciliation
///
/// This is the public representation of Reconciliation for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationDto {
    pub id: ReconciliationId,
    pub reconciliation_number: String,
    pub account_id: Uuid,
    pub account_number: String,
    pub account_name: String,
    pub reconciliation_type: ReconciliationType,
    pub period_start: NaiveDate,
    pub period_end: NaiveDate,
    pub statement_date: NaiveDate,
    pub opening_book_balance: Decimal,
    pub opening_statement_balance: Decimal,
    pub previous_reconciliation_id: Option<Uuid>,
    pub closing_book_balance: Decimal,
    pub closing_statement_balance: Decimal,
    pub total_matched_debits: Decimal,
    pub total_matched_credits: Decimal,
    pub matched_count: i32,
    pub total_unmatched_book_debits: Decimal,
    pub total_unmatched_book_credits: Decimal,
    pub unmatched_book_count: i32,
    pub total_unmatched_statement_debits: Decimal,
    pub total_unmatched_statement_credits: Decimal,
    pub unmatched_statement_count: i32,
    pub outstanding_deposits: Decimal,
    pub outstanding_checks: Decimal,
    pub deposits_in_transit: Decimal,
    pub bank_charges: Decimal,
    pub bank_interest: Decimal,
    pub nsf_checks: Decimal,
    pub other_adjustments: Decimal,
    pub adjusted_book_balance: Option<Decimal>,
    pub adjusted_statement_balance: Option<Decimal>,
    pub difference: Decimal,
    pub is_balanced: bool,
    pub status: ReconciliationStatus,
    pub started_at: Option<DateTime<Utc>>,
    pub started_by: Option<Uuid>,
    pub completed_at: Option<DateTime<Utc>>,
    pub completed_by: Option<Uuid>,
    pub reviewed_at: Option<DateTime<Utc>>,
    pub reviewed_by: Option<Uuid>,
    pub has_adjusting_entries: bool,
    pub adjusting_journal_ids: serde_json::Value,
    pub statement_source: Option<String>,
    pub statement_file_url: Option<String>,
    pub import_date: Option<DateTime<Utc>>,
    pub notes: Option<String>,
    pub discrepancy_notes: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of Reconciliation for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationSummary {
    pub id: ReconciliationId,
    pub account_name: String,
    pub status: ReconciliationStatus,
}

/// Reference to Reconciliation for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationRef {
    pub id: ReconciliationId,
}

// ============================================================================
// RECONCILIATIONITEM TYPES
// ============================================================================

/// Type-safe ID for ReconciliationItem
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ReconciliationItemId(pub Uuid);

impl ReconciliationItemId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for ReconciliationItemId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<ReconciliationItemId> for Uuid {
    fn from(id: ReconciliationItemId) -> Self {
        id.0
    }
}

/// Data transfer object for ReconciliationItem
///
/// This is the public representation of ReconciliationItem for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationItemDto {
    pub id: ReconciliationItemId,
    pub reconciliation_id: Uuid,
    pub item_number: i32,
    pub source: String,
    pub ledger_id: Option<Uuid>,
    pub journal_id: Option<Uuid>,
    pub book_date: Option<NaiveDate>,
    pub book_reference: Option<String>,
    pub book_description: Option<String>,
    pub book_debit: Decimal,
    pub book_credit: Decimal,
    pub statement_date: Option<NaiveDate>,
    pub statement_reference: Option<String>,
    pub statement_description: Option<String>,
    pub statement_debit: Decimal,
    pub statement_credit: Decimal,
    pub status: ReconciliationItemStatus,
    pub matched_with_id: Option<Uuid>,
    pub match_date: Option<DateTime<Utc>>,
    pub match_method: Option<String>,
    pub match_confidence: Option<Decimal>,
    pub has_difference: bool,
    pub difference_amount: Decimal,
    pub difference_reason: Option<String>,
    pub requires_adjustment: bool,
    pub adjustment_type: Option<String>,
    pub adjustment_journal_id: Option<Uuid>,
    pub adjusted_at: Option<DateTime<Utc>>,
    pub is_written_off: bool,
    pub write_off_reason: Option<String>,
    pub write_off_approved_by: Option<Uuid>,
    pub is_outstanding: bool,
    pub outstanding_type: Option<String>,
    pub expected_clear_date: Option<NaiveDate>,
    pub notes: Option<String>,
    pub data: serde_json::Value,
}

/// Summary view of ReconciliationItem for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationItemSummary {
    pub id: ReconciliationItemId,
    pub status: ReconciliationItemStatus,
}

/// Reference to ReconciliationItem for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReconciliationItemRef {
    pub id: ReconciliationItemId,
}

// ============================================================================
// FULLRECONCILE TYPES
// ============================================================================

/// Type-safe ID for FullReconcile
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FullReconcileId(pub Uuid);

impl FullReconcileId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for FullReconcileId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<FullReconcileId> for Uuid {
    fn from(id: FullReconcileId) -> Self {
        id.0
    }
}

/// Data transfer object for FullReconcile
///
/// This is the public representation of FullReconcile for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FullReconcileDto {
    pub id: FullReconcileId,
    pub exchange_total: Decimal,
    pub reconciled_at: DateTime<Utc>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: Option<serde_json::Value>,
}

/// Summary view of FullReconcile for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FullReconcileSummary {
    pub id: FullReconcileId,
    pub created_at: DateTime<Utc>,
}

/// Reference to FullReconcile for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FullReconcileRef {
    pub id: FullReconcileId,
}

// ============================================================================
// PARTIALRECONCILE TYPES
// ============================================================================

/// Type-safe ID for PartialReconcile
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PartialReconcileId(pub Uuid);

impl PartialReconcileId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PartialReconcileId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PartialReconcileId> for Uuid {
    fn from(id: PartialReconcileId) -> Self {
        id.0
    }
}

/// Data transfer object for PartialReconcile
///
/// This is the public representation of PartialReconcile for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PartialReconcileDto {
    pub id: PartialReconcileId,
    pub debit_move_id: Uuid,
    pub credit_move_id: Uuid,
    pub full_reconcile_id: Option<Uuid>,
    pub exchange_move_id: Option<Uuid>,
    pub amount: Decimal,
    pub debit_amount_currency: Option<Decimal>,
    pub credit_amount_currency: Option<Decimal>,
    pub currency: String,
    pub max_date: NaiveDate,
    pub origin: ReconcileOrigin,
    pub source_type: Option<String>,
    pub source_id: Option<Uuid>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub metadata: Option<serde_json::Value>,
}

/// Summary view of PartialReconcile for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PartialReconcileSummary {
    pub id: PartialReconcileId,
    pub created_at: DateTime<Utc>,
}

/// Reference to PartialReconcile for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PartialReconcileRef {
    pub id: PartialReconcileId,
}

// ============================================================================
// CUSTOM TYPES
// ============================================================================

// Add custom public types here