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

/// <summary>
/// The سامانه مودیان e-invoicing rail seam (introduced by b11). Handlers depend only on this contract; the
/// mock leaves a newly issued invoice at <c>moadian_status = pending</c> with no reference (no external call).
/// A config switch can force a deterministic <c>registered</c> result (with a fake 22-digit reference) so the
/// reconciliation/registered path is testable. The real مودیان adapter — enrollment, the معاملات/invoice
/// submission API, the <c>pending → submitted → registered</c> reconciliation callback — is a drop-in that
/// swaps only this registration.
/// </summary>
public interface IMoadianClient
{
    ValueTask<MoadianSubmissionResult> SubmitAsync(InvoiceSubmission submission, CancellationToken cancellationToken = default);
}

/// <summary>The minimal facts مودیان needs to register a commission invoice. Money is IRR <c>long</c>.</summary>
/// <param name="InvoiceNumber">The platform's own sequential number.</param>
/// <param name="BookingId">The booking the invoice is for.</param>
/// <param name="GrossIrr">The booking gross.</param>
/// <param name="PlatformCommissionIrr">The VAT-relevant commission line.</param>
/// <param name="VatIrr">The computed VAT on the commission.</param>
public sealed record InvoiceSubmission(
    string InvoiceNumber,
    long BookingId,
    long GrossIrr,
    long PlatformCommissionIrr,
    long VatIrr);

/// <summary>The outcome of a مودیان submission.</summary>
/// <param name="Status">A <c>moadian_status</c> code — <c>pending</c> from the mock by default.</param>
/// <param name="ReferenceNumber">The 22-digit مودیان reference when registered; null otherwise.</param>
public sealed record MoadianSubmissionResult(string Status, string? ReferenceNumber);
