/**
 * 경조사비 관리 타입 정의
 */

// ===== 코드 상수 =====

export type CondolenceCategory = 'congratulation' | 'condolence';
export type CashMethod = 'cash' | 'transfer' | 'card';

export const CATEGORY_OPTIONS: { value: CondolenceCategory; label: string }[] = [
  { value: 'congratulation', label: '축의' },
  { value: 'condolence', label: '부조' },
];

export const CASH_METHOD_OPTIONS: { value: CashMethod; label: string }[] = [
  { value: 'cash', label: '현금' },
  { value: 'transfer', label: '계좌이체' },
  { value: 'card', label: '카드' },
];

export const CATEGORY_BADGE: Record<CondolenceCategory, { label: string; className: string }> = {
  congratulation: { label: '축의', className: 'bg-red-100 text-red-700 border-red-200' },
  condolence: { label: '부조', className: 'bg-gray-100 text-gray-700 border-gray-200' },
};

// ===== 목록 아이템 =====

export interface CondolenceExpense {
  id: number;
  tenant_id: number;
  event_date: string | null;
  expense_date: string | null;
  partner_name: string;
  description: string | null;
  category: CondolenceCategory;
  category_label: string;
  has_cash: boolean;
  cash_method: CashMethod | null;
  cash_method_label: string | null;
  cash_amount: number;
  has_gift: boolean;
  gift_type: string | null;
  gift_amount: number;
  total_amount: number;
  options: Record<string, unknown> | null;
  memo: string | null;
  created_by: number | null;
  updated_by: number | null;
  created_at: string;
  updated_at: string;
  deleted_at: string | null;
}

// ===== 통계 =====

export interface CondolenceExpenseSummary {
  total_count: number;
  total_amount: number;
  cash_total: number;
  gift_total: number;
  congratulation_count: number;
  condolence_count: number;
  congratulation_amount: number;
  condolence_amount: number;
}

// ===== 폼 데이터 =====

export interface CondolenceExpenseFormData {
  event_date: string;
  expense_date: string;
  partner_name: string;
  description: string;
  category: CondolenceCategory;
  has_cash: boolean;
  cash_method: CashMethod | '';
  cash_amount: number | string;
  has_gift: boolean;
  gift_type: string;
  gift_amount: number | string;
  memo: string;
}

export const INITIAL_FORM_DATA: CondolenceExpenseFormData = {
  event_date: '',
  expense_date: '',
  partner_name: '',
  description: '',
  category: 'congratulation',
  has_cash: false,
  cash_method: '',
  cash_amount: 0,
  has_gift: false,
  gift_type: '',
  gift_amount: 0,
  memo: '',
};

// ===== 목록 조회 파라미터 =====

export interface CondolenceExpenseListParams {
  year?: number;
  category?: CondolenceCategory | 'all';
  search?: string;
  sort_by?: string;
  sort_order?: 'asc' | 'desc';
  per_page?: number;
  page?: number;
}
