feat: refactor week number handling to use WeekDefinitionId across multiple entities and queries

This commit is contained in:
masoodafar-web
2025-12-19 10:41:22 +03:30
parent 3cb95dc349
commit 8b784101be
83 changed files with 17592 additions and 566 deletions
@@ -16,17 +16,24 @@ public class WeeklyCommissionPoolConfiguration : IEntityTypeConfiguration<Weekly
builder.HasKey(entity => entity.Id);
builder.Property(entity => entity.Id).UseIdentityColumn();
builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20);
builder.Property(entity => entity.WeekDefinitionId).IsRequired();
builder.Property(entity => entity.TotalPoolAmount).IsRequired();
builder.Property(entity => entity.TotalBalances).IsRequired();
builder.Property(entity => entity.ValuePerBalance).IsRequired();
builder.Property(entity => entity.IsCalculated).IsRequired();
builder.Property(entity => entity.CalculatedAt).IsRequired(false);
// Index یونیک برای WeekNumber
builder.HasIndex(e => e.WeekNumber)
// رابطه با WeekDefinition (Required FK)
builder.HasOne(entity => entity.WeekDefinition)
.WithMany(wd => wd.WeeklyCommissionPools)
.HasForeignKey(entity => entity.WeekDefinitionId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
// Index یونیک برای WeekDefinitionId
builder.HasIndex(e => e.WeekDefinitionId)
.IsUnique()
.HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber");
.HasDatabaseName("IX_WeeklyCommissionPool_WeekDefinitionId");
// Index برای IsCalculated
builder.HasIndex(e => e.IsCalculated)