koprogo_api/application/ports/
unit_owner_repository.rs1use crate::domain::entities::UnitOwner;
2use async_trait::async_trait;
3use rust_decimal::Decimal;
4use uuid::Uuid;
5
6#[async_trait]
7pub trait UnitOwnerRepository: Send + Sync {
8 async fn create(&self, unit_owner: &UnitOwner) -> Result<UnitOwner, String>;
10
11 async fn find_by_id(&self, id: Uuid) -> Result<Option<UnitOwner>, String>;
13
14 async fn find_current_owners_by_unit(&self, unit_id: Uuid) -> Result<Vec<UnitOwner>, String>;
16
17 async fn find_current_units_by_owner(&self, owner_id: Uuid) -> Result<Vec<UnitOwner>, String>;
19
20 async fn find_all_owners_by_unit(&self, unit_id: Uuid) -> Result<Vec<UnitOwner>, String>;
22
23 async fn find_all_units_by_owner(&self, owner_id: Uuid) -> Result<Vec<UnitOwner>, String>;
25
26 async fn update(&self, unit_owner: &UnitOwner) -> Result<UnitOwner, String>;
28
29 async fn delete(&self, id: Uuid) -> Result<(), String>;
31
32 async fn has_active_owners(&self, unit_id: Uuid) -> Result<bool, String>;
34
35 async fn get_total_ownership_percentage(&self, unit_id: Uuid) -> Result<Decimal, String>;
37
38 async fn find_active_by_unit_and_owner(
40 &self,
41 unit_id: Uuid,
42 owner_id: Uuid,
43 ) -> Result<Option<UnitOwner>, String>;
44
45 async fn find_active_by_building(
49 &self,
50 building_id: Uuid,
51 ) -> Result<Vec<(Uuid, Uuid, Decimal)>, String>;
52}