feat: 매입 세금계산서 수취 토글 기능 추가
- Purchase 모델에 tax_invoice_received 필드 추가 - PurchaseService에 toggleTaxInvoice() 메서드 추가 - UpdatePurchaseRequest에 tax_invoice_received 검증 규칙 추가 - 마이그레이션: purchases 테이블에 tax_invoice_received 컬럼 추가
This commit is contained in:
@@ -1,5 +1,37 @@
|
||||
# SAM API 작업 현황
|
||||
|
||||
## 2025-12-24 (화) - 매입 세금계산서 수취 토글 기능 추가
|
||||
|
||||
### 작업 목표
|
||||
- 매입(Purchase) 테이블에 세금계산서 수취 여부(tax_invoice_received) 필드 추가
|
||||
- React 프론트엔드에서 토글 API 호출 가능하도록 지원
|
||||
|
||||
### 생성된 마이그레이션 (1개)
|
||||
|
||||
| 파일명 | 설명 |
|
||||
|--------|------|
|
||||
| `2025_12_24_160000_add_tax_invoice_received_to_purchases_table.php` | purchases 테이블에 tax_invoice_received 컬럼 추가 |
|
||||
|
||||
### 수정된 파일 (3개)
|
||||
|
||||
| 파일명 | 변경 내용 |
|
||||
|--------|----------|
|
||||
| `app/Models/Tenants/Purchase.php` | fillable에 tax_invoice_received 추가, casts에 boolean 타입 추가 |
|
||||
| `app/Services/PurchaseService.php` | toggleTaxInvoice() 메서드 추가 |
|
||||
| `app/Http/Requests/V1/Purchase/UpdatePurchaseRequest.php` | tax_invoice_received 필드 검증 규칙 추가 |
|
||||
|
||||
### 마이그레이션 실행
|
||||
```bash
|
||||
php artisan migrate
|
||||
# 2025_12_24_160000_add_tax_invoice_received_to_purchases_table ... DONE
|
||||
```
|
||||
|
||||
### 테스트 결과
|
||||
- 세금계산서 수취 토글 API 정상 동작
|
||||
- React 매입 관리 페이지에서 토글 기능 정상 작동
|
||||
|
||||
---
|
||||
|
||||
## 2025-12-22 (일) - 견적수식 시더 업데이트 (5130 연동)
|
||||
|
||||
### 작업 목표
|
||||
|
||||
@@ -21,6 +21,7 @@ public function rules(): array
|
||||
'total_amount' => ['sometimes', 'numeric', 'min:0'],
|
||||
'description' => ['nullable', 'string', 'max:1000'],
|
||||
'withdrawal_id' => ['nullable', 'integer', 'exists:withdrawals,id'],
|
||||
'tax_invoice_received' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class Purchase extends Model
|
||||
'description',
|
||||
'status',
|
||||
'withdrawal_id',
|
||||
'tax_invoice_received',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
@@ -34,6 +35,7 @@ class Purchase extends Model
|
||||
'total_amount' => 'decimal:2',
|
||||
'client_id' => 'integer',
|
||||
'withdrawal_id' => 'integer',
|
||||
'tax_invoice_received' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,8 +117,12 @@ public function update(int $id, array $data): Purchase
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
// 확정 후에는 수정 불가
|
||||
if (! $purchase->canEdit()) {
|
||||
// 토글 필드만 업데이트하는 경우는 canEdit 체크 건너뛰기
|
||||
$toggleOnlyFields = ['tax_invoice_received'];
|
||||
$isToggleOnly = count(array_diff(array_keys($data), $toggleOnlyFields)) === 0;
|
||||
|
||||
// 확정 후에는 수정 불가 (토글 필드만 업데이트하는 경우 제외)
|
||||
if (! $isToggleOnly && ! $purchase->canEdit()) {
|
||||
throw new \Exception(__('error.purchase.cannot_edit'));
|
||||
}
|
||||
|
||||
@@ -143,6 +147,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('tax_invoice_received', $data)) {
|
||||
$purchase->tax_invoice_received = $data['tax_invoice_received'];
|
||||
}
|
||||
|
||||
$purchase->updated_by = $userId;
|
||||
$purchase->save();
|
||||
|
||||
@@ -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->boolean('tax_invoice_received')->default(false)->after('withdrawal_id')->comment('세금계산서 수취 여부');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('purchases', function (Blueprint $table) {
|
||||
$table->dropColumn('tax_invoice_received');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user