fix(employee-payroll-register): base "cəlb edilən gəlirdən" columns on ƏH

Bookkeeper clarified the contribution net-of-exemption columns should be
computed from Əsas əmək haqqı minus the exemption amount, not from
gross_pay. With no exemption the column equals the existing (ƏH) column.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-05-11 16:48:39 +00:00
parent 671b2195fe
commit 8389e8502a
1 changed files with 4 additions and 4 deletions

View File

@ -185,7 +185,6 @@ def execute(filters=None):
rate = flt(ss.exchange_rate) if currency == company_currency else 1.0
eh_amount = flt(ss_earning_map.get(ss.name, {}).get(EH_COMPONENT, 0))
mk_amount = flt(ss_earning_map.get(ss.name, {}).get(MK_COMPONENT, 0))
gross_rated = flt(ss.gross_pay) * rate
for d in DEDUCTION_TYPES:
slug = frappe.scrub(d)
spec = ded_specs.get(d)
@ -193,13 +192,14 @@ def execute(filters=None):
row[prefix + "ded_eh_" + slug] += eval_deduction(spec, eh_amount, 0, ss)
row[prefix + "ded_mk_" + slug] += eval_deduction(spec, 0, mk_amount, ss) - baseline
# Contribution recomputed on gross net of its own "cəlb olunmayan" amount.
# Contribution recomputed on Əsas əmək haqqı net of its own
# "cəlb olunmayan gəlir" amount.
exempt_field = CONTRIBUTION_EXEMPT_FIELD.get(d)
if exempt_field:
base_net = max(gross_rated - flt(ss.get(exempt_field) or 0) * rate, 0.0)
base_net = max(eh_amount - flt(ss.get(exempt_field) or 0) * rate, 0.0)
row[prefix + "ded_cg_" + slug] += eval_deduction(spec, base_net, 0, ss) - baseline
row[prefix + "gross_pay"] += gross_rated
row[prefix + "gross_pay"] += flt(ss.gross_pay) * rate
row[prefix + "total_deduction"] += flt(ss.total_deduction) * rate
row[prefix + "net_pay"] += flt(ss.net_pay) * rate