Fix budget display issue
The budget was incorrectly displayed as 90,000,000 instead of 3,000,000. This commit fixes the display issue on all pages and budget/expense cards.
This commit is contained in:
@@ -124,24 +124,32 @@ async function processBudgetData(budgetData: any, localBudgetDataStr: string | n
|
||||
};
|
||||
|
||||
// 서버 데이터로 업데이트 (지출 금액은 유지)
|
||||
// 여기서 문제 발생: total_budget이 30과 4.3으로 나눠져서 너무 큰 값이 됨
|
||||
// 올바른 계산법으로 수정
|
||||
const monthlyBudget = budgetData.total_budget;
|
||||
const dailyBudget = Math.round(monthlyBudget / 30);
|
||||
const weeklyBudget = Math.round(monthlyBudget / 4.3);
|
||||
|
||||
const updatedBudgetData = {
|
||||
daily: {
|
||||
targetAmount: Math.round(budgetData.total_budget / 30),
|
||||
targetAmount: dailyBudget,
|
||||
spentAmount: localBudgetData.daily.spentAmount,
|
||||
remainingAmount: Math.round(budgetData.total_budget / 30) - localBudgetData.daily.spentAmount
|
||||
remainingAmount: dailyBudget - localBudgetData.daily.spentAmount
|
||||
},
|
||||
weekly: {
|
||||
targetAmount: Math.round(budgetData.total_budget / 4.3),
|
||||
targetAmount: weeklyBudget,
|
||||
spentAmount: localBudgetData.weekly.spentAmount,
|
||||
remainingAmount: Math.round(budgetData.total_budget / 4.3) - localBudgetData.weekly.spentAmount
|
||||
remainingAmount: weeklyBudget - localBudgetData.weekly.spentAmount
|
||||
},
|
||||
monthly: {
|
||||
targetAmount: budgetData.total_budget,
|
||||
targetAmount: monthlyBudget,
|
||||
spentAmount: localBudgetData.monthly.spentAmount,
|
||||
remainingAmount: budgetData.total_budget - localBudgetData.monthly.spentAmount
|
||||
remainingAmount: monthlyBudget - localBudgetData.monthly.spentAmount
|
||||
}
|
||||
};
|
||||
|
||||
console.log('계산된 예산 데이터:', updatedBudgetData);
|
||||
|
||||
// 로컬 스토리지에 저장
|
||||
localStorage.setItem('budgetData', JSON.stringify(updatedBudgetData));
|
||||
localStorage.setItem('budgetData_backup', JSON.stringify(updatedBudgetData));
|
||||
|
||||
@@ -64,6 +64,8 @@ async function uploadBudgetData(userId: string, parsedBudgetData: any): Promise<
|
||||
// 월간 타겟 금액 가져오기
|
||||
const monthlyTarget = parsedBudgetData.monthly.targetAmount;
|
||||
|
||||
console.log('업로드할 월간 예산:', monthlyTarget);
|
||||
|
||||
// 업데이트 또는 삽입 결정
|
||||
if (existingBudgets && existingBudgets.length > 0) {
|
||||
// 기존 데이터 업데이트
|
||||
|
||||
Reference in New Issue
Block a user