#nullable enable
namespace Baya.Application.Contracts.Payments;

/// <summary>
/// The تسهیم (settlement-sharing) seam — the <b>lawful split primitive</b>. A پرداخت‌یار may not custody funds
/// or run a wallet, so the platform never moves money between merchants: it registers a split-by-ratio to the
/// beneficiaries' <b>registered IBANs</b> and the provider credits each IBAN directly. The ledger only mirrors
/// money that legally sits at the provider/bank. Amounts are IRR <c>long</c>.
/// </summary>
public interface ISettlementSplitProvider
{
    /// <summary>Registers the split for a captured booking. <paramref name="legs"/> credit the nurse's payout
    /// and the platform's commission to their registered IBANs; their sum equals the captured gross.</summary>
    ValueTask<SettlementResult> RegisterSplitAsync(long bookingId, IReadOnlyList<SettlementLeg> legs, CancellationToken cancellationToken = default);

    ValueTask<SettlementResult> GetSplitStatusAsync(long bookingId, CancellationToken cancellationToken = default);
}

public enum SettlementStatus
{
    Registered,
    Settled,
    Failed
}

/// <param name="Sheba">The beneficiary's registered IBAN (SHEBA) the provider credits directly.</param>
/// <param name="AmountIrr">The IRR amount for this beneficiary.</param>
/// <param name="Beneficiary">A label — <c>nurse</c> / <c>platform</c>.</param>
public sealed record SettlementLeg(string Sheba, long AmountIrr, string Beneficiary);

public sealed record SettlementResult(SettlementStatus Status);
