export type ExportStatus = 'Success' | 'Failed' | 'Partial' | 'Pending';
export type EmploymentStatus = 'Active' | 'On Leave' | 'Terminated';
export type VariableType = 'New Hire' | 'Termination' | 'Salary Adjustment' | 'Grade Change' | 'Leave Without Pay' | 'Bonus' | 'Commission' | 'Overtime' | 'Advance Recovery';
export type ValidationStatus = 'Pass' | 'Fail' | 'Warning';

export interface PayrollEmployee {
  id: string;
  fullName: string;
  department: string;
  position: string;
  grade: string;
  status: EmploymentStatus;
  joiningDate: string;
  confirmationDate: string;
  bankName: string;
  accountNumber: string;
  branchCode: string;
  tin: string;
  nationalId: string;
  basicSalary: number;
  housingAllowance: number;
  transportAllowance: number;
  otherAllowances: { name: string; amount: number }[];
  deductions: { name: string; amount: number }[];
  effectiveDate: string;
}

export interface MonthlyVariable {
  id: string;
  employeeId: string;
  employeeName: string;
  type: VariableType;
  amount: number;
  description: string;
  effectiveDate: string;
  status: 'Pending' | 'Included' | 'Excluded';
}

export interface ExportLog {
  id: string;
  exportDate: string;
  exportedBy: string;
  month: string;
  totalRecords: number;
  successRecords: number;
  failedRecords: number;
  status: ExportStatus;
  fileName: string;
  fileSize: string;
  checksum: string;
  method: 'File-Based' | 'API';
}

export interface ValidationResult {
  employeeId: string;
  employeeName: string;
  field: string;
  issue: string;
  status: ValidationStatus;
}

export interface PayrollConfirmation {
  id: string;
  payrollRunDate: string;
  processedBy: string;
  totalEmployees: number;
  totalAmount: number;
  rejectedRecords: number;
  month: string;
  glCode: string;
  status: 'Processed' | 'Pending' | 'Reconciled';
}

