Add phone login support and member import functionality

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>
This commit is contained in:
2026-01-25 03:08:06 +08:00
parent ed7169b64e
commit 42099759e8
66 changed files with 3492 additions and 3803 deletions

View File

@@ -20,15 +20,11 @@ class FinanceDocumentFactory extends Factory
*/
public function definition(): array
{
$requestTypes = ['expense_reimbursement', 'advance_payment', 'purchase_request', 'petty_cash'];
$statuses = ['pending', 'approved_cashier', 'approved_accountant', 'approved_chair', 'rejected'];
return [
'title' => $this->faker->sentence(6),
'description' => $this->faker->paragraph(3),
'amount' => $this->faker->randomFloat(2, 100, 100000),
'request_type' => $this->faker->randomElement($requestTypes),
'status' => $this->faker->randomElement($statuses),
'status' => FinanceDocument::STATUS_PENDING,
'submitted_by_user_id' => User::factory(),
'submitted_at' => now(),
'amount_tier' => null,
@@ -54,52 +50,52 @@ class FinanceDocumentFactory extends Factory
public function pending(): static
{
return $this->state(fn (array $attributes) => [
'status' => 'pending',
'status' => FinanceDocument::STATUS_PENDING,
]);
}
/**
* Indicate that the document is approved by cashier.
* Indicate that the document is approved by secretary (first stage).
*/
public function approvedByCashier(): static
public function approvedBySecretary(): static
{
return $this->state(fn (array $attributes) => [
'status' => FinanceDocument::STATUS_APPROVED_CASHIER,
'approved_by_cashier_id' => User::factory(),
'cashier_approved_at' => now(),
'status' => FinanceDocument::STATUS_APPROVED_SECRETARY,
'approved_by_secretary_id' => User::factory(),
'secretary_approved_at' => now(),
]);
}
/**
* Indicate that the document is approved by accountant.
*/
public function approvedByAccountant(): static
{
return $this->state(fn (array $attributes) => [
'status' => FinanceDocument::STATUS_APPROVED_ACCOUNTANT,
'approved_by_cashier_id' => User::factory(),
'cashier_approved_at' => now(),
'approved_by_accountant_id' => User::factory(),
'accountant_approved_at' => now(),
]);
}
/**
* Indicate that the document is approved by chair.
* Indicate that the document is approved by chair (second stage).
*/
public function approvedByChair(): static
{
return $this->state(fn (array $attributes) => [
'status' => FinanceDocument::STATUS_APPROVED_CHAIR,
'approved_by_cashier_id' => User::factory(),
'cashier_approved_at' => now(),
'approved_by_accountant_id' => User::factory(),
'accountant_approved_at' => now(),
'approved_by_secretary_id' => User::factory(),
'secretary_approved_at' => now(),
'approved_by_chair_id' => User::factory(),
'chair_approved_at' => now(),
]);
}
/**
* Indicate that the document is approved by board (third stage - large amounts).
*/
public function approvedByBoard(): static
{
return $this->state(fn (array $attributes) => [
'status' => FinanceDocument::STATUS_APPROVED_BOARD,
'approved_by_secretary_id' => User::factory(),
'secretary_approved_at' => now(),
'approved_by_chair_id' => User::factory(),
'chair_approved_at' => now(),
'board_meeting_approved_by_id' => User::factory(),
'board_meeting_approved_at' => now(),
]);
}
/**
* Indicate that the document is rejected.
*/
@@ -119,7 +115,7 @@ class FinanceDocumentFactory extends Factory
{
return $this->state(fn (array $attributes) => [
'amount' => $this->faker->randomFloat(2, 100, 4999),
'amount_tier' => 'small',
'amount_tier' => FinanceDocument::AMOUNT_TIER_SMALL,
'requires_board_meeting' => false,
]);
}
@@ -131,7 +127,7 @@ class FinanceDocumentFactory extends Factory
{
return $this->state(fn (array $attributes) => [
'amount' => $this->faker->randomFloat(2, 5000, 50000),
'amount_tier' => null,
'amount_tier' => FinanceDocument::AMOUNT_TIER_MEDIUM,
'requires_board_meeting' => false,
]);
}
@@ -143,51 +139,11 @@ class FinanceDocumentFactory extends Factory
{
return $this->state(fn (array $attributes) => [
'amount' => $this->faker->randomFloat(2, 50001, 200000),
'amount_tier' => 'large',
'amount_tier' => FinanceDocument::AMOUNT_TIER_LARGE,
'requires_board_meeting' => true,
]);
}
/**
* Indicate that the document is an expense reimbursement.
*/
public function expenseReimbursement(): static
{
return $this->state(fn (array $attributes) => [
'request_type' => 'expense_reimbursement',
]);
}
/**
* Indicate that the document is an advance payment.
*/
public function advancePayment(): static
{
return $this->state(fn (array $attributes) => [
'request_type' => 'advance_payment',
]);
}
/**
* Indicate that the document is a purchase request.
*/
public function purchaseRequest(): static
{
return $this->state(fn (array $attributes) => [
'request_type' => 'purchase_request',
]);
}
/**
* Indicate that the document is petty cash.
*/
public function pettyCash(): static
{
return $this->state(fn (array $attributes) => [
'request_type' => 'petty_cash',
]);
}
/**
* Indicate that payment order has been created.
*/
@@ -195,7 +151,7 @@ class FinanceDocumentFactory extends Factory
{
return $this->state(fn (array $attributes) => [
'payment_order_created_at' => now(),
'payment_order_created_by_id' => User::factory(),
'payment_order_created_by_accountant_id' => User::factory(),
]);
}
@@ -212,16 +168,38 @@ class FinanceDocumentFactory extends Factory
}
/**
* Determine amount tier based on amount.
* Indicate that disbursement is complete (both confirmations).
*/
protected function determineAmountTier(float $amount): string
public function disbursementComplete(): static
{
if ($amount < 5000) {
return 'small';
} elseif ($amount <= 50000) {
return 'medium';
} else {
return 'large';
}
return $this->state(fn (array $attributes) => [
'requester_confirmed_at' => now(),
'requester_confirmed_by_id' => User::factory(),
'cashier_confirmed_at' => now(),
'cashier_confirmed_by_id' => User::factory(),
'disbursement_status' => FinanceDocument::DISBURSEMENT_COMPLETED,
]);
}
/**
* Indicate that recording is complete.
*/
public function recordingComplete(): static
{
return $this->state(fn (array $attributes) => [
'accountant_recorded_at' => now(),
'accountant_recorded_by_id' => User::factory(),
'recording_status' => FinanceDocument::RECORDING_COMPLETED,
]);
}
/**
* Create a fully processed document (all stages complete).
*/
public function fullyProcessed(): static
{
return $this->approvedBySecretary()
->disbursementComplete()
->recordingComplete();
}
}