export type PayrollImportType =
  | 'grades'
  | 'notches'
  | 'salary-structure'
  | 'allowances'
  | 'allowances-matrix'
  | 'deductions'
  | 'deductions-matrix'
  | 'salaries'
  | 'employee-grades'
  | 'bank-accounts'
  | 'pf-enrollments'
  | 'tax-reliefs';

export interface PartPayment {
  id: string;
  payroll_run_id: string;
  employee_id: string;
  employee?: {
    employee_id: string;
    staff_id: string;
    firstname: string;
    lastname: string;
  };
  payment_number: number;
  amount: string;
  payment_date: string;
  status: 'pending' | 'paid';
  created_at: string;
  updated_at: string;
}

export interface PartPaymentSummary {
  employee_count: number;
  payment_count: number;
  total_amount: number;
}

export interface CreatePartPaymentPayload {
  payroll_run_id: string;
  employee_ids?: string[];
  first_payment_date: string;
  second_payment_date: string;
  first_payment_percentage?: number;
}

export interface CreatePartPaymentResponse {
  message: string;
  data: PartPayment[];
  summary: PartPaymentSummary;
}

export interface IncrementalJumpPreviewRow {
  assignment_id: string;
  employee_id: string;
  staff_id: string | null;
  firstname: string | null;
  lastname: string | null;
  from_grade_id: string | null;
  from_grade_name: string | null;
  from_grade_code: string | null;
  from_notch_id: string | null;
  from_notch_position: number | null;
  to_grade_id: string | null;
  to_grade_name: string | null;
  to_grade_code: string | null;
  to_notch_id: string | null;
  to_notch_position: number | null;
  years_served: number | null;
  required_years: number | null;
  jump_year: number;
  is_eligible: boolean;
  ineligibility_reason: string | null;
}

export interface IncrementalJumpPreviewResponse {
  effective_date: string;
  data: IncrementalJumpPreviewRow[];
  summary: {
    total_rows: number;
    eligible_count: number;
    ineligible_count: number;
  };
}

export interface IncrementalJumpProcessPayload {
  effective_date: string;
  employee_ids?: string[];
}

export interface IncrementalJumpProcessResponse {
  message: string;
  data: {
    processed_count: number;
    processed_employee_ids: string[];
    jump_year: number;
  };
}

export interface IncrementalJumpRecord {
  id: string;
  employee_id: string;
  employee?: {
    employee_id: string;
    staff_id: string;
    firstname: string;
    lastname: string;
  };
  from_grade_id: string;
  from_grade?: {
    id: string;
    name: string;
    code: string;
  };
  from_notch_id: string;
  from_notch?: {
    id: string;
    notch_position: number;
    annual_salary: string;
  };
  to_grade_id: string;
  to_grade?: {
    id: string;
    name: string;
    code: string;
  };
  to_notch_id: string;
  to_notch?: {
    id: string;
    notch_position: number;
    annual_salary: string;
  };
  effective_date: string;
  jump_year: number;
  processed_by: string | null;
  created_at: string;
  updated_at: string;
}

export interface IncrementalJumpHistoryResponse {
  data: IncrementalJumpRecord[];
  meta: {
    current_page: number;
    last_page: number;
    per_page: number;
    total: number;
  };
}

export interface PayrollImportResponse {
  message: string;
  type: PayrollImportType;
  validate_only: boolean;
  imported_count: number;
  updated_count: number;
  failed_count: number;
  processed_count: number;
  failed_rows_file: string | null;
  failed_rows_download_url: string | null;
}

export interface PayrollImportBatchResponse {
  message: string;
  batch_id: string;
}

export interface PayrollImportBatchStatus {
  batch_id: string;
  progress: number;
  finished: boolean;
  cancelled: boolean;
  total_jobs: number;
  pending_jobs: number;
  processed_jobs: number;
  failed_jobs: number;
  imported_count?: number;
  updated_count?: number;
  failed_count?: number;
  processed_count?: number;
  failed_rows_download_url?: string | null;
  error?: string;
}
