Ejemplo n.º 1
0
	def test_validation_against_leave_application_after_submit(self):
		from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list

		make_holiday_list()
		frappe.db.set_value(
			"Company", self.employee.company, "default_holiday_list", "Salary Slip Test Holiday List"
		)

		leave_allocation = create_leave_allocation(
			employee=self.employee.name, employee_name=self.employee.employee_name
		)
		leave_allocation.submit()
		self.assertTrue(leave_allocation.total_leaves_allocated, 15)

		leave_application = frappe.get_doc(
			{
				"doctype": "Leave Application",
				"employee": self.employee.name,
				"leave_type": "_Test Leave Type",
				"from_date": add_months(nowdate(), 2),
				"to_date": add_months(add_days(nowdate(), 10), 2),
				"company": self.employee.company,
				"docstatus": 1,
				"status": "Approved",
				"leave_approver": "*****@*****.**",
			}
		)
		leave_application.submit()
		leave_application.reload()

		# allocate less leaves than the ones which are already approved
		leave_allocation.new_leaves_allocated = leave_application.total_leave_days - 1
		leave_allocation.total_leaves_allocated = leave_application.total_leave_days - 1
		self.assertRaises(frappe.ValidationError, leave_allocation.submit)
Ejemplo n.º 2
0
    def test_employee_status_inactive(self):
        from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list
        from erpnext.payroll.doctype.salary_structure.salary_structure import make_salary_slip
        from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure

        employee = make_employee("*****@*****.**")
        employee_doc = frappe.get_doc("Employee", employee)
        employee_doc.status = "Inactive"
        employee_doc.save()
        employee_doc.reload()

        make_holiday_list()
        frappe.db.set_value("Company", employee_doc.company,
                            "default_holiday_list",
                            "Salary Slip Test Holiday List")

        frappe.db.sql(
            """delete from `tabSalary Structure` where name='Test Inactive Employee Salary Slip'"""
        )
        salary_structure = make_salary_structure(
            "Test Inactive Employee Salary Slip",
            "Monthly",
            employee=employee_doc.name,
            company=employee_doc.company,
        )
        salary_slip = make_salary_slip(salary_structure.name,
                                       employee=employee_doc.name)

        self.assertRaises(InactiveEmployeeStatusError, salary_slip.save)
Ejemplo n.º 3
0
    def setUp(self):
        self.employee = make_employee("*****@*****.**",
                                      company="_Test Company")
        frappe.db.delete("Attendance")

        date = getdate()
        from_date = get_year_start(date)
        to_date = get_year_ending(date)
        make_holiday_list(from_date=from_date, to_date=to_date)
Ejemplo n.º 4
0
    def setUp(self):
        frappe.db.delete("Gratuity")
        frappe.db.delete("Salary Slip")
        frappe.db.delete("Additional Salary", {"ref_doctype": "Gratuity"})

        make_earning_salary_component(setup=True,
                                      test_tax=True,
                                      company_list=["_Test Company"])
        make_deduction_salary_component(setup=True,
                                        test_tax=True,
                                        company_list=["_Test Company"])
        make_holiday_list()
Ejemplo n.º 5
0
	def setUp(self):
		from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list

		from_date = get_year_start(getdate())
		to_date = get_year_ending(getdate())
		self.holiday_list = make_holiday_list(from_date=from_date, to_date=to_date)
		frappe.db.delete("Attendance")
Ejemplo n.º 6
0
def create_employee_and_get_last_salary_slip():
	employee = make_employee("*****@*****.**", company='_Test Company')
	frappe.db.set_value("Employee", employee, "relieving_date", getdate())
	frappe.db.set_value("Employee", employee, "date_of_joining", add_days(getdate(), - (6*365)))
	if not frappe.db.exists("Salary Slip", {"employee":employee}):
		salary_slip = make_employee_salary_slip("*****@*****.**", "Monthly")
		salary_slip.submit()
		salary_slip = salary_slip.name
	else:
		salary_slip = get_last_salary_slip(employee)

	if not frappe.db.get_value("Employee", "*****@*****.**", "holiday_list"):
		from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list
		make_holiday_list()
		frappe.db.set_value("Company", '_Test Company', "default_holiday_list", "Salary Slip Test Holiday List")

	return employee, salary_slip
Ejemplo n.º 7
0
    def setUp(self):
        frappe.db.delete("Shift Type")
        frappe.db.delete("Shift Assignment")
        frappe.db.delete("Employee Checkin")

        from_date = get_year_start(getdate())
        to_date = get_year_ending(getdate())
        self.holiday_list = make_holiday_list(from_date=from_date,
                                              to_date=to_date)
