profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
ISettlementService.cs 1,670 bytes
1 using App.BLL.DTO;
2 using App.Domain;
3
4 namespace App.BLL.Services;
5
6 public interface ISettlementService
7 {
8 Task<List<BalanceEntry>> CalculateBalancesAsync(Guid tripId);
9 Task<SettlementPlanBllDto?> CalculateSettlementAsync(Guid tripId, Guid userId);
10 List<PreviewPayment> PreviewSettlement(List<BalanceEntry> balances);
11 Task MarkPaidAsync(Guid paymentId, Guid userId);
12 Task ConfirmPaymentAsync(Guid paymentId, Guid userId);
13
14 // IDOR-protected queries
15 Task<List<BalanceEntry>> GetBalancesAsync(Guid tripId, Guid userId); // participant-only, empty if forbidden
16 Task<SettlementPlanBllDto?> GetLatestPlanAsync(Guid tripId, Guid userId); // participant-only
17 Task<SettlementPlanBllDto?> GetLatestPlanRawAsync(Guid tripId); // no IDOR (used internally after IDOR checked)
18
19 // Payment lookups
20 Task<SettlementPaymentBllDto?> GetPaymentByIdAsync(Guid paymentId);
21 Task<SettlementPlanBllDto?> GetPlanByIdAsync(Guid planId);
22
23 // Guarded mark/confirm that also validate trip participation
24 Task<(bool success, string? errorCode)> MarkPaidGuardedAsync(Guid paymentId, Guid userId);
25 Task<(bool success, string? errorCode)> ConfirmPaymentGuardedAsync(Guid paymentId, Guid userId);
26 }
27
28 public class BalanceEntry
29 {
30 public Guid UserId { get; set; }
31 public string UserName { get; set; } = default!;
32 public decimal TotalPaid { get; set; }
33 public decimal TotalOwed { get; set; }
34 public decimal NetBalance => TotalPaid - TotalOwed;
35 }
36
37 public class PreviewPayment
38 {
39 public string FromUserName { get; set; } = default!;
40 public string ToUserName { get; set; } = default!;
41 public decimal Amount { get; set; }
42 }
43