From 943648169a4cb2c74da7a8a0e8a11cba296466cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Mon, 9 Feb 2026 16:25:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=ED=99=88=ED=83=9D=EC=8A=A4=20=EB=B6=84?= =?UTF-8?q?=EA=B0=9C=20=EC=B0=A8/=EB=8C=80=20=ED=86=A0=EA=B8=80=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- .../Barobill/HometaxController.php | 11 +++++- .../views/barobill/hometax/index.blade.php | 38 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Barobill/HometaxController.php b/app/Http/Controllers/Barobill/HometaxController.php index e51de800..56f7597e 100644 --- a/app/Http/Controllers/Barobill/HometaxController.php +++ b/app/Http/Controllers/Barobill/HometaxController.php @@ -1677,13 +1677,22 @@ public function createJournalEntry(Request $request): JsonResponse 'message' => "전표 {$result->entry_no}가 생성되었습니다.", 'data' => $result->load('lines'), ]); + } catch (\Illuminate\Validation\ValidationException $e) { + $errors = $e->errors(); + $firstError = collect($errors)->flatten()->first() ?? '입력 데이터가 올바르지 않습니다.'; + Log::error('분개 생성 검증 오류', ['errors' => $errors]); + return response()->json([ + 'success' => false, + 'error' => $firstError, + 'errors' => $errors, + ], 422); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { return response()->json([ 'success' => false, 'error' => '해당 세금계산서를 찾을 수 없습니다.', ], 404); } catch (\Throwable $e) { - Log::error('분개 생성 오류: ' . $e->getMessage()); + Log::error('분개 생성 오류: ' . $e->getMessage(), ['trace' => $e->getTraceAsString()]); return response()->json([ 'success' => false, 'error' => '분개 생성 오류: ' . $e->getMessage(), diff --git a/resources/views/barobill/hometax/index.blade.php b/resources/views/barobill/hometax/index.blade.php index 8211be5d..ca30cfda 100644 --- a/resources/views/barobill/hometax/index.blade.php +++ b/resources/views/barobill/hometax/index.blade.php @@ -791,12 +791,16 @@ className="px-2 py-1 bg-red-50 text-red-700 rounded text-xs hover:bg-red-100 tra }); const data = await res.json(); if (data.success) { - notify(data.message, 'success'); + notify(data.message || '전표가 생성되었습니다.', 'success'); setShowJournalModal(false); + setJournalInvoice(null); } else { - notify(data.error || '분개 생성 실패', 'error'); + const errorMsg = data.error || '분개 생성 실패'; + console.error('분개 생성 실패:', data); + notify(errorMsg, 'error'); } } catch (err) { + console.error('분개 생성 오류:', err); notify('분개 생성 오류: ' + err.message, 'error'); } }; @@ -1190,7 +1194,7 @@ className="ml-auto px-4 py-3 text-sm font-medium rounded-lg bg-violet-600 text-w onRequestCollect={handleRequestCollect} summary={currentInvoiceSummary} onJournalEntry={(inv) => { - setJournalInvoice(inv); + setJournalInvoice({...inv, invoiceType: activeTab}); setShowJournalModal(true); }} onEditManual={(inv) => { @@ -2064,7 +2068,26 @@ className={`px-3 py-1.5 text-xs cursor-pointer ${ const totalCredit = lines.reduce((sum, l) => sum + (parseFloat(l.credit_amount) || 0), 0); const isBalanced = Math.abs(totalDebit - totalCredit) < 1; + const toggleDcType = (idx) => { + setLines(prev => prev.map((l, i) => { + if (i !== idx) return l; + const newType = l.dc_type === 'debit' ? 'credit' : 'debit'; + return { + ...l, + dc_type: newType, + debit_amount: l.credit_amount, + credit_amount: l.debit_amount, + }; + })); + }; + const handleSubmit = async () => { + // 계정과목 검증 + const emptyLine = lines.find(l => !l.account_code || !l.account_name); + if (emptyLine) { + notify('모든 분개 라인의 계정과목을 선택해주세요.', 'warning'); + return; + } if (!isBalanced) { notify('차변과 대변의 합계가 일치하지 않습니다.', 'warning'); return; @@ -2117,9 +2140,14 @@ className={`px-3 py-1.5 text-xs cursor-pointer ${ {lines.map((line, idx) => ( - +