대시보드 구현

This commit is contained in:
2026-02-12 14:20:07 +09:00
parent 8f1d75b4d5
commit 434a814246
23 changed files with 1759 additions and 24 deletions

50
lib/kis/account.ts Normal file
View File

@@ -0,0 +1,50 @@
/**
* @file lib/kis/account.ts
* @description KIS 계좌번호(8-2) 파싱/검증 유틸
*/
export interface KisAccountParts {
accountNo: string;
accountProductCode: string;
}
/**
* 입력된 계좌 문자열을 KIS 표준(8-2)으로 변환합니다.
* @param accountNoInput 계좌번호(예: 12345678-01 또는 1234567801)
* @param accountProductCodeInput 계좌상품코드(2자리, 선택)
* @returns 파싱 성공 시 accountNo/accountProductCode
* @see app/api/kis/domestic/balance/route.ts 잔고 조회 API에서 계좌 파싱에 사용합니다.
*/
export function parseKisAccountParts(
accountNoInput?: string | null,
accountProductCodeInput?: string | null,
): KisAccountParts | null {
const accountDigits = toDigits(accountNoInput);
const productDigits = toDigits(accountProductCodeInput);
if (accountDigits.length >= 10) {
return {
accountNo: accountDigits.slice(0, 8),
accountProductCode: accountDigits.slice(8, 10),
};
}
if (accountDigits.length === 8 && productDigits.length === 2) {
return {
accountNo: accountDigits,
accountProductCode: productDigits,
};
}
return null;
}
/**
* 문자열에서 숫자만 추출합니다.
* @param value 원본 문자열
* @returns 숫자만 남긴 문자열
* @see lib/kis/account.ts parseKisAccountParts 입력 정규화 처리
*/
function toDigits(value?: string | null) {
return (value ?? "").replace(/\D/g, "");
}