import { ComponentConfig } from "@/types/component";

export interface ShippingPlanEditorConfig extends ComponentConfig {
  title?: string;
  showSummaryCards?: boolean;
  showExistingPlans?: boolean;
  allowOverPlan?: boolean;
  autoCloseOnSave?: boolean;
  confirmBeforeSave?: boolean;
  confirmMessage?: string;
  visibleSummaryCards?: {
    totalBalance?: boolean;
    totalPlanQty?: boolean;
    currentStock?: boolean;
    availableStock?: boolean;
    inProductionQty?: boolean;
  };
}

// 백엔드에서 정규화해서 내려주는 수주 정보
export interface EnrichedOrder {
  sourceId: string;
  orderNo: string;
  partCode: string;
  partName: string;
  partnerName: string;
  dueDate: string;
  orderQty: number;
  shipQty: number;
  balanceQty: number;
}

export interface ItemAggregation {
  totalBalance: number;
  totalPlanQty: number;
  currentStock: number;
  availableStock: number;
  inProductionQty: number;
}

export interface ExistingPlan {
  id: number;
  sourceId: string;
  planQty: number;
  planDate: string;
  shipmentPlanNo: string;
  status: string;
}

// 상세 테이블 행 (기존 출하계획 + 신규 입력)
export interface PlanDetailRow {
  type: "existing" | "new";
  sourceId: string;
  orderNo: string;
  partnerName: string;
  dueDate: string;
  balanceQty: number;
  planQty: number;
  planDate?: string;
  existingPlanId?: number;
  splitKey?: string;
}

export interface ItemGroup {
  partCode: string;
  partName: string;
  aggregation: ItemAggregation;
  details: PlanDetailRow[];
}
