koprogo_api/application/dto/
unit_owner_dto.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use validator::Validate;
4
5#[derive(Debug, Deserialize, Validate)]
11pub struct AddOwnerToUnitDto {
12 #[validate(length(min = 1))]
13 pub owner_id: String,
14
15 pub ownership_percentage: rust_decimal::Decimal,
16
17 pub is_primary_contact: bool,
18}
19
20#[derive(Debug, Deserialize, Validate)]
23pub struct UpdateOwnershipDto {
24 pub ownership_percentage: Option<rust_decimal::Decimal>,
25
26 pub is_primary_contact: Option<bool>,
27}
28
29#[derive(Debug, Serialize, Clone)]
31pub struct UnitOwnerResponseDto {
32 pub id: String,
33 pub unit_id: String,
34 pub owner_id: String,
35 pub ownership_percentage: rust_decimal::Decimal,
36 pub start_date: DateTime<Utc>,
37 pub end_date: Option<DateTime<Utc>>,
38 pub is_primary_contact: bool,
39 pub is_active: bool,
40 pub created_at: DateTime<Utc>,
41 pub updated_at: DateTime<Utc>,
42}
43
44#[derive(Debug, Serialize)]
46pub struct UnitWithOwnersDto {
47 pub unit_id: String,
48 pub unit_number: String,
49 pub floor: Option<i32>,
50 pub area: Option<f64>,
51 pub owners: Vec<UnitOwnerWithDetailsDto>,
52 pub total_ownership_percentage: rust_decimal::Decimal,
53}
54
55#[derive(Debug, Serialize)]
57pub struct OwnerWithUnitsDto {
58 pub owner_id: String,
59 pub owner_name: String,
60 pub owner_email: String,
61 pub units: Vec<UnitOwnerWithDetailsDto>,
62}
63
64#[derive(Debug, Serialize, Clone)]
66pub struct UnitOwnerWithDetailsDto {
67 pub relationship_id: String,
68 pub ownership_percentage: rust_decimal::Decimal,
69 pub is_primary_contact: bool,
70 pub start_date: DateTime<Utc>,
71 pub end_date: Option<DateTime<Utc>>,
72 pub is_active: bool,
73
74 pub unit_id: Option<String>,
76 pub unit_number: Option<String>,
77 pub floor: Option<i32>,
78 pub area: Option<f64>,
79 pub building_id: Option<String>,
80
81 pub owner_id: Option<String>,
83 pub owner_first_name: Option<String>,
84 pub owner_last_name: Option<String>,
85 pub owner_email: Option<String>,
86 pub owner_phone: Option<String>,
87}
88
89#[derive(Debug, Deserialize, Validate)]
91pub struct TransferOwnershipDto {
92 #[validate(length(min = 1))]
93 pub from_owner_id: String,
94
95 #[validate(length(min = 1))]
96 pub to_owner_id: String,
97}