/**
 * 입고관리 목업 데이터
 */

import type {
  ReceivingItem,
  ReceivingDetail,
  ReceivingStats,
  FilterTab,
  InspectionTarget,
  InspectionCheckItem,
} from './types';

// 목업 입고 목록
export const mockReceivingItems: ReceivingItem[] = [
  {
    id: '1',
    orderNo: 'KD-SO-250312-001',
    itemCode: 'RM-COIL-08',
    itemName: '갈바코일 0.8T',
    supplier: '포항철강',
    orderQty: 5,
    orderUnit: '톤',
    receivingQty: undefined,
    lotNo: undefined,
    unit: '톤',
    status: 'inspection_pending',
  },
  {
    id: '2',
    orderNo: 'KD-SO-250311-001',
    itemCode: 'PP-ENDLOCK-01',
    itemName: '엔드락 2100',
    supplier: '부품산업',
    orderQty: 200,
    orderUnit: 'EA',
    receivingQty: undefined,
    lotNo: undefined,
    unit: 'EA',
    status: 'receiving_pending',
  },
  {
    id: '3',
    orderNo: 'KD-SO-250310-001',
    itemCode: 'RM-SCREEN-01',
    itemName: '방충망 원단 1016',
    supplier: '한국망사',
    orderQty: 100,
    orderUnit: 'M',
    receivingQty: undefined,
    lotNo: undefined,
    unit: 'M',
    status: 'inspection_pending',
  },
  {
    id: '4',
    orderNo: 'KD-SO-250302-001',
    itemCode: 'PP-MOTOR-01',
    itemName: '튜블러모터',
    supplier: '모터공사',
    orderQty: 50,
    orderUnit: 'EA',
    receivingQty: undefined,
    lotNo: undefined,
    unit: 'EA',
    status: 'order_completed',
  },
  {
    id: '5',
    orderNo: 'KD-SO-250301-001',
    itemCode: 'RM-COIL-05',
    itemName: '갈바코일 0.5T',
    supplier: '철강공업',
    orderQty: 10,
    orderUnit: '톤',
    receivingQty: undefined,
    lotNo: undefined,
    unit: '톤',
    status: 'shipping',
  },
];

// 상세 정보 목업
export const mockReceivingDetails: Record<string, ReceivingDetail> = {
  '1': {
    id: '1',
    orderNo: 'KD-SO-250312-001',
    orderDate: undefined,
    supplier: '포항철강',
    itemCode: 'RM-COIL-08',
    itemName: '갈바코일 0.8T',
    specification: undefined,
    orderQty: 5,
    orderUnit: '톤',
    dueDate: undefined,
    status: 'inspection_pending',
    receivingDate: undefined,
    receivingQty: undefined,
    receivingLot: undefined,
    supplierLot: undefined,
    receivingLocation: undefined,
    receivingManager: '자재팀',
    unit: '톤',
  },
  '5': {
    id: '5',
    orderNo: 'KD-SO-250301-001',
    orderDate: undefined,
    supplier: '철강공업',
    itemCode: 'RM-COIL-05',
    itemName: '갈바코일 0.5T',
    specification: undefined,
    orderQty: 10,
    orderUnit: '톤',
    dueDate: undefined,
    status: 'shipping',
    receivingDate: undefined,
    receivingQty: undefined,
    receivingLot: undefined,
    supplierLot: undefined,
    receivingLocation: undefined,
    receivingManager: undefined,
    unit: '톤',
  },
};

// 통계 목업
export const mockStats: ReceivingStats = {
  receivingPendingCount: 2,
  receivingCompletedCount: 0,
  inspectionPendingCount: 2,
  inspectionCompletedCount: 0,
  shippingCount: 1,
  todayReceivingCount: 0,
};

// 필터 탭 목업
export const mockFilterTabs: FilterTab[] = [
  { key: 'all', label: '전체', count: 5 },
  { key: 'receiving_pending', label: '입고대기', count: 2 },
  { key: 'completed', label: '입고완료', count: 2 },
];

// 검사 대상 목업
export const mockInspectionTargets: InspectionTarget[] = [
  { id: '3', orderNo: 'KD-SO-250310-001', supplier: '한국망사', qty: '100EA' },
  { id: '2', orderNo: 'KD-SO-250311-001', supplier: '부품산업', qty: '200EA' },
  { id: '1', orderNo: 'KD-SO-250312-001', supplier: '포항철강', qty: '5EA' },
];

// 검사 항목 템플릿
export const defaultInspectionItems: InspectionCheckItem[] = [
  { id: '1', name: '겉모양', specification: '사용상 해로운 결함이 없을 것', method: '육안검사', judgment: '', remark: '' },
  { id: '2', name: '두께', specification: '규격 참조', method: '마이크로미터', judgment: '', remark: '' },
  { id: '3', name: '폭', specification: '규격 참조', method: '줄자', judgment: '', remark: '' },
  { id: '4', name: '길이', specification: '규격 참조', method: '줄자', judgment: '', remark: '' },
];

// LOT 번호 생성
export function generateLotNo(): string {
  const now = new Date();
  const year = now.getFullYear().toString().slice(-2);
  const month = (now.getMonth() + 1).toString().padStart(2, '0');
  const day = now.getDate().toString().padStart(2, '0');
  const seq = Math.floor(Math.random() * 100).toString().padStart(2, '0');
  return `${year}${month}${day}-${seq}`;
}