koprogo_api/application/ports/
quote_repository.rs

1use crate::domain::entities::Quote;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5/// Port (interface) for Quote repository (Belgian legal requirement: 3 quotes >5000€)
6#[async_trait]
7pub trait QuoteRepository: Send + Sync {
8    /// Create new quote
9    async fn create(&self, quote: &Quote) -> Result<Quote, String>;
10
11    /// Find quote by ID
12    async fn find_by_id(&self, id: Uuid) -> Result<Option<Quote>, String>;
13
14    /// Find all quotes for a building
15    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<Quote>, String>;
16
17    /// Find all quotes for a contractor
18    async fn find_by_contractor(&self, contractor_id: Uuid) -> Result<Vec<Quote>, String>;
19
20    /// Find quotes by status
21    async fn find_by_status(&self, building_id: Uuid, status: &str) -> Result<Vec<Quote>, String>;
22
23    /// Find multiple quotes by IDs (for comparison)
24    async fn find_by_ids(&self, ids: Vec<Uuid>) -> Result<Vec<Quote>, String>;
25
26    /// Find quotes for a specific project (by title)
27    async fn find_by_project_title(
28        &self,
29        building_id: Uuid,
30        project_title: &str,
31    ) -> Result<Vec<Quote>, String>;
32
33    /// Find expired quotes (for background job)
34    async fn find_expired(&self) -> Result<Vec<Quote>, String>;
35
36    /// Update quote
37    async fn update(&self, quote: &Quote) -> Result<Quote, String>;
38
39    /// Delete quote
40    async fn delete(&self, id: Uuid) -> Result<bool, String>;
41
42    /// Count quotes by building
43    async fn count_by_building(&self, building_id: Uuid) -> Result<i64, String>;
44
45    /// Count quotes by status for a building
46    async fn count_by_status(&self, building_id: Uuid, status: &str) -> Result<i64, String>;
47}