diff --git a/src/components/accounting/BankTransactionInquiry/index.tsx b/src/components/accounting/BankTransactionInquiry/index.tsx index e70c8ee5..996b09b3 100644 --- a/src/components/accounting/BankTransactionInquiry/index.tsx +++ b/src/components/accounting/BankTransactionInquiry/index.tsx @@ -54,6 +54,7 @@ import { type BankTransactionSummaryData, } from './actions'; import { TransactionFormModal } from './TransactionFormModal'; +import { syncBankTransactions } from '@/components/settings/BarobillIntegration/actions'; import { isNextRedirectError } from '@/lib/utils/redirect-error'; import { formatNumber } from '@/lib/utils/amount'; import { downloadExcel, type ExcelColumn } from '@/lib/utils/excel-download'; @@ -130,6 +131,7 @@ export function BankTransactionInquiry() { // 수정 추적 (로컬 변경사항) const [localChanges, setLocalChanges] = useState>>(new Map()); const [isBatchSaving, setIsBatchSaving] = useState(false); + const [isSyncing, setIsSyncing] = useState(false); // ===== 데이터 로드 ===== const loadData = useCallback(async () => { @@ -241,6 +243,26 @@ export function BankTransactionInquiry() { } }, [localChanges, loadData]); + // 바로빌 동기화 + const handleSync = useCallback(async () => { + setIsSyncing(true); + try { + const sd = startDate.replace(/-/g, ''); + const ed = endDate.replace(/-/g, ''); + const result = await syncBankTransactions(sd, ed); + if (result.success && result.data) { + toast.success(`은행 거래 ${result.data.synced}건 동기화 완료`); + loadData(); + } else { + toast.error(result.error || '동기화에 실패했습니다.'); + } + } catch { + toast.error('동기화 중 오류가 발생했습니다.'); + } finally { + setIsSyncing(false); + } + }, [startDate, endDate, loadData]); + // 엑셀 다운로드 (프론트 xlsx 생성) const handleExcelDownload = useCallback(async () => { try { @@ -359,9 +381,22 @@ export function BankTransactionInquiry() { onEndDateChange: setEndDate, }, - // 헤더 액션: ①저장 + 엑셀 다운로드 + ②수기 입력 + // 헤더 액션: 동기화 + ①저장 + 엑셀 다운로드 + ②수기 입력 headerActions: () => (
+ +
+ )} + {balanceLow && ( +
+ + 바로빌 충전잔액이 부족합니다. (현재: {balance?.toLocaleString()}원) +
+ )} + + )} + + + + )} + + {/* ===== 등록된 계좌/카드 목록 ===== */} + {(accounts.length > 0 || cards.length > 0) && ( +
+
+ {/* 등록된 계좌 */} + {accounts.length > 0 && ( +
+

+ 등록된 계좌 {accounts.length}개 +

+ + +
    + {accounts.map((acc, idx) => ( +
  • + + {acc.bankName} + {acc.bankAccountNum} +
  • + ))} +
+
+
+
+ )} + + {/* 등록된 카드 */} + {cards.length > 0 && ( +
+

+ 등록된 카드 {cards.length}개 +

+ + +
    + {cards.map((card, idx) => ( +
  • + + {card.cardCompanyName} + {card.cardNum} + {card.alias && ( + ({card.alias}) + )} +
  • + ))} +
+
+
+
+ )} +
+
+ )} + + {/* ===== 바로빌 연동 ===== */}

바로빌 연동

@@ -144,7 +347,7 @@ export function BarobillIntegration() {
- {/* 계좌 연동 */} + {/* ===== 계좌 연동 ===== */}

계좌 연동

@@ -200,7 +403,7 @@ export function BarobillIntegration() {
- {/* 카드 연동 & 공인인증서 등록 */} + {/* ===== 카드 연동 & 공인인증서 등록 ===== */}
{/* 카드 연동 */}
diff --git a/src/components/settings/BarobillIntegration/types.ts b/src/components/settings/BarobillIntegration/types.ts index f9186153..5ed6a29e 100644 --- a/src/components/settings/BarobillIntegration/types.ts +++ b/src/components/settings/BarobillIntegration/types.ts @@ -54,10 +54,34 @@ export const ACCOUNT_TYPE_OPTIONS = [ export interface IntegrationStatus { bankServiceCount: number; accountLinkCount: number; + cardCount: number; member?: { barobillId: string; bizNo: string; + corpName: string; status: string; serverMode: string; }; } + +// ===== 등록 계좌 ===== +export interface RegisteredAccount { + bankAccountNum: string; + bankName: string; + bankCode: string; +} + +// ===== 등록 카드 ===== +export interface RegisteredCard { + cardNum: string; + cardCompany: string; + cardCompanyName: string; + alias: string; +} + +// ===== 인증서 상태 ===== +export interface CertificateInfo { + is_valid: boolean; + expire_date: string | null; + regist_date: string | null; +}