Files
sam-react-prod/src/utils/formatAmount.ts

30 lines
760 B
TypeScript
Raw Normal View History

/**
*
*
* 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")}만원`;
}