feat: [finance] 계정과목 확장 및 전표 연동 시스템 구현
- AccountCode 모델/서비스 확장 (업데이트, 기본 계정과목 시딩) - JournalSyncService 추가 (전표 자동 연동) - SyncsExpenseAccounts 트레이트 추가 - CardTransactionController, TaxInvoiceController 기능 확장 - expense_accounts 테이블에 전표 연결 컬럼 마이그레이션 - account_codes 테이블 확장 마이그레이션 - 전체 테넌트 기본 계정과목 시딩 마이그레이션 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,11 +5,13 @@
|
||||
use App\Models\Tenants\AccountCode;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Models\Tenants\JournalEntryLine;
|
||||
use App\Traits\SyncsExpenseAccounts;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class GeneralJournalEntryService extends Service
|
||||
{
|
||||
use SyncsExpenseAccounts;
|
||||
/**
|
||||
* 일반전표입력 통합 목록 (입금 + 출금 + 수기전표)
|
||||
* deposits/withdrawals는 계좌이체 건만, LEFT JOIN journal_entries로 분개 여부 표시
|
||||
@@ -326,6 +328,9 @@ public function store(array $data): JournalEntry
|
||||
// 분개 행 생성
|
||||
$this->createLines($entry, $data['rows'], $tenantId);
|
||||
|
||||
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->syncExpenseAccounts($entry);
|
||||
|
||||
return $entry->load('lines');
|
||||
});
|
||||
}
|
||||
@@ -373,6 +378,9 @@ public function updateJournal(int $id, array $data): JournalEntry
|
||||
|
||||
$entry->save();
|
||||
|
||||
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->syncExpenseAccounts($entry);
|
||||
|
||||
return $entry->load('lines');
|
||||
});
|
||||
}
|
||||
@@ -389,6 +397,9 @@ public function destroyJournal(int $id): bool
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
// expense_accounts 정리 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->cleanupExpenseAccounts($tenantId, $entry->id);
|
||||
|
||||
// lines 먼저 삭제 (soft delete가 아니므로 물리 삭제)
|
||||
JournalEntryLine::query()
|
||||
->where('journal_entry_id', $entry->id)
|
||||
@@ -503,6 +514,9 @@ private function resolveVendorName(?int $vendorId): string
|
||||
return $vendor ? $vendor->name : '';
|
||||
}
|
||||
|
||||
// syncExpenseAccounts, cleanupExpenseAccounts, getExpenseAccountType
|
||||
// → SyncsExpenseAccounts 트레이트로 이관
|
||||
|
||||
/**
|
||||
* 원본 거래 정보 조회 (입금/출금)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user