// Gusto API Types

export interface GustoConfig {
  apiToken: string;
  baseUrl?: string;
}

export interface GustoError {
  message: string;
  code?: string;
  status?: number;
}

// Employee Types
export interface Employee {
  id: string;
  version: string;
  first_name: string;
  middle_initial?: string;
  last_name: string;
  email?: string;
  ssn?: string;
  date_of_birth?: string;
  jobs: Job[];
  home_address?: Address;
  terminations?: Termination[];
  onboarded?: boolean;
  phone?: string;
}

export interface Job {
  id: string;
  version: string;
  employee_id: string;
  location_id?: string;
  hire_date: string;
  title: string;
  rate?: string;
  payment_unit?: 'Hour' | 'Week' | 'Month' | 'Year' | 'Paycheck';
  current_compensation_id?: string;
  compensations?: Compensation[];
}

export interface Termination {
  id: string;
  version: string;
  employee_id: string;
  active: boolean;
  effective_date: string;
  run_termination_payroll?: boolean;
}

export interface Address {
  street_1?: string;
  street_2?: string;
  city?: string;
  state?: string;
  zip?: string;
  country?: string;
}

// Company Types
export interface Company {
  id: string;
  name: string;
  trade_name?: string;
  ein?: string;
  entity_type?: string;
  company_status?: string;
  locations?: Location[];
  compensations?: Compensation[];
  primary_signatory?: Person;
  primary_payroll_admin?: Person;
}

export interface Location {
  id: string;
  version: string;
  company_id: string;
  phone_number?: string;
  street_1?: string;
  street_2?: string;
  city?: string;
  state?: string;
  zip?: string;
  country?: string;
}

export interface Department {
  id: string;
  version: string;
  title: string;
}

export interface Person {
  first_name: string;
  last_name: string;
  email: string;
}

// Payroll Types
export interface Payroll {
  id: string;
  version: string;
  company_id: string;
  payroll_deadline: string;
  processed: boolean;
  processed_date?: string;
  check_date: string;
  pay_period: PayPeriod;
  totals?: PayrollTotals;
  employee_compensations?: EmployeeCompensation[];
  calculated_at?: string;
}

export interface PayPeriod {
  start_date: string;
  end_date: string;
}

export interface PayrollTotals {
  company_debit: string;
  reimbursements: string;
  net_pay: string;
  gross_pay: string;
  employer_taxes: string;
  employee_taxes: string;
  benefits: string;
}

export interface EmployeeCompensation {
  employee_id: string;
  fixed_compensations?: FixedCompensation[];
  hourly_compensations?: HourlyCompensation[];
  paid_time_off?: PaidTimeOff[];
}

export interface FixedCompensation {
  name: string;
  amount: string;
  job_id: string;
}

export interface HourlyCompensation {
  name: string;
  hours: string;
  job_id: string;
  compensation_multiplier?: number;
}

export interface PaidTimeOff {
  name: string;
  hours: string;
}

// Compensation Types
export interface Compensation {
  id: string;
  version: string;
  job_id: string;
  rate: string;
  payment_unit: 'Hour' | 'Week' | 'Month' | 'Year' | 'Paycheck';
  flsa_status?: 'Exempt' | 'Nonexempt';
  effective_date: string;
}

// Benefits Types
export interface CompanyBenefit {
  id: string;
  version: string;
  company_id: string;
  benefit_type: string;
  active: boolean;
  description?: string;
  responsible_for_employer_taxes?: boolean;
  responsible_for_employee_w2?: boolean;
}

export interface EmployeeBenefit {
  id: string;
  version: string;
  employee_id: string;
  company_benefit_id: string;
  active: boolean;
  employee_deduction?: string;
  company_contribution?: string;
  employee_deduction_annual_maximum?: string;
  company_contribution_annual_maximum?: string;
  limit_option?: string;
  deduct_as_percentage?: boolean;
  contribute_as_percentage?: boolean;
  catch_up?: boolean;
  coverage_amount?: string;
  coverage_salary_multiplier?: string;
}

// Time Off Types
export interface TimeOffPolicy {
  id: string;
  name: string;
  policy_type: string;
  accrual_unit: string;
  accrual_rate?: string;
  accrual_balance?: string;
  maximum_accrual_balance?: string;
  paid?: boolean;
}

export interface TimeOffBalance {
  employee_id: string;
  policy_id: string;
  balance: string;
  accrued_balance?: string;
}

export interface TimeOffRequest {
  id: string;
  employee_id: string;
  policy_id: string;
  request_date: string;
  start_date: string;
  end_date: string;
  status: 'pending' | 'approved' | 'denied';
  hours?: string;
  note?: string;
}

// Tax Types
export interface FederalTax {
  version: string;
  employee_id: string;
  filing_status?: string;
  allowances?: number;
  extra_withholding?: string;
  two_jobs?: boolean;
  dependents_amount?: string;
  other_income?: string;
  deductions?: string;
}

export interface StateTax {
  version: string;
  employee_id: string;
  state: string;
  filing_status?: string;
  allowances?: number;
  extra_withholding?: string;
  supplemental_withholding?: string;
}

// Contractor Types
export interface Contractor {
  id: string;
  version: string;
  first_name: string;
  last_name: string;
  middle_initial?: string;
  email?: string;
  company_id: string;
  self_onboarding?: boolean;
  onboarded?: boolean;
  start_date?: string;
  business_name?: string;
  ein?: string;
  ssn?: string;
  is_active?: boolean;
}

export interface ContractorPayment {
  id: string;
  contractor_id: string;
  wage: string;
  hours?: string;
  bonus?: string;
  reimbursement?: string;
  date: string;
  payment_method?: string;
}

// Garnishment Types
export interface Garnishment {
  id: string;
  version: string;
  employee_id: string;
  active: boolean;
  amount: string;
  description?: string;
  court_ordered?: boolean;
  times?: number;
  recurring?: boolean;
  annual_maximum?: string;
  pay_period_maximum?: string;
  deduct_as_percentage?: boolean;
}

// Bank Account Types
export interface BankAccount {
  id: string;
  name?: string;
  account_number: string;
  routing_number: string;
  account_type: 'Checking' | 'Savings';
  verification_status?: 'awaiting_deposits' | 'ready_for_verification' | 'verified';
}

// Pagination
export interface PaginationParams {
  page?: number;
  per?: number;
}

export interface PaginatedResponse<T> {
  data: T[];
  page: number;
  per: number;
  total_pages?: number;
  total_count?: number;
}
