namespace Baya.Application.Models.Payments;

/// <summary>
/// The minimal facts <c>InitiatePayment</c> needs to validate a card attempt against an
/// <c>accepted_awaiting_payment</c> request: the owning customer (tenancy), the request status, the frozen
/// payment window, and the gross to charge (variant price × session count — the same figure b9 freezes onto
/// the booking on capture).
/// </summary>
public record BookingPaymentContext(long RequestId, long CustomerId, string Status, System.DateTime? PaymentDeadlineAt, long GrossIrr);

/// <summary>The three frozen amounts + nurse a card-capture ledger group posts against, read from an existing
/// booking (the confirm path is idempotent — a booking created by a prior confirm reuses this).</summary>
public record BookingLedgerAmounts(long NurseId, long GrossIrr, long CommissionIrr, long PayoutIrr);

/// <summary>
/// The result of starting a card payment: the redirect the client sends the payer to, plus the ids that
/// identify the attempt. Money never appears here — it is the booking's frozen gross, echoed nowhere the
/// customer could tamper with it.
/// </summary>
/// <param name="TransactionId">The <c>payment_transactions</c> row id for this attempt.</param>
/// <param name="RedirectUrl">Where to send the payer to complete the card payment.</param>
/// <param name="GatewayReferenceCode">The deterministic gateway reference persisted on the attempt.</param>
public record InitiatePaymentResult(long TransactionId, string RedirectUrl, string GatewayReferenceCode);

/// <summary>
/// The outcome of a webhook ingest — the terminal <c>processing_status</c> and whether this call was a
/// duplicate replay that was short-circuited. The endpoint always returns success (at-least-once tolerant).
/// </summary>
/// <param name="ProcessingStatus">A <c>payment_webhook_events.processing_status</c> code.</param>
/// <param name="Duplicate">True when the idempotency key was already stored — no money state was touched.</param>
public record WebhookIngestResult(string ProcessingStatus, bool Duplicate);

/// <summary>
/// The IRR balance currently owed a nurse, <b>derived from the ledger</b> (signed by direction), never a
/// stored column. Serialized as a string of digits per the money convention.
/// </summary>
/// <param name="NurseId">The nurse profile id.</param>
/// <param name="BalanceIrr">The signed <c>nurse_payable</c> sum, as a digit string.</param>
public record NursePayableBalanceDto(long NurseId, string BalanceIrr);
