From 5f437d493fd844f6e43bd8ed9d39e9cf22336c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Tue, 24 Feb 2026 19:25:49 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[ecard]=20=EB=B6=84=EB=A6=AC=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EA=B8=B0=EB=B0=98=20=EB=B6=84?= =?UTF-8?q?=EA=B0=9C=20=EC=9E=90=EB=8F=99=20=EC=83=9D=EC=84=B1=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - handleOpenJournalModal에 splits 데이터 전달 - getDefaultLines()에서 splits 기반 차변 라인 자동 생성 - 공제 항목: 비용계정 + 부가세대급금 분리, 불공제: 합산 - 분개 모달에 분리 데이터 기반 인디케이터 배지 표시 - storeJournal의 splits 자동삭제 코드 제거 (분리+분개 공존) --- .../Controllers/Barobill/EcardController.php | 5 -- .../views/barobill/ecard/index.blade.php | 71 +++++++++++++++++-- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Barobill/EcardController.php b/app/Http/Controllers/Barobill/EcardController.php index b4915ca5..7d064b74 100644 --- a/app/Http/Controllers/Barobill/EcardController.php +++ b/app/Http/Controllers/Barobill/EcardController.php @@ -1934,11 +1934,6 @@ public function storeJournal(Request $request): JsonResponse ]); } - // 동일 uniqueKey의 구버전 splits 자동 삭제 - CardTransactionSplit::where('tenant_id', $tenantId) - ->where('original_unique_key', $request->source_key) - ->delete(); - return $entry; }); diff --git a/resources/views/barobill/ecard/index.blade.php b/resources/views/barobill/ecard/index.blade.php index 85ffeca1..395cc2a6 100644 --- a/resources/views/barobill/ecard/index.blade.php +++ b/resources/views/barobill/ecard/index.blade.php @@ -703,6 +703,58 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg- // 기본 분개 라인 const getDefaultLines = () => { + // splits 데이터가 있으면 분리 항목 기반으로 라인 생성 + const splits = log._splits || []; + if (splits.length > 0) { + const debitLines = []; + let totalDebitSum = 0; + + splits.forEach(split => { + const splitSupply = Math.round(parseFloat(split.split_supply_amount ?? split.supplyAmount ?? split.split_amount ?? split.amount ?? 0)); + const splitTax = Math.round(parseFloat(split.split_tax ?? split.tax ?? 0)); + const splitDeductionType = split.deduction_type || split.deductionType || 'non_deductible'; + const splitAccountCode = split.account_code || split.accountCode || '826'; + const splitAccountName = split.account_name || split.accountName || '잡비'; + + if (splitDeductionType === 'deductible') { + // 공제: 비용 계정 = 공급가액, 부가세대급금 = 세액 + debitLines.push({ + dc_type: 'debit', account_code: splitAccountCode, account_name: splitAccountName, + debit_amount: splitSupply, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: split.memo || '' + }); + totalDebitSum += splitSupply; + if (splitTax > 0) { + debitLines.push({ + dc_type: 'debit', account_code: '135', account_name: '부가세대급금', + debit_amount: splitTax, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: '' + }); + totalDebitSum += splitTax; + } + } else { + // 불공제: 비용 계정 = 공급가액 + 세액 + const combined = splitSupply + splitTax; + debitLines.push({ + dc_type: 'debit', account_code: splitAccountCode, account_name: splitAccountName, + debit_amount: combined, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: split.memo || '' + }); + totalDebitSum += combined; + } + }); + + // 대변: 미지급비용 = 전체 합계 + debitLines.push({ + dc_type: 'credit', account_code: '205', account_name: '미지급비용', + debit_amount: 0, credit_amount: totalDebitSum, + trading_partner_id: null, trading_partner_name: '', description: '' + }); + + return debitLines; + } + + // splits가 없으면 기존 로직 (원본 금액 기반) const expenseCode = log.accountCode || '826'; const expenseName = log.accountName || '잡비'; @@ -863,6 +915,16 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg-
공급가액: {formatCurrency(supplyAmount)}
세액: {formatCurrency(taxAmount)}
+ {(log._splits || []).length > 0 && ( +
+ + 분리 데이터 기반 ({log._splits.length}건) + + {isEditMode && ( + 저장된 분개가 있어 참고용으로 표시됩니다 + )} +
+ )} {loadingJournal ? ( @@ -1515,7 +1577,7 @@ className="p-1.5 text-amber-500 hover:bg-amber-100 rounded-lg transition-colors" if (jInfo) { return (