Improved compliance monitoring

This commit is contained in:
2026-10-22 15:42:36 +02:00
parent 9835121fd9
commit 299d6ff4dc
27 changed files with 4245 additions and 149 deletions
@@ -9,6 +9,8 @@ public class ComplianceItem : Models.ComplianceItem, ITenantEntity
public virtual Project? Project { get; set; }
public virtual Beneficiary? Beneficiary { get; set; }
public virtual User? Creator { get; set; }
public virtual User? Verifier { get; set; }
@@ -23,6 +25,7 @@ public sealed class ComplianceItemConfiguration : IEntityTypeConfiguration<Compl
builder.HasKey(pk => pk.Id);
builder.Property(f => f.TenantId).IsRequired();
builder.Property(f => f.ProjectId).IsRequired();
builder.Property(f => f.BeneficiaryId).IsRequired(false);
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.VerifiedBy).IsRequired(false);
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
@@ -30,7 +33,7 @@ public sealed class ComplianceItemConfiguration : IEntityTypeConfiguration<Compl
builder.Property(f => f.Title).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Requirements).IsRequired().HasMaxLength(MediumTextLength);
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ApprovalStatus.Pending);
.HasSentinel(ComplianceStatus.NotMet);
builder.HasOne(f => f.Project)
.WithMany()
@@ -38,6 +41,12 @@ public sealed class ComplianceItemConfiguration : IEntityTypeConfiguration<Compl
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Beneficiary)
.WithMany()
.HasForeignKey(fk => fk.BeneficiaryId)
.IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
@@ -50,4 +59,4 @@ public sealed class ComplianceItemConfiguration : IEntityTypeConfiguration<Compl
.IsRequired(false)
.OnDelete(DeleteBehavior.NoAction);
}
}
}
@@ -25,6 +25,8 @@ public sealed class OutcomeConfiguration : IEntityTypeConfiguration<Outcome>
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Description).IsRequired().HasMaxLength(TextLength);
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ComplianceStatus.NotMet);
builder.HasOne(f => f.Tenant)
.WithMany()
@@ -44,4 +46,4 @@ public sealed class OutcomeConfiguration : IEntityTypeConfiguration<Outcome>
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
}
}
}
+8 -1
View File
@@ -197,4 +197,11 @@ public enum ActivityStatus : int
Active = 1,
Inactive = 2,
Disabled = 3,
}
}
public enum ComplianceStatus : int
{
NotMet = 1,
Met = 2,
Exceeded = 3,
}
@@ -137,6 +137,7 @@ public static class Mappers
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
ProjectId = entity.ProjectId,
BeneficiaryId = entity.BeneficiaryId,
Requirements = entity.Requirements,
Status = entity.Status,
Title = entity.Title,
@@ -288,7 +289,8 @@ public static class Mappers
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Name = entity.Name
Name = entity.Name,
Status = entity.Status
};
public static Portfolio Map(this Entities.Portfolio entity) => new()
@@ -8,11 +8,13 @@ public class ComplianceItem
public long ProjectId { get; set; }
public long? BeneficiaryId { get; set; }
public string? Title { get; set; }
public string? Requirements { get; set; }
public ApprovalStatus Status { get; set; }
public ComplianceStatus Status { get; set; } = ComplianceStatus.NotMet;
public Guid CreatedBy { get; set; }
@@ -21,4 +23,4 @@ public class ComplianceItem
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
}
+3 -1
View File
@@ -15,4 +15,6 @@ public class Outcome
public string? Name { get; set; }
public string? Description { get; set; }
}
public ComplianceStatus Status { get; set; } = ComplianceStatus.NotMet;
}