koprogo_api/application/dto/
pcn_dto.rs

1use crate::domain::services::{PcnAccount, PcnReportLine};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6/// Request to generate PCN report for a building
7#[derive(Debug, Serialize, Deserialize)]
8pub struct PcnReportRequest {
9    /// Building ID to generate report for
10    pub building_id: Uuid,
11    /// Optional start date for filtering expenses
12    pub start_date: Option<DateTime<Utc>>,
13    /// Optional end date for filtering expenses
14    pub end_date: Option<DateTime<Utc>>,
15}
16
17/// Response containing PCN report data
18#[derive(Debug, Serialize, Deserialize)]
19pub struct PcnReportResponse {
20    /// Building ID
21    pub building_id: Uuid,
22    /// Report generation timestamp
23    pub generated_at: DateTime<Utc>,
24    /// Period start date (if filtered)
25    pub period_start: Option<DateTime<Utc>>,
26    /// Period end date (if filtered)
27    pub period_end: Option<DateTime<Utc>>,
28    /// PCN report lines (one per account with expenses)
29    pub lines: Vec<PcnReportLineDto>,
30    /// Total amount across all accounts
31    pub total_amount: f64,
32    /// Total number of expense entries
33    pub total_entries: usize,
34}
35
36/// DTO for a single PCN report line
37#[derive(Debug, Serialize, Deserialize)]
38pub struct PcnReportLineDto {
39    /// PCN account code (e.g., "611")
40    pub account_code: String,
41    /// Account label in Dutch (Nederlands - 60%)
42    pub account_label_nl: String,
43    /// Account label in French (Français - 40%)
44    pub account_label_fr: String,
45    /// Account label in German (Deutsch - <1%)
46    pub account_label_de: String,
47    /// Account label in English (International)
48    pub account_label_en: String,
49    /// Total amount for this account
50    pub total_amount: f64,
51    /// Number of expense entries for this account
52    pub entry_count: usize,
53}
54
55impl From<PcnReportLine> for PcnReportLineDto {
56    fn from(line: PcnReportLine) -> Self {
57        Self {
58            account_code: line.account.code,
59            account_label_nl: line.account.label_nl,
60            account_label_fr: line.account.label_fr,
61            account_label_de: line.account.label_de,
62            account_label_en: line.account.label_en,
63            total_amount: line.total_amount,
64            entry_count: line.entry_count,
65        }
66    }
67}
68
69/// Response for PCN account mapping lookup
70#[derive(Debug, Serialize, Deserialize)]
71pub struct PcnAccountDto {
72    /// PCN account code
73    pub code: String,
74    /// Account label in Dutch
75    pub label_nl: String,
76    /// Account label in French
77    pub label_fr: String,
78    /// Account label in German
79    pub label_de: String,
80    /// Account label in English
81    pub label_en: String,
82}
83
84impl From<PcnAccount> for PcnAccountDto {
85    fn from(account: PcnAccount) -> Self {
86        Self {
87            code: account.code,
88            label_nl: account.label_nl,
89            label_fr: account.label_fr,
90            label_de: account.label_de,
91            label_en: account.label_en,
92        }
93    }
94}