Add membership fee system with disability discount and fix document permissions
Features: - Implement two fee types: entrance fee and annual fee (both NT$1,000) - Add 50% discount for disability certificate holders - Add disability certificate upload in member profile - Integrate disability verification into cashier approval workflow - Add membership fee settings in system admin Document permissions: - Fix hard-coded role logic in Document model - Use permission-based authorization instead of role checks Additional features: - Add announcements, general ledger, and trial balance modules - Add income management and accounting entries - Add comprehensive test suite with factories - Update UI translations to Traditional Chinese 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,48 +11,85 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* 此 Seeder 建立統一的角色與權限系統,整合:
|
||||
* - 財務工作流程權限
|
||||
* - 會員繳費審核權限(原 PaymentVerificationRolesSeeder)
|
||||
* - 基礎角色(原 RoleSeeder)
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Create permissions for financial workflow
|
||||
$permissions = [
|
||||
// Approval Stage Permissions
|
||||
'approve_finance_cashier' => '出納審核財務申請單(第一階段)',
|
||||
'approve_finance_accountant' => '會計審核財務申請單(第二階段)',
|
||||
'approve_finance_chair' => '理事長審核財務申請單(第三階段)',
|
||||
'approve_finance_board' => '理事會審核大額財務申請(大於50,000)',
|
||||
// ===== 會員繳費審核權限(原 PaymentVerificationRolesSeeder) =====
|
||||
'verify_payments_cashier' => '出納審核會員繳費(第一階段)',
|
||||
'verify_payments_accountant' => '會計審核會員繳費(第二階段)',
|
||||
'verify_payments_chair' => '理事長審核會員繳費(第三階段)',
|
||||
'activate_memberships' => '啟用會員帳號',
|
||||
'view_payment_verifications' => '查看繳費審核儀表板',
|
||||
|
||||
// Payment Stage Permissions
|
||||
// ===== 財務申請單審核權限(新工作流程) =====
|
||||
'approve_finance_secretary' => '秘書長審核財務申請單(第一階段)',
|
||||
'approve_finance_chair' => '理事長審核財務申請單(第二階段:中額以上)',
|
||||
'approve_finance_board' => '董理事會審核財務申請單(第三階段:大額)',
|
||||
// Legacy permissions
|
||||
'approve_finance_cashier' => '出納審核財務申請單(舊流程)',
|
||||
'approve_finance_accountant' => '會計審核財務申請單(舊流程)',
|
||||
|
||||
// ===== 出帳確認權限 =====
|
||||
'confirm_disbursement_requester' => '申請人確認領款',
|
||||
'confirm_disbursement_cashier' => '出納確認出帳',
|
||||
|
||||
// ===== 入帳確認權限 =====
|
||||
'confirm_recording_accountant' => '會計確認入帳',
|
||||
|
||||
// ===== 收入管理權限 =====
|
||||
'view_incomes' => '查看收入記錄',
|
||||
'record_income' => '記錄收入(出納)',
|
||||
'confirm_income' => '確認收入(會計)',
|
||||
'cancel_income' => '取消收入',
|
||||
'export_incomes' => '匯出收入報表',
|
||||
'view_income_statistics' => '查看收入統計',
|
||||
|
||||
// ===== 付款階段權限 =====
|
||||
'create_payment_order' => '會計製作付款單',
|
||||
'verify_payment_order' => '出納覆核付款單',
|
||||
'execute_payment' => '出納執行付款',
|
||||
'upload_payment_receipt' => '上傳付款憑證',
|
||||
|
||||
// Recording Stage Permissions
|
||||
// ===== 記錄階段權限 =====
|
||||
'record_cashier_ledger' => '出納記錄現金簿',
|
||||
'record_accounting_transaction' => '會計記錄會計分錄',
|
||||
'view_cashier_ledger' => '查看出納現金簿',
|
||||
'view_accounting_transactions' => '查看會計分錄',
|
||||
|
||||
// Reconciliation Permissions
|
||||
// ===== 銀行調節權限 =====
|
||||
'prepare_bank_reconciliation' => '出納製作銀行調節表',
|
||||
'review_bank_reconciliation' => '會計覆核銀行調節表',
|
||||
'approve_bank_reconciliation' => '主管核准銀行調節表',
|
||||
|
||||
// General Finance Document Permissions
|
||||
// ===== 財務文件權限 =====
|
||||
'view_finance_documents' => '查看財務申請單',
|
||||
'create_finance_documents' => '建立財務申請單',
|
||||
'edit_finance_documents' => '編輯財務申請單',
|
||||
'delete_finance_documents' => '刪除財務申請單',
|
||||
|
||||
// Chart of Accounts & Budget Permissions
|
||||
// ===== 會計科目與預算權限 =====
|
||||
'assign_chart_of_account' => '指定會計科目',
|
||||
'assign_budget_item' => '指定預算項目',
|
||||
|
||||
// Dashboard & Reports Permissions
|
||||
// ===== 儀表板與報表權限 =====
|
||||
'view_finance_dashboard' => '查看財務儀表板',
|
||||
'view_finance_reports' => '查看財務報表',
|
||||
'export_finance_reports' => '匯出財務報表',
|
||||
|
||||
// ===== 公告系統權限 =====
|
||||
'view_announcements' => '查看公告',
|
||||
'create_announcements' => '建立公告',
|
||||
'edit_announcements' => '編輯公告',
|
||||
'delete_announcements' => '刪除公告',
|
||||
'publish_announcements' => '發布公告',
|
||||
'manage_all_announcements' => '管理所有公告',
|
||||
];
|
||||
|
||||
foreach ($permissions as $name => $description) {
|
||||
@@ -63,81 +100,175 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
||||
$this->command->info("Permission created: {$name}");
|
||||
}
|
||||
|
||||
// Create roles for financial workflow
|
||||
// ===== 建立基礎角色(原 RoleSeeder) =====
|
||||
$baseRoles = [
|
||||
'admin' => '系統管理員 - 擁有系統所有權限,負責使用者管理、系統設定與維護',
|
||||
'staff' => '工作人員 - 一般協會工作人員,可檢視文件與協助行政事務',
|
||||
];
|
||||
|
||||
foreach ($baseRoles as $roleName => $description) {
|
||||
Role::updateOrCreate(
|
||||
['name' => $roleName, 'guard_name' => 'web'],
|
||||
['description' => $description]
|
||||
);
|
||||
$this->command->info("Base role created: {$roleName}");
|
||||
}
|
||||
|
||||
// ===== 建立財務與會員管理角色 =====
|
||||
$roles = [
|
||||
'secretary_general' => [
|
||||
'permissions' => [
|
||||
// 財務申請單審核(新工作流程第一階段)
|
||||
'approve_finance_secretary',
|
||||
// 一般
|
||||
'view_finance_documents',
|
||||
'view_finance_dashboard',
|
||||
'view_finance_reports',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
'manage_all_announcements',
|
||||
],
|
||||
'description' => '秘書長 - 協會行政負責人,負責初審所有財務申請',
|
||||
],
|
||||
'finance_cashier' => [
|
||||
'permissions' => [
|
||||
// Approval stage
|
||||
// 會員繳費審核(原 payment_cashier)
|
||||
'verify_payments_cashier',
|
||||
'view_payment_verifications',
|
||||
// 財務申請單審核(舊流程,保留)
|
||||
'approve_finance_cashier',
|
||||
// Payment stage
|
||||
// 出帳確認(新工作流程)
|
||||
'confirm_disbursement_cashier',
|
||||
// 收入管理
|
||||
'view_incomes',
|
||||
'record_income',
|
||||
// 付款階段
|
||||
'verify_payment_order',
|
||||
'execute_payment',
|
||||
'upload_payment_receipt',
|
||||
// Recording stage
|
||||
// 記錄階段
|
||||
'record_cashier_ledger',
|
||||
'view_cashier_ledger',
|
||||
// Reconciliation
|
||||
// 銀行調節
|
||||
'prepare_bank_reconciliation',
|
||||
// General
|
||||
// 一般
|
||||
'view_finance_documents',
|
||||
'view_finance_dashboard',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
],
|
||||
'description' => '出納 - 管錢(覆核付款單、執行付款、記錄現金簿、製作銀行調節表)',
|
||||
'description' => '出納 - 負責現金收付、銀行調節表製作、出帳確認、記錄收入',
|
||||
],
|
||||
'finance_accountant' => [
|
||||
'permissions' => [
|
||||
// Approval stage
|
||||
// 會員繳費審核(原 payment_accountant)
|
||||
'verify_payments_accountant',
|
||||
'view_payment_verifications',
|
||||
// 財務申請單審核(舊流程,保留)
|
||||
'approve_finance_accountant',
|
||||
// Payment stage
|
||||
// 入帳確認(新工作流程)
|
||||
'confirm_recording_accountant',
|
||||
// 收入管理
|
||||
'view_incomes',
|
||||
'confirm_income',
|
||||
'cancel_income',
|
||||
'export_incomes',
|
||||
'view_income_statistics',
|
||||
// 付款階段
|
||||
'create_payment_order',
|
||||
// Recording stage
|
||||
// 記錄階段
|
||||
'record_accounting_transaction',
|
||||
'view_accounting_transactions',
|
||||
// Reconciliation
|
||||
// 銀行調節
|
||||
'review_bank_reconciliation',
|
||||
// Chart of accounts & budget
|
||||
// 會計科目與預算
|
||||
'assign_chart_of_account',
|
||||
'assign_budget_item',
|
||||
// General
|
||||
// 一般
|
||||
'view_finance_documents',
|
||||
'view_finance_dashboard',
|
||||
'view_finance_reports',
|
||||
'export_finance_reports',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
],
|
||||
'description' => '會計 - 管帳(製作付款單、記錄會計分錄、覆核銀行調節表、指定會計科目)',
|
||||
'description' => '會計 - 負責會計傳票製作、財務報表編製、入帳確認、確認收入',
|
||||
],
|
||||
'finance_chair' => [
|
||||
'permissions' => [
|
||||
// Approval stage
|
||||
// 會員繳費審核(原 payment_chair)
|
||||
'verify_payments_chair',
|
||||
'view_payment_verifications',
|
||||
// 財務申請單審核
|
||||
'approve_finance_chair',
|
||||
// Reconciliation
|
||||
// 銀行調節
|
||||
'approve_bank_reconciliation',
|
||||
// General
|
||||
// 一般
|
||||
'view_finance_documents',
|
||||
'view_finance_dashboard',
|
||||
'view_finance_reports',
|
||||
'export_finance_reports',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
'manage_all_announcements',
|
||||
],
|
||||
'description' => '理事長 - 審核中大額財務申請、核准銀行調節表',
|
||||
'description' => '理事長 - 協會負責人,負責核決重大財務支出與會員繳費最終審核',
|
||||
],
|
||||
'finance_board_member' => [
|
||||
'permissions' => [
|
||||
// Approval stage (for large amounts)
|
||||
// 大額審核
|
||||
'approve_finance_board',
|
||||
// General
|
||||
// 一般
|
||||
'view_finance_documents',
|
||||
'view_finance_dashboard',
|
||||
'view_finance_reports',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
],
|
||||
'description' => '理事 - 審核大額財務申請(大於50,000)',
|
||||
'description' => '理事 - 理事會成員,協助監督協會運作與審核特定議案',
|
||||
],
|
||||
'finance_requester' => [
|
||||
'permissions' => [
|
||||
'view_finance_documents',
|
||||
'create_finance_documents',
|
||||
'edit_finance_documents',
|
||||
// 出帳確認(新工作流程)
|
||||
'confirm_disbursement_requester',
|
||||
],
|
||||
'description' => '財務申請人 - 可建立和編輯自己的財務申請單',
|
||||
'description' => '財務申請人 - 一般有權申請款項之人員(如活動負責人),可確認領款',
|
||||
],
|
||||
'membership_manager' => [
|
||||
'permissions' => [
|
||||
'activate_memberships',
|
||||
'view_payment_verifications',
|
||||
// 公告系統
|
||||
'view_announcements',
|
||||
'create_announcements',
|
||||
'edit_announcements',
|
||||
'delete_announcements',
|
||||
'publish_announcements',
|
||||
],
|
||||
'description' => '會員管理員 - 專責處理會員入會審核、資料維護與會籍管理',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -153,24 +284,32 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
||||
$this->command->info("Role created: {$roleName} with permissions: " . implode(', ', $roleData['permissions']));
|
||||
}
|
||||
|
||||
// Assign all financial workflow permissions to admin role (if exists)
|
||||
// Assign all permissions to admin role
|
||||
$adminRole = Role::where('name', 'admin')->first();
|
||||
if ($adminRole) {
|
||||
$adminRole->givePermissionTo(array_keys($permissions));
|
||||
$this->command->info("Admin role updated with all financial workflow permissions");
|
||||
$this->command->info("Admin role updated with all permissions");
|
||||
}
|
||||
|
||||
$this->command->info("\n=== Financial Workflow Roles & Permissions Created ===");
|
||||
$this->command->info("Roles created:");
|
||||
$this->command->info("1. finance_cashier - 出納(管錢)");
|
||||
$this->command->info("2. finance_accountant - 會計(管帳)");
|
||||
$this->command->info("3. finance_chair - 理事長");
|
||||
$this->command->info("4. finance_board_member - 理事");
|
||||
$this->command->info("5. finance_requester - 財務申請人");
|
||||
$this->command->info("\nWorkflow stages:");
|
||||
$this->command->info("1. Approval Stage: Cashier → Accountant → Chair (→ Board for large amounts)");
|
||||
$this->command->info("2. Payment Stage: Accountant creates order → Cashier verifies → Cashier executes");
|
||||
$this->command->info("3. Recording Stage: Cashier records ledger + Accountant records transactions");
|
||||
$this->command->info("4. Reconciliation: Cashier prepares → Accountant reviews → Chair approves");
|
||||
$this->command->info("\n=== 統一角色系統建立完成 ===");
|
||||
$this->command->info("基礎角色:");
|
||||
$this->command->info(" - admin - 系統管理員");
|
||||
$this->command->info(" - staff - 工作人員");
|
||||
$this->command->info("\n財務角色:");
|
||||
$this->command->info(" - secretary_general - 秘書長(新增:財務申請初審)");
|
||||
$this->command->info(" - finance_cashier - 出納(出帳確認)");
|
||||
$this->command->info(" - finance_accountant - 會計(入帳確認)");
|
||||
$this->command->info(" - finance_chair - 理事長(中額以上審核)");
|
||||
$this->command->info(" - finance_board_member - 理事(大額審核)");
|
||||
$this->command->info(" - finance_requester - 財務申請人(可確認領款)");
|
||||
$this->command->info("\n會員管理角色:");
|
||||
$this->command->info(" - membership_manager - 會員管理員");
|
||||
$this->command->info("\n新財務申請審核工作流程:");
|
||||
$this->command->info(" 審核階段:");
|
||||
$this->command->info(" 小額 (< 5,000): secretary_general");
|
||||
$this->command->info(" 中額 (5,000-50,000): secretary_general → finance_chair");
|
||||
$this->command->info(" 大額 (> 50,000): secretary_general → finance_chair → finance_board_member");
|
||||
$this->command->info(" 出帳階段: finance_requester(申請人確認) + finance_cashier(出納確認)");
|
||||
$this->command->info(" 入帳階段: finance_accountant(會計入帳)");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user