/**
 * Sales API Types - Mirror backend schemas
 */

export interface SalesDataCreate {
  date: string;
  product_name: string;
  product_category?: string;
  quantity_sold: number;
  unit_price: number;
  total_revenue: number;
  location_id?: string;
  sales_channel?: string;
  discount_applied?: number;
  promotion_used?: string;
  customer_id?: string;
  inventory_product_id?: string;
  cost_of_goods_sold?: number;
  profit_margin?: number;
  weather_condition?: string;
  temperature?: number;
  precipitation?: number;
  is_holiday?: boolean;
  day_of_week?: string;
  hour_of_day?: number;
  season?: string;
  local_event?: string;
  source?: string;
}

export interface SalesDataUpdate {
  date?: string;
  product_name?: string;
  product_category?: string;
  quantity_sold?: number;
  unit_price?: number;
  total_revenue?: number;
  location_id?: string;
  sales_channel?: string;
  discount_applied?: number;
  promotion_used?: string;
  customer_id?: string;
  inventory_product_id?: string;
  cost_of_goods_sold?: number;
  profit_margin?: number;
  weather_condition?: string;
  temperature?: number;
  precipitation?: number;
  is_holiday?: boolean;
  day_of_week?: string;
  hour_of_day?: number;
  season?: string;
  local_event?: string;
  validation_notes?: string;
}

export interface SalesDataResponse {
  id: string;
  tenant_id: string;
  date: string;
  product_name: string;
  product_category?: string;
  quantity_sold: number;
  unit_price: number;
  total_revenue: number;
  location_id?: string;
  sales_channel?: string;
  discount_applied?: number;
  promotion_used?: string;
  customer_id?: string;
  inventory_product_id?: string;
  cost_of_goods_sold?: number;
  profit_margin?: number;
  weather_condition?: string;
  temperature?: number;
  precipitation?: number;
  is_holiday?: boolean;
  day_of_week?: string;
  hour_of_day?: number;
  season?: string;
  local_event?: string;
  source?: string;
  is_validated?: boolean;
  validation_notes?: string;
  created_at: string;
  updated_at: string;
  created_by?: string;
}

export interface SalesDataQuery {
  start_date?: string;
  end_date?: string;
  product_name?: string;
  product_category?: string;
  location_id?: string;
  sales_channel?: string;
  source?: string;
  is_validated?: boolean;
  limit?: number;
  offset?: number;
  order_by?: string;
  order_direction?: 'asc' | 'desc';
}

export interface SalesAnalytics {
  total_revenue: number;
  total_quantity: number;
  average_unit_price: number;
  total_transactions: number;
  top_products: Array<{
    product_name: string;
    total_revenue: number;
    total_quantity: number;
    transaction_count: number;
  }>;
  revenue_by_date: Array<{
    date: string;
    revenue: number;
    quantity: number;
  }>;
  revenue_by_category: Array<{
    category: string;
    revenue: number;
    quantity: number;
  }>;
  revenue_by_channel: Array<{
    channel: string;
    revenue: number;
    quantity: number;
  }>;
}

export interface SalesValidationRequest {
  record_id: string;
  tenant_id: string;
  validation_notes?: string;
}