feat: 회계 시스템 확장 — 계정과목·전표·세금계산서·카드·바로빌

- 계정과목 확장 및 더존 Smart A 표준 시딩 (전 테넌트)
- 전표 연동 시스템 구현 (JournalSyncService, SyncsExpenseAccounts)
- 세금계산서 매입/매출 필수값 조건 분리 + null 방어
- 카드거래 대시보드 리다이렉트 + 악성채권 집계 수정
- 바로빌 연동 API 엔드포인트 추가
- 복리후생 날짜 필터 + 바로빌 조인 컬럼 수정
- codebridge DB 커넥션 설정 추가
This commit is contained in:
2026-03-10 11:29:39 +09:00
parent 7ff9206f93
commit c46b950fde
24 changed files with 1850 additions and 96 deletions

View File

@@ -86,8 +86,8 @@ public function summary(array $params = []): array
// is_active=true인 악성채권만 통계
$query = BadDebt::query()
->where('tenant_id', $tenantId)
->where('is_active', true);
->where('bad_debts.tenant_id', $tenantId)
->where('bad_debts.is_active', true);
// 거래처 필터
if (! empty($params['client_id'])) {
@@ -110,6 +110,9 @@ public function summary(array $params = []): array
->distinct('client_id')
->count('client_id');
// per-card sub_label: 각 상태별 최다 금액 거래처명 + 건수
$subLabels = $this->buildPerCardSubLabels($query);
return [
'total_amount' => (float) $totalAmount,
'collecting_amount' => (float) $collectingAmount,
@@ -117,9 +120,56 @@ public function summary(array $params = []): array
'recovered_amount' => (float) $recoveredAmount,
'bad_debt_amount' => (float) $badDebtAmount,
'client_count' => $clientCount,
'sub_labels' => $subLabels,
];
}
/**
* 카드별 sub_label 생성 (최다 금액 거래처명 + 건수)
*/
private function buildPerCardSubLabels($baseQuery): array
{
$result = [];
$statusScopes = [
'dc1' => null, // 전체 (누적)
'dc2' => 'collecting', // 추심중
'dc3' => 'legalAction', // 법적조치
'dc4' => 'recovered', // 회수완료
];
foreach ($statusScopes as $cardId => $scope) {
$q = clone $baseQuery;
if ($scope) {
$q = $q->$scope();
}
$clientCount = (clone $q)->distinct('client_id')->count('client_id');
if ($clientCount <= 0) {
$result[$cardId] = null;
continue;
}
$topClient = (clone $q)
->join('clients', 'bad_debts.client_id', '=', 'clients.id')
->selectRaw('clients.name, SUM(bad_debts.debt_amount) as total_amount')
->groupBy('clients.id', 'clients.name')
->orderByDesc('total_amount')
->first();
if ($topClient) {
$result[$cardId] = $clientCount > 1
? $topClient->name.' 외 '.($clientCount - 1).'건'
: $topClient->name;
} else {
$result[$cardId] = null;
}
}
return $result;
}
/**
* 악성채권 상세 조회
*/