From 9f91683633c87a01f48cde8d352398d27d97be60 Mon Sep 17 00:00:00 2001 From: Chris Chen Date: Wed, 24 Jun 2026 19:54:00 -0700 Subject: [PATCH] docs: sync DB_SCHEMA with Form 990 functional-expense schema Co-Authored-By: Claude Sonnet 4.6 --- docs/DB_SCHEMA.md | 75 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/docs/DB_SCHEMA.md b/docs/DB_SCHEMA.md index 83cf196..6072b0e 100644 --- a/docs/DB_SCHEMA.md +++ b/docs/DB_SCHEMA.md @@ -279,6 +279,7 @@ Table: Ministries | Description_zh | text? | | | SortOrder | int NOT NULL DEFAULT 0 | 顯示排序 | | IsActive | bool NOT NULL DEFAULT true | | +| **DefaultFunctionalClass** | varchar(20) NOT NULL DEFAULT 'Program' | IRS Form 990 功能性費用分類:'Program' \| 'ManagementGeneral' \| 'Fundraising'。Seed:Administration → 'ManagementGeneral',其餘 → 'Program' | --- @@ -495,6 +496,27 @@ Table: GivingRecurringSchedules ## 8. Expense Tracking(支出) +### Form990ExpenseLines(IRS Form 990 Part IX 自然費用科目) + +``` +Table: Form990ExpenseLines +``` + +| 欄位 | 型別 | 說明 | +|------|------|------| +| Id | int PK | | +| LineCode | varchar(10) NOT NULL UNIQUE | Part IX 行號,如 "7"、"11b"、"16"、"24" | +| Name_en | varchar(200) NOT NULL | 英文科目名稱 | +| Name_zh | varchar(200)? | 中文科目名稱 | +| SortOrder | int NOT NULL | 排序 | +| IsActive | bool NOT NULL DEFAULT true | | +| CreatedAt | timestamp NOT NULL | | +| CreatedBy | varchar(450) NOT NULL | FK → AspNetUsers.Id | +| UpdatedAt | timestamp NOT NULL | | +| UpdatedBy | varchar(450) NOT NULL | FK → AspNetUsers.Id | + +> **IRS Form 990 Part IX 說明:** Part IX「Statement of Functional Expenses」要求將每筆支出依 IRS 自然費用科目(LineCode)分類,同時按功能性費用分類(Program / Management & General / Fundraising)橫向彙總,生成 Form 990 Schedule Part IX 報表。 + ### ExpenseCategoryGroup(支出大類) ``` @@ -508,8 +530,9 @@ Table: ExpenseCategoryGroups | Name_zh | varchar(200)? | | | SortOrder | int NOT NULL DEFAULT 0 | | | IsActive | bool NOT NULL DEFAULT true | | +| **Form990LineId** | int? | FK → Form990ExpenseLines.Id,ON DELETE SET NULL。大類層級預設 990 行號;Seed 預設為行 "24"(其他費用)| -**Seed 大類(11 個):** +**Seed 大類(14 個):** | Id | Name_en | Name_zh | |----|---------|---------| @@ -524,6 +547,9 @@ Table: ExpenseCategoryGroups | 9 | Benevolence | 關懷救助 | | 10 | Other | 其他 | | 11 | Personnel | 人事 | +| 12 | Professional Services | 專業服務 | +| 13 | Information Technology | 資訊科技 | +| 14 | Finance & Banking | 財務與銀行 | ### ExpenseSubCategory(支出子項目) @@ -539,6 +565,9 @@ Table: ExpenseSubCategories | Name_zh | varchar(200)? | | | SortOrder | int NOT NULL DEFAULT 0 | | | IsActive | bool NOT NULL DEFAULT true | | +| **Form990LineId** | int? | FK → Form990ExpenseLines.Id,ON DELETE SET NULL。子項目層級 990 行號(優先於大類值)| + +> **有效 990 行號解析順序:** `SubCategory.Form990LineId ?? Group.Form990LineId ?? "24"`(先取子項目的行號;若為 null 則取大類的行號;仍為 null 則視為行 "24" — Other Expenses)。 **Seed 子項目(完整種子):** @@ -554,12 +583,12 @@ Table: ExpenseSubCategories | 3 Food & Beverage | Catering | 出餐費用 | | 3 Food & Beverage | Food Ingredients | 食材採購 | | 3 Food & Beverage | Utensils | 器具 | -| 3 Food & Beverage | Consumables | 消耗品 | +| 3 Food & Beverage | Disposable Tableware | 一次性餐具 | | 4 Training | Course Fees | 課程費用 | | 4 Training | Books | 書籍 | | 4 Training | Conference | 研討會 | | 4 Training | Travel | 差旅 | -| 5 Materials | Printing | 印刷費用 | +| 5 Materials | Curriculum Printing | 教材印刷 | | 5 Materials | Craft Supplies | 手工材料 | | 5 Materials | Copyright & Licensing | 版權購買 | | 6 Facility | Rent | 場地租金 | @@ -569,22 +598,27 @@ Table: ExpenseSubCategories | 7 Printing | Bulletins | 週報 | | 7 Printing | Order of Service | 程序單 | | 7 Printing | Posters | 海報 | +| 7 Printing | Advertising & Promotion | 廣告與推廣 | | 8 Missions | Offering Transfer | 奉獻轉帳 | | 8 Missions | Missionary Support | 宣教士支援 | +| 8 Missions | Foreign Missions Support | 海外宣教支援 | | 8 Missions | Travel | 差旅 | | 9 Benevolence | Emergency Aid | 急難救助 | | 9 Benevolence | Condolence Gifts | 慰問禮品 | | 9 Benevolence | Visit Expenses | 探訪費用 | | 10 Other | Miscellaneous | 雜支 | | 11 Personnel | Salary & Wages | 薪資 | +| 11 Personnel | Officer / Key Employee Compensation | 主任/關鍵員工薪酬 | | 11 Personnel | Payroll Taxes | 薪資稅費 | | 11 Personnel | Employee Benefits | 員工福利 | +| 11 Personnel | Retirement / Pension | 退休/養老金 | | 11 Personnel | Workers Compensation | 勞工保險 | | 11 Personnel | Honorarium | 酬庸 | | 11 Personnel | Staff Training | 同工進修 | | 11 Personnel | Contract Labor | 外包勞務 | -> **備注:** `Facility > 財產保險` 指建築物/場地責任險;員工健保、團體保險等歸 `Personnel > 員工福利`。同工代墊報銷依**實際購買物**選大類,不歸人事。 +> **備注:** `Facility > 財產保險` 指建築物/場地責任險;員工健保、團體保險等歸 `Personnel > 員工福利`。同工代墊報銷依**實際購買物**選大類,不歸人事。 +> **子項目更名說明:** `Food & Beverage > Consumables`(消耗品)更名為 `Disposable Tableware`(一次性餐具)以消除與大類同名的歧義;`Materials > Printing`(印刷費用)更名為 `Curriculum Printing`(教材印刷)以與 Printing 大類區分。 ### Expense(支出記錄) @@ -614,6 +648,7 @@ Table: Expenses | ReviewNotes | varchar(500)? | 審核備注 | | PaidAt | timestamp? | 標記已付款時間 | | PaidBy | varchar(450)? | FK → AspNetUsers.Id | +| **FunctionalClass** | varchar(20)? | IRS Form 990 功能性費用分類個別覆寫:'Program' \| 'ManagementGeneral' \| 'Fundraising';null = 繼承 Ministry.DefaultFunctionalClass | | IsDeleted | bool NOT NULL DEFAULT false | | | DeletedAt | timestamp? | | | DeletedBy | varchar(450)? | FK → AspNetUsers.Id | @@ -622,6 +657,8 @@ Table: Expenses | UpdatedAt | timestamp NOT NULL | | | UpdatedBy | varchar(450) NOT NULL | FK → AspNetUsers.Id | +> **有效功能性費用分類解析順序:** `Expense.FunctionalClass ?? Ministry.DefaultFunctionalClass ?? 'Program'`(先取費用記錄的個別覆寫值;若為 null 則取所屬事工的預設值;仍為 null 則視為 'Program')。 + **Status 工作流程:** ``` @@ -960,16 +997,16 @@ super_admin, pastor, board_member, coworker_chair, ministry_leader, district_lea ### Ministries(10 個事工部門) ``` -1. Administration / 行政 -2. Preaching / 講道 -3. Emcee / 司會 -4. Worship / 敬拜 -5. PPT/Media / PPT/影音 -6. Sound / 音控 -7. Facility / 場地組 -8. Hospitality / 招待 -9. Children / 兒牧 -10. Catering / 餐飲 +1. Administration / 行政 DefaultFunctionalClass = 'ManagementGeneral' +2. Preaching / 講道 DefaultFunctionalClass = 'Program' +3. Emcee / 司會 DefaultFunctionalClass = 'Program' +4. Worship / 敬拜 DefaultFunctionalClass = 'Program' +5. PPT/Media / PPT/影音 DefaultFunctionalClass = 'Program' +6. Sound / 音控 DefaultFunctionalClass = 'Program' +7. Facility / 場地組 DefaultFunctionalClass = 'Program' +8. Hospitality / 招待 DefaultFunctionalClass = 'Program' +9. Children / 兒牧 DefaultFunctionalClass = 'Program' +10. Catering / 餐飲 DefaultFunctionalClass = 'Program' ``` ### GivingCategories(奉獻類型) @@ -981,9 +1018,14 @@ super_admin, pastor, board_member, coworker_chair, ministry_leader, district_lea 5. Mission / 宣教奉獻 ``` -### ExpenseCategoryGroups(11 個大類) +### ExpenseCategoryGroups(14 個大類) ``` -見 §8 Seed 大類列表 +見 §8 Seed 大類列表(含新增 Professional Services、Information Technology、Finance & Banking) +``` + +### Form990 權限模組 +``` +Form990Report — 唯讀報表權限,授予角色:finance、pastor、board_member ``` ### CmsPages(靜態頁面 Slug) @@ -1057,6 +1099,7 @@ public class RolacDbContext : IdentityDbContext public DbSet GivingReceipts => Set(); public DbSet GivingRecurringSchedules => Set(); + public DbSet Form990ExpenseLines => Set(); public DbSet ExpenseCategoryGroups => Set(); public DbSet ExpenseSubCategories => Set(); public DbSet Expenses => Set();