feat(API): 결재함 및 대시보드 관련 개선

- ApprovalService: inbox 쿼리에 결재자 상세 정보 추가 (직책, 부서)
- PurchaseController: dashboardDetail 엔드포인트 추가
- CardTransactionService: 당월 이용 건수 추가
- SaleService: 대시보드 조회 개선
- LOGICAL_RELATIONSHIPS.md 업데이트

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 23:19:05 +09:00
parent 5ac83399b3
commit 871db32e04
6 changed files with 58 additions and 7 deletions

View File

@@ -392,9 +392,18 @@ public function inbox(array $params): LengthAwarePaginator
$q->where('approver_id', $userId)
->whereIn('step_type', [ApprovalLine::STEP_TYPE_APPROVAL, ApprovalLine::STEP_TYPE_AGREEMENT]);
})
->with(['form:id,name,code,category', 'drafter:id,name', 'steps' => function ($q) use ($userId) {
$q->where('approver_id', $userId);
}]);
->with([
'form:id,name,code,category',
'drafter:id,name',
'drafter.tenantProfile:id,user_id,position_key,department_id',
'drafter.tenantProfile.department:id,name',
'steps' => function ($q) use ($userId) {
$q->where('approver_id', $userId);
},
'steps.approver:id,name',
'steps.approver.tenantProfile:id,user_id,position_key,department_id',
'steps.approver.tenantProfile.department:id,name',
]);
// 상태 필터
if (! empty($params['status'])) {

View File

@@ -267,13 +267,14 @@ public function destroy(int $id): bool
/**
* 카드 거래 대시보드 데이터
*
* CEO 대시보드 카드/가지급금 관리 섹션cm1 모달용 상세 데이터 제공
* CEO 대시보드 카드/가지급금 관리 섹션(cm1) 및 당월 예상 지출내역 카드(me2) 모달용 상세 데이터 제공
*
* @return array{
* summary: array{
* current_month_total: float,
* previous_month_total: float,
* change_rate: float,
* current_month_count: int,
* unprocessed_count: int
* },
* monthly_trend: array<array{month: string, amount: float}>,
@@ -299,6 +300,12 @@ public function dashboard(): array
? round((($currentMonthTotal - $previousMonthTotal) / $previousMonthTotal) * 100, 1)
: ($currentMonthTotal > 0 ? 100 : 0);
// 당월 이용 건수
$currentMonthCount = Withdrawal::query()
->where('payment_method', 'card')
->whereBetween(DB::raw('DATE(COALESCE(used_at, withdrawal_date))'), [$currentMonthStart, $currentMonthEnd])
->count();
// 미정리 건수 (account_code가 없는 건)
$unprocessedCount = Withdrawal::query()
->where('payment_method', 'card')
@@ -319,6 +326,7 @@ public function dashboard(): array
'current_month_total' => (float) $currentMonthTotal,
'previous_month_total' => (float) $previousMonthTotal,
'change_rate' => $changeRate,
'current_month_count' => $currentMonthCount,
'unprocessed_count' => $unprocessedCount,
],
'monthly_trend' => $monthlyTrend,

View File

@@ -69,7 +69,25 @@ public function show(int $id): Sale
return Sale::query()
->where('tenant_id', $tenantId)
->with(['client:id,name', 'deposit', 'creator:id,name'])
->with([
'client:id,name',
'deposit',
'creator:id,name',
'order.items' => function ($query) {
$query->select([
'id',
'order_id',
'item_name',
'quantity',
'unit_price',
'supply_amount',
'tax_amount',
'total_amount',
'note',
'sort_order',
])->orderBy('sort_order');
},
])
->findOrFail($id);
}