fix: 修正部分進貨採購單更新失敗與狀態顯示問題
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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('goods_receipts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->index(); // GR 單號
|
||||
$table->foreignId('warehouse_id')->constrained()->onDelete('restrict');
|
||||
$table->foreignId('purchase_order_id')->nullable()->constrained()->onDelete('set null');
|
||||
$table->foreignId('vendor_id')->constrained()->onDelete('restrict'); // 關聯到 Inventory 模組內的 Vendor 邏輯或跨模組 ID (此處僅 FK 約束通常指向同一 DB 的 vendors 表)
|
||||
$table->date('received_date');
|
||||
$table->enum('status', ['draft', 'completed', 'cancelled'])->default('draft');
|
||||
$table->text('remarks')->nullable();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('restrict'); // 經辦人
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('goods_receipt_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('goods_receipt_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('product_id')->constrained()->onDelete('restrict');
|
||||
$table->foreignId('purchase_order_item_id')->nullable()->constrained()->onDelete('set null'); // 用於回寫 PO Item
|
||||
$table->decimal('quantity_received', 10, 2);
|
||||
$table->decimal('unit_price', 10, 2); // 暫定價格 (來自 PO)
|
||||
$table->decimal('total_amount', 12, 2); // 小計
|
||||
$table->string('batch_number')->nullable();
|
||||
$table->date('expiry_date')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('goods_receipt_items');
|
||||
Schema::dropIfExists('goods_receipts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('goods_receipts', function (Blueprint $table) {
|
||||
$table->enum('type', ['standard', 'miscellaneous', 'other'])->default('standard')->after('warehouse_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('goods_receipts', function (Blueprint $table) {
|
||||
$table->dropColumn('type');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -38,6 +38,10 @@ class PermissionSeeder extends Seeder
|
||||
'inventory.adjust',
|
||||
'inventory.transfer',
|
||||
|
||||
// 進貨單管理
|
||||
'goods_receipts.view',
|
||||
'goods_receipts.create',
|
||||
|
||||
// 供應商管理
|
||||
'vendors.view',
|
||||
'vendors.create',
|
||||
@@ -98,6 +102,7 @@ class PermissionSeeder extends Seeder
|
||||
'purchase_orders.view', 'purchase_orders.create', 'purchase_orders.edit',
|
||||
'purchase_orders.delete', 'purchase_orders.publish',
|
||||
'inventory.view', 'inventory.view_cost', 'inventory.adjust', 'inventory.transfer',
|
||||
'goods_receipts.view', 'goods_receipts.create',
|
||||
'vendors.view', 'vendors.create', 'vendors.edit', 'vendors.delete',
|
||||
'warehouses.view', 'warehouses.create', 'warehouses.edit', 'warehouses.delete',
|
||||
'users.view', 'users.create', 'users.edit',
|
||||
@@ -111,6 +116,7 @@ class PermissionSeeder extends Seeder
|
||||
$warehouseManager->givePermissionTo([
|
||||
'products.view',
|
||||
'inventory.view', 'inventory.adjust', 'inventory.transfer',
|
||||
'goods_receipts.view', 'goods_receipts.create',
|
||||
'warehouses.view', 'warehouses.create', 'warehouses.edit',
|
||||
]);
|
||||
|
||||
@@ -120,6 +126,7 @@ class PermissionSeeder extends Seeder
|
||||
'purchase_orders.view', 'purchase_orders.create', 'purchase_orders.edit',
|
||||
'vendors.view', 'vendors.create', 'vendors.edit',
|
||||
'inventory.view',
|
||||
'goods_receipts.view', 'goods_receipts.create',
|
||||
]);
|
||||
|
||||
// viewer 僅能查看
|
||||
@@ -127,6 +134,7 @@ class PermissionSeeder extends Seeder
|
||||
'products.view',
|
||||
'purchase_orders.view',
|
||||
'inventory.view',
|
||||
'goods_receipts.view',
|
||||
'vendors.view',
|
||||
'warehouses.view',
|
||||
'utility_fees.view',
|
||||
|
||||
Reference in New Issue
Block a user