export interface SalesSummary {
  total_sales: number
  total_orders: number
  total_items: number
  average_order_value: number
  total_tax: number
  total_discount: number
  net_sales: number
}

export interface SalesDataItem {
  date: string // ISO string, e.g., "2025-08-03T00:00:00Z"
  sales: number
  orders: number
  items: number
  tax: number
  discount: number
  net_sales: number
}

export interface SalesReport {
  organization_id: string
  outlet_id: string
  date_from: string // ISO string with timezone, e.g., "2025-08-01T00:00:00+07:00"
  date_to: string // ISO string with timezone
  group_by: string // e.g., "day", "month", etc.
  summary: SalesSummary
  data: SalesDataItem[]
}

export interface ProductData {
  product_id: string
  product_name: string
  category_id: string
  category_name: string
  quantity_sold: number
  revenue: number
  average_price: number
  order_count: number
}

export interface ProductSalesReport {
  organization_id: string
  outlet_id: string
  date_from: string
  date_to: string
  data: ProductData[]
}

export type PaymentDataItem = {
  payment_method_id: string
  payment_method_name: string
  payment_method_type: string
  total_amount: number
  order_count: number
  payment_count: number
  percentage: number
}

export type SummaryData = {
  total_amount: number
  total_orders: number
  total_payments: number
  average_order_value: number
}

export type PaymentReport = {
  organization_id: string
  outlet_id: string
  date_from: string
  date_to: string
  group_by: string
  summary: SummaryData
  data: PaymentDataItem[]
}

export type Overview = {
  total_sales: number
  total_orders: number
  average_order_value: number
  total_customers: number
  voided_orders: number
  refunded_orders: number
}

export type RecentSale = {
  date: string
  sales: number
  orders: number
  items: number
  tax: number
  discount: number
  net_sales: number
}

export type DashboardReport = {
  organization_id: string
  outlet_id: string
  date_from: string
  date_to: string
  overview: Overview
  top_products: ProductData[]
  payment_methods: PaymentDataItem[]
  recent_sales: RecentSale[]
}

export interface ProfitLossReport {
  organization_id: string
  date_from: string // ISO date string with timezone
  date_to: string // ISO date string with timezone
  group_by: string
  summary: Summary
  data: DailyData[]
  product_data: ProductDataReport[]
}

export interface Summary {
  total_revenue: number
  total_cost: number
  gross_profit: number
  gross_profit_margin: number
  total_tax: number
  total_discount: number
  net_profit: number
  net_profit_margin: number
  total_orders: number
  average_profit: number
  profitability_ratio: number
}

export interface DailyData {
  date: string // ISO date string with timezone
  revenue: number
  cost: number
  gross_profit: number
  gross_profit_margin: number
  tax: number
  discount: number
  net_profit: number
  net_profit_margin: number
  orders: number
}

export interface ProductDataReport {
  product_id: string
  product_name: string
  category_id: string
  category_name: string
  quantity_sold: number
  revenue: number
  cost: number
  gross_profit: number
  gross_profit_margin: number
  average_price: number
  average_cost: number
  profit_per_unit: number
}

export interface CategoryReport {
  organization_id: string
  outlet_id: string
  date_from: string
  date_to: string
  data: CategoryDataReport[]
}

export interface CategoryDataReport {
  category_id: string
  category_name: string
  total_revenue: number
  total_quantity: number
  product_count: number
  order_count: number
}

export interface InventoryReport {
  summary: InventorySummaryReport
  products: InventoryProductReport[]
  ingredients: InventoryIngredientReport[]
}

export interface InventorySummaryReport {
  total_products: number
  total_ingredients: number
  total_value: number
  low_stock_products: number
  low_stock_ingredients: number
  zero_stock_products: number
  zero_stock_ingredients: number
  total_sold_products: number
  total_sold_ingredients: number
  outlet_id: string
  outlet_name: string
  generated_at: string
}

export interface InventoryProductReport {
  id: string
  product_id: string
  product_name: string
  category_name: string
  quantity: number
  reorder_level: number
  unit_cost: number
  total_value: number
  total_in: number
  total_out: number
  is_low_stock: boolean
  is_zero_stock: boolean
  updated_at: string
}

export interface InventoryIngredientReport {
  id: string
  ingredient_id: string
  ingredient_name: string
  unit_name: string
  quantity: number
  reorder_level: number
  unit_cost: number
  total_value: number
  total_in: number
  total_out: number
  is_low_stock: boolean
  is_zero_stock: boolean
  updated_at: string
}
