• 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
.claude Loading commit data...
Another ERP that we may want to cheat from Loading commit data...
HR requests Loading commit data...
Proposal Loading commit data...
Server Connection Data Loading commit data...
app Loading commit data...
config Loading commit data...
cron Loading commit data...
database Loading commit data...
docker Loading commit data...
docs Loading commit data...
public Loading commit data...
support_tickets_downloads/support_screenshots Loading commit data...
tests Loading commit data...
tools Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.env Loading commit data...
.env.example Loading commit data...
.gitignore Loading commit data...
.php-cs-fixer.php Loading commit data...
BalanceSheet.html Loading commit data...
CLAUDE.md Loading commit data...
Dockerfile Loading commit data...
Makefile Loading commit data...
SYSTEM_MAP.md Loading commit data...
Sports Module System Design DETAILED.md Loading commit data...
UPGRADE_PLAN.md Loading commit data...
captain-definition Loading commit data...
cli.php Loading commit data...
composer.json Loading commit data...
composer.lock Loading commit data...
interesting_features.md Loading commit data...
phpstan.neon Loading commit data...
phpunit.xml Loading commit data...
sports activity stuff .txt Loading commit data...
sports-activity-alignment-plan.md Loading commit data...
sports-activity-smart-filtering-plan.md Loading commit data...
trial_balance_2026-01-01_to_2026-05-10.csv Loading commit data...