using Baya.Application.Models.Common;
using Baya.Application.Models.Payouts;
using Mediator;

namespace Baya.Application.Features.Payouts.Commands.GeneratePayoutBatch;

/// <summary>Opens a <c>draft</c> payout batch for a window: shifts the period end + processing date off bank-closed
/// days, selects the payout-eligible unpaid bookings, and materializes one payout per nurse (netting pending
/// clawbacks, snapshotting the verified primary IBAN, linking each booking under the UNIQUE guard). Returns the
/// draft batch + payouts for admin preview; no money moves until <c>process</c>.</summary>
public record GeneratePayoutBatchCommand(DateOnly PeriodStart, DateOnly PeriodEnd)
    : IRequest<OperationResult<GeneratePayoutBatchResult>>
{
    /// <summary>
    /// True only when the in-process scheduler runs the weekly generation unattended (refinement-phase-7): the
    /// batch is recorded with a null initiator instead of requiring an authenticated admin. The HTTP path always
    /// leaves this <c>false</c> — <c>AdminPayoutsController</c> neutralizes any request-supplied value — so it can
    /// never be set by an API caller.
    /// </summary>
    public bool SystemInitiated { get; init; }
}
