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