export const payrollEmployees: PayrollEmployee[] = [
  {
    id: 'EMP-00101', fullName: 'Alice Wanjiru Kamau', department: 'Finance', position: 'Senior Accountant',
    grade: 'G5', status: 'Active', joiningDate: '2019-03-15', confirmationDate: '2019-09-15',
    bankName: 'Equity Bank', accountNumber: '0123456789', branchCode: 'EQ-001',
    tin: 'A002345678', nationalId: 'KE-12345678',
    basicSalary: 95000, housingAllowance: 28500, transportAllowance: 9500,
    otherAllowances: [{ name: 'Medical Allowance', amount: 8000 }, { name: 'Airtime', amount: 2000 }],
    deductions: [{ name: 'Loan Repayment', amount: 12000 }, { name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00102', fullName: 'Brian Odhiambo Otieno', department: 'ICT', position: 'Systems Administrator',
    grade: 'G4', status: 'Active', joiningDate: '2020-07-01', confirmationDate: '2021-01-01',
    bankName: 'KCB Bank', accountNumber: '9876543210', branchCode: 'KCB-012',
    tin: 'B009876543', nationalId: 'KE-87654321',
    basicSalary: 78000, housingAllowance: 23400, transportAllowance: 7800,
    otherAllowances: [{ name: 'Telephone Allowance', amount: 3000 }],
    deductions: [{ name: 'Insurance Premium', amount: 5500 }, { name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00103', fullName: 'Catherine Njeri Mwangi', department: 'HR', position: 'HR Manager',
    grade: 'G6', status: 'Active', joiningDate: '2017-05-10', confirmationDate: '2017-11-10',
    bankName: 'NCBA Bank', accountNumber: '1122334455', branchCode: 'NCBA-007',
    tin: 'C001122334', nationalId: 'KE-11223344',
    basicSalary: 125000, housingAllowance: 37500, transportAllowance: 12500,
    otherAllowances: [{ name: 'Medical Allowance', amount: 10000 }, { name: 'Entertainment', amount: 5000 }],
    deductions: [{ name: 'Union Fees', amount: 1200 }, { name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00104', fullName: 'David Mwenda Kariuki', department: 'Operations', position: 'Operations Officer',
    grade: 'G3', status: 'On Leave', joiningDate: '2022-02-14', confirmationDate: '2022-08-14',
    bankName: 'Cooperative Bank', accountNumber: '5544332211', branchCode: 'COOP-003',
    tin: 'D005544332', nationalId: 'KE-55443322',
    basicSalary: 55000, housingAllowance: 16500, transportAllowance: 5500,
    otherAllowances: [{ name: 'Airtime', amount: 1500 }],
    deductions: [{ name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00105', fullName: 'Esther Akinyi Ouma', department: 'Credit', position: 'Credit Analyst',
    grade: 'G4', status: 'Active', joiningDate: '2021-09-01', confirmationDate: '2022-03-01',
    bankName: 'Stanbic Bank', accountNumber: '6677889900', branchCode: 'STAN-005',
    tin: 'E006677889', nationalId: 'KE-66778899',
    basicSalary: 72000, housingAllowance: 21600, transportAllowance: 7200,
    otherAllowances: [{ name: 'Medical Allowance', amount: 6000 }],
    deductions: [{ name: 'Loan Repayment', amount: 8500 }, { name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00106', fullName: 'Francis Kipchoge Mutai', department: 'Field Operations', position: 'Field Officer',
    grade: 'G2', status: 'Active', joiningDate: '2023-04-03', confirmationDate: '2023-10-03',
    bankName: 'Family Bank', accountNumber: '3344556677', branchCode: 'FAM-009',
    tin: 'F003344556', nationalId: 'KE-33445566',
    basicSalary: 38000, housingAllowance: 11400, transportAllowance: 3800,
    otherAllowances: [{ name: 'Field Allowance', amount: 4000 }],
    deductions: [{ name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00107', fullName: 'Grace Wambui Ndungu', department: 'Legal', position: 'Legal Officer',
    grade: 'G5', status: 'Active', joiningDate: '2018-11-20', confirmationDate: '2019-05-20',
    bankName: 'Barclays Kenya', accountNumber: '7788990011', branchCode: 'BAR-002',
    tin: 'G007788990', nationalId: 'KE-77889900',
    basicSalary: 88000, housingAllowance: 26400, transportAllowance: 8800,
    otherAllowances: [{ name: 'Professional Allowance', amount: 7000 }, { name: 'Airtime', amount: 2000 }],
    deductions: [{ name: 'Insurance Premium', amount: 7000 }, { name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
  {
    id: 'EMP-00108', fullName: 'Hassan Omar Abdi', department: 'Finance', position: 'Finance Officer',
    grade: 'G3', status: 'Active', joiningDate: '2022-06-15', confirmationDate: '2022-12-15',
    bankName: 'Gulf African Bank', accountNumber: '9900112233', branchCode: 'GAB-006',
    tin: 'H009900112', nationalId: 'KE-99001122',
    basicSalary: 52000, housingAllowance: 15600, transportAllowance: 5200,
    otherAllowances: [{ name: 'Airtime', amount: 1500 }],
    deductions: [{ name: 'NHIF', amount: 1700 }, { name: 'NSSF', amount: 2160 }],
    effectiveDate: '2025-01-01',
  },
];

export const monthlyVariables: MonthlyVariable[] = [
  { id: 'MV-001', employeeId: 'EMP-00109', employeeName: 'Irene Chebet Koech', type: 'New Hire', amount: 45000, description: 'Prorated salary – joined Apr 14 (effective mid-month)', effectiveDate: '2026-04-14', status: 'Pending' },
  { id: 'MV-002', employeeId: 'EMP-00103', employeeName: 'Catherine Njeri Mwangi', type: 'Bonus', amount: 25000, description: 'Q1 2026 performance bonus – Outstanding rating', effectiveDate: '2026-04-01', status: 'Included' },
  { id: 'MV-003', employeeId: 'EMP-00104', employeeName: 'David Mwenda Kariuki', type: 'Leave Without Pay', amount: 3667, description: '2 days unpaid leave deduction (KES 55,000 ÷ 30)', effectiveDate: '2026-04-05', status: 'Included' },
  { id: 'MV-004', employeeId: 'EMP-00105', employeeName: 'Esther Akinyi Ouma', type: 'Salary Adjustment', amount: 78000, description: 'Annual increment – from KES 72,000 to KES 78,000', effectiveDate: '2026-04-01', status: 'Included' },
  { id: 'MV-005', employeeId: 'EMP-00102', employeeName: 'Brian Odhiambo Otieno', type: 'Overtime', amount: 6500, description: '13 hours approved OT (Rate: KES 500/hr)', effectiveDate: '2026-04-30', status: 'Pending' },
  { id: 'MV-006', employeeId: 'EMP-00101', employeeName: 'Alice Wanjiru Kamau', type: 'Advance Recovery', amount: 15000, description: 'Emergency salary advance recovery – Month 2 of 3', effectiveDate: '2026-04-30', status: 'Included' },
  { id: 'MV-007', employeeId: 'EMP-00107', employeeName: 'Grace Wambui Ndungu', type: 'Commission', amount: 12000, description: 'Q1 2026 contract completion commission', effectiveDate: '2026-04-15', status: 'Pending' },
  { id: 'MV-008', employeeId: 'EMP-00110', employeeName: 'James Kibet Rono', type: 'Termination', amount: 0, description: 'Last working day: April 10 – Final settlement required', effectiveDate: '2026-04-10', status: 'Included' },
  { id: 'MV-009', employeeId: 'EMP-00106', employeeName: 'Francis Kipchoge Mutai', type: 'Grade Change', amount: 55000, description: 'Promoted to G3 – new basic salary effective April 1', effectiveDate: '2026-04-01', status: 'Included' },
];

export const exportLogs: ExportLog[] = [
  { id: 'EXP-001', exportDate: '2026-03-25 09:14:32', exportedBy: 'Catherine Njeri', month: '2026-03', totalRecords: 87, successRecords: 87, failedRecords: 0, status: 'Success', fileName: 'Payroll_20260325_091432.csv', fileSize: '342 KB', checksum: 'a3f4e8c1d9b7...', method: 'File-Based' },
  { id: 'EXP-002', exportDate: '2026-02-24 10:05:11', exportedBy: 'Catherine Njeri', month: '2026-02', totalRecords: 85, successRecords: 84, failedRecords: 1, status: 'Partial', fileName: 'Payroll_20260224_100511.csv', fileSize: '338 KB', checksum: 'b7d2f1a4e6c9...', method: 'File-Based' },
  { id: 'EXP-003', exportDate: '2026-01-25 08:47:20', exportedBy: 'Admin User', month: '2026-01', totalRecords: 84, successRecords: 84, failedRecords: 0, status: 'Success', fileName: 'Payroll_20260125_084720.csv', fileSize: '335 KB', checksum: 'c1e9a6f3b8d4...', method: 'API' },
  { id: 'EXP-004', exportDate: '2025-12-24 14:22:05', exportedBy: 'Catherine Njeri', month: '2025-12', totalRecords: 83, successRecords: 81, failedRecords: 2, status: 'Partial', fileName: 'Payroll_20251224_142205.csv', fileSize: '331 KB', checksum: 'd5c2b9e7a1f6...', method: 'File-Based' },
  { id: 'EXP-005', exportDate: '2025-11-25 09:58:43', exportedBy: 'Admin User', month: '2025-11', totalRecords: 83, successRecords: 83, failedRecords: 0, status: 'Success', fileName: 'Payroll_20251125_095843.csv', fileSize: '329 KB', checksum: 'e8f4d1c5a2b7...', method: 'File-Based' },
];

export const validationResults: ValidationResult[] = [
  { employeeId: 'EMP-00104', employeeName: 'David Mwenda Kariuki', field: 'Employment Status', issue: 'Employee on leave – verify LWOP days before export', status: 'Warning' },
  { employeeId: 'EMP-00110', employeeName: 'James Kibet Rono', field: 'Termination Date', issue: 'Termination date April 10 – ensure final settlement computed', status: 'Warning' },
  { employeeId: 'EMP-00109', employeeName: 'Irene Chebet Koech', field: 'Salary (Prorated)', issue: 'New hire mid-month – prorated amount should be KES 22,500', status: 'Warning' },
  { employeeId: 'EMP-00101', employeeName: 'Alice Wanjiru Kamau', field: 'Bank Account', issue: 'Bank account verified and active', status: 'Pass' },
  { employeeId: 'EMP-00102', employeeName: 'Brian Odhiambo Otieno', field: 'TIN Number', issue: 'TIN format validated successfully', status: 'Pass' },
  { employeeId: 'EMP-00103', employeeName: 'Catherine Njeri Mwangi', field: 'All Fields', issue: 'All mandatory fields complete', status: 'Pass' },
];

export const payrollConfirmations: PayrollConfirmation[] = [
  { id: 'PCR-001', payrollRunDate: '2026-03-28', processedBy: 'Payroll System v3.2', totalEmployees: 87, totalAmount: 7842500, rejectedRecords: 0, month: '2026-03', glCode: 'GL-5001-SALARY', status: 'Reconciled' },
  { id: 'PCR-002', payrollRunDate: '2026-02-27', processedBy: 'Payroll System v3.2', totalEmployees: 84, totalAmount: 7610200, rejectedRecords: 1, month: '2026-02', glCode: 'GL-5001-SALARY', status: 'Reconciled' },
  { id: 'PCR-003', payrollRunDate: '2026-01-28', processedBy: 'Payroll System v3.2', totalEmployees: 84, totalAmount: 7588400, rejectedRecords: 0, month: '2026-01', glCode: 'GL-5001-SALARY', status: 'Reconciled' },
];

export const csvSampleRows = [
  { employee_id: 'EMP-00101', full_name: 'Alice Wanjiru Kamau', department: 'Finance', grade: 'G5', status: 'Active', basic_salary: '95000.00', housing_allowance: '28500.00', transport_allowance: '9500.00', other_allowances: '10000.00', total_deductions: '15860.00', leave_without_pay_days: '0', overtime_hours: '0', salary_deduction: '0.00', bonus: '0.00', advance_recovery: '15000.00', effective_month: '2026-04' },
  { employee_id: 'EMP-00102', full_name: 'Brian Odhiambo Otieno', department: 'ICT', grade: 'G4', status: 'Active', basic_salary: '78000.00', housing_allowance: '23400.00', transport_allowance: '7800.00', other_allowances: '3000.00', total_deductions: '9360.00', leave_without_pay_days: '0', overtime_hours: '13', salary_deduction: '0.00', bonus: '0.00', advance_recovery: '0.00', effective_month: '2026-04' },
  { employee_id: 'EMP-00103', full_name: 'Catherine Njeri Mwangi', department: 'HR', grade: 'G6', status: 'Active', basic_salary: '125000.00', housing_allowance: '37500.00', transport_allowance: '12500.00', other_allowances: '15000.00', total_deductions: '5060.00', leave_without_pay_days: '0', overtime_hours: '0', salary_deduction: '0.00', bonus: '25000.00', advance_recovery: '0.00', effective_month: '2026-04' },
  { employee_id: 'EMP-00104', full_name: 'David Mwenda Kariuki', department: 'Operations', grade: 'G3', status: 'On Leave', basic_salary: '55000.00', housing_allowance: '16500.00', transport_allowance: '5500.00', other_allowances: '1500.00', total_deductions: '7527.00', leave_without_pay_days: '2', overtime_hours: '0', salary_deduction: '0.00', bonus: '0.00', advance_recovery: '0.00', effective_month: '2026-04' },
];
