/**
 * Dummy Taxes Report Data
 * Structure matches /woonoow/v1/analytics/taxes API response
 */

export interface TaxesOverview {
  total_tax: number;
  avg_tax_per_order: number;
  orders_with_tax: number;
  change_percent: number;
}

export interface TaxByRate {
  rate_id: number;
  rate: string;
  percentage: number;
  orders: number;
  tax_amount: number;
}

export interface TaxByLocation {
  country: string;
  country_name: string;
  state: string;
  state_name: string;
  orders: number;
  tax_amount: number;
  percentage: number;
}

export interface TaxChartData {
  date: string;
  tax: number;
  orders: number;
}

export interface TaxesData {
  overview: TaxesOverview;
  by_rate: TaxByRate[];
  by_location: TaxByLocation[];
  chart_data: TaxChartData[];
}

// Generate 30 days of tax data
const generateChartData = (): TaxChartData[] => {
  const data: TaxChartData[] = [];
  const today = new Date();
  
  for (let i = 29; i >= 0; i--) {
    const date = new Date(today);
    date.setDate(date.getDate() - i);
    
    const orders = Math.floor(30 + Math.random() * 30);
    const avgOrderValue = 250000 + Math.random() * 300000;
    const tax = orders * avgOrderValue * 0.11;
    
    data.push({
      date: date.toISOString().split('T')[0],
      tax: Math.round(tax),
      orders,
    });
  }
  
  return data;
};

export const DUMMY_TAXES_DATA: TaxesData = {
  overview: {
    total_tax: 37922500,
    avg_tax_per_order: 30534,
    orders_with_tax: 1242,
    change_percent: 15.3,
  },
  by_rate: [
    {
      rate_id: 1,
      rate: 'PPN 11%',
      percentage: 11.0,
      orders: 1242,
      tax_amount: 37922500,
    },
  ],
  by_location: [
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'JK',
      state_name: 'DKI Jakarta',
      orders: 486,
      tax_amount: 14850000,
      percentage: 39.2,
    },
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'JB',
      state_name: 'Jawa Barat',
      orders: 324,
      tax_amount: 9900000,
      percentage: 26.1,
    },
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'JT',
      state_name: 'Jawa Tengah',
      orders: 186,
      tax_amount: 5685000,
      percentage: 15.0,
    },
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'JI',
      state_name: 'Jawa Timur',
      orders: 124,
      tax_amount: 3792250,
      percentage: 10.0,
    },
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'BT',
      state_name: 'Banten',
      orders: 74,
      tax_amount: 2263875,
      percentage: 6.0,
    },
    {
      country: 'ID',
      country_name: 'Indonesia',
      state: 'YO',
      state_name: 'DI Yogyakarta',
      orders: 48,
      tax_amount: 1467375,
      percentage: 3.9,
    },
  ],
  chart_data: generateChartData(),
};
