feat: [approvals] 지출결의서 불러오기 기능 추가
- 기안 작성 시 '불러오기' 버튼으로 기존 지출결의서 불러오기 - 지출결의서 이력 API 엔드포인트 추가 (/expense-history) - 선택한 지출결의서의 내용을 새 폼에 복사 (날짜는 오늘로 초기화)
This commit is contained in:
@@ -444,6 +444,36 @@ public function destroyLine(int $id): JsonResponse
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 지출결의서 이력 (불러오기용)
|
||||
*/
|
||||
public function expenseHistory(Request $request): JsonResponse
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$approvals = \App\Models\Approvals\Approval::where('tenant_id', $tenantId)
|
||||
->where('drafter_id', auth()->id())
|
||||
->whereHas('form', fn ($q) => $q->where('code', 'expense'))
|
||||
->whereIn('status', ['draft', 'pending', 'approved', 'rejected', 'cancelled'])
|
||||
->whereNotNull('content')
|
||||
->orderByDesc('created_at')
|
||||
->limit(30)
|
||||
->get(['id', 'title', 'content', 'status', 'created_at']);
|
||||
|
||||
$data = $approvals->map(fn ($a) => [
|
||||
'id' => $a->id,
|
||||
'title' => $a->title,
|
||||
'status' => $a->status,
|
||||
'status_label' => $a->status_label,
|
||||
'total_amount' => $a->content['total_amount'] ?? 0,
|
||||
'expense_type' => $a->content['expense_type'] ?? '',
|
||||
'created_at' => $a->created_at->format('Y-m-d'),
|
||||
'content' => $a->content,
|
||||
]);
|
||||
|
||||
return response()->json(['success' => true, 'data' => $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 양식 목록
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user