Skip to main content

backbone_accounting/exports/
types.rs

1//! Public types for Accounting module
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! These DTOs are the ONLY types other modules should use.
6//! They are decoupled from internal domain entities.
7
8use serde::{Deserialize, Serialize};
9use uuid::Uuid;
10use chrono::{DateTime, Utc, NaiveDate};
11use rust_decimal::Decimal;
12use crate::domain::entity::*;
13
14// ============================================================================
15// ACCOUNT TYPES
16// ============================================================================
17
18/// Type-safe ID for Account
19///
20/// Use this instead of raw Uuid for type safety across modules.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
22pub struct AccountId(pub Uuid);
23
24impl AccountId {
25    pub fn new(id: Uuid) -> Self {
26        Self(id)
27    }
28
29    pub fn into_inner(self) -> Uuid {
30        self.0
31    }
32}
33
34impl From<Uuid> for AccountId {
35    fn from(id: Uuid) -> Self {
36        Self(id)
37    }
38}
39
40impl From<AccountId> for Uuid {
41    fn from(id: AccountId) -> Self {
42        id.0
43    }
44}
45
46/// Data transfer object for Account
47///
48/// This is the public representation of Account for other modules.
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct AccountDto {
51    pub id: AccountId,
52    pub account_number: String,
53    pub account_code: String,
54    pub name: String,
55    pub description: Option<String>,
56    pub account_type: AccountType,
57    pub account_subtype: AccountSubtype,
58    pub normal_balance: NormalBalance,
59    pub parent_id: Option<Uuid>,
60    pub level: i32,
61    pub path: Option<String>,
62    pub is_header: bool,
63    pub is_detail: bool,
64    pub currency: String,
65    pub opening_balance: Decimal,
66    pub opening_balance_date: Option<NaiveDate>,
67    pub current_balance: Decimal,
68    pub is_reconcilable: bool,
69    pub has_budget: bool,
70    pub budget_amount: Option<Decimal>,
71    pub sort_order: i32,
72    pub show_in_reports: bool,
73    pub status: AccountStatus,
74    pub is_system: bool,
75    pub notes: Option<String>,
76    pub source_id: Option<Uuid>,
77    pub is_cloned: bool,
78    pub chart_code: Option<String>,
79    pub chart_version: Option<String>,
80    pub metadata: serde_json::Value,
81}
82
83/// Summary view of Account for list displays
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct AccountSummary {
86    pub id: AccountId,
87    pub name: String,
88    pub status: AccountStatus,
89}
90
91/// Reference to Account for foreign key relationships
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct AccountRef {
94    pub id: AccountId,
95}
96
97// ============================================================================
98// ACCOUNTINGPOST TYPES
99// ============================================================================
100
101/// Type-safe ID for AccountingPost
102///
103/// Use this instead of raw Uuid for type safety across modules.
104#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
105pub struct AccountingPostId(pub Uuid);
106
107impl AccountingPostId {
108    pub fn new(id: Uuid) -> Self {
109        Self(id)
110    }
111
112    pub fn into_inner(self) -> Uuid {
113        self.0
114    }
115}
116
117impl From<Uuid> for AccountingPostId {
118    fn from(id: Uuid) -> Self {
119        Self(id)
120    }
121}
122
123impl From<AccountingPostId> for Uuid {
124    fn from(id: AccountingPostId) -> Self {
125        id.0
126    }
127}
128
129/// Data transfer object for AccountingPost
130///
131/// This is the public representation of AccountingPost for other modules.
132#[derive(Debug, Clone, Serialize, Deserialize)]
133pub struct AccountingPostDto {
134    pub id: AccountingPostId,
135    pub branch_id: Option<Uuid>,
136    pub source_type: PostingSourceType,
137    pub source_id: Uuid,
138    pub source_reference: Option<String>,
139    pub journal_id: Option<Uuid>,
140    pub posting_type: PostingType,
141    pub posting_status: PostingStatus,
142    pub currency: String,
143    pub total_debit: Decimal,
144    pub total_credit: Decimal,
145    pub scheduled_at: Option<DateTime<Utc>>,
146    pub posted_at: Option<DateTime<Utc>>,
147    pub failed_at: Option<DateTime<Utc>>,
148    pub retry_count: i32,
149    pub max_retries: i32,
150    pub next_retry_at: Option<DateTime<Utc>>,
151    pub error_code: Option<String>,
152    pub error_message: Option<String>,
153    pub reverses_post_id: Option<Uuid>,
154    pub reversed_by_post_id: Option<Uuid>,
155    pub posted_by: Option<Uuid>,
156    pub notes: Option<String>,
157    pub metadata: serde_json::Value,
158}
159
160/// Summary view of AccountingPost for list displays
161#[derive(Debug, Clone, Serialize, Deserialize)]
162pub struct AccountingPostSummary {
163    pub id: AccountingPostId,
164}
165
166/// Reference to AccountingPost for foreign key relationships
167#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct AccountingPostRef {
169    pub id: AccountingPostId,
170}
171
172// ============================================================================
173// COSTCENTER TYPES
174// ============================================================================
175
176/// Type-safe ID for CostCenter
177///
178/// Use this instead of raw Uuid for type safety across modules.
179#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
180pub struct CostCenterId(pub Uuid);
181
182impl CostCenterId {
183    pub fn new(id: Uuid) -> Self {
184        Self(id)
185    }
186
187    pub fn into_inner(self) -> Uuid {
188        self.0
189    }
190}
191
192impl From<Uuid> for CostCenterId {
193    fn from(id: Uuid) -> Self {
194        Self(id)
195    }
196}
197
198impl From<CostCenterId> for Uuid {
199    fn from(id: CostCenterId) -> Self {
200        id.0
201    }
202}
203
204/// Data transfer object for CostCenter
205///
206/// This is the public representation of CostCenter for other modules.
207#[derive(Debug, Clone, Serialize, Deserialize)]
208pub struct CostCenterDto {
209    pub id: CostCenterId,
210    pub code: String,
211    pub name: String,
212    pub description: Option<String>,
213    pub parent_id: Option<Uuid>,
214    pub level: i32,
215    pub is_group: bool,
216    pub branch_id: Option<Uuid>,
217    pub status: CostCenterStatus,
218    pub sort_order: i32,
219    pub metadata: serde_json::Value,
220}
221
222/// Summary view of CostCenter for list displays
223#[derive(Debug, Clone, Serialize, Deserialize)]
224pub struct CostCenterSummary {
225    pub id: CostCenterId,
226    pub name: String,
227    pub status: CostCenterStatus,
228}
229
230/// Reference to CostCenter for foreign key relationships
231#[derive(Debug, Clone, Serialize, Deserialize)]
232pub struct CostCenterRef {
233    pub id: CostCenterId,
234}
235
236// ============================================================================
237// EMVQRCONFIG TYPES
238// ============================================================================
239
240/// Type-safe ID for EmvQrConfig
241///
242/// Use this instead of raw Uuid for type safety across modules.
243#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
244pub struct EmvQrConfigId(pub Uuid);
245
246impl EmvQrConfigId {
247    pub fn new(id: Uuid) -> Self {
248        Self(id)
249    }
250
251    pub fn into_inner(self) -> Uuid {
252        self.0
253    }
254}
255
256impl From<Uuid> for EmvQrConfigId {
257    fn from(id: Uuid) -> Self {
258        Self(id)
259    }
260}
261
262impl From<EmvQrConfigId> for Uuid {
263    fn from(id: EmvQrConfigId) -> Self {
264        id.0
265    }
266}
267
268/// Data transfer object for EmvQrConfig
269///
270/// This is the public representation of EmvQrConfig for other modules.
271#[derive(Debug, Clone, Serialize, Deserialize)]
272pub struct EmvQrConfigDto {
273    pub id: EmvQrConfigId,
274    pub merchant_name: String,
275    pub merchant_city: String,
276    pub country_code: String,
277    pub mcc: String,
278    pub gui: String,
279    pub merchant_identifier: String,
280    pub currency: String,
281    pub initiation_method: String,
282    pub bank_account_id: Option<Uuid>,
283    pub created_at: DateTime<Utc>,
284    pub updated_at: DateTime<Utc>,
285    pub metadata: serde_json::Value,
286}
287
288/// Summary view of EmvQrConfig for list displays
289#[derive(Debug, Clone, Serialize, Deserialize)]
290pub struct EmvQrConfigSummary {
291    pub id: EmvQrConfigId,
292    pub merchant_name: String,
293    pub created_at: DateTime<Utc>,
294}
295
296/// Reference to EmvQrConfig for foreign key relationships
297#[derive(Debug, Clone, Serialize, Deserialize)]
298pub struct EmvQrConfigRef {
299    pub id: EmvQrConfigId,
300}
301
302// ============================================================================
303// BANKCHECKSEQUENCE TYPES
304// ============================================================================
305
306/// Type-safe ID for BankCheckSequence
307///
308/// Use this instead of raw Uuid for type safety across modules.
309#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
310pub struct BankCheckSequenceId(pub Uuid);
311
312impl BankCheckSequenceId {
313    pub fn new(id: Uuid) -> Self {
314        Self(id)
315    }
316
317    pub fn into_inner(self) -> Uuid {
318        self.0
319    }
320}
321
322impl From<Uuid> for BankCheckSequenceId {
323    fn from(id: Uuid) -> Self {
324        Self(id)
325    }
326}
327
328impl From<BankCheckSequenceId> for Uuid {
329    fn from(id: BankCheckSequenceId) -> Self {
330        id.0
331    }
332}
333
334/// Data transfer object for BankCheckSequence
335///
336/// This is the public representation of BankCheckSequence for other modules.
337#[derive(Debug, Clone, Serialize, Deserialize)]
338pub struct BankCheckSequenceDto {
339    pub id: BankCheckSequenceId,
340    pub bank_account_id: Uuid,
341    pub numbering_mode: String,
342    pub next_number: i64,
343    pub created_at: DateTime<Utc>,
344    pub updated_at: DateTime<Utc>,
345    pub metadata: serde_json::Value,
346}
347
348/// Summary view of BankCheckSequence for list displays
349#[derive(Debug, Clone, Serialize, Deserialize)]
350pub struct BankCheckSequenceSummary {
351    pub id: BankCheckSequenceId,
352    pub created_at: DateTime<Utc>,
353}
354
355/// Reference to BankCheckSequence for foreign key relationships
356#[derive(Debug, Clone, Serialize, Deserialize)]
357pub struct BankCheckSequenceRef {
358    pub id: BankCheckSequenceId,
359}
360
361// ============================================================================
362// PRINTEDCHECK TYPES
363// ============================================================================
364
365/// Type-safe ID for PrintedCheck
366///
367/// Use this instead of raw Uuid for type safety across modules.
368#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
369pub struct PrintedCheckId(pub Uuid);
370
371impl PrintedCheckId {
372    pub fn new(id: Uuid) -> Self {
373        Self(id)
374    }
375
376    pub fn into_inner(self) -> Uuid {
377        self.0
378    }
379}
380
381impl From<Uuid> for PrintedCheckId {
382    fn from(id: Uuid) -> Self {
383        Self(id)
384    }
385}
386
387impl From<PrintedCheckId> for Uuid {
388    fn from(id: PrintedCheckId) -> Self {
389        id.0
390    }
391}
392
393/// Data transfer object for PrintedCheck
394///
395/// This is the public representation of PrintedCheck for other modules.
396#[derive(Debug, Clone, Serialize, Deserialize)]
397pub struct PrintedCheckDto {
398    pub id: PrintedCheckId,
399    pub bank_account_id: Uuid,
400    pub payment_id: Uuid,
401    pub payment_number: Option<String>,
402    pub check_number: String,
403    pub amount: Decimal,
404    pub payee_name: Option<String>,
405    pub status: String,
406    pub printed_at: DateTime<Utc>,
407    pub printed_by: Option<Uuid>,
408    pub created_at: DateTime<Utc>,
409    pub updated_at: DateTime<Utc>,
410    pub metadata: serde_json::Value,
411}
412
413/// Summary view of PrintedCheck for list displays
414#[derive(Debug, Clone, Serialize, Deserialize)]
415pub struct PrintedCheckSummary {
416    pub id: PrintedCheckId,
417    pub payee_name: Option<String>,
418    pub status: String,
419    pub created_at: DateTime<Utc>,
420}
421
422/// Reference to PrintedCheck for foreign key relationships
423#[derive(Debug, Clone, Serialize, Deserialize)]
424pub struct PrintedCheckRef {
425    pub id: PrintedCheckId,
426}
427
428// ============================================================================
429// TAXTAGREPAIRRUN TYPES
430// ============================================================================
431
432/// Type-safe ID for TaxTagRepairRun
433///
434/// Use this instead of raw Uuid for type safety across modules.
435#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
436pub struct TaxTagRepairRunId(pub Uuid);
437
438impl TaxTagRepairRunId {
439    pub fn new(id: Uuid) -> Self {
440        Self(id)
441    }
442
443    pub fn into_inner(self) -> Uuid {
444        self.0
445    }
446}
447
448impl From<Uuid> for TaxTagRepairRunId {
449    fn from(id: Uuid) -> Self {
450        Self(id)
451    }
452}
453
454impl From<TaxTagRepairRunId> for Uuid {
455    fn from(id: TaxTagRepairRunId) -> Self {
456        id.0
457    }
458}
459
460/// Data transfer object for TaxTagRepairRun
461///
462/// This is the public representation of TaxTagRepairRun for other modules.
463#[derive(Debug, Clone, Serialize, Deserialize)]
464pub struct TaxTagRepairRunDto {
465    pub id: TaxTagRepairRunId,
466    pub date_from: NaiveDate,
467    pub date_to: NaiveDate,
468    pub rules: serde_json::Value,
469    pub lines_examined: i64,
470    pub lines_retagged: i64,
471    pub dry_run: bool,
472    pub closed_periods_overridden: serde_json::Value,
473    pub actor: Option<Uuid>,
474    pub reason: String,
475    pub ran_at: DateTime<Utc>,
476    pub created_at: DateTime<Utc>,
477    pub updated_at: DateTime<Utc>,
478    pub metadata: serde_json::Value,
479}
480
481/// Summary view of TaxTagRepairRun for list displays
482#[derive(Debug, Clone, Serialize, Deserialize)]
483pub struct TaxTagRepairRunSummary {
484    pub id: TaxTagRepairRunId,
485    pub created_at: DateTime<Utc>,
486}
487
488/// Reference to TaxTagRepairRun for foreign key relationships
489#[derive(Debug, Clone, Serialize, Deserialize)]
490pub struct TaxTagRepairRunRef {
491    pub id: TaxTagRepairRunId,
492}
493
494// ============================================================================
495// FINANCIALSTATEMENT TYPES
496// ============================================================================
497
498/// Type-safe ID for FinancialStatement
499///
500/// Use this instead of raw Uuid for type safety across modules.
501#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
502pub struct FinancialStatementId(pub Uuid);
503
504impl FinancialStatementId {
505    pub fn new(id: Uuid) -> Self {
506        Self(id)
507    }
508
509    pub fn into_inner(self) -> Uuid {
510        self.0
511    }
512}
513
514impl From<Uuid> for FinancialStatementId {
515    fn from(id: Uuid) -> Self {
516        Self(id)
517    }
518}
519
520impl From<FinancialStatementId> for Uuid {
521    fn from(id: FinancialStatementId) -> Self {
522        id.0
523    }
524}
525
526/// Data transfer object for FinancialStatement
527///
528/// This is the public representation of FinancialStatement for other modules.
529#[derive(Debug, Clone, Serialize, Deserialize)]
530pub struct FinancialStatementDto {
531    pub id: FinancialStatementId,
532    pub statement_number: String,
533    pub statement_type: StatementType,
534    pub name: String,
535    pub fiscal_period_id: Option<Uuid>,
536    pub fiscal_year: i32,
537    pub fiscal_month: Option<i32>,
538    pub as_of_date: NaiveDate,
539    pub period_start: Option<NaiveDate>,
540    pub period_end: Option<NaiveDate>,
541    pub is_comparative: bool,
542    pub comparative_period_id: Option<Uuid>,
543    pub comparative_as_of_date: Option<NaiveDate>,
544    pub status: StatementStatus,
545    pub total_current_assets: Option<Decimal>,
546    pub total_non_current_assets: Option<Decimal>,
547    pub total_assets: Option<Decimal>,
548    pub total_current_liabilities: Option<Decimal>,
549    pub total_non_current_liabilities: Option<Decimal>,
550    pub total_liabilities: Option<Decimal>,
551    pub total_equity: Option<Decimal>,
552    pub balance_check: bool,
553    pub balance_difference: Option<Decimal>,
554    pub total_revenue: Option<Decimal>,
555    pub total_cogs: Option<Decimal>,
556    pub gross_profit: Option<Decimal>,
557    pub gross_profit_margin: Option<Decimal>,
558    pub total_operating_expenses: Option<Decimal>,
559    pub operating_income: Option<Decimal>,
560    pub operating_margin: Option<Decimal>,
561    pub total_other_income: Option<Decimal>,
562    pub total_other_expenses: Option<Decimal>,
563    pub income_before_tax: Option<Decimal>,
564    pub tax_expense: Option<Decimal>,
565    pub net_income: Option<Decimal>,
566    pub net_profit_margin: Option<Decimal>,
567    pub cash_from_operations: Option<Decimal>,
568    pub cash_from_investing: Option<Decimal>,
569    pub cash_from_financing: Option<Decimal>,
570    pub net_cash_change: Option<Decimal>,
571    pub beginning_cash: Option<Decimal>,
572    pub ending_cash: Option<Decimal>,
573    pub total_debits: Option<Decimal>,
574    pub total_credits: Option<Decimal>,
575    pub trial_balance_check: bool,
576    pub line_items: serde_json::Value,
577    pub comparative_data: serde_json::Value,
578    pub variance_data: serde_json::Value,
579    pub notes: serde_json::Value,
580    pub management_notes: Option<String>,
581    pub generated_at: Option<DateTime<Utc>>,
582    pub generated_by: Option<Uuid>,
583    pub generation_parameters: serde_json::Value,
584    pub reviewed_at: Option<DateTime<Utc>>,
585    pub reviewed_by: Option<Uuid>,
586    pub approved_at: Option<DateTime<Utc>>,
587    pub approved_by: Option<Uuid>,
588    pub published_at: Option<DateTime<Utc>>,
589    pub pdf_url: Option<String>,
590    pub excel_url: Option<String>,
591    pub currency: String,
592    pub metadata: serde_json::Value,
593}
594
595/// Summary view of FinancialStatement for list displays
596#[derive(Debug, Clone, Serialize, Deserialize)]
597pub struct FinancialStatementSummary {
598    pub id: FinancialStatementId,
599    pub name: String,
600    pub status: StatementStatus,
601}
602
603/// Reference to FinancialStatement for foreign key relationships
604#[derive(Debug, Clone, Serialize, Deserialize)]
605pub struct FinancialStatementRef {
606    pub id: FinancialStatementId,
607}
608
609// ============================================================================
610// FISCALPERIOD TYPES
611// ============================================================================
612
613/// Type-safe ID for FiscalPeriod
614///
615/// Use this instead of raw Uuid for type safety across modules.
616#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
617pub struct FiscalPeriodId(pub Uuid);
618
619impl FiscalPeriodId {
620    pub fn new(id: Uuid) -> Self {
621        Self(id)
622    }
623
624    pub fn into_inner(self) -> Uuid {
625        self.0
626    }
627}
628
629impl From<Uuid> for FiscalPeriodId {
630    fn from(id: Uuid) -> Self {
631        Self(id)
632    }
633}
634
635impl From<FiscalPeriodId> for Uuid {
636    fn from(id: FiscalPeriodId) -> Self {
637        id.0
638    }
639}
640
641/// Data transfer object for FiscalPeriod
642///
643/// This is the public representation of FiscalPeriod for other modules.
644#[derive(Debug, Clone, Serialize, Deserialize)]
645pub struct FiscalPeriodDto {
646    pub id: FiscalPeriodId,
647    pub period_code: String,
648    pub name: String,
649    pub period_type: PeriodType,
650    pub start_date: NaiveDate,
651    pub end_date: NaiveDate,
652    pub fiscal_year: i32,
653    pub fiscal_quarter: Option<i32>,
654    pub fiscal_month: Option<i32>,
655    pub parent_id: Option<Uuid>,
656    pub level: i32,
657    pub status: PeriodStatus,
658    pub is_current: bool,
659    pub opening_balance_set: bool,
660    pub opening_balance_date: Option<DateTime<Utc>>,
661    pub opening_balance_by: Option<Uuid>,
662    pub closing_started_at: Option<DateTime<Utc>>,
663    pub closing_started_by: Option<Uuid>,
664    pub closed_at: Option<DateTime<Utc>>,
665    pub closed_by: Option<Uuid>,
666    pub locked_at: Option<DateTime<Utc>>,
667    pub locked_by: Option<Uuid>,
668    pub lock_reason: Option<String>,
669    pub allow_adjustments: bool,
670    pub adjustment_deadline: Option<NaiveDate>,
671    pub total_debits: Decimal,
672    pub total_credits: Decimal,
673    pub journal_count: i32,
674    pub total_revenue: Decimal,
675    pub total_expenses: Decimal,
676    pub net_income: Decimal,
677    pub total_assets: Decimal,
678    pub total_liabilities: Decimal,
679    pub total_equity: Decimal,
680    pub balance_sheet_generated: bool,
681    pub income_statement_generated: bool,
682    pub statements_generated_at: Option<DateTime<Utc>>,
683    pub notes: Option<String>,
684    pub metadata: serde_json::Value,
685}
686
687/// Summary view of FiscalPeriod for list displays
688#[derive(Debug, Clone, Serialize, Deserialize)]
689pub struct FiscalPeriodSummary {
690    pub id: FiscalPeriodId,
691    pub name: String,
692    pub status: PeriodStatus,
693}
694
695/// Reference to FiscalPeriod for foreign key relationships
696#[derive(Debug, Clone, Serialize, Deserialize)]
697pub struct FiscalPeriodRef {
698    pub id: FiscalPeriodId,
699}
700
701// ============================================================================
702// JOURNAL TYPES
703// ============================================================================
704
705/// Type-safe ID for Journal
706///
707/// Use this instead of raw Uuid for type safety across modules.
708#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
709pub struct JournalId(pub Uuid);
710
711impl JournalId {
712    pub fn new(id: Uuid) -> Self {
713        Self(id)
714    }
715
716    pub fn into_inner(self) -> Uuid {
717        self.0
718    }
719}
720
721impl From<Uuid> for JournalId {
722    fn from(id: Uuid) -> Self {
723        Self(id)
724    }
725}
726
727impl From<JournalId> for Uuid {
728    fn from(id: JournalId) -> Self {
729        id.0
730    }
731}
732
733/// Data transfer object for Journal
734///
735/// This is the public representation of Journal for other modules.
736#[derive(Debug, Clone, Serialize, Deserialize)]
737pub struct JournalDto {
738    pub id: JournalId,
739    pub journal_number: String,
740    pub reference_number: Option<String>,
741    pub journal_type: JournalType,
742    pub branch_id: Option<Uuid>,
743    pub transaction_date: NaiveDate,
744    pub posting_date: Option<NaiveDate>,
745    pub fiscal_period_id: Option<Uuid>,
746    pub fiscal_year: Option<i32>,
747    pub fiscal_month: Option<i32>,
748    pub description: String,
749    pub notes: Option<String>,
750    pub currency: String,
751    pub total_debit: Decimal,
752    pub total_credit: Decimal,
753    pub line_count: i32,
754    pub source: JournalSource,
755    pub source_type: Option<String>,
756    pub source_id: Option<Uuid>,
757    pub source_reference: Option<String>,
758    pub is_reversed: bool,
759    pub reversed_by_id: Option<Uuid>,
760    pub reversed_at: Option<DateTime<Utc>>,
761    pub reversal_reason: Option<String>,
762    pub reverses_id: Option<Uuid>,
763    pub is_reversing: bool,
764    pub auto_reverse: bool,
765    pub auto_reverse_date: Option<NaiveDate>,
766    pub status: JournalStatus,
767    pub requires_approval: bool,
768    pub approval_threshold: Option<Decimal>,
769    pub submitted_at: Option<DateTime<Utc>>,
770    pub submitted_by: Option<Uuid>,
771    pub approved_at: Option<DateTime<Utc>>,
772    pub approved_by: Option<Uuid>,
773    pub rejected_at: Option<DateTime<Utc>>,
774    pub rejected_by: Option<Uuid>,
775    pub rejection_reason: Option<String>,
776    pub posted_at: Option<DateTime<Utc>>,
777    pub posted_by: Option<Uuid>,
778    pub is_voided: bool,
779    pub voided_at: Option<DateTime<Utc>>,
780    pub voided_by: Option<Uuid>,
781    pub void_reason: Option<String>,
782    pub attachments: serde_json::Value,
783    pub metadata: serde_json::Value,
784}
785
786/// Summary view of Journal for list displays
787#[derive(Debug, Clone, Serialize, Deserialize)]
788pub struct JournalSummary {
789    pub id: JournalId,
790    pub status: JournalStatus,
791}
792
793/// Reference to Journal for foreign key relationships
794#[derive(Debug, Clone, Serialize, Deserialize)]
795pub struct JournalRef {
796    pub id: JournalId,
797}
798
799// ============================================================================
800// JOURNALLINE TYPES
801// ============================================================================
802
803/// Type-safe ID for JournalLine
804///
805/// Use this instead of raw Uuid for type safety across modules.
806#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
807pub struct JournalLineId(pub Uuid);
808
809impl JournalLineId {
810    pub fn new(id: Uuid) -> Self {
811        Self(id)
812    }
813
814    pub fn into_inner(self) -> Uuid {
815        self.0
816    }
817}
818
819impl From<Uuid> for JournalLineId {
820    fn from(id: Uuid) -> Self {
821        Self(id)
822    }
823}
824
825impl From<JournalLineId> for Uuid {
826    fn from(id: JournalLineId) -> Self {
827        id.0
828    }
829}
830
831/// Data transfer object for JournalLine
832///
833/// This is the public representation of JournalLine for other modules.
834#[derive(Debug, Clone, Serialize, Deserialize)]
835pub struct JournalLineDto {
836    pub id: JournalLineId,
837    pub journal_id: Uuid,
838    pub branch_id: Option<Uuid>,
839    pub party_type: Option<PartyType>,
840    pub party_id: Option<Uuid>,
841    pub line_number: i32,
842    pub account_id: Uuid,
843    pub account_number: String,
844    pub account_name: String,
845    pub debit_amount: Decimal,
846    pub credit_amount: Decimal,
847    pub currency: String,
848    pub exchange_rate: Decimal,
849    pub base_debit_amount: Decimal,
850    pub base_credit_amount: Decimal,
851    pub description: Option<String>,
852    pub cost_center_id: Option<Uuid>,
853    pub project_id: Option<Uuid>,
854    pub department_id: Option<Uuid>,
855    pub dimensions: Option<serde_json::Value>,
856    pub source_type: Option<String>,
857    pub source_id: Option<Uuid>,
858    pub source_reference: Option<String>,
859    pub is_tax_line: bool,
860    pub tax_rate: Option<Decimal>,
861    pub tax_base_amount: Option<Decimal>,
862    pub related_line_id: Option<Uuid>,
863    pub has_quantity: bool,
864    pub quantity: Option<Decimal>,
865    pub unit: Option<String>,
866    pub unit_price: Option<Decimal>,
867    pub is_reconciled: bool,
868    pub reconciliation_id: Option<Uuid>,
869    pub reconciled_at: Option<DateTime<Utc>>,
870    pub full_reconcile_id: Option<Uuid>,
871    pub is_posted: bool,
872    pub ledger_id: Option<Uuid>,
873    pub posted_at: Option<DateTime<Utc>>,
874    pub tags: serde_json::Value,
875    pub data: serde_json::Value,
876}
877
878/// Summary view of JournalLine for list displays
879#[derive(Debug, Clone, Serialize, Deserialize)]
880pub struct JournalLineSummary {
881    pub id: JournalLineId,
882    pub account_name: String,
883}
884
885/// Reference to JournalLine for foreign key relationships
886#[derive(Debug, Clone, Serialize, Deserialize)]
887pub struct JournalLineRef {
888    pub id: JournalLineId,
889}
890
891// ============================================================================
892// LEDGER TYPES
893// ============================================================================
894
895/// Type-safe ID for Ledger
896///
897/// Use this instead of raw Uuid for type safety across modules.
898#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
899pub struct LedgerId(pub Uuid);
900
901impl LedgerId {
902    pub fn new(id: Uuid) -> Self {
903        Self(id)
904    }
905
906    pub fn into_inner(self) -> Uuid {
907        self.0
908    }
909}
910
911impl From<Uuid> for LedgerId {
912    fn from(id: Uuid) -> Self {
913        Self(id)
914    }
915}
916
917impl From<LedgerId> for Uuid {
918    fn from(id: LedgerId) -> Self {
919        id.0
920    }
921}
922
923/// Data transfer object for Ledger
924///
925/// This is the public representation of Ledger for other modules.
926#[derive(Debug, Clone, Serialize, Deserialize)]
927pub struct LedgerDto {
928    pub id: LedgerId,
929    pub account_id: Uuid,
930    pub account_number: String,
931    pub account_name: String,
932    pub account_type: AccountType,
933    pub normal_balance: NormalBalance,
934    pub journal_id: Uuid,
935    pub journal_number: String,
936    pub journal_line_id: Uuid,
937    pub transaction_date: NaiveDate,
938    pub posting_date: NaiveDate,
939    pub fiscal_period_id: Option<Uuid>,
940    pub fiscal_year: i32,
941    pub fiscal_month: i32,
942    pub description: String,
943    pub reference: Option<String>,
944    pub currency: String,
945    pub debit_amount: Decimal,
946    pub credit_amount: Decimal,
947    pub balance_before: Decimal,
948    pub balance_after: Decimal,
949    pub balance_change: Decimal,
950    pub sequence_number: i32,
951    pub branch_id: Option<Uuid>,
952    pub party_type: Option<PartyType>,
953    pub party_id: Option<Uuid>,
954    pub cost_center_id: Option<Uuid>,
955    pub project_id: Option<Uuid>,
956    pub department_id: Option<Uuid>,
957    pub dimensions: Option<serde_json::Value>,
958    pub source_type: Option<String>,
959    pub source_id: Option<Uuid>,
960    pub source_reference: Option<String>,
961    pub is_reconciled: bool,
962    pub reconciliation_id: Option<Uuid>,
963    pub reconciled_at: Option<DateTime<Utc>>,
964    pub is_opening_balance: bool,
965    pub is_closing_entry: bool,
966    pub is_adjustment: bool,
967    pub is_reversed: bool,
968    pub reversed_by_id: Option<Uuid>,
969    pub reverses_id: Option<Uuid>,
970    pub metadata: serde_json::Value,
971}
972
973/// Summary view of Ledger for list displays
974#[derive(Debug, Clone, Serialize, Deserialize)]
975pub struct LedgerSummary {
976    pub id: LedgerId,
977    pub account_name: String,
978}
979
980/// Reference to Ledger for foreign key relationships
981#[derive(Debug, Clone, Serialize, Deserialize)]
982pub struct LedgerRef {
983    pub id: LedgerId,
984}
985
986// ============================================================================
987// RECONCILIATION TYPES
988// ============================================================================
989
990/// Type-safe ID for Reconciliation
991///
992/// Use this instead of raw Uuid for type safety across modules.
993#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
994pub struct ReconciliationId(pub Uuid);
995
996impl ReconciliationId {
997    pub fn new(id: Uuid) -> Self {
998        Self(id)
999    }
1000
1001    pub fn into_inner(self) -> Uuid {
1002        self.0
1003    }
1004}
1005
1006impl From<Uuid> for ReconciliationId {
1007    fn from(id: Uuid) -> Self {
1008        Self(id)
1009    }
1010}
1011
1012impl From<ReconciliationId> for Uuid {
1013    fn from(id: ReconciliationId) -> Self {
1014        id.0
1015    }
1016}
1017
1018/// Data transfer object for Reconciliation
1019///
1020/// This is the public representation of Reconciliation for other modules.
1021#[derive(Debug, Clone, Serialize, Deserialize)]
1022pub struct ReconciliationDto {
1023    pub id: ReconciliationId,
1024    pub reconciliation_number: String,
1025    pub account_id: Uuid,
1026    pub account_number: String,
1027    pub account_name: String,
1028    pub reconciliation_type: ReconciliationType,
1029    pub period_start: NaiveDate,
1030    pub period_end: NaiveDate,
1031    pub statement_date: NaiveDate,
1032    pub opening_book_balance: Decimal,
1033    pub opening_statement_balance: Decimal,
1034    pub previous_reconciliation_id: Option<Uuid>,
1035    pub closing_book_balance: Decimal,
1036    pub closing_statement_balance: Decimal,
1037    pub total_matched_debits: Decimal,
1038    pub total_matched_credits: Decimal,
1039    pub matched_count: i32,
1040    pub total_unmatched_book_debits: Decimal,
1041    pub total_unmatched_book_credits: Decimal,
1042    pub unmatched_book_count: i32,
1043    pub total_unmatched_statement_debits: Decimal,
1044    pub total_unmatched_statement_credits: Decimal,
1045    pub unmatched_statement_count: i32,
1046    pub outstanding_deposits: Decimal,
1047    pub outstanding_checks: Decimal,
1048    pub deposits_in_transit: Decimal,
1049    pub bank_charges: Decimal,
1050    pub bank_interest: Decimal,
1051    pub nsf_checks: Decimal,
1052    pub other_adjustments: Decimal,
1053    pub adjusted_book_balance: Option<Decimal>,
1054    pub adjusted_statement_balance: Option<Decimal>,
1055    pub difference: Decimal,
1056    pub is_balanced: bool,
1057    pub status: ReconciliationStatus,
1058    pub started_at: Option<DateTime<Utc>>,
1059    pub started_by: Option<Uuid>,
1060    pub completed_at: Option<DateTime<Utc>>,
1061    pub completed_by: Option<Uuid>,
1062    pub reviewed_at: Option<DateTime<Utc>>,
1063    pub reviewed_by: Option<Uuid>,
1064    pub has_adjusting_entries: bool,
1065    pub adjusting_journal_ids: serde_json::Value,
1066    pub statement_source: Option<String>,
1067    pub statement_file_url: Option<String>,
1068    pub import_date: Option<DateTime<Utc>>,
1069    pub notes: Option<String>,
1070    pub discrepancy_notes: Option<String>,
1071    pub metadata: serde_json::Value,
1072}
1073
1074/// Summary view of Reconciliation for list displays
1075#[derive(Debug, Clone, Serialize, Deserialize)]
1076pub struct ReconciliationSummary {
1077    pub id: ReconciliationId,
1078    pub account_name: String,
1079    pub status: ReconciliationStatus,
1080}
1081
1082/// Reference to Reconciliation for foreign key relationships
1083#[derive(Debug, Clone, Serialize, Deserialize)]
1084pub struct ReconciliationRef {
1085    pub id: ReconciliationId,
1086}
1087
1088// ============================================================================
1089// RECONCILIATIONITEM TYPES
1090// ============================================================================
1091
1092/// Type-safe ID for ReconciliationItem
1093///
1094/// Use this instead of raw Uuid for type safety across modules.
1095#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1096pub struct ReconciliationItemId(pub Uuid);
1097
1098impl ReconciliationItemId {
1099    pub fn new(id: Uuid) -> Self {
1100        Self(id)
1101    }
1102
1103    pub fn into_inner(self) -> Uuid {
1104        self.0
1105    }
1106}
1107
1108impl From<Uuid> for ReconciliationItemId {
1109    fn from(id: Uuid) -> Self {
1110        Self(id)
1111    }
1112}
1113
1114impl From<ReconciliationItemId> for Uuid {
1115    fn from(id: ReconciliationItemId) -> Self {
1116        id.0
1117    }
1118}
1119
1120/// Data transfer object for ReconciliationItem
1121///
1122/// This is the public representation of ReconciliationItem for other modules.
1123#[derive(Debug, Clone, Serialize, Deserialize)]
1124pub struct ReconciliationItemDto {
1125    pub id: ReconciliationItemId,
1126    pub reconciliation_id: Uuid,
1127    pub item_number: i32,
1128    pub source: String,
1129    pub ledger_id: Option<Uuid>,
1130    pub journal_id: Option<Uuid>,
1131    pub book_date: Option<NaiveDate>,
1132    pub book_reference: Option<String>,
1133    pub book_description: Option<String>,
1134    pub book_debit: Decimal,
1135    pub book_credit: Decimal,
1136    pub statement_date: Option<NaiveDate>,
1137    pub statement_reference: Option<String>,
1138    pub statement_description: Option<String>,
1139    pub statement_debit: Decimal,
1140    pub statement_credit: Decimal,
1141    pub status: ReconciliationItemStatus,
1142    pub matched_with_id: Option<Uuid>,
1143    pub match_date: Option<DateTime<Utc>>,
1144    pub match_method: Option<String>,
1145    pub match_confidence: Option<Decimal>,
1146    pub has_difference: bool,
1147    pub difference_amount: Decimal,
1148    pub difference_reason: Option<String>,
1149    pub requires_adjustment: bool,
1150    pub adjustment_type: Option<String>,
1151    pub adjustment_journal_id: Option<Uuid>,
1152    pub adjusted_at: Option<DateTime<Utc>>,
1153    pub is_written_off: bool,
1154    pub write_off_reason: Option<String>,
1155    pub write_off_approved_by: Option<Uuid>,
1156    pub is_outstanding: bool,
1157    pub outstanding_type: Option<String>,
1158    pub expected_clear_date: Option<NaiveDate>,
1159    pub notes: Option<String>,
1160    pub data: serde_json::Value,
1161}
1162
1163/// Summary view of ReconciliationItem for list displays
1164#[derive(Debug, Clone, Serialize, Deserialize)]
1165pub struct ReconciliationItemSummary {
1166    pub id: ReconciliationItemId,
1167    pub status: ReconciliationItemStatus,
1168}
1169
1170/// Reference to ReconciliationItem for foreign key relationships
1171#[derive(Debug, Clone, Serialize, Deserialize)]
1172pub struct ReconciliationItemRef {
1173    pub id: ReconciliationItemId,
1174}
1175
1176// ============================================================================
1177// FULLRECONCILE TYPES
1178// ============================================================================
1179
1180/// Type-safe ID for FullReconcile
1181///
1182/// Use this instead of raw Uuid for type safety across modules.
1183#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1184pub struct FullReconcileId(pub Uuid);
1185
1186impl FullReconcileId {
1187    pub fn new(id: Uuid) -> Self {
1188        Self(id)
1189    }
1190
1191    pub fn into_inner(self) -> Uuid {
1192        self.0
1193    }
1194}
1195
1196impl From<Uuid> for FullReconcileId {
1197    fn from(id: Uuid) -> Self {
1198        Self(id)
1199    }
1200}
1201
1202impl From<FullReconcileId> for Uuid {
1203    fn from(id: FullReconcileId) -> Self {
1204        id.0
1205    }
1206}
1207
1208/// Data transfer object for FullReconcile
1209///
1210/// This is the public representation of FullReconcile for other modules.
1211#[derive(Debug, Clone, Serialize, Deserialize)]
1212pub struct FullReconcileDto {
1213    pub id: FullReconcileId,
1214    pub exchange_total: Decimal,
1215    pub reconciled_at: DateTime<Utc>,
1216    pub created_at: DateTime<Utc>,
1217    pub updated_at: DateTime<Utc>,
1218    pub metadata: Option<serde_json::Value>,
1219}
1220
1221/// Summary view of FullReconcile for list displays
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1223pub struct FullReconcileSummary {
1224    pub id: FullReconcileId,
1225    pub created_at: DateTime<Utc>,
1226}
1227
1228/// Reference to FullReconcile for foreign key relationships
1229#[derive(Debug, Clone, Serialize, Deserialize)]
1230pub struct FullReconcileRef {
1231    pub id: FullReconcileId,
1232}
1233
1234// ============================================================================
1235// PARTIALRECONCILE TYPES
1236// ============================================================================
1237
1238/// Type-safe ID for PartialReconcile
1239///
1240/// Use this instead of raw Uuid for type safety across modules.
1241#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1242pub struct PartialReconcileId(pub Uuid);
1243
1244impl PartialReconcileId {
1245    pub fn new(id: Uuid) -> Self {
1246        Self(id)
1247    }
1248
1249    pub fn into_inner(self) -> Uuid {
1250        self.0
1251    }
1252}
1253
1254impl From<Uuid> for PartialReconcileId {
1255    fn from(id: Uuid) -> Self {
1256        Self(id)
1257    }
1258}
1259
1260impl From<PartialReconcileId> for Uuid {
1261    fn from(id: PartialReconcileId) -> Self {
1262        id.0
1263    }
1264}
1265
1266/// Data transfer object for PartialReconcile
1267///
1268/// This is the public representation of PartialReconcile for other modules.
1269#[derive(Debug, Clone, Serialize, Deserialize)]
1270pub struct PartialReconcileDto {
1271    pub id: PartialReconcileId,
1272    pub debit_move_id: Uuid,
1273    pub credit_move_id: Uuid,
1274    pub full_reconcile_id: Option<Uuid>,
1275    pub exchange_move_id: Option<Uuid>,
1276    pub amount: Decimal,
1277    pub debit_amount_currency: Option<Decimal>,
1278    pub credit_amount_currency: Option<Decimal>,
1279    pub currency: String,
1280    pub max_date: NaiveDate,
1281    pub origin: ReconcileOrigin,
1282    pub source_type: Option<String>,
1283    pub source_id: Option<Uuid>,
1284    pub created_at: DateTime<Utc>,
1285    pub updated_at: DateTime<Utc>,
1286    pub metadata: Option<serde_json::Value>,
1287}
1288
1289/// Summary view of PartialReconcile for list displays
1290#[derive(Debug, Clone, Serialize, Deserialize)]
1291pub struct PartialReconcileSummary {
1292    pub id: PartialReconcileId,
1293    pub created_at: DateTime<Utc>,
1294}
1295
1296/// Reference to PartialReconcile for foreign key relationships
1297#[derive(Debug, Clone, Serialize, Deserialize)]
1298pub struct PartialReconcileRef {
1299    pub id: PartialReconcileId,
1300}
1301
1302// ============================================================================
1303// CUSTOM TYPES
1304// ============================================================================
1305
1306// <<< CUSTOM TYPES START >>>
1307// Add custom public types here
1308// <<< CUSTOM TYPES END >>>