#nullable enable
using Baya.Domain.Common;

namespace Baya.Domain.Entities.Payouts;

/// <summary>
/// The join from a payout to the specific booking it covers — and the platform's strongest correctness feature:
/// <see cref="BookingId"/> carries a <b>UNIQUE</b> index so a booking can be paid in <b>exactly one</b> payout
/// across all batches, ever. A duplicate insert <i>is</i> the already-paid signal (the handler catches it, treats
/// the booking as not-eligible, and continues) — the structural anti-double-pay guard, not just a pre-check.
/// <para>
/// The <see cref="BookingId"/> UNIQUE is <b>unconditional</b> (not filtered on soft-delete): the link is a
/// permanent record of an irreversible transfer, so even a removed row must never re-open a booking for
/// re-payment. <see cref="SessionId"/> is nullable for a future per-session accrual model; today one link per
/// booking carries the whole booking payout. Money is IRR <c>BIGINT</c>.
/// </para>
/// </summary>
public class NursePayoutBookingLink : BaseEntity<long>
{
    public long PayoutId { get; set; }

    /// <summary><b>UNIQUE</b> (unconditional) across every batch — the hard one-payout-per-booking guard.</summary>
    public long BookingId { get; set; }

    /// <summary>Set only when paying a per-session accrual; null for whole-booking payment.</summary>
    public long? SessionId { get; set; }

    /// <summary>The portion of this booking (or session) paid in this payout (IRR).</summary>
    public long PayoutAmountIrr { get; set; }

    public DateTimeOffset? DeletedAt { get; set; }
}
