koprogo_api/application/ports/stats_repository.rs
1use crate::application::dto::{
2 AdminDashboardStats, DuAupresDuneAcp, SeedDataStats, SyndicDashboardStats, UrgentTask,
3};
4use crate::application::error::AppError;
5use async_trait::async_trait;
6use uuid::Uuid;
7
8#[async_trait]
9pub trait StatsRepository: Send + Sync {
10 async fn get_admin_dashboard_stats(&self) -> Result<AdminDashboardStats, AppError>;
11
12 async fn get_seed_data_stats(&self) -> Result<SeedDataStats, AppError>;
13
14 /// Returns stats for all buildings in the given organization.
15 async fn get_syndic_stats(
16 &self,
17 organization_id: Uuid,
18 ) -> Result<SyndicDashboardStats, AppError>;
19
20 /// Returns stats for buildings where the given owner has active units.
21 async fn get_owner_stats(&self, owner_id: Uuid) -> Result<SyndicDashboardStats, AppError>;
22
23 /// Ce que le copropriétaire doit, **ventilé par association**.
24 ///
25 /// Séparée de `get_owner_stats` parce qu'elle répond à une autre question :
26 /// celle-là dit « combien », celle-ci dit « à QUI ». Un copropriétaire peut
27 /// détenir des lots dans plusieurs ACP, et chacune est une personne morale
28 /// avec son propre compte bancaire (Art. 3.86 § 1er et § 3).
29 ///
30 /// Un montant global laisse croire qu'un virement unique suffit. Il paierait
31 /// la mauvaise personne morale pour une partie de la somme (#867).
32 ///
33 /// Liste vide si le copropriétaire ne doit rien : c'est une bonne nouvelle,
34 /// pas une erreur.
35 async fn get_owner_dues_by_acp(&self, owner_id: Uuid)
36 -> Result<Vec<DuAupresDuneAcp>, AppError>;
37
38 /// Looks up the owner record id associated with a user id.
39 async fn find_owner_id_by_user_id(&self, user_id: Uuid) -> Result<Option<Uuid>, AppError>;
40
41 /// Returns urgent tasks (overdue expenses, upcoming meetings, old pending charges)
42 /// for the given organization.
43 async fn get_syndic_urgent_tasks(
44 &self,
45 organization_id: Uuid,
46 ) -> Result<Vec<UrgentTask>, AppError>;
47}