koprogo_api/application/dto/
work_report_dto.rs1use crate::domain::entities::{WarrantyType, WorkType};
2use serde::{Deserialize, Serialize};
3use validator::Validate;
4
5#[derive(Debug, Deserialize, Validate, Clone)]
6pub struct CreateWorkReportDto {
7 pub organization_id: String,
8 pub building_id: String,
9
10 #[validate(length(min = 1, max = 255))]
11 pub title: String,
12
13 #[validate(length(min = 1))]
14 pub description: String,
15
16 pub work_type: WorkType,
17
18 #[validate(length(min = 1, max = 255))]
19 pub contractor_name: String,
20
21 #[validate(length(max = 255))]
22 pub contractor_contact: Option<String>,
23
24 pub work_date: String, pub completion_date: Option<String>, #[validate(range(min = 0.0))]
28 pub cost: f64,
29
30 #[validate(length(max = 100))]
31 pub invoice_number: Option<String>,
32
33 pub notes: Option<String>,
34 pub warranty_type: WarrantyType,
35}
36
37#[derive(Debug, Deserialize, Validate, Clone)]
38pub struct UpdateWorkReportDto {
39 #[validate(length(min = 1, max = 255))]
40 pub title: Option<String>,
41
42 #[validate(length(min = 1))]
43 pub description: Option<String>,
44
45 pub work_type: Option<WorkType>,
46
47 #[validate(length(min = 1, max = 255))]
48 pub contractor_name: Option<String>,
49
50 #[validate(length(max = 255))]
51 pub contractor_contact: Option<String>,
52
53 pub work_date: Option<String>,
54 pub completion_date: Option<String>,
55
56 #[validate(range(min = 0.0))]
57 pub cost: Option<f64>,
58
59 #[validate(length(max = 100))]
60 pub invoice_number: Option<String>,
61
62 pub notes: Option<String>,
63 pub warranty_type: Option<WarrantyType>,
64}
65
66#[derive(Debug, Serialize)]
67pub struct WorkReportResponseDto {
68 pub id: String,
69 pub organization_id: String,
70 pub building_id: String,
71 pub title: String,
72 pub description: String,
73 pub work_type: WorkType,
74 pub contractor_name: String,
75 pub contractor_contact: Option<String>,
76 pub work_date: String,
77 pub completion_date: Option<String>,
78 pub cost: f64,
79 pub invoice_number: Option<String>,
80 pub photos: Vec<String>,
81 pub documents: Vec<String>,
82 pub notes: Option<String>,
83 pub warranty_type: WarrantyType,
84 pub warranty_expiry: String,
85 pub is_warranty_valid: bool,
86 pub warranty_days_remaining: i64,
87 pub created_at: String,
88 pub updated_at: String,
89}
90
91#[derive(Debug, Deserialize, Validate)]
92pub struct AddPhotoDto {
93 #[validate(length(min = 1))]
94 pub photo_path: String,
95}
96
97#[derive(Debug, Deserialize, Validate)]
98pub struct AddDocumentDto {
99 #[validate(length(min = 1))]
100 pub document_path: String,
101}
102
103#[derive(Debug, Serialize)]
104pub struct WorkReportListResponseDto {
105 pub work_reports: Vec<WorkReportResponseDto>,
106 pub total: i64,
107 pub page: i64,
108 pub page_size: i64,
109}
110
111#[derive(Debug, Serialize)]
112pub struct WarrantyStatusDto {
113 pub work_report_id: String,
114 pub title: String,
115 pub warranty_type: WarrantyType,
116 pub warranty_expiry: String,
117 pub is_valid: bool,
118 pub days_remaining: i64,
119}