Skip to content

Commit

Permalink
Merge pull request #1164 from frappe/mergify/bp/version-14-hotfix/pr-…
Browse files Browse the repository at this point in the history
…1160

test(Additional Salary): Overwrite Salary Structure Amount (backport #1160)
  • Loading branch information
ruchamahabal authored Dec 11, 2023
2 parents d5cb298 + a679716 commit a9d2fe0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def validate_duplicate_additional_salary(self):
existing_additional_salary = frappe.db.exists(
"Additional Salary",
{
"name": ["!=", self.name],
"salary_component": self.salary_component,
"payroll_date": self.payroll_date,
"overwrite_salary_structure_amount": 1,
Expand Down
26 changes: 23 additions & 3 deletions hrms/payroll/doctype/additional_salary/test_additional_salary.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,38 @@ def test_non_recurring_additional_salary(self):
self.assertIsNone(amount)
self.assertIsNone(salary_component)

def test_overwrite_salary_structure_amount(self):
emp_id = make_employee("[email protected]")

# Salary Structure created with HRA Salary Component amount as 3000
salary_structure = make_salary_structure(
"Test Salary Structure Additional Salary", "Monthly", employee=emp_id
)
self.assertEqual(salary_structure.earnings[1].amount, 3000)

date = nowdate()

# this will overwrite HRA Salary Component amount as 5000
get_additional_salary(
emp_id, recurring=False, payroll_date=date, salary_component="HRA", overwrite_salary_structure=1
)
salary_slip = make_salary_slip(salary_structure.name, employee=emp_id, posting_date=date)
self.assertEqual(salary_slip.earnings[1].amount, 5000)


def get_additional_salary(emp_id, recurring=True, payroll_date=None):
def get_additional_salary(
emp_id, recurring=True, payroll_date=None, salary_component=None, overwrite_salary_structure=0
):
create_salary_component("Recurring Salary Component")
add_sal = frappe.new_doc("Additional Salary")
add_sal.employee = emp_id
add_sal.salary_component = "Recurring Salary Component"
add_sal.salary_component = salary_component or "Recurring Salary Component"

add_sal.is_recurring = 1 if recurring else 0
add_sal.from_date = add_days(nowdate(), -50)
add_sal.to_date = add_days(nowdate(), 180)
add_sal.payroll_date = payroll_date
add_sal.overwrite_salary_structure_amount = 0
add_sal.overwrite_salary_structure_amount = overwrite_salary_structure

add_sal.amount = 5000
add_sal.currency = erpnext.get_default_currency()
Expand Down

0 comments on commit a9d2fe0

Please sign in to comment.