Commit 982aa243 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(hr): use correct column references in getComprehensiveSalary query

calculation_type lives on hr_salary_components (sc), not hr_employee_salary_details (sd).
Also fixed sc.component_type → sc.type to match actual DB schema.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 919975e2
...@@ -201,14 +201,14 @@ class HrEmployeeProfile extends Model ...@@ -201,14 +201,14 @@ class HrEmployeeProfile extends Model
$earningsSum = $db->selectOne( $earningsSum = $db->selectOne(
"SELECT COALESCE(SUM( "SELECT COALESCE(SUM(
CASE CASE
WHEN sd.calculation_type = 'fixed' THEN sd.amount WHEN sc.calculation_type = 'fixed' THEN sd.amount
WHEN sd.calculation_type = 'percentage' THEN (? * sd.amount / 100) WHEN sc.calculation_type = 'percentage' THEN (? * COALESCE(sd.percentage, sd.amount) / 100)
ELSE 0 ELSE sd.amount
END END
), 0) as total ), 0) as total
FROM hr_employee_salary_details sd FROM hr_employee_salary_details sd
JOIN hr_salary_components sc ON sc.id = sd.component_id JOIN hr_salary_components sc ON sc.id = sd.component_id
WHERE sd.employee_profile_id = ? AND sc.component_type = 'earning' AND sd.is_active = 1", WHERE sd.employee_profile_id = ? AND sc.type = 'earning' AND sd.is_active = 1",
[$basicSalary, $profileId] [$basicSalary, $profileId]
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment