koprogo_api/application/dto/
pcn_dto.rs1use crate::domain::services::{PcnAccount, PcnReportLine};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6#[derive(Debug, Serialize, Deserialize)]
8pub struct PcnReportRequest {
9 pub building_id: Uuid,
11 pub start_date: Option<DateTime<Utc>>,
13 pub end_date: Option<DateTime<Utc>>,
15}
16
17#[derive(Debug, Serialize, Deserialize)]
19pub struct PcnReportResponse {
20 pub building_id: Uuid,
22 pub generated_at: DateTime<Utc>,
24 pub period_start: Option<DateTime<Utc>>,
26 pub period_end: Option<DateTime<Utc>>,
28 pub lines: Vec<PcnReportLineDto>,
30 pub total_amount: f64,
32 pub total_entries: usize,
34}
35
36#[derive(Debug, Serialize, Deserialize)]
38pub struct PcnReportLineDto {
39 pub account_code: String,
41 pub account_label_nl: String,
43 pub account_label_fr: String,
45 pub account_label_de: String,
47 pub account_label_en: String,
49 pub total_amount: f64,
51 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#[derive(Debug, Serialize, Deserialize)]
71pub struct PcnAccountDto {
72 pub code: String,
74 pub label_nl: String,
76 pub label_fr: String,
78 pub label_de: String,
80 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}