// ===== 악성채권 추심관리 타입 정의 =====

// 추심 상태
export type CollectionStatus = 'collecting' | 'legalAction' | 'recovered' | 'badDebt';

// 정렬 옵션
export type SortOption = 'latest' | 'oldest';

// 담당자 정보
export interface Manager {
  id: string;
  departmentName: string;
  name: string;
  position: string;
  phone: string;
}

// 메모
export interface BadDebtMemo {
  id: string;
  content: string;
  createdAt: string;
  createdBy: string;
}

// 첨부 파일
export interface AttachedFile {
  id: string;
  name: string;
  url: string;
  type: 'businessRegistration' | 'taxInvoice' | 'additional';
}

// 악성채권 레코드
export interface BadDebtRecord {
  id: string;
  // 거래처 기본 정보
  vendorId: string;
  vendorCode: string;
  vendorName: string;
  businessNumber: string;
  representativeName: string;
  vendorType: 'sales' | 'purchase' | 'both';
  businessType: string;
  businessCategory: string;
  // 연락처 정보
  zipCode: string;
  address1: string;
  address2: string;
  phone: string;
  mobile: string;
  fax: string;
  email: string;
  // 담당자 정보
  contactName: string;
  contactPhone: string;
  systemManager: string;
  // 악성채권 정보
  debtAmount: number;
  status: CollectionStatus;
  overdueDays: number;
  overdueToggle: boolean;
  occurrenceDate: string;
  endDate: string | null;
  assignedManagerId: string | null;
  assignedManager: Manager | null;
  settingToggle: boolean;
  // 첨부 파일
  files: AttachedFile[];
  // 메모
  memos: BadDebtMemo[];
  // 타임스탬프
  createdAt: string;
  updatedAt: string;
}

// ===== 상태 라벨 =====
export const COLLECTION_STATUS_LABELS: Record<CollectionStatus, string> = {
  collecting: '추심중',
  legalAction: '법적조치',
  recovered: '회수완료',
  badDebt: '대손처리',
};

// ===== 상태 필터 옵션 =====
export const STATUS_FILTER_OPTIONS = [
  { value: 'all', label: '전체' },
  { value: 'collecting', label: '추심중' },
  { value: 'legalAction', label: '법적조치' },
  { value: 'recovered', label: '회수완료' },
  { value: 'badDebt', label: '대손처리' },
] as const;

// ===== 상태 셀렉트 옵션 (상세 페이지용, 전체 제외) =====
export const STATUS_SELECT_OPTIONS = [
  { value: 'collecting', label: '추심중' },
  { value: 'legalAction', label: '법적조치' },
  { value: 'recovered', label: '회수완료' },
  { value: 'badDebt', label: '대손처리' },
] as const;

// ===== 상태 Badge 스타일 =====
export const STATUS_BADGE_STYLES: Record<CollectionStatus, string> = {
  collecting: 'border-orange-300 text-orange-600 bg-orange-50',
  legalAction: 'border-red-300 text-red-600 bg-red-50',
  recovered: 'border-green-300 text-green-600 bg-green-50',
  badDebt: 'border-gray-300 text-gray-600 bg-gray-50',
};

// ===== 정렬 옵션 =====
export const SORT_OPTIONS = [
  { value: 'latest', label: '최신순' },
  { value: 'oldest', label: '등록순' },
] as const;

// ===== 거래처 유형 라벨 =====
export const VENDOR_TYPE_LABELS: Record<string, string> = {
  sales: '매출',
  purchase: '매입',
  both: '매출매입',
};