Fix budget input and display

- Fix issue where budget input for transportation and other categories were not saved correctly.
- Fix issue where total budget amount was calculated incorrectly.
- Fix issue where daily and weekly budgets were not displayed correctly.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 07:35:55 +00:00
parent 22aae75d13
commit b79c6b2314
6 changed files with 66 additions and 65 deletions

View File

@@ -6,7 +6,9 @@ import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
export const DEFAULT_CATEGORY_BUDGETS: Record<string, number> = {
음식: 0,
쇼핑: 0,
교통비: 0
교통비: 0,
교통: 0,
기타: 0
};
export const DEFAULT_MONTHLY_BUDGET = 0;

View File

@@ -26,11 +26,7 @@ export const useExtendedBudgetUpdate = (
const totalAmount = Object.values(newCategoryBudgets).reduce((sum, val) => sum + val, 0);
console.log('카테고리 총액:', totalAmount);
// 일/주/월 모든 예산 업데이트를 위해 monthly로 처리
// (monthly 타입은 모든 예산을 계산해 줌)
const updatedBudgetData = calculateUpdatedBudgetData(budgetData, 'monthly', totalAmount);
// 각 기간별 예산 업데이트
// 예산 데이터 업데이트를 위해 월간 금액으로 처리 (type은 'monthly'설정)
handleBudgetGoalUpdate('monthly', totalAmount);
} else {
// 카테고리 예산이 없는 경우, 기존 로직 사용

View File

@@ -14,7 +14,7 @@ export const loadCategoryBudgetsFromStorage = (): Record<string, number> => {
const parsed = JSON.parse(storedCategoryBudgets);
console.log('카테고리 예산 로드 완료:', parsed);
// 4개 카테고리만 유지
// 모든 허용된 카테고리 포함
const filteredBudgets: Record<string, number> = {};
EXPENSE_CATEGORIES.forEach(category => {
// 이전 카테고리명이 있을 경우 새 카테고리명으로 값 이전
@@ -36,7 +36,7 @@ export const loadCategoryBudgetsFromStorage = (): Record<string, number> => {
const parsedBackup = JSON.parse(backupCategoryBudgets);
console.log('백업에서 카테고리 예산 복구:', parsedBackup);
// 4개 카테고리만 유지
// 모든 허용된 카테고리 포함
const filteredBudgets: Record<string, number> = {};
EXPENSE_CATEGORIES.forEach(category => {
// 이전 카테고리명이 있을 경우 새 카테고리명으로 값 이전
@@ -83,7 +83,7 @@ export const saveCategoryBudgetsToStorage = (categoryBudgets: Record<string, num
console.error('이전 카테고리 예산 비교 오류:', e);
}
// 4개 카테고리만 유지하고 나머지는 제거
// 모든 허용된 카테고리 포함하여 유지
const filteredBudgets: Record<string, number> = {};
EXPENSE_CATEGORIES.forEach(category => {
filteredBudgets[category] = categoryBudgets[category] || 0;