1use serde::{Deserialize, Serialize};
9use uuid::Uuid;
10use chrono::{DateTime, Utc, NaiveDate};
11use rust_decimal::Decimal;
12use crate::domain::entity::*;
13
14#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct BankSummary {
62 pub id: BankId,
63 pub name: String,
64 pub status: BankStatus,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct BankRef {
70 pub id: BankId,
71}
72
73#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
126pub struct BankAccountSummary {
127 pub id: BankAccountId,
128 pub account_name: String,
129 pub status: BankAccountStatus,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct BankAccountRef {
135 pub id: BankAccountId,
136}
137
138#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
189pub struct BankClearanceSummary {
190 pub id: BankClearanceId,
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize)]
195pub struct BankClearanceRef {
196 pub id: BankClearanceId,
197}
198
199#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
251pub struct BankReconciliationSummary {
252 pub id: BankReconciliationId,
253 pub status: ReconStatus,
254}
255
256#[derive(Debug, Clone, Serialize, Deserialize)]
258pub struct BankReconciliationRef {
259 pub id: BankReconciliationId,
260}
261
262#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
314pub struct BankStatementImportSummary {
315 pub id: BankStatementImportId,
316 pub status: ImportStatus,
317}
318
319#[derive(Debug, Clone, Serialize, Deserialize)]
321pub struct BankStatementImportRef {
322 pub id: BankStatementImportId,
323}
324
325#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
379pub struct BankTransactionSummary {
380 pub id: BankTransactionId,
381 pub status: TxnStatus,
382}
383
384#[derive(Debug, Clone, Serialize, Deserialize)]
386pub struct BankTransactionRef {
387 pub id: BankTransactionId,
388}
389
390#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
441pub struct FxGainLossSummary {
442 pub id: FxGainLossId,
443}
444
445#[derive(Debug, Clone, Serialize, Deserialize)]
447pub struct FxGainLossRef {
448 pub id: FxGainLossId,
449}
450
451#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
501pub struct ReconcilePresetSummary {
502 pub id: ReconcilePresetId,
503 pub name: String,
504 pub status: PresetStatus,
505}
506
507#[derive(Debug, Clone, Serialize, Deserialize)]
509pub struct ReconcilePresetRef {
510 pub id: ReconcilePresetId,
511}
512
513