koprogo_api/application/dto/
account_dto.rs

1// DTOs for Account API
2//
3// CREDITS: Structure inspired by Noalyss API patterns (GPL-2.0+)
4// https://gitlab.com/noalyss/noalyss
5
6use serde::{Deserialize, Serialize};
7use validator::Validate;
8
9/// Request DTO for creating a new account
10#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
11pub struct CreateAccountDto {
12    #[validate(length(min = 1, max = 40, message = "Account code must be 1-40 characters"))]
13    pub code: String,
14
15    #[validate(length(min = 1, max = 255, message = "Account label must be 1-255 characters"))]
16    pub label: String,
17
18    pub parent_code: Option<String>,
19
20    pub account_type: String, // "ASSET", "LIABILITY", "EXPENSE", "REVENUE", "OFF_BALANCE"
21
22    pub direct_use: bool,
23
24    pub organization_id: String,
25}
26
27/// Request DTO for updating an existing account
28#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
29pub struct UpdateAccountDto {
30    #[validate(length(min = 1, max = 255))]
31    pub label: Option<String>,
32
33    pub parent_code: Option<Option<String>>,
34
35    pub account_type: Option<String>, // "ASSET", "LIABILITY", "EXPENSE", "REVENUE", "OFF_BALANCE"
36
37    pub direct_use: Option<bool>,
38}
39
40/// Response DTO for account data
41#[derive(Debug, Serialize, Deserialize, Clone)]
42pub struct AccountResponseDto {
43    pub id: String,
44    pub code: String,
45    pub label: String,
46    pub parent_code: Option<String>,
47    pub account_type: String, // "ASSET", "LIABILITY", "EXPENSE", "REVENUE", "OFF_BALANCE"
48    pub direct_use: bool,
49    pub organization_id: String,
50    pub created_at: String,
51    pub updated_at: String,
52}
53
54/// Request DTO for seeding Belgian PCMN
55#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
56pub struct SeedBelgianPcmnDto {
57    pub organization_id: String,
58}
59
60/// Response DTO for seed operation
61#[derive(Debug, Serialize, Deserialize, Clone)]
62pub struct SeedPcmnResponseDto {
63    pub accounts_created: i64,
64    pub message: String,
65}
66
67/// Query parameters for searching accounts
68#[derive(Debug, Deserialize, Clone)]
69pub struct AccountSearchQuery {
70    pub code_pattern: Option<String>,
71    pub account_type: Option<String>,
72    pub direct_use_only: Option<bool>,
73    pub parent_code: Option<String>,
74}