diff --git a/resources/views/barobill/ecard/index.blade.php b/resources/views/barobill/ecard/index.blade.php index e6827f8a..1942180d 100644 --- a/resources/views/barobill/ecard/index.blade.php +++ b/resources/views/barobill/ecard/index.blade.php @@ -796,12 +796,19 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg- if (!isOpen || !log) return; setAmountMismatch(null); - const checkMismatch = (journalLines) => { + // 금액 불일치 감지 → 불일치 시 카드 데이터 기준으로 자동 갱신 + const checkAndAutoSync = (journalLines, journalId) => { const journalTotal = journalLines.reduce((sum, l) => sum + (parseInt(l.debit_amount) || 0), 0); const expectedTotal = getExpectedCardAmount(); if (Math.abs(journalTotal - expectedTotal) > 0) { + // 카드 금액이 변경됨 → 새 카드 금액 기준으로 라인 자동 갱신 + setLines(getDefaultLines()); setAmountMismatch({ journalTotal, expectedTotal, diff: expectedTotal - journalTotal }); + setIsEditMode(true); + setJournalId(journalId); + return true; } + return false; }; if (log._journalData) { @@ -815,10 +822,11 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg- trading_partner_name: l.trading_partner_name || '', description: l.description || '', })); - setLines(mappedLines); - setIsEditMode(true); - setJournalId(log._journalData.id); - checkMismatch(mappedLines); + if (!checkAndAutoSync(mappedLines, log._journalData.id)) { + setLines(mappedLines); + setIsEditMode(true); + setJournalId(log._journalData.id); + } } else if (log._hasJournal) { setLoadingJournal(true); fetch(`${API.journalShow}?source_key=${encodeURIComponent(uniqueKey)}`) @@ -835,10 +843,11 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg- trading_partner_name: l.trading_partner_name || '', description: l.description || '', })); - setLines(mappedLines); - setIsEditMode(true); - setJournalId(data.data.id); - checkMismatch(mappedLines); + if (!checkAndAutoSync(mappedLines, data.data.id)) { + setLines(mappedLines); + setIsEditMode(true); + setJournalId(data.data.id); + } } else { setLines(getDefaultLines()); setIsEditMode(false); @@ -965,26 +974,20 @@ className={`px-3 py-1.5 text-sm cursor-pointer ${index === highlightIndex ? 'bg- )} - {/* 카드 금액 ↔ 분개 금액 불일치 경고 */} + {/* 카드 금액 변경으로 분개 자동 갱신 안내 */} {amountMismatch && ( -
+
- - + +
-

카드 금액과 분개 금액이 일치하지 않습니다

+

카드 금액이 변경되어 분개 라인이 자동 갱신되었습니다

-
카드 금액: {formatCurrency(amountMismatch.expectedTotal)}원
-
분개 금액: {formatCurrency(amountMismatch.journalTotal)}원
-
차이: {formatCurrency(Math.abs(amountMismatch.diff))}원
+
현재 카드 금액: {formatCurrency(amountMismatch.expectedTotal)}원
+
이전 분개 금액: {formatCurrency(amountMismatch.journalTotal)}원
+
차이: {formatCurrency(Math.abs(amountMismatch.diff))}원
-