Fix budget calculation and storage
Correct budget calculation and storage issues for 교통 and 기타 categories, and ensure daily/weekly budgets are displayed correctly.
This commit is contained in:
@@ -20,19 +20,20 @@ export const useExtendedBudgetUpdate = (
|
||||
|
||||
// 카테고리 예산이 제공된 경우 업데이트
|
||||
if (newCategoryBudgets) {
|
||||
// 카테고리 예산 저장
|
||||
updateCategoryBudgets(newCategoryBudgets);
|
||||
|
||||
// 총액 계산
|
||||
const totalAmount = Object.values(newCategoryBudgets).reduce((sum, val) => sum + val, 0);
|
||||
console.log('카테고리 총액:', totalAmount);
|
||||
|
||||
// 예산 데이터 업데이트를 위해 월간 금액으로 처리 (type은 'monthly'로 설정)
|
||||
// 월간 예산 금액으로 예산 데이터 업데이트 (type에 관계없이 월간으로 처리)
|
||||
handleBudgetGoalUpdate('monthly', totalAmount);
|
||||
} else {
|
||||
// 카테고리 예산이 없는 경우, 기존 로직 사용
|
||||
// 카테고리 예산이 없는 경우, 선택된 기간 유형에 따라 예산 설정
|
||||
handleBudgetGoalUpdate(type, amount);
|
||||
}
|
||||
}, [budgetData, categoryBudgets, handleBudgetGoalUpdate, updateCategoryBudgets]);
|
||||
}, [categoryBudgets, handleBudgetGoalUpdate, updateCategoryBudgets]);
|
||||
|
||||
return { extendedBudgetGoalUpdate };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user