feat: 품질관리·대시보드·결재 양식 개선

- 품질관리 수주선택 필터링 + 검사 상태 자동 재계산
- 제품검사 요청서 Document(EAV) 자동생성 및 동기화
- 현황판 결재 카드 approvalOnly 스코프 + sub_label 추가
- 캘린더 어음 만기일 일정 연동
- QuoteStatService codebridge DB 커넥션 연결
- 테넌트 부트스트랩 기본 결재 양식 자동 시딩
This commit is contained in:
2026-03-10 11:29:56 +09:00
parent c46b950fde
commit bd500a87bd
7 changed files with 316 additions and 42 deletions

View File

@@ -67,16 +67,35 @@ private function getOrdersStatus(int $tenantId, Carbon $today): array
*/
private function getBadDebtStatus(int $tenantId): array
{
$count = BadDebt::query()
->where('tenant_id', $tenantId)
->where('status', BadDebt::STATUS_COLLECTING) // 추심 진행 중
->where('is_active', true) // 활성 채권만 (목록 페이지와 일치)
->count();
$query = BadDebt::query()
->where('bad_debts.tenant_id', $tenantId)
->where('bad_debts.status', BadDebt::STATUS_COLLECTING)
->where('bad_debts.is_active', true);
$count = (clone $query)->count();
// 최다 금액 거래처명 조회
$subLabel = null;
if ($count > 0) {
$topClient = (clone $query)
->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) {
$subLabel = $count > 1
? $topClient->name.' 외 '.($count - 1).'건'
: $topClient->name;
}
}
return [
'id' => 'bad_debts',
'label' => __('message.status_board.bad_debts'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/accounting/bad-debt-collection',
'isHighlighted' => false,
];
@@ -152,15 +171,31 @@ private function getTaxDeadlineStatus(int $tenantId, Carbon $today): array
*/
private function getNewClientStatus(int $tenantId, Carbon $today): array
{
$count = Client::query()
$query = Client::query()
->where('tenant_id', $tenantId)
->where('created_at', '>=', $today->copy()->subDays(7))
->count();
->where('created_at', '>=', $today->copy()->subDays(7));
$count = (clone $query)->count();
// 가장 최근 등록 업체명 조회
$subLabel = null;
if ($count > 0) {
$latestClient = (clone $query)
->orderByDesc('created_at')
->first();
if ($latestClient) {
$subLabel = $count > 1
? $latestClient->name.' 외 '.($count - 1).'건'
: $latestClient->name;
}
}
return [
'id' => 'new_clients',
'label' => __('message.status_board.new_clients'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/accounting/vendors',
'isHighlighted' => false,
];
@@ -211,19 +246,34 @@ private function getPurchaseStatus(int $tenantId): array
*/
private function getApprovalStatus(int $tenantId, int $userId): array
{
$count = ApprovalStep::query()
->whereHas('approval', function ($query) use ($tenantId) {
$query->where('tenant_id', $tenantId)
$query = ApprovalStep::query()
->whereHas('approval', function ($q) use ($tenantId) {
$q->where('tenant_id', $tenantId)
->where('status', 'pending');
})
->where('approver_id', $userId)
->where('status', 'pending')
->count();
->approvalOnly();
$count = (clone $query)->count();
// 최근 결재 유형 조회
$subLabel = null;
if ($count > 0) {
$latestStep = (clone $query)->with('approval')->latest()->first();
if ($latestStep && $latestStep->approval) {
$typeLabel = $latestStep->approval->title ?? '결재';
$subLabel = $count > 1
? $typeLabel.' 외 '.($count - 1).'건'
: $typeLabel;
}
}
return [
'id' => 'approvals',
'label' => __('message.status_board.approvals'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/approval/inbox',
'isHighlighted' => $count > 0,
];