feat: [ecard] 카드사용내역 복식부기 분개 시스템 추가
- EcardController에 storeJournal/getJournal/deleteJournal/getJournalStatuses 4개 메서드 추가 - journal_entries + journal_entry_lines 통합 (source_type='ecard_transaction') - CardJournalModal 차변/대변 복식부기 UI 추가 - 거래 테이블에 분개완료/구버전/미분개 3단계 상태 표시 - 기존 splits 데이터 자동 전환 지원
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,10 @@
|
||||
hide: '{{ route("barobill.ecard.hide") }}',
|
||||
restore: '{{ route("barobill.ecard.restore") }}',
|
||||
hidden: '{{ route("barobill.ecard.hidden") }}',
|
||||
journalStore: '{{ route("barobill.ecard.journal.store") }}',
|
||||
journalShow: '{{ route("barobill.ecard.journal.show") }}',
|
||||
journalDelete: '/barobill/ecard/journal/',
|
||||
journalStatuses: '{{ route("barobill.ecard.journal.statuses") }}',
|
||||
};
|
||||
|
||||
const CSRF_TOKEN = '{{ csrf_token() }}';
|
||||
@@ -552,6 +556,309 @@ className="flex-1 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 t
|
||||
);
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// CardJournalModal - 복식부기 분개 모달
|
||||
// ============================================
|
||||
const CardJournalModal = ({ isOpen, onClose, onSave, onDelete, log, accountCodes = [] }) => {
|
||||
const formatCurrency = (val) => new Intl.NumberFormat('ko-KR').format(val || 0);
|
||||
const formatAmountInput = (val) => { const n = String(val).replace(/[^\d]/g, ''); return n ? Number(n).toLocaleString() : ''; };
|
||||
const parseAmountInput = (val) => parseInt(String(val).replace(/[^\d]/g, ''), 10) || 0;
|
||||
|
||||
if (!log) return null;
|
||||
|
||||
const supplyAmount = Math.round(log.effectiveSupplyAmount ?? ((log.approvalAmount || 0) - (log.tax || 0)));
|
||||
const taxAmount = Math.round(log.effectiveTax ?? (log.tax || 0));
|
||||
const totalAmount = supplyAmount + taxAmount;
|
||||
const isDeductible = (log.deductionType || 'non_deductible') === 'deductible';
|
||||
|
||||
const uniqueKey = log.uniqueKey || `${log.cardNum}|${log.useDt}|${log.approvalNum}|${Math.floor(log.approvalAmount)}`;
|
||||
|
||||
// 기본 분개 라인
|
||||
const getDefaultLines = () => {
|
||||
const expenseCode = log.accountCode || '826';
|
||||
const expenseName = log.accountName || '잡비';
|
||||
|
||||
if (isDeductible) {
|
||||
return [
|
||||
{ dc_type: 'debit', account_code: expenseCode, account_name: expenseName, debit_amount: supplyAmount, credit_amount: 0, description: '' },
|
||||
{ dc_type: 'debit', account_code: '135', account_name: '부가세대급금', debit_amount: taxAmount, credit_amount: 0, description: '' },
|
||||
{ dc_type: 'credit', account_code: '205', account_name: '미지급비용', debit_amount: 0, credit_amount: totalAmount, description: '' },
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
{ dc_type: 'debit', account_code: expenseCode, account_name: expenseName, debit_amount: totalAmount, credit_amount: 0, description: '' },
|
||||
{ dc_type: 'credit', account_code: '205', account_name: '미지급비용', debit_amount: 0, credit_amount: totalAmount, description: '' },
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
const [lines, setLines] = useState(getDefaultLines());
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [loadingJournal, setLoadingJournal] = useState(false);
|
||||
const [isEditMode, setIsEditMode] = useState(false);
|
||||
const [journalId, setJournalId] = useState(null);
|
||||
|
||||
// 기존 분개 로드
|
||||
useEffect(() => {
|
||||
if (!isOpen || !log) return;
|
||||
|
||||
if (log._journalData) {
|
||||
// 이미 로드된 분개 데이터가 있으면 사용
|
||||
setLines(log._journalData.lines.map(l => ({
|
||||
dc_type: l.dc_type,
|
||||
account_code: l.account_code,
|
||||
account_name: l.account_name,
|
||||
debit_amount: l.debit_amount,
|
||||
credit_amount: l.credit_amount,
|
||||
description: l.description || '',
|
||||
})));
|
||||
setIsEditMode(true);
|
||||
setJournalId(log._journalData.id);
|
||||
} else if (log._hasJournal) {
|
||||
// 분개가 있는 것으로 알고 있으면 API 조회
|
||||
setLoadingJournal(true);
|
||||
fetch(`${API.journalShow}?source_key=${encodeURIComponent(uniqueKey)}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.success && data.data) {
|
||||
setLines(data.data.lines.map(l => ({
|
||||
dc_type: l.dc_type,
|
||||
account_code: l.account_code,
|
||||
account_name: l.account_name,
|
||||
debit_amount: l.debit_amount,
|
||||
credit_amount: l.credit_amount,
|
||||
description: l.description || '',
|
||||
})));
|
||||
setIsEditMode(true);
|
||||
setJournalId(data.data.id);
|
||||
} else {
|
||||
setLines(getDefaultLines());
|
||||
setIsEditMode(false);
|
||||
setJournalId(null);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('분개 로드 오류:', err))
|
||||
.finally(() => setLoadingJournal(false));
|
||||
} else {
|
||||
setLines(getDefaultLines());
|
||||
setIsEditMode(false);
|
||||
setJournalId(null);
|
||||
}
|
||||
}, [isOpen, log]);
|
||||
|
||||
const updateLine = (idx, field, value) => {
|
||||
setLines(prev => prev.map((l, i) => i === idx ? { ...l, [field]: value } : l));
|
||||
};
|
||||
|
||||
const addLine = () => {
|
||||
setLines(prev => [...prev, { dc_type: 'debit', account_code: '', account_name: '', debit_amount: 0, credit_amount: 0, description: '' }]);
|
||||
};
|
||||
|
||||
const removeLine = (idx) => {
|
||||
if (lines.length <= 2) return;
|
||||
setLines(prev => prev.filter((_, i) => i !== idx));
|
||||
};
|
||||
|
||||
const totalDebit = lines.reduce((sum, l) => sum + (parseInt(l.debit_amount) || 0), 0);
|
||||
const totalCredit = lines.reduce((sum, l) => sum + (parseInt(l.credit_amount) || 0), 0);
|
||||
const isBalanced = totalDebit === totalCredit && totalDebit > 0;
|
||||
|
||||
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;
|
||||
}
|
||||
setSaving(true);
|
||||
|
||||
// entry_date: useDt에서 YYYY-MM-DD 추출
|
||||
const useDt = log.useDt || '';
|
||||
const entryDate = useDt.length >= 8
|
||||
? `${useDt.substring(0,4)}-${useDt.substring(4,6)}-${useDt.substring(6,8)}`
|
||||
: new Date().toISOString().substring(0,10);
|
||||
|
||||
await onSave({
|
||||
source_key: uniqueKey,
|
||||
entry_date: entryDate,
|
||||
description: `${log.merchantName || ''} 카드결제`,
|
||||
lines,
|
||||
});
|
||||
setSaving(false);
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!journalId) return;
|
||||
if (!confirm('분개를 삭제하시겠습니까?')) return;
|
||||
setSaving(true);
|
||||
await onDelete(journalId);
|
||||
setSaving(false);
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
||||
<div className="bg-white rounded-2xl shadow-2xl w-full max-w-3xl mx-4 max-h-[90vh] overflow-hidden">
|
||||
<div className="p-6 border-b border-stone-100 flex items-center justify-between">
|
||||
<h3 className="text-lg font-bold text-stone-900">
|
||||
{isEditMode ? '분개 수정' : '분개 생성'}
|
||||
</h3>
|
||||
<button onClick={onClose} className="p-2 hover:bg-stone-100 rounded-lg transition-colors">
|
||||
<svg className="w-5 h-5 text-stone-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-6 overflow-y-auto max-h-[65vh] space-y-5">
|
||||
{/* 카드 거래 정보 */}
|
||||
<div className="bg-stone-50 rounded-xl p-4">
|
||||
<h4 className="text-sm font-semibold text-stone-700 mb-3">카드 거래 정보</h4>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-3 text-sm">
|
||||
<div><span className="text-stone-500">가맹점: </span><span className="font-medium">{log.merchantName || '-'}</span></div>
|
||||
<div><span className="text-stone-500">사용일시: </span><span className="font-medium">{log.useDateTime || '-'}</span></div>
|
||||
<div><span className="text-stone-500">공급가액: </span><span className="font-medium">{formatCurrency(supplyAmount)}</span></div>
|
||||
<div><span className="text-stone-500">세액: </span><span className="font-medium">{formatCurrency(taxAmount)}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loadingJournal ? (
|
||||
<div className="flex items-center justify-center py-8">
|
||||
<div className="animate-spin rounded-full h-6 w-6 border-2 border-purple-600 border-t-transparent"></div>
|
||||
<span className="ml-2 text-sm text-stone-500">분개 데이터 로딩중...</span>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold text-stone-700 mb-3">분개 내역</h4>
|
||||
<table className="w-full text-sm border border-stone-200 rounded-lg overflow-hidden">
|
||||
<thead>
|
||||
<tr className="bg-stone-100">
|
||||
<th className="px-3 py-2 text-center text-xs font-semibold text-stone-600 border-b border-stone-200" style={{width:'60px'}}>차/대</th>
|
||||
<th className="px-3 py-2 text-center text-xs font-semibold text-stone-600 border-b border-stone-200">계정과목</th>
|
||||
<th className="px-3 py-2 text-center text-xs font-semibold text-stone-600 border-b border-stone-200" style={{width:'140px'}}>차변금액</th>
|
||||
<th className="px-3 py-2 text-center text-xs font-semibold text-stone-600 border-b border-stone-200" style={{width:'140px'}}>대변금액</th>
|
||||
<th className="px-3 py-2 text-center text-xs font-semibold text-stone-600 border-b border-stone-200" style={{width:'40px'}}></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{lines.map((line, idx) => (
|
||||
<tr key={idx} className="border-b border-stone-100">
|
||||
<td className="px-3 py-2 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggleDcType(idx)}
|
||||
className={`px-2 py-0.5 rounded text-xs font-medium cursor-pointer hover:opacity-80 transition-opacity ${line.dc_type === 'debit' ? 'bg-blue-100 text-blue-700' : 'bg-red-100 text-red-700'}`}
|
||||
title="클릭하여 차변/대변 전환"
|
||||
>
|
||||
{line.dc_type === 'debit' ? '차변' : '대변'}
|
||||
</button>
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<AccountCodeSelect
|
||||
value={line.account_code}
|
||||
onChange={(code, name) => {
|
||||
setLines(prev => prev.map((l, i) => i === idx ? { ...l, account_code: code, account_name: name } : l));
|
||||
}}
|
||||
accountCodes={accountCodes}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="text"
|
||||
value={formatAmountInput(line.debit_amount)}
|
||||
onChange={(e) => updateLine(idx, 'debit_amount', parseAmountInput(e.target.value))}
|
||||
className="w-full px-2 py-1 border border-stone-200 rounded text-sm text-right focus:ring-1 focus:ring-purple-500 outline-none"
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="text"
|
||||
value={formatAmountInput(line.credit_amount)}
|
||||
onChange={(e) => updateLine(idx, 'credit_amount', parseAmountInput(e.target.value))}
|
||||
className="w-full px-2 py-1 border border-stone-200 rounded text-sm text-right focus:ring-1 focus:ring-purple-500 outline-none"
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-2 text-center">
|
||||
<button
|
||||
onClick={() => removeLine(idx)}
|
||||
disabled={lines.length <= 2}
|
||||
className="text-red-400 hover:text-red-600 disabled:opacity-30 disabled:cursor-not-allowed"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M20 12H4" />
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{/* 합계 */}
|
||||
<tr className={`font-bold ${isBalanced ? 'bg-green-50' : 'bg-red-50'}`}>
|
||||
<td colSpan="2" className="px-3 py-2 text-center text-sm">합계</td>
|
||||
<td className="px-3 py-2 text-right text-sm">{formatCurrency(totalDebit)}</td>
|
||||
<td className="px-3 py-2 text-right text-sm">{formatCurrency(totalCredit)}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{!isBalanced && (
|
||||
<p className="text-red-500 text-xs mt-2">차변과 대변의 합계가 일치하지 않습니다. (차이: {formatCurrency(Math.abs(totalDebit - totalCredit))})</p>
|
||||
)}
|
||||
|
||||
{/* 행 추가 버튼 */}
|
||||
<button
|
||||
onClick={addLine}
|
||||
className="mt-3 w-full py-2 border-2 border-dashed border-stone-300 text-stone-500 rounded-lg hover:border-purple-400 hover:text-purple-600 transition-colors flex items-center justify-center gap-2 text-sm"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
행 추가
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="p-4 border-t border-stone-100 flex justify-between">
|
||||
<div>
|
||||
{isEditMode && journalId && (
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={saving}
|
||||
className="px-4 py-2 bg-red-50 text-red-600 rounded-lg text-sm font-medium hover:bg-red-100 transition-colors disabled:opacity-50"
|
||||
>
|
||||
분개 삭제
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<button onClick={onClose} className="px-4 py-2 bg-stone-100 text-stone-700 rounded-lg text-sm font-medium hover:bg-stone-200 transition-colors">
|
||||
취소
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
disabled={saving || !isBalanced || loadingJournal}
|
||||
className="px-6 py-2 bg-purple-600 text-white rounded-lg text-sm font-medium hover:bg-purple-700 transition-colors disabled:opacity-50 flex items-center gap-2"
|
||||
>
|
||||
{saving && <div className="animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"></div>}
|
||||
{isEditMode ? '분개 수정' : '분개 저장'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 카드사 코드 목록
|
||||
const CARD_COMPANIES = [
|
||||
{ code: '01', name: '비씨' },
|
||||
@@ -979,6 +1286,8 @@ className="flex-1 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 t
|
||||
hiddenLogs,
|
||||
onRestore,
|
||||
loadingHidden,
|
||||
journalMap,
|
||||
onOpenJournalModal,
|
||||
}) => {
|
||||
const formatCurrency = (val) => new Intl.NumberFormat('ko-KR').format(val || 0) + '원';
|
||||
|
||||
@@ -1029,27 +1338,45 @@ className="flex-1 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 t
|
||||
{/* 원본 거래 행 */}
|
||||
<tr className={`hover:bg-stone-50 transition-colors ${log.isSaved ? 'bg-purple-50/30' : ''} ${hasSplits ? 'bg-amber-50/50' : ''}`}>
|
||||
<td className="px-3 py-3 text-center">
|
||||
{hasSplits ? (
|
||||
<button
|
||||
onClick={() => onDeleteSplits(uniqueKey)}
|
||||
className="p-1.5 text-red-500 hover:bg-red-100 rounded-lg transition-colors"
|
||||
title="분개 삭제"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M20 12H4" />
|
||||
</svg>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => onOpenSplitModal(log, uniqueKey)}
|
||||
className="p-1.5 text-purple-500 hover:bg-purple-100 rounded-lg transition-colors"
|
||||
title="분개 추가"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
{(() => {
|
||||
const jInfo = journalMap[uniqueKey];
|
||||
if (jInfo) {
|
||||
// 복식부기 분개 완료
|
||||
return (
|
||||
<button
|
||||
onClick={() => onOpenJournalModal(log, uniqueKey, true)}
|
||||
className="px-1.5 py-0.5 bg-emerald-100 text-emerald-700 rounded text-[10px] font-bold hover:bg-emerald-200 transition-colors"
|
||||
title={`전표: ${jInfo.entry_no}`}
|
||||
>
|
||||
분개완료
|
||||
</button>
|
||||
);
|
||||
} else if (hasSplits) {
|
||||
// 구버전 splits만 존재
|
||||
return (
|
||||
<button
|
||||
onClick={() => onOpenJournalModal(log, uniqueKey, false)}
|
||||
className="px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded text-[10px] font-bold hover:bg-amber-200 transition-colors"
|
||||
title="구버전 분개 → 복식부기 전환"
|
||||
>
|
||||
구버전
|
||||
</button>
|
||||
);
|
||||
} else {
|
||||
// 분개 없음
|
||||
return (
|
||||
<button
|
||||
onClick={() => onOpenJournalModal(log, uniqueKey, false)}
|
||||
className="p-1.5 text-purple-500 hover:bg-purple-100 rounded-lg transition-colors"
|
||||
title="분개 추가"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</td>
|
||||
<td className="px-4 py-3 whitespace-nowrap">
|
||||
<div className="font-medium text-stone-900">{log.useDateTime || '-'}</div>
|
||||
@@ -1133,8 +1460,11 @@ className="w-full px-2 py-1 text-sm border border-stone-200 rounded focus:outlin
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
{hasSplits && (
|
||||
<div className="text-xs text-amber-600 mt-1">분개됨 ({logSplits.length}건)</div>
|
||||
{journalMap[uniqueKey] && (
|
||||
<div className="text-xs text-emerald-600 mt-1">{journalMap[uniqueKey].entry_no}</div>
|
||||
)}
|
||||
{!journalMap[uniqueKey] && hasSplits && (
|
||||
<div className="text-xs text-amber-600 mt-1">구버전({logSplits.length}건)</div>
|
||||
)}
|
||||
</td>
|
||||
<td className={`px-4 py-3 text-right ${log.isAmountModified && log.modifiedSupplyAmount !== null ? 'bg-orange-50' : ''}`}>
|
||||
@@ -1395,7 +1725,12 @@ className="px-3 py-1 bg-green-500 text-white text-xs rounded-lg hover:bg-green-6
|
||||
const [accountCodes, setAccountCodes] = useState([]);
|
||||
const [hasChanges, setHasChanges] = useState(false);
|
||||
|
||||
// 분개 관련 상태
|
||||
// 복식부기 분개 관련 상태
|
||||
const [journalMap, setJournalMap] = useState({});
|
||||
const [journalModalOpen, setJournalModalOpen] = useState(false);
|
||||
const [journalModalLog, setJournalModalLog] = useState(null);
|
||||
|
||||
// 구버전 분개 관련 상태
|
||||
const [splits, setSplits] = useState({});
|
||||
const [splitModalOpen, setSplitModalOpen] = useState(false);
|
||||
const [splitModalLog, setSplitModalLog] = useState(null);
|
||||
@@ -1501,6 +1836,7 @@ className="px-3 py-1 bg-green-500 text-white text-xs rounded-lg hover:bg-green-6
|
||||
|
||||
// 분개 데이터 로드
|
||||
loadSplits();
|
||||
loadJournalStatuses();
|
||||
};
|
||||
|
||||
// 분개 데이터 로드
|
||||
@@ -1522,6 +1858,88 @@ className="px-3 py-1 bg-green-500 text-white text-xs rounded-lg hover:bg-green-6
|
||||
}
|
||||
};
|
||||
|
||||
// 복식부기 분개 상태 로드
|
||||
const loadJournalStatuses = async () => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
startDate: dateFrom.replace(/-/g, ''),
|
||||
endDate: dateTo.replace(/-/g, '')
|
||||
});
|
||||
const response = await fetch(`${API.journalStatuses}?${params}`);
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
setJournalMap(data.data || {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('분개 상태 로드 오류:', err);
|
||||
}
|
||||
};
|
||||
|
||||
// 복식부기 분개 모달 열기
|
||||
const handleOpenJournalModal = (log, uniqueKey, hasJournal) => {
|
||||
const logWithJournalInfo = {
|
||||
...log,
|
||||
uniqueKey,
|
||||
_hasJournal: hasJournal,
|
||||
_journalData: null,
|
||||
};
|
||||
setJournalModalLog(logWithJournalInfo);
|
||||
setJournalModalOpen(true);
|
||||
};
|
||||
|
||||
// 복식부기 분개 저장
|
||||
const handleSaveJournal = async (payload) => {
|
||||
try {
|
||||
const response = await fetch(API.journalStore, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': CSRF_TOKEN,
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
notify(data.message, 'success');
|
||||
setJournalModalOpen(false);
|
||||
setJournalModalLog(null);
|
||||
loadJournalStatuses();
|
||||
loadSplits(); // splits 자동 삭제 반영
|
||||
} else {
|
||||
notify(data.message || '분개 저장 실패', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
notify('분개 저장 오류: ' + err.message, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
// 복식부기 분개 삭제
|
||||
const handleDeleteJournal = async (journalId) => {
|
||||
try {
|
||||
const response = await fetch(`${API.journalDelete}${journalId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': CSRF_TOKEN,
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
notify(data.message, 'success');
|
||||
setJournalModalOpen(false);
|
||||
setJournalModalLog(null);
|
||||
loadJournalStatuses();
|
||||
} else {
|
||||
notify(data.message || '분개 삭제 실패', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
notify('분개 삭제 오류: ' + err.message, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
// 요약 재계산: 분개가 있는 거래는 원본 대신 분개별 통계로 대체
|
||||
// 수정된 공급가액/세액이 있으면 해당 값으로 합계 반영
|
||||
const recalculateSummary = (currentLogs, allSplits) => {
|
||||
@@ -2245,6 +2663,8 @@ className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium tra
|
||||
hiddenLogs={hiddenLogs}
|
||||
onRestore={handleRestore}
|
||||
loadingHidden={loadingHidden}
|
||||
journalMap={journalMap}
|
||||
onOpenJournalModal={handleOpenJournalModal}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -2259,6 +2679,16 @@ className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium tra
|
||||
splits={splitModalExisting}
|
||||
/>
|
||||
|
||||
{/* Card Journal Modal (복식부기) */}
|
||||
<CardJournalModal
|
||||
isOpen={journalModalOpen}
|
||||
onClose={() => { setJournalModalOpen(false); setJournalModalLog(null); }}
|
||||
onSave={handleSaveJournal}
|
||||
onDelete={handleDeleteJournal}
|
||||
log={journalModalLog}
|
||||
accountCodes={accountCodes}
|
||||
/>
|
||||
|
||||
{/* Manual Entry Modal */}
|
||||
<ManualEntryModal
|
||||
isOpen={manualModalOpen}
|
||||
|
||||
@@ -580,6 +580,11 @@
|
||||
Route::post('/hide', [\App\Http\Controllers\Barobill\EcardController::class, 'hideTransaction'])->name('hide');
|
||||
Route::post('/restore', [\App\Http\Controllers\Barobill\EcardController::class, 'restoreTransaction'])->name('restore');
|
||||
Route::get('/hidden', [\App\Http\Controllers\Barobill\EcardController::class, 'hiddenTransactions'])->name('hidden');
|
||||
// 복식부기 분개 (journal_entries 통합)
|
||||
Route::post('/journal', [\App\Http\Controllers\Barobill\EcardController::class, 'storeJournal'])->name('journal.store');
|
||||
Route::get('/journal', [\App\Http\Controllers\Barobill\EcardController::class, 'getJournal'])->name('journal.show');
|
||||
Route::delete('/journal/{id}', [\App\Http\Controllers\Barobill\EcardController::class, 'deleteJournal'])->name('journal.delete');
|
||||
Route::get('/journal-statuses', [\App\Http\Controllers\Barobill\EcardController::class, 'getJournalStatuses'])->name('journal.statuses');
|
||||
});
|
||||
|
||||
// 홈택스 매출/매입 (React 페이지)
|
||||
|
||||
Reference in New Issue
Block a user