koprogo_api/application/dto/dashboard_dto.rs
1// Application DTOs: Dashboard
2//
3// Data Transfer Objects for dashboard statistics and recent transactions
4
5use chrono::{DateTime, Utc};
6use rust_decimal::Decimal;
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10/// Accountant dashboard statistics.
11///
12/// MONETARY: amounts use rust_decimal::Decimal (cf. ADR-0007).
13/// Percentages remain Decimal to preserve exactness on display.
14#[derive(Debug, Serialize, Deserialize)]
15pub struct AccountantDashboardStats {
16 /// Total expenses for current month
17 pub total_expenses_current_month: Decimal,
18
19 /// Total paid expenses
20 pub total_paid: Decimal,
21
22 /// Percentage of expenses paid
23 pub paid_percentage: Decimal,
24
25 /// Total unpaid/pending expenses
26 pub total_pending: Decimal,
27
28 /// Percentage of expenses pending
29 pub pending_percentage: Decimal,
30
31 /// Number of owners with overdue payments
32 pub owners_with_overdue: i64,
33}
34
35/// Transaction type for dashboard display
36///
37/// **Important**: Currently only displays expenses (payments made).
38/// For a complete ACP (Association de Copropriétaires) accounting view, we would need:
39/// - PaymentReceived: Appels de fonds paid by owners (classe 7 PCMN - Produits)
40/// - PaymentMade: Expenses paid to suppliers (classe 6 PCMN - Charges)
41///
42/// **TODO**: Implement owner contributions tracking (appels de fonds) to show incoming payments
43#[derive(Debug, Serialize, Deserialize)]
44#[serde(rename_all = "lowercase")]
45pub enum TransactionType {
46 /// Payment received from owner (appels de fonds) - NOT YET IMPLEMENTED
47 PaymentReceived,
48 /// Payment made to supplier (expenses)
49 PaymentMade,
50}
51
52/// Recent transaction for dashboard
53#[derive(Debug, Serialize, Deserialize)]
54pub struct RecentTransaction {
55 /// Transaction ID
56 pub id: Uuid,
57
58 /// Transaction type
59 pub transaction_type: TransactionType,
60
61 /// Transaction description
62 pub description: String,
63
64 /// Related entity (owner name, supplier, etc.)
65 pub related_entity: Option<String>,
66
67 /// Transaction amount (positive for received, negative for paid). Decimal exact.
68 pub amount: Decimal,
69
70 /// Transaction date
71 pub date: DateTime<Utc>,
72}