koprogo_api/application/ports/
payment_reminder_repository.rs1use crate::domain::entities::{PaymentReminder, ReminderLevel, ReminderStatus};
2use async_trait::async_trait;
3use chrono::{DateTime, Utc};
4use uuid::Uuid;
5
6#[async_trait]
8pub trait PaymentReminderRepository: Send + Sync {
9 async fn create(&self, reminder: &PaymentReminder) -> Result<PaymentReminder, String>;
11
12 async fn find_by_id(&self, id: Uuid) -> Result<Option<PaymentReminder>, String>;
14
15 async fn find_by_expense(&self, expense_id: Uuid) -> Result<Vec<PaymentReminder>, String>;
17
18 async fn find_by_owner(&self, owner_id: Uuid) -> Result<Vec<PaymentReminder>, String>;
20
21 async fn find_by_organization(
23 &self,
24 organization_id: Uuid,
25 ) -> Result<Vec<PaymentReminder>, String>;
26
27 async fn find_by_status(&self, status: ReminderStatus) -> Result<Vec<PaymentReminder>, String>;
29
30 async fn find_by_organization_and_status(
32 &self,
33 organization_id: Uuid,
34 status: ReminderStatus,
35 ) -> Result<Vec<PaymentReminder>, String>;
36
37 async fn find_pending_reminders(&self) -> Result<Vec<PaymentReminder>, String>;
39
40 async fn find_reminders_needing_escalation(
42 &self,
43 cutoff_date: DateTime<Utc>,
44 ) -> Result<Vec<PaymentReminder>, String>;
45
46 async fn find_latest_by_expense(
48 &self,
49 expense_id: Uuid,
50 ) -> Result<Option<PaymentReminder>, String>;
51
52 async fn find_active_by_owner(&self, owner_id: Uuid) -> Result<Vec<PaymentReminder>, String>;
54
55 async fn count_by_status(
57 &self,
58 organization_id: Uuid,
59 ) -> Result<Vec<(ReminderStatus, i64)>, String>;
60
61 async fn get_total_owed_by_organization(&self, organization_id: Uuid) -> Result<f64, String>;
63
64 async fn get_total_penalties_by_organization(
66 &self,
67 organization_id: Uuid,
68 ) -> Result<f64, String>;
69
70 async fn find_overdue_expenses_without_reminders(
73 &self,
74 organization_id: Uuid,
75 min_days_overdue: i64,
76 ) -> Result<Vec<(Uuid, Uuid, i64, f64)>, String>;
77
78 async fn update(&self, reminder: &PaymentReminder) -> Result<PaymentReminder, String>;
80
81 async fn delete(&self, id: Uuid) -> Result<bool, String>;
83
84 async fn get_dashboard_stats(
87 &self,
88 organization_id: Uuid,
89 ) -> Result<(f64, f64, Vec<(ReminderLevel, i64)>), String>;
90}