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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user