using Baya.Domain.Entities.Payouts; using Baya.Domain.Entities.User; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Baya.Infrastructure.Persistence.Configuration.PayoutsConfig; /// /// nurse_payout_batches — the weekly aggregation, in the dedicated payouts schema. The /// total_amount = Σ payouts / payout_count = COUNT(payouts) invariants are enforced by the handler /// when the rows are materialized (a cross-row aggregate can't be a single-row DB CHECK); the periods are /// holiday-shifted before insert. 1:N → nurse_payouts. /// internal sealed class NursePayoutBatchConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("NursePayoutBatches", "payouts"); builder.Property(b => b.Status).HasMaxLength(30).IsRequired(); builder.Property(b => b.FailureNotes).HasMaxLength(1000); builder.HasIndex(b => b.Status); builder.HasIndex(b => b.ProcessingDate); builder.HasMany(b => b.Payouts).WithOne(p => p.Batch).HasForeignKey(p => p.BatchId).IsRequired(); builder.HasOne().WithMany().HasForeignKey(b => b.InitiatedByAdminId).IsRequired(); builder.HasQueryFilter(b => b.DeletedAt == null); } }