15 lines
441 B
TypeScript
15 lines
441 B
TypeScript
|
|
export const formatCurrency = (amount: number): string => {
|
|
return new Intl.NumberFormat('ko-KR', {
|
|
style: 'currency',
|
|
currency: 'KRW',
|
|
maximumFractionDigits: 0
|
|
}).format(amount);
|
|
};
|
|
|
|
export const calculatePercentage = (spent: number, target: number): number => {
|
|
// 타겟이 0이면 0%를 반환하도록 수정
|
|
if (target === 0 || isNaN(target)) return 0;
|
|
return Math.min(Math.round(spent / target * 100), 100);
|
|
};
|