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:
101
tests/Traits/SeedsRolesAndPermissions.php
Normal file
101
tests/Traits/SeedsRolesAndPermissions.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Traits;
|
||||
|
||||
use App\Models\User;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
trait SeedsRolesAndPermissions
|
||||
{
|
||||
/**
|
||||
* Seed all roles and permissions for testing
|
||||
*/
|
||||
protected function seedRolesAndPermissions(): void
|
||||
{
|
||||
$this->artisan('db:seed', ['--class' => 'FinancialWorkflowPermissionsSeeder', '--force' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user with a specific role
|
||||
*/
|
||||
protected function createUserWithRole(string $role, array $attributes = []): User
|
||||
{
|
||||
$user = User::factory()->create($attributes);
|
||||
$user->assignRole($role);
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an admin user
|
||||
*/
|
||||
protected function createAdmin(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('admin', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a finance cashier user
|
||||
*/
|
||||
protected function createCashier(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('finance_cashier', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a finance accountant user
|
||||
*/
|
||||
protected function createAccountant(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('finance_accountant', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a finance chair user
|
||||
*/
|
||||
protected function createChair(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('finance_chair', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a finance board member user
|
||||
*/
|
||||
protected function createBoardMember(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('finance_board_member', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a membership manager user
|
||||
*/
|
||||
protected function createMembershipManager(array $attributes = []): User
|
||||
{
|
||||
return $this->createUserWithRole('membership_manager', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user with specific permissions
|
||||
*/
|
||||
protected function createUserWithPermissions(array $permissions, array $attributes = []): User
|
||||
{
|
||||
$user = User::factory()->create($attributes);
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::findOrCreate($permission, 'web');
|
||||
$user->givePermissionTo($permission);
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all finance approval users (cashier, accountant, chair)
|
||||
*/
|
||||
protected function createFinanceApprovalTeam(): array
|
||||
{
|
||||
return [
|
||||
'cashier' => $this->createCashier(['email' => 'cashier@test.com']),
|
||||
'accountant' => $this->createAccountant(['email' => 'accountant@test.com']),
|
||||
'chair' => $this->createChair(['email' => 'chair@test.com']),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user