Fix budget display issues
The budget was not being displayed correctly in the spending and analytics screens, as well as the weekly and monthly views on the home screen. This commit addresses these issues.
This commit is contained in:
@@ -67,14 +67,48 @@ export const calculateUpdatedBudgetData = (
|
||||
remainingAmount: Math.max(0, amount - prevBudgetData.monthly.spentAmount)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
const remainingAmount = Math.max(0, amount - prevBudgetData[type].spentAmount);
|
||||
} else if (type === 'weekly') {
|
||||
// 주간 예산이 설정되면 월간 예산도 자동 계산
|
||||
const monthlyAmount = Math.round(amount * 4.3);
|
||||
const dailyAmount = Math.round(amount / 7);
|
||||
|
||||
return {
|
||||
...prevBudgetData,
|
||||
[type]: {
|
||||
...prevBudgetData[type],
|
||||
daily: {
|
||||
targetAmount: dailyAmount,
|
||||
spentAmount: prevBudgetData.daily.spentAmount,
|
||||
remainingAmount: Math.max(0, dailyAmount - prevBudgetData.daily.spentAmount)
|
||||
},
|
||||
weekly: {
|
||||
targetAmount: amount,
|
||||
remainingAmount: remainingAmount
|
||||
spentAmount: prevBudgetData.weekly.spentAmount,
|
||||
remainingAmount: Math.max(0, amount - prevBudgetData.weekly.spentAmount)
|
||||
},
|
||||
monthly: {
|
||||
targetAmount: monthlyAmount,
|
||||
spentAmount: prevBudgetData.monthly.spentAmount,
|
||||
remainingAmount: Math.max(0, monthlyAmount - prevBudgetData.monthly.spentAmount)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// 일일 예산이 설정되면 주간/월간 예산도 자동 계산
|
||||
const weeklyAmount = Math.round(amount * 7);
|
||||
const monthlyAmount = Math.round(amount * 30);
|
||||
|
||||
return {
|
||||
daily: {
|
||||
targetAmount: amount,
|
||||
spentAmount: prevBudgetData.daily.spentAmount,
|
||||
remainingAmount: Math.max(0, amount - prevBudgetData.daily.spentAmount)
|
||||
},
|
||||
weekly: {
|
||||
targetAmount: weeklyAmount,
|
||||
spentAmount: prevBudgetData.weekly.spentAmount,
|
||||
remainingAmount: Math.max(0, weeklyAmount - prevBudgetData.weekly.spentAmount)
|
||||
},
|
||||
monthly: {
|
||||
targetAmount: monthlyAmount,
|
||||
spentAmount: prevBudgetData.monthly.spentAmount,
|
||||
remainingAmount: Math.max(0, monthlyAmount - prevBudgetData.monthly.spentAmount)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user