feat(procurement): 實作採購退回單模組並修復商品選單報錯
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 58s
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 58s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?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('purchase_returns', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->unique()->comment('退回單號');
|
||||
$table->unsignedBigInteger('vendor_id')->comment('廠商 ID');
|
||||
$table->unsignedBigInteger('warehouse_id')->comment('退貨出庫倉庫 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('建立者 ID');
|
||||
$table->date('return_date')->comment('退貨日期');
|
||||
|
||||
$table->string('status', 20)->default('draft')->comment('狀態: draft, completed, cancelled');
|
||||
|
||||
$table->decimal('total_amount', 12, 2)->default(0)->comment('總金額 (不含稅)');
|
||||
$table->decimal('tax_amount', 12, 2)->default(0)->comment('稅金');
|
||||
$table->decimal('grand_total', 12, 2)->default(0)->comment('總計含稅金額');
|
||||
|
||||
$table->text('remarks')->nullable()->comment('備註');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// 由於 Modular Monolith 規範,外部模組的 Foreign Key 不一定建立實體約束以避免牽一髮動全身
|
||||
// $table->foreign('vendor_id')->references('id')->on('vendors')->onDelete('restrict');
|
||||
$table->index('code');
|
||||
$table->index('vendor_id');
|
||||
$table->index('warehouse_id');
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('purchase_returns');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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('purchase_return_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('purchase_return_id')->constrained('purchase_returns')->onDelete('cascade');
|
||||
$table->unsignedBigInteger('product_id')->comment('商品 ID');
|
||||
|
||||
$table->decimal('quantity_returned', 10, 2)->comment('退貨數量');
|
||||
$table->decimal('unit_price', 12, 2)->comment('退貨單價');
|
||||
$table->decimal('total_amount', 12, 2)->comment('小計金額');
|
||||
|
||||
$table->string('batch_number', 100)->nullable()->comment('指定退回之批號');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('product_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('purchase_return_items');
|
||||
}
|
||||
};
|
||||
@@ -33,6 +33,14 @@ class PermissionSeeder extends Seeder
|
||||
'purchase_orders.approve' => '核准',
|
||||
'purchase_orders.cancel' => '作廢',
|
||||
|
||||
// 採購退回管理
|
||||
'purchase_returns.view' => '檢視',
|
||||
'purchase_returns.create' => '建立',
|
||||
'purchase_returns.edit' => '編輯',
|
||||
'purchase_returns.delete' => '刪除',
|
||||
'purchase_returns.approve' => '核准',
|
||||
'purchase_returns.cancel' => '作廢',
|
||||
|
||||
// 庫存管理
|
||||
'inventory.view' => '檢視',
|
||||
'inventory.view_cost' => '檢視成本',
|
||||
@@ -173,6 +181,8 @@ class PermissionSeeder extends Seeder
|
||||
'products.view', 'products.create', 'products.edit', 'products.delete',
|
||||
'purchase_orders.view', 'purchase_orders.create', 'purchase_orders.edit',
|
||||
'purchase_orders.delete', 'purchase_orders.approve', 'purchase_orders.cancel',
|
||||
'purchase_returns.view', 'purchase_returns.create', 'purchase_returns.edit',
|
||||
'purchase_returns.delete', 'purchase_returns.approve', 'purchase_returns.cancel',
|
||||
'inventory.view', 'inventory.view_cost', 'inventory.delete',
|
||||
'inventory_count.view', 'inventory_count.create', 'inventory_count.edit', 'inventory_count.delete',
|
||||
'inventory_adjust.view', 'inventory_adjust.create', 'inventory_adjust.edit', 'inventory_adjust.delete',
|
||||
@@ -215,6 +225,7 @@ class PermissionSeeder extends Seeder
|
||||
$purchaser->givePermissionTo([
|
||||
'products.view',
|
||||
'purchase_orders.view', 'purchase_orders.create', 'purchase_orders.edit',
|
||||
'purchase_returns.view', 'purchase_returns.create', 'purchase_returns.edit',
|
||||
'vendors.view', 'vendors.create', 'vendors.edit',
|
||||
'inventory.view',
|
||||
'goods_receipts.view', 'goods_receipts.create',
|
||||
@@ -224,6 +235,7 @@ class PermissionSeeder extends Seeder
|
||||
$viewer->givePermissionTo([
|
||||
'products.view',
|
||||
'purchase_orders.view',
|
||||
'purchase_returns.view',
|
||||
'inventory.view',
|
||||
'goods_receipts.view',
|
||||
'vendors.view',
|
||||
|
||||
Reference in New Issue
Block a user