Ejemplo n.º 8
0
	def setUp(self):
		frappe.db.delete("Leave Period")
		frappe.db.delete("Leave Policy Assignment")
		frappe.db.delete("Leave Allocation")
		frappe.db.delete("Leave Ledger Entry")
		frappe.db.delete("Additional Salary")
		frappe.db.delete("Leave Encashment")

		if not frappe.db.exists("Leave Type", "_Test Leave Type Encashment"):
			frappe.get_doc(test_records[2]).insert()

		date = getdate()
		year_start = getdate(get_year_start(date))
		year_end = getdate(get_year_ending(date))

		make_holiday_list("_Test Leave Encashment", year_start, year_end)

		# create the leave policy
		leave_policy = create_leave_policy(
			leave_type="_Test Leave Type Encashment", annual_allocation=10
		)
		leave_policy.submit()

		# create employee, salary structure and assignment
		self.employee = make_employee("*****@*****.**", company="_Test Company")

		self.leave_period = create_leave_period(year_start, year_end, "_Test Company")

		data = {
			"assignment_based_on": "Leave Period",
			"leave_policy": leave_policy.name,
			"leave_period": self.leave_period.name,
		}

		leave_policy_assignments = create_assignment_for_multiple_employees(
			[self.employee], frappe._dict(data)
		)

		salary_structure = make_salary_structure(
			"Salary Structure for Encashment",
			"Monthly",
			self.employee,
			other_details={"leave_encashment_amount_per_day": 50},
		)
Ejemplo n.º 9
0
    def test_no_shift_fetched_on_holiday_as_per_shift_holiday_list(self):
        date = getdate()
        from_date = get_year_start(date)
        to_date = get_year_ending(date)
        holiday_list = make_holiday_list(from_date=from_date, to_date=to_date)

        employee = make_employee("*****@*****.**",
                                 company="_Test Company")
        setup_shift_type(shift_type="Test Holiday Shift",
                         holiday_list=holiday_list)

        first_sunday = get_first_sunday(holiday_list, for_date=date)
        timestamp = datetime.combine(first_sunday, get_time("08:00:00"))
        log = make_checkin(employee, timestamp)

        self.assertIsNone(log.shift)
Ejemplo n.º 10
0
	def setUp(self):
		for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Leave Ledger Entry"]:
			frappe.db.delete(dt)

		frappe.set_user("Administrator")
		set_leave_approver()

		frappe.db.delete("Attendance", {"employee": "_T-Employee-00001"})
		frappe.db.set_value("Employee", "_T-Employee-00001", "holiday_list", "")

		from_date = get_year_start(getdate())
		to_date = get_year_ending(getdate())
		self.holiday_list = make_holiday_list(from_date=from_date, to_date=to_date)

		if not frappe.db.exists("Leave Type", "_Test Leave Type"):
			frappe.get_doc(
				dict(leave_type_name="_Test Leave Type", doctype="Leave Type", include_holiday=True)
			).insert()
	def setUp(self):
		for dt in [
			"Leave Application",
			"Leave Allocation",
			"Salary Slip",
			"Leave Ledger Entry",
			"Leave Type",
		]:
			frappe.db.delete(dt)

		frappe.set_user("Administrator")

		self.employee_id = make_employee("*****@*****.**", company="_Test Company")

		self.date = getdate()
		self.year_start = getdate(get_year_start(self.date))
		self.year_end = getdate(get_year_ending(self.date))

		self.holiday_list = make_holiday_list(
			"_Test Emp Balance Holiday List", self.year_start, self.year_end
		)
Ejemplo n.º 12
0
def create_employee_onboarding():
    applicant = get_job_applicant()
    job_offer = get_job_offer(applicant.name)

    holiday_list = make_holiday_list("_Test Employee Boarding")
    holiday_list = frappe.get_doc("Holiday List", holiday_list)
    holiday_list.holidays = []
    holiday_list.save()

    onboarding = frappe.new_doc("Employee Onboarding")
    onboarding.job_applicant = applicant.name
    onboarding.job_offer = job_offer.name
    onboarding.date_of_joining = onboarding.boarding_begins_on = getdate()
    onboarding.company = "_Test Company"
    onboarding.holiday_list = holiday_list.name
    onboarding.designation = "Researcher"
    onboarding.append(
        "activities",
        {
            "activity_name": "Assign ID Card",
            "role": "HR User",
            "required_for_employee_creation": 1,
            "begin_on": 0,
            "duration": 1,
        },
    )
    onboarding.append(
        "activities",
        {
            "activity_name": "Assign a laptop",
            "role": "HR User",
            "begin_on": 1,
            "duration": 1
        },
    )
    onboarding.status = "Pending"
    onboarding.insert()
    onboarding.submit()

    return onboarding