feat: 매입유형(purchase_type) 필드 추가

- 마이그레이션: purchases 테이블에 purchase_type 컬럼 추가
- Purchase 모델: $fillable 및 PURCHASE_TYPES 상수 추가
- StorePurchaseRequest: purchase_type validation 추가
- UpdatePurchaseRequest: purchase_type validation 추가
- PurchaseService: store/update에 purchase_type 처리 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-27 16:47:26 +09:00
parent cdec2519d9
commit 71a33d79cc
5 changed files with 57 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ public function rules(): array
'supply_amount' => ['required', 'numeric', 'min:0'],
'tax_amount' => ['required', 'numeric', 'min:0'],
'total_amount' => ['required', 'numeric', 'min:0'],
'purchase_type' => ['nullable', 'string', 'max:50'],
'description' => ['nullable', 'string', 'max:1000'],
'withdrawal_id' => ['nullable', 'integer', 'exists:withdrawals,id'],
];

View File

@@ -19,6 +19,7 @@ public function rules(): array
'supply_amount' => ['sometimes', 'numeric', 'min:0'],
'tax_amount' => ['sometimes', 'numeric', 'min:0'],
'total_amount' => ['sometimes', 'numeric', 'min:0'],
'purchase_type' => ['nullable', 'string', 'max:50'],
'description' => ['nullable', 'string', 'max:1000'],
'withdrawal_id' => ['nullable', 'integer', 'exists:withdrawals,id'],
'tax_invoice_received' => ['sometimes', 'boolean'],

View File

@@ -21,6 +21,7 @@ class Purchase extends Model
'total_amount',
'description',
'status',
'purchase_type',
'withdrawal_id',
'tax_invoice_received',
'created_by',
@@ -28,6 +29,28 @@ class Purchase extends Model
'deleted_by',
];
/**
* 매입 유형 목록
*/
public const PURCHASE_TYPES = [
'unset' => '미설정',
'raw_material' => '원재료매입',
'subsidiary_material' => '부재료매입',
'product' => '상품매입',
'outsourcing' => '외주가공비',
'consumables' => '소모품비',
'repair' => '수선비',
'transportation' => '운반비',
'office_supplies' => '사무용품비',
'rent' => '임차료',
'utilities' => '수도광열비',
'communication' => '통신비',
'vehicle' => '차량유지비',
'entertainment' => '접대비',
'insurance' => '보험료',
'other_service' => '기타용역비',
];
protected $casts = [
'purchase_date' => 'date',
'supply_amount' => 'decimal:2',

View File

@@ -93,6 +93,7 @@ public function store(array $data): Purchase
$purchase->supply_amount = $data['supply_amount'];
$purchase->tax_amount = $data['tax_amount'];
$purchase->total_amount = $data['total_amount'];
$purchase->purchase_type = $data['purchase_type'] ?? null;
$purchase->description = $data['description'] ?? null;
$purchase->status = 'draft';
$purchase->withdrawal_id = $data['withdrawal_id'] ?? null;
@@ -147,6 +148,9 @@ public function update(int $id, array $data): Purchase
if (array_key_exists('withdrawal_id', $data)) {
$purchase->withdrawal_id = $data['withdrawal_id'];
}
if (array_key_exists('purchase_type', $data)) {
$purchase->purchase_type = $data['purchase_type'];
}
if (array_key_exists('tax_invoice_received', $data)) {
$purchase->tax_invoice_received = $data['tax_invoice_received'];
}

View File

@@ -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('purchases', function (Blueprint $table) {
$table->string('purchase_type', 50)->nullable()->after('status')->comment('매입유형');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('purchases', function (Blueprint $table) {
$table->dropColumn('purchase_type');
});
}
};