export interface Customer {
  id: string;
  name: string;
  phone?: string;
  city?: string;
  notes?: string;
  created_at?: string;
  updated_at?: string;
}

export interface SaleItem {
  id: string;
  sale_id: string;
  filament_id: string;
  item_type: 'refill' | 'spulna';
  quantity: number;
  unit_price: number;
  created_at?: string;
  // Joined fields
  filament_tip?: string;
  filament_finish?: string;
  filament_boja?: string;
}

export interface Sale {
  id: string;
  customer_id?: string;
  total_amount: number;
  notes?: string;
  created_at?: string;
  updated_at?: string;
  // Joined fields
  customer_name?: string;
  customer_phone?: string;
  items?: SaleItem[];
  item_count?: number;
}

export interface CreateSaleRequest {
  customer: {
    name: string;
    phone?: string;
    city?: string;
    notes?: string;
  };
  items: {
    filament_id: string;
    item_type: 'refill' | 'spulna';
    quantity: number;
  }[];
  notes?: string;
}

export interface AnalyticsOverview {
  revenue: number;
  sales_count: number;
  avg_order_value: number;
  unique_customers: number;
}

export interface TopSeller {
  boja: string;
  tip: string;
  finish: string;
  total_qty: number;
  total_revenue: number;
}

export interface RevenueDataPoint {
  period: string;
  revenue: number;
  count: number;
}

export interface InventoryAlert {
  id: string;
  boja: string;
  tip: string;
  finish: string;
  refill: number;
  spulna: number;
  kolicina: number;
  avg_daily_sales: number;
  days_until_stockout: number | null;
}

export interface TypeBreakdown {
  item_type: string;
  total_qty: number;
  total_revenue: number;
}
