Fix budget display issue

The budget amount was displaying incorrectly, showing three times the actual value. This commit fixes the issue.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 01:10:20 +00:00
parent 146cb92bc5
commit a6ca34e049
4 changed files with 63 additions and 18 deletions

View File

@@ -59,10 +59,15 @@ export const calculateUpdatedBudgetData = (
type: BudgetPeriod,
amount: number
): BudgetData => {
console.log(`예산 업데이트 계산: 타입=${type}, 금액=${amount}`);
if (type === 'monthly') {
// 월간 예산을 기준으로 일일, 주간 예산 계산 (30일, 4.3주 기준)
const dailyAmount = Math.round(amount / 30);
const weeklyAmount = Math.round(amount / 4.3);
console.log(`월간 예산 ${amount}원으로 설정 → 일일: ${dailyAmount}원, 주간: ${weeklyAmount}`);
return {
daily: {
targetAmount: dailyAmount,
@@ -75,16 +80,18 @@ export const calculateUpdatedBudgetData = (
remainingAmount: Math.max(0, weeklyAmount - prevBudgetData.weekly.spentAmount)
},
monthly: {
targetAmount: amount,
targetAmount: amount, // 원래 입력한 금액 그대로 사용
spentAmount: prevBudgetData.monthly.spentAmount,
remainingAmount: Math.max(0, amount - prevBudgetData.monthly.spentAmount)
}
};
} else if (type === 'weekly') {
// 주간 예산이 설정되면 월간 예산도 자동 계산
// 주간 예산이 설정되면 월간 예산은 주간 * 4.3, 일일 예산은 주간 / 7
const monthlyAmount = Math.round(amount * 4.3);
const dailyAmount = Math.round(amount / 7);
console.log(`주간 예산 ${amount}원으로 설정 → 월간: ${monthlyAmount}원, 일일: ${dailyAmount}`);
return {
daily: {
targetAmount: dailyAmount,
@@ -92,7 +99,7 @@ export const calculateUpdatedBudgetData = (
remainingAmount: Math.max(0, dailyAmount - prevBudgetData.daily.spentAmount)
},
weekly: {
targetAmount: amount,
targetAmount: amount, // 원래 입력한 금액 그대로 사용
spentAmount: prevBudgetData.weekly.spentAmount,
remainingAmount: Math.max(0, amount - prevBudgetData.weekly.spentAmount)
},
@@ -103,13 +110,15 @@ export const calculateUpdatedBudgetData = (
}
};
} else {
// 일일 예산이 설정되면 주간/월간 예산도 자동 계산
// 일일 예산이 설정되면 주간 예산은 일일 * 7, 월간 예산은 일일 * 30
const weeklyAmount = Math.round(amount * 7);
const monthlyAmount = Math.round(amount * 30);
console.log(`일일 예산 ${amount}원으로 설정 → 주간: ${weeklyAmount}원, 월간: ${monthlyAmount}`);
return {
daily: {
targetAmount: amount,
targetAmount: amount, // 원래 입력한 금액 그대로 사용
spentAmount: prevBudgetData.daily.spentAmount,
remainingAmount: Math.max(0, amount - prevBudgetData.daily.spentAmount)
},