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

namespace Baya.Application.Features.Bnpl.Commands.RevertBnplOrder;

/// <summary>
/// Reverses a <c>settled</c> BNPL order back through the provider (full via revert; partial/shortened-visit via
/// update to a strictly-lower amount) and records the reversal audit on the <c>bnpl_transactions</c> row. It
/// <b>reuses the b11 refund path</b> (<c>CreateRefundCommand</c>) — which creates the <c>refunds</c> row with
/// <c>refund_channel='bnpl_revert'</c>, executes the provider revert, posts the balanced reversal ledger (fee +
/// payout legs; a clawback if the nurse was already paid), and surfaces the async ~7–10-business-day customer
/// ETA. Money <b>always</b> flows customer ↔ provider ↔ Balinyaar. Admin-only.
/// </summary>
/// <param name="BnplTransactionId">The settled BNPL order to reverse.</param>
/// <param name="RefundPercentage">The reversed fraction (0–1]; 1 = full revert, &lt;1 = a strictly-lower partial.</param>
/// <param name="TicketId">Optional support-ticket link (config-gated "ticket required" rule, b15 FK).</param>
/// <param name="ReasonNotes">Free-text reason recorded on the refund.</param>
public record RevertBnplOrderCommand(
    long BnplTransactionId,
    decimal? RefundPercentage,
    long? TicketId,
    string? ReasonNotes,
    string? CallbackPayloadJson = null) : IRequest<OperationResult<RevertBnplResult>>;
