Skip to main content

koprogo_api/application/ports/
call_for_funds_repository.rs

1use crate::domain::entities::CallForFunds;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait CallForFundsRepository: Send + Sync {
7    /// Create a new call for funds
8    async fn create(&self, call_for_funds: &CallForFunds) -> Result<CallForFunds, String>;
9
10    /// Find a call for funds by ID
11    async fn find_by_id(&self, id: Uuid) -> Result<Option<CallForFunds>, String>;
12
13    /// Find all calls for funds for a building
14    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<CallForFunds>, String>;
15
16    /// Find all calls for funds for an organization
17    async fn find_by_organization(
18        &self,
19        organization_id: Uuid,
20    ) -> Result<Vec<CallForFunds>, String>;
21
22    /// Update a call for funds
23    async fn update(&self, call_for_funds: &CallForFunds) -> Result<CallForFunds, String>;
24
25    /// Delete a call for funds
26    async fn delete(&self, id: Uuid) -> Result<bool, String>;
27
28    /// Find overdue calls for funds (past due date, not completed/cancelled),
29    /// scoped to one organization.
30    ///
31    /// `organization_id` est obligatoire depuis #882 : sans lui, cette
32    /// méthode rendait les arriérés de TOUTE l'instance à qui la lisait.
33    async fn find_overdue(&self, organization_id: Uuid) -> Result<Vec<CallForFunds>, String>;
34}