30 lines
760 B
TypeScript
30 lines
760 B
TypeScript
|
|
/**
|
||
|
|
* 금액 포맷팅 유틸리티
|
||
|
|
*
|
||
|
|
* 1만원 미만: "1,000원"
|
||
|
|
* 1만원 이상: "1,000만원"
|
||
|
|
*/
|
||
|
|
|
||
|
|
export function formatAmount(amount: number): string {
|
||
|
|
if (amount < 10000) {
|
||
|
|
return `${amount.toLocaleString("ko-KR")}원`;
|
||
|
|
} else {
|
||
|
|
const manwon = Math.round(amount / 10000);
|
||
|
|
return `${manwon.toLocaleString("ko-KR")}만원`;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 금액을 원 단위로 포맷 (항상 "원" 단위)
|
||
|
|
*/
|
||
|
|
export function formatAmountWon(amount: number): string {
|
||
|
|
return `${amount.toLocaleString("ko-KR")}원`;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 금액을 만원 단위로 포맷 (항상 "만원" 단위)
|
||
|
|
*/
|
||
|
|
export function formatAmountManwon(amount: number): string {
|
||
|
|
const manwon = Math.round(amount / 10000);
|
||
|
|
return `${manwon.toLocaleString("ko-KR")}만원`;
|
||
|
|
}
|