feat:법인카드 결제 기능 개선 (동적 항목 입력, 선불결제→결제 명칭 변경)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -255,34 +255,40 @@ public function summary(): JsonResponse
|
||||
'cardUsages' => $usageResult['perCard'],
|
||||
'prepaidAmount' => (int) $prepayment->amount,
|
||||
'prepaidMemo' => $prepayment->memo ?? '',
|
||||
'prepaidItems' => $prepayment->items ?? [],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 선불결제 금액 수정
|
||||
* 결제 내역 수정
|
||||
*/
|
||||
public function updatePrepayment(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'amount' => 'required|integer|min:0',
|
||||
'memo' => 'nullable|string|max:200',
|
||||
'items' => 'present|array',
|
||||
'items.*.date' => 'required|date',
|
||||
'items.*.amount' => 'required|integer|min:0',
|
||||
'items.*.description' => 'nullable|string|max:200',
|
||||
]);
|
||||
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
$yearMonth = Carbon::now()->format('Y-m');
|
||||
|
||||
$items = collect($request->input('items', []))->filter(fn($item) => ($item['amount'] ?? 0) > 0)->values()->toArray();
|
||||
$amount = collect($items)->sum('amount');
|
||||
|
||||
$prepayment = CorporateCardPrepayment::updateOrCreate(
|
||||
['tenant_id' => $tenantId, 'year_month' => $yearMonth],
|
||||
['amount' => $request->input('amount'), 'memo' => $request->input('memo')]
|
||||
['amount' => $amount, 'items' => $items, 'memo' => null]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '선불결제 금액이 저장되었습니다.',
|
||||
'message' => '결제 내역이 저장되었습니다.',
|
||||
'data' => [
|
||||
'amount' => (int) $prepayment->amount,
|
||||
'memo' => $prepayment->memo ?? '',
|
||||
'items' => $prepayment->items ?? [],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user