koprogo_api/application/ports/
etat_date_repository.rs

1use crate::application::dto::etat_date_dto::EtatDateStatsResponse;
2use crate::application::dto::PageRequest;
3use crate::domain::entities::{EtatDate, EtatDateStatus};
4use async_trait::async_trait;
5use uuid::Uuid;
6
7#[async_trait]
8pub trait EtatDateRepository: Send + Sync {
9    /// Create a new état daté
10    async fn create(&self, etat_date: &EtatDate) -> Result<EtatDate, String>;
11
12    /// Find état daté by ID
13    async fn find_by_id(&self, id: Uuid) -> Result<Option<EtatDate>, String>;
14
15    /// Find état daté by reference number
16    async fn find_by_reference_number(
17        &self,
18        reference_number: &str,
19    ) -> Result<Option<EtatDate>, String>;
20
21    /// Find all états datés for a unit
22    async fn find_by_unit(&self, unit_id: Uuid) -> Result<Vec<EtatDate>, String>;
23
24    /// Find all états datés for a building
25    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<EtatDate>, String>;
26
27    /// Find all états datés for an organization (paginated)
28    async fn find_all_paginated(
29        &self,
30        page_request: &PageRequest,
31        organization_id: Option<Uuid>,
32        status: Option<EtatDateStatus>,
33    ) -> Result<(Vec<EtatDate>, i64), String>;
34
35    /// Find overdue états datés (>10 days since request, not yet generated)
36    async fn find_overdue(&self, organization_id: Uuid) -> Result<Vec<EtatDate>, String>;
37
38    /// Find expired états datés (>3 months since reference date)
39    async fn find_expired(&self, organization_id: Uuid) -> Result<Vec<EtatDate>, String>;
40
41    /// Update an état daté
42    async fn update(&self, etat_date: &EtatDate) -> Result<EtatDate, String>;
43
44    /// Delete an état daté
45    async fn delete(&self, id: Uuid) -> Result<bool, String>;
46
47    /// Get statistics for dashboard
48    async fn get_stats(&self, organization_id: Uuid) -> Result<EtatDateStatsResponse, String>;
49
50    /// Count états datés by status
51    async fn count_by_status(
52        &self,
53        organization_id: Uuid,
54        status: EtatDateStatus,
55    ) -> Result<i64, String>;
56}