using Baya.Domain.Entities.Booking;
using Baya.Domain.Entities.Identity;
using Baya.Domain.Entities.Refunds;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Baya.Infrastructure.Persistence.Configuration.RefundsConfig;
///
/// nurse_clawbacks — a first-class receivable opened when a booking is refunded after the nurse was
/// already paid. original_payout_id / recovered_in_payout_id are nullable columns + indexes now
/// with no FK — nurse_payouts is a forward-dep on b13, which sets the values and wires the FKs.
///
internal sealed class NurseClawbackConfig : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.ToTable("NurseClawbacks", "payments");
builder.Property(c => c.Status).HasMaxLength(30).IsRequired();
builder.Property(c => c.ResolutionNotes).HasMaxLength(500);
builder.HasIndex(c => c.NurseId);
builder.HasIndex(c => c.BookingId);
builder.HasIndex(c => c.RefundId).IsUnique();
builder.HasIndex(c => c.Status);
builder.HasIndex(c => c.OriginalPayoutId);
builder.HasIndex(c => c.RecoveredInPayoutId);
builder.HasOne().WithMany().HasForeignKey(c => c.NurseId).IsRequired();
builder.HasOne().WithMany().HasForeignKey(c => c.BookingId).IsRequired();
builder.HasOne().WithMany().HasForeignKey(c => c.RefundId).IsRequired();
builder.HasQueryFilter(c => c.DeletedAt == null);
}
}