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:
gpt-engineer-app[bot]
2025-03-22 07:42:46 +00:00
parent 09e29d57f3
commit 0d716d79d2
6 changed files with 35 additions and 17 deletions

View File

@@ -6,7 +6,6 @@ import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
export const DEFAULT_CATEGORY_BUDGETS: Record<string, number> = {
음식: 0,
쇼핑: 0,
교통비: 0,
교통: 0,
기타: 0
};
@@ -23,7 +22,7 @@ export const calculateCategorySpending = (
// 모든 카테고리에 대해 초기값 0 설정
Object.keys(categoryBudgets).forEach(category => {
// 3개 카테고리만 유지
// 정의된 카테고리만 유지
if (EXPENSE_CATEGORIES.includes(category)) {
categorySpending[category] = 0;
}
@@ -42,9 +41,12 @@ export const calculateCategorySpending = (
} else if (EXPENSE_CATEGORIES.includes(t.category)) {
// 지원되는 카테고리이지만 초기화되지 않은 경우
categorySpending[t.category] = t.amount;
} else if (t.category === '교통비') {
// 예전 카테고리명 '교통비'를 '교통'으로 매핑
categorySpending['교통'] = (categorySpending['교통'] || 0) + t.amount;
} else {
// 지원되지 않는 카테고리는 '쇼핑'으로 집계
categorySpending['쇼핑'] = (categorySpending['쇼핑'] || 0) + t.amount;
// 지원되지 않는 카테고리는 '기타'로 집계
categorySpending['기타'] = (categorySpending['기타'] || 0) + t.amount;
}
});