mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 00:01:18 +00:00
fix: test Payroll Entry
This commit is contained in:
@@ -14,6 +14,7 @@ from erpnext.payroll.doctype.salary_slip.test_salary_slip import get_salary_comp
|
||||
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure, create_salary_structure_assignment
|
||||
from erpnext.loan_management.doctype.loan.test_loan import create_loan, make_loan_disbursement_entry, create_loan_type, create_loan_accounts
|
||||
from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import process_loan_interest_accrual_for_term_loans
|
||||
from erpnext.payroll.doctype.salary_slip.test_salary_slip import get_salary_component_for_overtime
|
||||
|
||||
test_dependencies = ['Holiday List']
|
||||
|
||||
@@ -21,6 +22,9 @@ class TestPayrollEntry(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", '_Test Holiday List')
|
||||
frappe.db.set_value("Payroll Settings", None, "overtime_salary_component", "Overtime Allowance")
|
||||
get_salary_component_for_overtime()
|
||||
|
||||
|
||||
def setUp(self):
|
||||
for dt in ["Salary Slip", "Salary Component", "Salary Component Account",
|
||||
|
||||
@@ -610,8 +610,10 @@ class SalarySlip(TransactionBase):
|
||||
frappe.bold("Overtime Salary Component"), frappe.bold("Payroll Settings")
|
||||
))
|
||||
else:
|
||||
component_data = frappe._dict(get_salary_component_data(overtime_salary_component) or {})
|
||||
component_data.salary_component = overtime_salary_component
|
||||
self.update_component_row(
|
||||
get_salary_component_data(overtime_salary_component),
|
||||
component_data,
|
||||
sum(amounts),
|
||||
'earnings',
|
||||
processed_overtime_slips = processed_overtime_slips
|
||||
|
||||
@@ -474,7 +474,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
frappe.db.set_value("Payroll Settings", None, "overtime_based_on", "Attendance")
|
||||
frappe.db.set_value("Payroll Settings", None, "fetch_standard_working_hours_from_shift_type", 0)
|
||||
self.get_salary_component_for_overtime()
|
||||
get_salary_component_for_overtime()
|
||||
frappe.db.set_value("Payroll Settings", None, "overtime_salary_component", "Overtime Allowance")
|
||||
|
||||
overtime_type = create_overtime_type(employee = employee).name
|
||||
@@ -505,17 +505,6 @@ class TestSalarySlip(unittest.TestCase):
|
||||
# formula = sum(applicable_component)/(working_days)/ daily_standard_working_time * overtime hours * multiplier
|
||||
self.assertEquals(flt(overtime_amount, 2), flt(overtime_component_details.amount, 2))
|
||||
|
||||
def get_salary_component_for_overtime(self):
|
||||
component = [{
|
||||
"salary_component": 'Overtime Allowance',
|
||||
"abbr":'OA',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 0
|
||||
}]
|
||||
|
||||
company = erpnext.get_default_company()
|
||||
make_salary_component(component, test_tax = 0, company_list=[company])
|
||||
|
||||
def make_activity_for_employee(self):
|
||||
activity_type = frappe.get_doc("Activity Type", "_Test Activity Type")
|
||||
activity_type.billing_rate = 50
|
||||
@@ -531,6 +520,17 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
return [no_of_days_in_month[1], no_of_holidays_in_month]
|
||||
|
||||
def get_salary_component_for_overtime():
|
||||
component = [{
|
||||
"salary_component": 'Overtime Allowance',
|
||||
"abbr":'OA',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 0
|
||||
}]
|
||||
|
||||
company = erpnext.get_default_company()
|
||||
make_salary_component(component, test_tax = 0, company_list=[company])
|
||||
|
||||
def make_employee_salary_slip(user, payroll_frequency, salary_structure=None):
|
||||
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure
|
||||
|
||||
|
||||
@@ -127,7 +127,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(hours=3),
|
||||
"company": "_Test Company"
|
||||
"company": "_Test Company",
|
||||
"hours": 3
|
||||
}
|
||||
)
|
||||
timesheet.append(
|
||||
@@ -137,7 +138,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(hours=3),
|
||||
"company": "_Test Company"
|
||||
"company": "_Test Company",
|
||||
"hours": 3
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user