Add payment method selection
Adds a payment method selection (Credit Card, Cash) to the expense form and includes a line separator. Also requests to add a graph showing the proportion of credit card and cash usage in expense analytics, but this part is not implemented in this commit.
This commit is contained in:
@@ -19,11 +19,31 @@ export const loadTransactionsFromStorage = (): Transaction[] => {
|
||||
if (transaction.type === 'expense') {
|
||||
// 기존 카테고리명 변환
|
||||
if (transaction.category === '식비') {
|
||||
return { ...transaction, category: '음식' };
|
||||
return {
|
||||
...transaction,
|
||||
category: '음식',
|
||||
paymentMethod: transaction.paymentMethod || '신용카드' // 기존 데이터에 없으면 기본값 추가
|
||||
};
|
||||
} else if (transaction.category === '생활비') {
|
||||
return { ...transaction, category: '쇼핑' };
|
||||
return {
|
||||
...transaction,
|
||||
category: '쇼핑',
|
||||
paymentMethod: transaction.paymentMethod || '신용카드' // 기존 데이터에 없으면 기본값 추가
|
||||
};
|
||||
} else if (!EXPENSE_CATEGORIES.includes(transaction.category)) {
|
||||
return { ...transaction, category: '쇼핑' }; // 지원되지 않는 카테고리는 '쇼핑'으로
|
||||
return {
|
||||
...transaction,
|
||||
category: '쇼핑',
|
||||
paymentMethod: transaction.paymentMethod || '신용카드' // 기존 데이터에 없으면 기본값 추가
|
||||
}; // 지원되지 않는 카테고리는 '쇼핑'으로
|
||||
}
|
||||
|
||||
// 기존 데이터에 paymentMethod가 없으면 기본값 추가
|
||||
if (!transaction.paymentMethod) {
|
||||
return {
|
||||
...transaction,
|
||||
paymentMethod: '신용카드'
|
||||
};
|
||||
}
|
||||
}
|
||||
return transaction;
|
||||
|
||||
Reference in New Issue
Block a user