feat: 예상 지출 자동 동기화 Observer 구현

- expected_expenses 테이블에 source_type, source_id 컬럼 추가
- PurchaseExpenseSyncObserver: 매입 → 예상 지출 동기화
- WithdrawalExpenseSyncObserver: 카드결제만 → 예상 지출 동기화
- BillExpenseSyncObserver: 발행어음만 → 예상 지출 동기화
- 생성/수정/삭제/복원/강제삭제 이벤트 모두 처리
- 조건 변경 시 자동 동기화 해제 (카드→현금, 발행→수취)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-23 11:06:06 +09:00
parent 73e49f2736
commit fa210b91c2
6 changed files with 515 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('expected_expenses', function (Blueprint $table) {
$table->string('source_type', 50)->nullable()->after('description')->comment('원본 테이블: purchases/withdrawals/bills');
$table->unsignedBigInteger('source_id')->nullable()->after('source_type')->comment('원본 레코드 ID');
// 복합 인덱스: 동기화된 레코드 검색용
$table->index(['source_type', 'source_id'], 'idx_source');
});
}
public function down(): void
{
Schema::table('expected_expenses', function (Blueprint $table) {
$table->dropIndex('idx_source');
$table->dropColumn(['source_type', 'source_id']);
});
}
};