-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from frappe/mergify/bp/version-14-hotfix/pr-…
…1160 test(Additional Salary): Overwrite Salary Structure Amount (backport #1160)
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
|