
import { Transaction } from '@/components/TransactionCard';

// 월별로 트랜잭션 필터링
export const filterTransactionsByMonth = (
  transactions: Transaction[], 
  selectedMonth: string
): Transaction[] => {
  return transactions.filter(transaction => 
    transaction.date.includes(selectedMonth) && transaction.type === 'expense'
  );
};

// 검색어로 트랜잭션 필터링
export const filterTransactionsByQuery = (
  transactions: Transaction[],
  searchQuery: string
): Transaction[] => {
  if (!searchQuery.trim()) return transactions;
  
  const query = searchQuery.toLowerCase().trim();
  return transactions.filter(transaction => 
    transaction.title.toLowerCase().includes(query) || 
    transaction.category.toLowerCase().includes(query)
  );
};

// 총 지출 금액 계산
export const calculateTotalExpenses = (transactions: Transaction[]): number => {
  return transactions.reduce((sum, t) => sum + t.amount, 0);
};
