diff --git a/resources/views/barobill/ecard/index.blade.php b/resources/views/barobill/ecard/index.blade.php index b068a3f6..bc1acb87 100644 --- a/resources/views/barobill/ecard/index.blade.php +++ b/resources/views/barobill/ecard/index.blade.php @@ -703,58 +703,56 @@ 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 = []; + // 단일 split 분개 (분리 항목별 개별 분개) + const singleSplit = log._split; + if (singleSplit) { + const splitSupply = Math.round(parseFloat(singleSplit.split_supply_amount ?? singleSplit.supplyAmount ?? singleSplit.split_amount ?? singleSplit.amount ?? 0)); + const splitTax = Math.round(parseFloat(singleSplit.split_tax ?? singleSplit.tax ?? 0)); + const splitDeductionType = singleSplit.deduction_type || singleSplit.deductionType || 'non_deductible'; + const splitAccountCode = singleSplit.account_code || singleSplit.accountCode || '826'; + const splitAccountName = singleSplit.account_name || singleSplit.accountName || '잡비'; + + const lines = []; 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 || '' + if (splitDeductionType === 'deductible') { + // 공제: 비용 계정 = 공급가액, 부가세대급금 = 세액 + lines.push({ + dc_type: 'debit', account_code: splitAccountCode, account_name: splitAccountName, + debit_amount: splitSupply, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: singleSplit.memo || '' + }); + totalDebitSum += splitSupply; + if (splitTax > 0) { + lines.push({ + dc_type: 'debit', account_code: '135', account_name: '부가세대급금', + debit_amount: splitTax, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: '' }); - 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; + totalDebitSum += splitTax; } - }); + } else { + // 불공제: 비용 계정 = 공급가액 + 세액 + const combined = splitSupply + splitTax; + lines.push({ + dc_type: 'debit', account_code: splitAccountCode, account_name: splitAccountName, + debit_amount: combined, credit_amount: 0, + trading_partner_id: null, trading_partner_name: '', description: singleSplit.memo || '' + }); + totalDebitSum += combined; + } - // 대변: 미지급비용 = 전체 합계 - debitLines.push({ + // 대변: 미지급비용 = 합계 + lines.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; + return lines; } - // splits가 없으면 기존 로직 (원본 금액 기반) + // splits가 없으면 기존 로직 (원본 금액 기반, 분리 없는 거래용) const expenseCode = log.accountCode || '826'; const expenseName = log.accountName || '잡비'; @@ -915,14 +913,22 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg-