Features: - Support login via phone number or email (LoginRequest) - Add members:import-roster command for Excel roster import - Merge survey emails with roster data Code Quality (Phase 1-4): - Add database locking for balance calculation - Add self-approval checks for finance workflow - Create service layer (FinanceDocumentApprovalService, PaymentVerificationService) - Add HasAccountingEntries and HasApprovalWorkflow traits - Create FormRequest classes for validation - Add status-badge component - Define authorization gates in AuthServiceProvider - Add accounting config file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Taiwan NPO (Non-Profit Organization) management platform built with Laravel 11. Features member lifecycle management, multi-tier financial approval workflows, issue tracking, and document management with version control.
Commands
# Development
php artisan serve && npm run dev # Start both servers
# Testing
php artisan test # Run all tests
php artisan test --filter=ClassName # Run specific test class
php artisan test --filter=test_method_name # Run specific test method
php artisan dusk # Run browser tests
# Database
php artisan migrate:fresh --seed # Reset with all seeders
php artisan db:seed --class=TestDataSeeder # Seed test data only
php artisan db:seed --class=FinancialWorkflowTestDataSeeder # Finance test data
# Code Quality
./vendor/bin/pint # Fix code style (PSR-12)
./vendor/bin/phpstan analyse # Static analysis
Architecture
Multi-Tier Approval Workflows
The system uses tiered approval based on amount thresholds (configurable):
- Small (<5,000): Secretary approval only
- Medium (5,000-50,000): Secretary → Chair
- Large (>50,000): Secretary → Chair → Board
Finance documents follow a 3-stage lifecycle:
- Approval Stage: Multi-tier approval based on amount
- Disbursement Stage: Dual confirmation (requester + cashier)
- Recording Stage: Accountant records to ledger
Key model methods for workflow state:
$doc->isApprovalComplete() // All required approvals obtained
$doc->isDisbursementComplete() // Both parties confirmed
$doc->isRecordingComplete() // Ledger entry created
$doc->isFullyProcessed() // All 3 stages complete
RBAC Structure
Uses Spatie Laravel Permission. Core financial roles:
finance_requester: Submit finance documentsfinance_cashier: Tier 1 approval, payment executionfinance_accountant: Tier 2 approval, create payment ordersfinance_chair: Tier 3 approvalfinance_board_member: Large amount approval
Permission checks: $user->can('permission-name') or @can('permission-name') in Blade.
Service Layer
Complex business logic lives in app/Services/:
MembershipFeeCalculator: Calculates fees with disability discount supportSettingsService: System-wide settings with caching
Data Security Patterns
- National ID: AES-256 encrypted (
national_id_encrypted), SHA256 hashed for search (national_id_hash) - File uploads: Private disk storage, served via authenticated controller methods
- Audit logging: All significant actions logged to
audit_logstable
Member Lifecycle
States: pending → active → expired / suspended
Key model methods:
$member->hasPaidMembership() // Active with future expiry
$member->canSubmitPayment() // Pending with no pending payment
$member->getNextFeeType() // entrance_fee or annual_fee
Testing Patterns
Tests use RefreshDatabase trait. Setup commonly includes:
protected function setUp(): void
{
parent::setUp();
$this->artisan('db:seed', ['--class' => 'RoleSeeder']);
}
Test accounts (password: password):
admin@test.com- Full accessrequester@test.com- Submit documentscashier@test.com- Tier 1 approvalaccountant@test.com- Tier 2 approvalchair@test.com- Tier 3 approval
Key Files
routes/web.php- All web routes (admin routes under/adminprefix)app/Models/FinanceDocument.php- Core financial workflow logic with status constantsapp/Models/Member.php- Member lifecycle with encrypted field handlingdatabase/seeders/- RoleSeeder, ChartOfAccountSeeder, TestDataSeederdocs/SYSTEM_SPECIFICATION.md- Complete system specification