Skip to main content

backbone_banking/exports/
types.rs

1//! Public types for Banking 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// BANK TYPES
16// ============================================================================
17
18/// Type-safe ID for Bank
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 BankId(pub Uuid);
23
24impl BankId {
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 BankId {
35    fn from(id: Uuid) -> Self {
36        Self(id)
37    }
38}
39
40impl From<BankId> for Uuid {
41    fn from(id: BankId) -> Self {
42        id.0
43    }
44}
45
46/// Data transfer object for Bank
47///
48/// This is the public representation of Bank for other modules.
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct BankDto {
51    pub id: BankId,
52    pub name: String,
53    pub swift_bic: Option<String>,
54    pub country: String,
55    pub status: BankStatus,
56    pub metadata: serde_json::Value,
57}
58
59/// Summary view of Bank for list displays
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct BankSummary {
62    pub id: BankId,
63    pub name: String,
64    pub status: BankStatus,
65}
66
67/// Reference to Bank for foreign key relationships
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct BankRef {
70    pub id: BankId,
71}
72
73// ============================================================================
74// BANKACCOUNT TYPES
75// ============================================================================
76
77/// Type-safe ID for BankAccount
78///
79/// Use this instead of raw Uuid for type safety across modules.
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
81pub struct BankAccountId(pub Uuid);
82
83impl BankAccountId {
84    pub fn new(id: Uuid) -> Self {
85        Self(id)
86    }
87
88    pub fn into_inner(self) -> Uuid {
89        self.0
90    }
91}
92
93impl From<Uuid> for BankAccountId {
94    fn from(id: Uuid) -> Self {
95        Self(id)
96    }
97}
98
99impl From<BankAccountId> for Uuid {
100    fn from(id: BankAccountId) -> Self {
101        id.0
102    }
103}
104
105/// Data transfer object for BankAccount
106///
107/// This is the public representation of BankAccount for other modules.
108#[derive(Debug, Clone, Serialize, Deserialize)]
109pub struct BankAccountDto {
110    pub id: BankAccountId,
111    pub branch_id: Option<Uuid>,
112    pub bank_id: Uuid,
113    pub account_name: String,
114    pub account_number: String,
115    pub gl_account_id: Uuid,
116    pub clearing_account_id: Uuid,
117    pub currency: String,
118    pub account_type: BankAccountType,
119    pub is_default: bool,
120    pub status: BankAccountStatus,
121    pub metadata: serde_json::Value,
122}
123
124/// Summary view of BankAccount for list displays
125#[derive(Debug, Clone, Serialize, Deserialize)]
126pub struct BankAccountSummary {
127    pub id: BankAccountId,
128    pub account_name: String,
129    pub status: BankAccountStatus,
130}
131
132/// Reference to BankAccount for foreign key relationships
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct BankAccountRef {
135    pub id: BankAccountId,
136}
137
138// ============================================================================
139// BANKCLEARANCE TYPES
140// ============================================================================
141
142/// Type-safe ID for BankClearance
143///
144/// Use this instead of raw Uuid for type safety across modules.
145#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
146pub struct BankClearanceId(pub Uuid);
147
148impl BankClearanceId {
149    pub fn new(id: Uuid) -> Self {
150        Self(id)
151    }
152
153    pub fn into_inner(self) -> Uuid {
154        self.0
155    }
156}
157
158impl From<Uuid> for BankClearanceId {
159    fn from(id: Uuid) -> Self {
160        Self(id)
161    }
162}
163
164impl From<BankClearanceId> for Uuid {
165    fn from(id: BankClearanceId) -> Self {
166        id.0
167    }
168}
169
170/// Data transfer object for BankClearance
171///
172/// This is the public representation of BankClearance for other modules.
173#[derive(Debug, Clone, Serialize, Deserialize)]
174pub struct BankClearanceDto {
175    pub id: BankClearanceId,
176    pub bank_transaction_id: Uuid,
177    pub matched_source_type: MatchedSourceType,
178    pub matched_source_id: Uuid,
179    pub matched_amount: Decimal,
180    pub match_method: MatchMethod,
181    pub clearance_date: NaiveDate,
182    pub accounting_post_id: Option<Uuid>,
183    pub journal_id: Option<Uuid>,
184    pub metadata: serde_json::Value,
185}
186
187/// Summary view of BankClearance for list displays
188#[derive(Debug, Clone, Serialize, Deserialize)]
189pub struct BankClearanceSummary {
190    pub id: BankClearanceId,
191}
192
193/// Reference to BankClearance for foreign key relationships
194#[derive(Debug, Clone, Serialize, Deserialize)]
195pub struct BankClearanceRef {
196    pub id: BankClearanceId,
197}
198
199// ============================================================================
200// BANKRECONCILIATION TYPES
201// ============================================================================
202
203/// Type-safe ID for BankReconciliation
204///
205/// Use this instead of raw Uuid for type safety across modules.
206#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
207pub struct BankReconciliationId(pub Uuid);
208
209impl BankReconciliationId {
210    pub fn new(id: Uuid) -> Self {
211        Self(id)
212    }
213
214    pub fn into_inner(self) -> Uuid {
215        self.0
216    }
217}
218
219impl From<Uuid> for BankReconciliationId {
220    fn from(id: Uuid) -> Self {
221        Self(id)
222    }
223}
224
225impl From<BankReconciliationId> for Uuid {
226    fn from(id: BankReconciliationId) -> Self {
227        id.0
228    }
229}
230
231/// Data transfer object for BankReconciliation
232///
233/// This is the public representation of BankReconciliation for other modules.
234#[derive(Debug, Clone, Serialize, Deserialize)]
235pub struct BankReconciliationDto {
236    pub id: BankReconciliationId,
237    pub bank_account_id: Uuid,
238    pub from_date: NaiveDate,
239    pub to_date: NaiveDate,
240    pub statement_closing_balance: Decimal,
241    pub ledger_balance: Decimal,
242    pub computed_difference: Decimal,
243    pub unreconciled_count: i32,
244    pub status: ReconStatus,
245    pub preset_id: Option<Uuid>,
246    pub metadata: serde_json::Value,
247}
248
249/// Summary view of BankReconciliation for list displays
250#[derive(Debug, Clone, Serialize, Deserialize)]
251pub struct BankReconciliationSummary {
252    pub id: BankReconciliationId,
253    pub status: ReconStatus,
254}
255
256/// Reference to BankReconciliation for foreign key relationships
257#[derive(Debug, Clone, Serialize, Deserialize)]
258pub struct BankReconciliationRef {
259    pub id: BankReconciliationId,
260}
261
262// ============================================================================
263// BANKSTATEMENTIMPORT TYPES
264// ============================================================================
265
266/// Type-safe ID for BankStatementImport
267///
268/// Use this instead of raw Uuid for type safety across modules.
269#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
270pub struct BankStatementImportId(pub Uuid);
271
272impl BankStatementImportId {
273    pub fn new(id: Uuid) -> Self {
274        Self(id)
275    }
276
277    pub fn into_inner(self) -> Uuid {
278        self.0
279    }
280}
281
282impl From<Uuid> for BankStatementImportId {
283    fn from(id: Uuid) -> Self {
284        Self(id)
285    }
286}
287
288impl From<BankStatementImportId> for Uuid {
289    fn from(id: BankStatementImportId) -> Self {
290        id.0
291    }
292}
293
294/// Data transfer object for BankStatementImport
295///
296/// This is the public representation of BankStatementImport for other modules.
297#[derive(Debug, Clone, Serialize, Deserialize)]
298pub struct BankStatementImportDto {
299    pub id: BankStatementImportId,
300    pub bank_account_id: Uuid,
301    pub source_format: SourceFormat,
302    pub statement_period_start: NaiveDate,
303    pub statement_period_end: NaiveDate,
304    pub opening_balance: Decimal,
305    pub closing_balance: Decimal,
306    pub file_ref: Option<String>,
307    pub status: ImportStatus,
308    pub row_count: i32,
309    pub metadata: serde_json::Value,
310}
311
312/// Summary view of BankStatementImport for list displays
313#[derive(Debug, Clone, Serialize, Deserialize)]
314pub struct BankStatementImportSummary {
315    pub id: BankStatementImportId,
316    pub status: ImportStatus,
317}
318
319/// Reference to BankStatementImport for foreign key relationships
320#[derive(Debug, Clone, Serialize, Deserialize)]
321pub struct BankStatementImportRef {
322    pub id: BankStatementImportId,
323}
324
325// ============================================================================
326// BANKTRANSACTION TYPES
327// ============================================================================
328
329/// Type-safe ID for BankTransaction
330///
331/// Use this instead of raw Uuid for type safety across modules.
332#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
333pub struct BankTransactionId(pub Uuid);
334
335impl BankTransactionId {
336    pub fn new(id: Uuid) -> Self {
337        Self(id)
338    }
339
340    pub fn into_inner(self) -> Uuid {
341        self.0
342    }
343}
344
345impl From<Uuid> for BankTransactionId {
346    fn from(id: Uuid) -> Self {
347        Self(id)
348    }
349}
350
351impl From<BankTransactionId> for Uuid {
352    fn from(id: BankTransactionId) -> Self {
353        id.0
354    }
355}
356
357/// Data transfer object for BankTransaction
358///
359/// This is the public representation of BankTransaction for other modules.
360#[derive(Debug, Clone, Serialize, Deserialize)]
361pub struct BankTransactionDto {
362    pub id: BankTransactionId,
363    pub bank_account_id: Uuid,
364    pub import_id: Uuid,
365    pub txn_date: NaiveDate,
366    pub value_date: Option<NaiveDate>,
367    pub description: Option<String>,
368    pub reference_no: Option<String>,
369    pub deposit: Decimal,
370    pub withdrawal: Decimal,
371    pub currency: String,
372    pub status: TxnStatus,
373    pub allocated_amount: Decimal,
374    pub metadata: serde_json::Value,
375}
376
377/// Summary view of BankTransaction for list displays
378#[derive(Debug, Clone, Serialize, Deserialize)]
379pub struct BankTransactionSummary {
380    pub id: BankTransactionId,
381    pub status: TxnStatus,
382}
383
384/// Reference to BankTransaction for foreign key relationships
385#[derive(Debug, Clone, Serialize, Deserialize)]
386pub struct BankTransactionRef {
387    pub id: BankTransactionId,
388}
389
390// ============================================================================
391// FXGAINLOSS TYPES
392// ============================================================================
393
394/// Type-safe ID for FxGainLoss
395///
396/// Use this instead of raw Uuid for type safety across modules.
397#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
398pub struct FxGainLossId(pub Uuid);
399
400impl FxGainLossId {
401    pub fn new(id: Uuid) -> Self {
402        Self(id)
403    }
404
405    pub fn into_inner(self) -> Uuid {
406        self.0
407    }
408}
409
410impl From<Uuid> for FxGainLossId {
411    fn from(id: Uuid) -> Self {
412        Self(id)
413    }
414}
415
416impl From<FxGainLossId> for Uuid {
417    fn from(id: FxGainLossId) -> Self {
418        id.0
419    }
420}
421
422/// Data transfer object for FxGainLoss
423///
424/// This is the public representation of FxGainLoss for other modules.
425#[derive(Debug, Clone, Serialize, Deserialize)]
426pub struct FxGainLossDto {
427    pub id: FxGainLossId,
428    pub bank_clearance_id: Option<Uuid>,
429    pub matched_source_id: Uuid,
430    pub currency: String,
431    pub original_rate: Decimal,
432    pub realised_rate: Decimal,
433    pub base_amount_delta: Decimal,
434    pub direction: FxDirection,
435    pub fx_account_id: Uuid,
436    pub metadata: serde_json::Value,
437}
438
439/// Summary view of FxGainLoss for list displays
440#[derive(Debug, Clone, Serialize, Deserialize)]
441pub struct FxGainLossSummary {
442    pub id: FxGainLossId,
443}
444
445/// Reference to FxGainLoss for foreign key relationships
446#[derive(Debug, Clone, Serialize, Deserialize)]
447pub struct FxGainLossRef {
448    pub id: FxGainLossId,
449}
450
451// ============================================================================
452// RECONCILEPRESET TYPES
453// ============================================================================
454
455/// Type-safe ID for ReconcilePreset
456///
457/// Use this instead of raw Uuid for type safety across modules.
458#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
459pub struct ReconcilePresetId(pub Uuid);
460
461impl ReconcilePresetId {
462    pub fn new(id: Uuid) -> Self {
463        Self(id)
464    }
465
466    pub fn into_inner(self) -> Uuid {
467        self.0
468    }
469}
470
471impl From<Uuid> for ReconcilePresetId {
472    fn from(id: Uuid) -> Self {
473        Self(id)
474    }
475}
476
477impl From<ReconcilePresetId> for Uuid {
478    fn from(id: ReconcilePresetId) -> Self {
479        id.0
480    }
481}
482
483/// Data transfer object for ReconcilePreset
484///
485/// This is the public representation of ReconcilePreset for other modules.
486#[derive(Debug, Clone, Serialize, Deserialize)]
487pub struct ReconcilePresetDto {
488    pub id: ReconcilePresetId,
489    pub name: String,
490    pub note: Option<String>,
491    pub priority: i32,
492    pub match_on: MatchOn,
493    pub tolerance_percent: Option<Decimal>,
494    pub days_window: Option<i32>,
495    pub status: PresetStatus,
496    pub metadata: serde_json::Value,
497}
498
499/// Summary view of ReconcilePreset for list displays
500#[derive(Debug, Clone, Serialize, Deserialize)]
501pub struct ReconcilePresetSummary {
502    pub id: ReconcilePresetId,
503    pub name: String,
504    pub status: PresetStatus,
505}
506
507/// Reference to ReconcilePreset for foreign key relationships
508#[derive(Debug, Clone, Serialize, Deserialize)]
509pub struct ReconcilePresetRef {
510    pub id: ReconcilePresetId,
511}
512
513// ============================================================================
514// CUSTOM TYPES
515// ============================================================================
516
517// <<< CUSTOM TYPES START >>>
518// Add custom public types here
519// <<< CUSTOM TYPES END >>>