• Mahmoud Aglan's avatar
    fix(hr): payroll posted nothing — the handler had the schema wrong three ways · 7313a539
    Mahmoud Aglan authored
    onPayrollPaid read total_gross and total_net off hr_payroll_runs and grouped
    hr_payroll_components_log by component_type. None of those columns exist:
    
      hr_payroll_runs          has gross_earnings / net_salary
      hr_payroll_components_log has `type`, not component_type
      hr_payroll_periods        has period_code, not period_name
    
    Confirmed with SHOW COLUMNS on the live database. The handler threw "Unknown
    column" on its first query, and the listener only logs, so payroll silently
    posted NOTHING — no salary expense, no employer insurance share, no withheld
    tax anywhere in the ledger.
    
    It also had the grain wrong. PayrollController dispatches hr.payroll.paid once
    PER EMPLOYEE; an hr_payroll_runs row is a single payslip, not a whole run, and
    the period lives in hr_payroll_periods. Every amount needed is on the payslip.
    
    Rewritten against the real schema:
    
      Dr Salary Expense              gross_earnings
      Dr Employer Insurance Expense  insurance_employer
      Cr Bank                        net_salary
      Cr Insurance Payable           insurance_employee + insurance_employer
      Cr Tax Payable                 tax_amount
      Cr Employee Loans              loan_deduction
      Cr Other Deductions Payable    penalty + absence + other
    
    Balances by construction: the payslip satisfies gross - total_deductions = net
    and the deduction buckets sum to total_deductions. Verified on all three live
    payslips — e.g. run 1: Dr 15,000.00 + 2,362.50 = Cr 4,402.20 + 3,748.50 +
    9,211.80 = 17,362.50.
    
    A salary-deducted loan instalment credits the employee-advances receivable
    rather than being treated as income. Penalties and absence deductions are parked
    in accrued expenses and registered as a configurable pointer, because whether
    they belong there or as a reduction of salary expense is a decision for the
    accountants, not a constant in code.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    7313a539
Name
Last commit
Last update
..
Academies Loading commit data...
AcademyContracts Loading commit data...
AccessMatrix Loading commit data...
Accounting Loading commit data...
Achievements Loading commit data...
ActivitySubscriptions Loading commit data...
Alerts Loading commit data...
Archive Loading commit data...
Audit Loading commit data...
Auth Loading commit data...
Branches Loading commit data...
Carnets Loading commit data...
Cashier Loading commit data...
Children Loading commit data...
Coaches Loading commit data...
Dashboard Loading commit data...
Death Loading commit data...
Disciplines Loading commit data...
Divorce Loading commit data...
Documents Loading commit data...
Facilities Loading commit data...
FacilityDashboards Loading commit data...
FacilityGrids Loading commit data...
Fines Loading commit data...
Foreign Loading commit data...
Forms Loading commit data...
HR Loading commit data...
Honorary Loading commit data...
Installments Loading commit data...
Interviews Loading commit data...
Inventory Loading commit data...
MatchCenter Loading commit data...
MedicalBoard Loading commit data...
Members Loading commit data...
News Loading commit data...
Notifications Loading commit data...
ParentPortal Loading commit data...
Payments Loading commit data...
PlayerAffairs Loading commit data...
PlayerApi Loading commit data...
PlayerAuth Loading commit data...
PlaygroundAdmin Loading commit data...
PoolManagement Loading commit data...
Pricing Loading commit data...
Procurement Loading commit data...
Receipts Loading commit data...
Rentals Loading commit data...
Reports Loading commit data...
Reservations Loading commit data...
Roles Loading commit data...
Rules Loading commit data...
Sales Loading commit data...
Scheduling Loading commit data...
Seasonal Loading commit data...
ServiceCatalog Loading commit data...
Sessions Loading commit data...
Settings Loading commit data...
Sports Loading commit data...
SportsActivity Loading commit data...
SportsDashboard Loading commit data...
Spouses Loading commit data...
Subscriptions Loading commit data...
Support Loading commit data...
Temporary Loading commit data...
Tournaments Loading commit data...
TrainerPortal Loading commit data...
Training Loading commit data...
TrainingGroups Loading commit data...
Transfers Loading commit data...
Treasury Loading commit data...
Tutorials Loading commit data...
Users Loading commit data...
Waiver Loading commit data...
Workflow Loading commit data...