feat(accounting): 實作公共事業費管理與會計支出報表功能
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('utility_fees', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('transaction_date')->comment('費用日期');
|
||||
$table->string('category')->comment('費用類別 (例如:電費、水費、瓦斯費)');
|
||||
$table->decimal('amount', 12, 2)->comment('金額');
|
||||
$table->string('invoice_number', 20)->nullable()->comment('發票號碼');
|
||||
$table->text('description')->nullable()->comment('說明/備註');
|
||||
$table->timestamps();
|
||||
|
||||
// 常用查詢索引
|
||||
$table->index(['transaction_date', 'category']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('utility_fees');
|
||||
}
|
||||
};
|
||||
49
database/seeders/FinancePermissionSeeder.php
Normal file
49
database/seeders/FinancePermissionSeeder.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class FinancePermissionSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// 建立新權限
|
||||
$permissions = [
|
||||
'utility_fees.view',
|
||||
'utility_fees.create',
|
||||
'utility_fees.edit',
|
||||
'utility_fees.delete',
|
||||
'accounting.view',
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::firstOrCreate(['name' => $permission]);
|
||||
}
|
||||
|
||||
// 分配權限給現有角色
|
||||
|
||||
// Super Admin 獲得所有
|
||||
$superAdmin = Role::where('name', 'super-admin')->first();
|
||||
if ($superAdmin) {
|
||||
$superAdmin->givePermissionTo($permissions);
|
||||
}
|
||||
|
||||
// Admin 獲得所有
|
||||
$admin = Role::where('name', 'admin')->first();
|
||||
if ($admin) {
|
||||
$admin->givePermissionTo($permissions);
|
||||
}
|
||||
|
||||
// Viewer 獲得檢視權限
|
||||
$viewer = Role::where('name', 'viewer')->first();
|
||||
if ($viewer) {
|
||||
$viewer->givePermissionTo([
|
||||
'utility_fees.view',
|
||||
'accounting.view',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user