Skip to content

Commit

Permalink
fix(Payroll JE): link employee in advance deduction entries
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Aug 15, 2023
1 parent b69a82e commit b31fdab
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions hrms/payroll/doctype/payroll_entry/payroll_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,14 @@ def get_salary_components(self, component_type):
frappe.qb.from_(ss)
.join(ssd)
.on(ss.name == ssd.parent)
.select(ssd.salary_component, ssd.amount, ssd.parentfield, ss.salary_structure, ss.employee)
.select(
ssd.salary_component,
ssd.amount,
ssd.parentfield,
ssd.additional_salary,
ss.salary_structure,
ss.employee,
)
.where((ssd.parentfield == component_type) & (ss.name.isin([d.name for d in salary_slips])))
).run(as_dict=True)

Expand Down Expand Up @@ -303,9 +310,12 @@ def get_salary_component_total(
add_component_to_accrual_jv_entry = False

if add_component_to_accrual_jv_entry:
is_advance_deduction = self.is_advance_deduction(component_type, item)

for cost_center, percentage in employee_cost_centers.items():
amount_against_cost_center = flt(item.amount) * percentage / 100
key = (item.salary_component, cost_center)
party = item.employee if is_advance_deduction else None
key = (item.salary_component, cost_center, party)
component_dict[key] = component_dict.get(key, 0) + amount_against_cost_center

if employee_wise_accounting_enabled:
Expand All @@ -317,6 +327,13 @@ def get_salary_component_total(

return account_details

def is_advance_deduction(self, component_type: str, item: dict) -> bool:
if component_type == "deductions" and item.additional_salary:
ref_doctype = frappe.db.get_value("Additional Salary", item.additional_salary, "ref_doctype")

return ref_doctype == "Employee Advance"
return False

def set_employee_based_payroll_payable_entries(
self, component_type, employee, amount, salary_structure=None
):
Expand Down Expand Up @@ -371,7 +388,7 @@ def get_account(self, component_dict=None):
account_dict = {}
for key, amount in component_dict.items():
account = self.get_salary_component_account(key[0])
accouting_key = (account, key[1])
accouting_key = (account, key[1], key[2])

account_dict[accouting_key] = account_dict.get(accouting_key, 0) + amount

Expand Down Expand Up @@ -524,6 +541,7 @@ def get_payable_amount_for_earnings_and_deductions(
precision,
entry_type="credit",
accounts=accounts,
party=acc_cc[2],
)

return payable_amount
Expand Down

0 comments on commit b31fdab

Please sign in to comment.