Implement dark mode, bug report page, and schema dump
This commit is contained in:
43
database/factories/BudgetFactory.php
Normal file
43
database/factories/BudgetFactory.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Budget;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class BudgetFactory extends Factory
|
||||
{
|
||||
protected $model = Budget::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$start = now()->startOfYear();
|
||||
|
||||
return [
|
||||
'fiscal_year' => now()->year,
|
||||
'name' => $this->faker->sentence(3),
|
||||
'period_type' => 'annual',
|
||||
'period_start' => $start,
|
||||
'period_end' => $start->copy()->endOfYear(),
|
||||
'status' => Budget::STATUS_DRAFT,
|
||||
'created_by_user_id' => User::factory(),
|
||||
'approved_by_user_id' => null,
|
||||
'approved_at' => null,
|
||||
'notes' => $this->faker->sentence(),
|
||||
];
|
||||
}
|
||||
|
||||
public function submitted(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => Budget::STATUS_SUBMITTED]);
|
||||
}
|
||||
|
||||
public function approved(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => Budget::STATUS_APPROVED,
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
38
database/factories/BudgetItemFactory.php
Normal file
38
database/factories/BudgetItemFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Budget;
|
||||
use App\Models\BudgetItem;
|
||||
use App\Models\ChartOfAccount;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class BudgetItemFactory extends Factory
|
||||
{
|
||||
protected $model = BudgetItem::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$account = ChartOfAccount::first();
|
||||
|
||||
if (! $account) {
|
||||
$account = ChartOfAccount::create([
|
||||
'account_code' => $this->faker->unique()->numerify('4###'),
|
||||
'account_name_zh' => '測試費用',
|
||||
'account_name_en' => 'Test Expense',
|
||||
'account_type' => 'expense',
|
||||
'category' => 'operating',
|
||||
'is_active' => true,
|
||||
'display_order' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'budget_id' => Budget::factory(),
|
||||
'chart_of_account_id' => $account->id,
|
||||
'budgeted_amount' => $this->faker->numberBetween(1000, 5000),
|
||||
'actual_amount' => $this->faker->numberBetween(0, 4000),
|
||||
'notes' => $this->faker->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -20,23 +20,34 @@ class FinanceDocumentFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$amount = $this->faker->randomFloat(2, 100, 100000);
|
||||
$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' => $amount,
|
||||
'amount' => $this->faker->randomFloat(2, 100, 100000),
|
||||
'request_type' => $this->faker->randomElement($requestTypes),
|
||||
'status' => $this->faker->randomElement($statuses),
|
||||
'submitted_by_id' => User::factory(),
|
||||
'submitted_by_user_id' => User::factory(),
|
||||
'submitted_at' => now(),
|
||||
'amount_tier' => $this->determineAmountTier($amount),
|
||||
'requires_board_meeting' => $amount > 50000,
|
||||
'amount_tier' => null,
|
||||
'requires_board_meeting' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterMaking(function (FinanceDocument $document) {
|
||||
$document->amount_tier = $document->determineAmountTier();
|
||||
$document->requires_board_meeting = $document->needsBoardMeetingApproval();
|
||||
})->afterCreating(function (FinanceDocument $document) {
|
||||
$document->amount_tier = $document->determineAmountTier();
|
||||
$document->requires_board_meeting = $document->needsBoardMeetingApproval();
|
||||
$document->save();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the document is pending approval.
|
||||
*/
|
||||
@@ -54,7 +65,7 @@ class FinanceDocumentFactory extends Factory
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => FinanceDocument::STATUS_APPROVED_CASHIER,
|
||||
'cashier_approved_by_id' => User::factory(),
|
||||
'approved_by_cashier_id' => User::factory(),
|
||||
'cashier_approved_at' => now(),
|
||||
]);
|
||||
}
|
||||
@@ -66,9 +77,9 @@ class FinanceDocumentFactory extends Factory
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => FinanceDocument::STATUS_APPROVED_ACCOUNTANT,
|
||||
'cashier_approved_by_id' => User::factory(),
|
||||
'approved_by_cashier_id' => User::factory(),
|
||||
'cashier_approved_at' => now(),
|
||||
'accountant_approved_by_id' => User::factory(),
|
||||
'approved_by_accountant_id' => User::factory(),
|
||||
'accountant_approved_at' => now(),
|
||||
]);
|
||||
}
|
||||
@@ -80,11 +91,11 @@ class FinanceDocumentFactory extends Factory
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => FinanceDocument::STATUS_APPROVED_CHAIR,
|
||||
'cashier_approved_by_id' => User::factory(),
|
||||
'approved_by_cashier_id' => User::factory(),
|
||||
'cashier_approved_at' => now(),
|
||||
'accountant_approved_by_id' => User::factory(),
|
||||
'approved_by_accountant_id' => User::factory(),
|
||||
'accountant_approved_at' => now(),
|
||||
'chair_approved_by_id' => User::factory(),
|
||||
'approved_by_chair_id' => User::factory(),
|
||||
'chair_approved_at' => now(),
|
||||
]);
|
||||
}
|
||||
@@ -120,7 +131,7 @@ class FinanceDocumentFactory extends Factory
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'amount' => $this->faker->randomFloat(2, 5000, 50000),
|
||||
'amount_tier' => 'medium',
|
||||
'amount_tier' => null,
|
||||
'requires_board_meeting' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
24
database/factories/IssueAttachmentFactory.php
Normal file
24
database/factories/IssueAttachmentFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueAttachment;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class IssueAttachmentFactory extends Factory
|
||||
{
|
||||
protected $model = IssueAttachment::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'issue_id' => Issue::factory(),
|
||||
'user_id' => \App\Models\User::factory(),
|
||||
'file_path' => 'issues/'.$this->faker->uuid.'.txt',
|
||||
'file_name' => $this->faker->word.'.txt',
|
||||
'file_size' => $this->faker->numberBetween(1000, 5000),
|
||||
'mime_type' => 'text/plain',
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/IssueCommentFactory.php
Normal file
23
database/factories/IssueCommentFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueComment;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class IssueCommentFactory extends Factory
|
||||
{
|
||||
protected $model = IssueComment::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'issue_id' => Issue::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'comment_text' => $this->faker->sentence(),
|
||||
'is_internal' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/IssueFactory.php
Normal file
32
database/factories/IssueFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class IssueFactory extends Factory
|
||||
{
|
||||
protected $model = Issue::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'issue_number' => null, // auto-generated in model boot
|
||||
'title' => $this->faker->sentence(),
|
||||
'description' => $this->faker->paragraph(),
|
||||
'issue_type' => Issue::TYPE_WORK_ITEM,
|
||||
'status' => Issue::STATUS_NEW,
|
||||
'priority' => Issue::PRIORITY_MEDIUM,
|
||||
'created_by_user_id' => User::factory(),
|
||||
'assigned_to_user_id' => null,
|
||||
'reviewer_id' => null,
|
||||
'member_id' => null,
|
||||
'parent_issue_id' => null,
|
||||
'due_date' => now()->addDays(7),
|
||||
'estimated_hours' => 4,
|
||||
'actual_hours' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
20
database/factories/IssueLabelFactory.php
Normal file
20
database/factories/IssueLabelFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\IssueLabel;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class IssueLabelFactory extends Factory
|
||||
{
|
||||
protected $model = IssueLabel::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->word(),
|
||||
'color' => $this->faker->safeHexColor(),
|
||||
'description' => $this->faker->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
database/factories/IssueTimeLogFactory.php
Normal file
24
database/factories/IssueTimeLogFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueTimeLog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class IssueTimeLogFactory extends Factory
|
||||
{
|
||||
protected $model = IssueTimeLog::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'issue_id' => Issue::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'hours' => $this->faker->randomFloat(1, 0.5, 8),
|
||||
'description' => $this->faker->sentence(),
|
||||
'logged_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/MemberFactory.php
Normal file
33
database/factories/MemberFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Member;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class MemberFactory extends Factory
|
||||
{
|
||||
protected $model = Member::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'full_name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'phone' => $this->faker->numerify('09########'),
|
||||
'membership_status' => Member::STATUS_PENDING,
|
||||
'membership_type' => Member::TYPE_REGULAR,
|
||||
'membership_started_at' => now()->subMonth(),
|
||||
'membership_expires_at' => now()->addYear(),
|
||||
];
|
||||
}
|
||||
|
||||
public function active(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'membership_status' => Member::STATUS_ACTIVE,
|
||||
]);
|
||||
}
|
||||
}
|
||||
51
database/factories/MembershipPaymentFactory.php
Normal file
51
database/factories/MembershipPaymentFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Member;
|
||||
use App\Models\MembershipPayment;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class MembershipPaymentFactory extends Factory
|
||||
{
|
||||
protected $model = MembershipPayment::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'member_id' => Member::factory(),
|
||||
'paid_at' => now()->format('Y-m-d'),
|
||||
'amount' => $this->faker->numberBetween(500, 5000),
|
||||
'method' => MembershipPayment::METHOD_BANK_TRANSFER,
|
||||
'payment_method' => MembershipPayment::METHOD_BANK_TRANSFER,
|
||||
'reference' => $this->faker->bothify('REF-######'),
|
||||
'status' => MembershipPayment::STATUS_PENDING,
|
||||
'submitted_by_user_id' => null,
|
||||
'notes' => $this->faker->sentence(),
|
||||
];
|
||||
}
|
||||
|
||||
public function approvedCashier(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => MembershipPayment::STATUS_APPROVED_CASHIER,
|
||||
'cashier_verified_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function approvedAccountant(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => MembershipPayment::STATUS_APPROVED_ACCOUNTANT,
|
||||
'accountant_verified_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function approvedChair(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => MembershipPayment::STATUS_APPROVED_CHAIR,
|
||||
'chair_verified_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user