-- Employee-specific deductions: damages, missing items, penalties, etc.
CREATE TABLE IF NOT EXISTS `payroll_employee_deductions` (
  `ded_id` int(11) NOT NULL AUTO_INCREMENT,
  `employee_id` int(11) NOT NULL,
  `deduction_type` enum('Damages','Missing','Penalty','Other') NOT NULL DEFAULT 'Other',
  `description` varchar(255) NOT NULL DEFAULT '',
  `amount` decimal(14,2) NOT NULL DEFAULT 0.00,
  `incident_date` date DEFAULT NULL,
  `payroll_run_id` int(11) DEFAULT NULL,
  `status` enum('pending','applied','cancelled') NOT NULL DEFAULT 'pending',
  `recorded_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`ded_id`),
  KEY `employee_id` (`employee_id`),
  KEY `payroll_run_id` (`payroll_run_id`),
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
