#nullable enable
namespace Baya.Application.Models.PartnerCenters;

/// <summary>A partner center in the admin list (never carries the settlement IBAN), with its sponsored-nurse count.</summary>
public record PartnerCenterListItemDto(
    long Id,
    string Name,
    string? LegalEntityType,
    bool IsMerchantOfRecord,
    bool IsActive,
    DateTimeOffset? VerifiedAt,
    int SponsoredNurseCount,
    int AdminUserId);

/// <summary>The admin detail view of a partner center. <see cref="SettlementIbanMasked"/> is the last-4 mask —
/// the plaintext/full IBAN is <b>never</b> returned.</summary>
public record PartnerCenterDetailDto(
    long Id,
    string Name,
    string? LegalEntityType,
    string MohEstablishmentPermitNo,
    int? TechnicalDirectorNurseUserId,
    string? TechnicalDirectorLicenseNo,
    string? EnamadCode,
    string? SettlementIbanMasked,
    bool IsMerchantOfRecord,
    decimal? CommissionRate,
    int AdminUserId,
    bool IsActive,
    DateTimeOffset? VerifiedAt,
    int SponsoredNurseCount,
    DateTimeOffset CreatedAt);

/// <summary>The issuer/settlement decision for a booking. <see cref="IssuingEntityType"/> is <c>platform</c> or
/// <c>partner_center</c>; when a merchant-of-record center legally covers the booking it is the invoice issuer
/// and settlement target. This is the single resolver b11's invoice issuance calls.</summary>
public record CenterForBookingDto(
    long BookingId,
    string IssuingEntityType,
    long? PartnerCenterId,
    string? PartnerCenterName,
    bool IsMerchantOfRecord);

/// <summary>A nurse sponsored by a center (for the center dashboard).</summary>
public record SponsoredNurseDto(
    long NurseProfileId,
    int UserId,
    bool IsVerified,
    decimal AverageRating,
    int TotalCompletedBookings);

/// <summary>The center dashboard read model — scoped to the center's <c>admin_user_id</c>: the sponsored nurses,
/// the count of bookings its nurses served, and the settlement/invoice summary (only meaningful when the center
/// is merchant-of-record). Surfaces b13 payout / b11 invoice read models filtered to the center; it does not
/// re-implement that logic.</summary>
public record CenterDashboardDto(
    long CenterId,
    string Name,
    bool IsMerchantOfRecord,
    bool IsActive,
    string? SettlementIbanMasked,
    int SponsoredNurseCount,
    int SponsoredBookingCount,
    int InvoiceCount,
    IReadOnlyList<SponsoredNurseDto> SponsoredNurses);
