feat(expense): add AddExpenseModule EF migration

Creates Ministries, ExpenseCategoryGroups, ExpenseSubCategories,
Expenses (with filtered Status index, MinistryId/ExpenseDate indexes,
Restrict FKs + SetNull on Member), and MonthlyStatements (unique
Year+Month index) tables. No existing tables modified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Chen
2026-05-29 18:15:16 -07:00
parent cf929557fe
commit ac65c68e18
3 changed files with 1778 additions and 0 deletions
@@ -245,6 +245,226 @@ namespace ROLAC.API.Migrations
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("ROLAC.API.Entities.Expense", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Amount")
.HasColumnType("decimal(18,2)");
b.Property<int>("CategoryGroupId")
.HasColumnType("integer");
b.Property<string>("CheckNumber")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeletedBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateOnly>("ExpenseDate")
.HasColumnType("date");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<int?>("MemberId")
.HasColumnType("integer");
b.Property<int>("MinistryId")
.HasColumnType("integer");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<DateTimeOffset?>("PaidAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("PaidBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("ReceiptBlobPath")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("ReviewNotes")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateTimeOffset?>("ReviewedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReviewedBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(30)
.HasColumnType("character varying(30)")
.HasDefaultValue("Draft");
b.Property<int>("SubCategoryId")
.HasColumnType("integer");
b.Property<DateTimeOffset?>("SubmittedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("SubmittedBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("VendorName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("Id");
b.HasIndex("CategoryGroupId");
b.HasIndex("ExpenseDate");
b.HasIndex("MemberId");
b.HasIndex("MinistryId");
b.HasIndex("Status")
.HasFilter("\"IsDeleted\" = false");
b.HasIndex("SubCategoryId");
b.ToTable("Expenses");
});
modelBuilder.Entity("ROLAC.API.Entities.ExpenseCategoryGroup", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name_en")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Name_zh")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.HasKey("Id");
b.ToTable("ExpenseCategoryGroups");
});
modelBuilder.Entity("ROLAC.API.Entities.ExpenseSubCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name_en")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Name_zh")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.HasKey("Id");
b.HasIndex("GroupId");
b.ToTable("ExpenseSubCategories");
});
modelBuilder.Entity("ROLAC.API.Entities.FamilyUnit", b =>
{
b.Property<int>("Id")
@@ -557,6 +777,112 @@ namespace ROLAC.API.Migrations
b.ToTable("Members");
});
modelBuilder.Entity("ROLAC.API.Entities.Ministry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description_en")
.HasColumnType("text");
b.Property<string>("Description_zh")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name_en")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Name_zh")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Ministries");
});
modelBuilder.Entity("ROLAC.API.Entities.MonthlyStatement", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("BankStatementBalance")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("CalculatedClosingBalance")
.HasColumnType("decimal(18,2)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<decimal>("Difference")
.HasColumnType("decimal(18,2)");
b.Property<DateTimeOffset?>("FinalizedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FinalizedBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<bool>("IsFinalized")
.HasColumnType("boolean");
b.Property<int>("Month")
.HasColumnType("integer");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<decimal>("OpeningBalance")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("TotalExpenses")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("TotalGiving")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("TotalOtherIncome")
.HasColumnType("decimal(18,2)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<int>("Year")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Year", "Month")
.IsUnique();
b.ToTable("MonthlyStatements");
});
modelBuilder.Entity("ROLAC.API.Entities.OfferingSession", b =>
{
b.Property<int>("Id")
@@ -728,6 +1054,51 @@ namespace ROLAC.API.Migrations
.IsRequired();
});
modelBuilder.Entity("ROLAC.API.Entities.Expense", b =>
{
b.HasOne("ROLAC.API.Entities.ExpenseCategoryGroup", "CategoryGroup")
.WithMany()
.HasForeignKey("CategoryGroupId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ROLAC.API.Entities.Member", "Member")
.WithMany()
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("ROLAC.API.Entities.Ministry", "Ministry")
.WithMany()
.HasForeignKey("MinistryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ROLAC.API.Entities.ExpenseSubCategory", "SubCategory")
.WithMany()
.HasForeignKey("SubCategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("CategoryGroup");
b.Navigation("Member");
b.Navigation("Ministry");
b.Navigation("SubCategory");
});
modelBuilder.Entity("ROLAC.API.Entities.ExpenseSubCategory", b =>
{
b.HasOne("ROLAC.API.Entities.ExpenseCategoryGroup", "Group")
.WithMany("SubCategories")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Group");
});
modelBuilder.Entity("ROLAC.API.Entities.Giving", b =>
{
b.HasOne("ROLAC.API.Entities.GivingCategory", "GivingCategory")
@@ -779,6 +1150,11 @@ namespace ROLAC.API.Migrations
b.Navigation("RefreshTokens");
});
modelBuilder.Entity("ROLAC.API.Entities.ExpenseCategoryGroup", b =>
{
b.Navigation("SubCategories");
});
modelBuilder.Entity("ROLAC.API.Entities.OfferingSession", b =>
{
b.Navigation("Givings");