示例#1
0
 def setUpClass(cls):
     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'])
示例#2
0
	def setUp(self):
		for dt in ["Salary Slip", "Salary Component", "Salary Component Account",
			"Payroll Entry", "Salary Structure", "Salary Structure Assignment", "Payroll Employee Detail", "Additional Salary"]:
				frappe.db.sql("delete from `tab%s`" % dt)

		make_earning_salary_component(setup=True, company_list=["_Test Company"])
		make_deduction_salary_component(setup=True, test_tax=False, company_list=["_Test Company"])

		frappe.db.set_value("Payroll Settings", None, "email_salary_slip_to_employee", 0)
示例#3
0
    def setUp(self):
        frappe.db.delete("Gratuity")
        frappe.db.delete("Additional Salary", {"ref_doctype": "Gratuity"})

        make_earning_salary_component(setup=True,
                                      test_tax=True,
                                      company_list=["_Test Company"],
                                      include_flexi_benefits=True)
        make_deduction_salary_component(setup=True,
                                        test_tax=True,
                                        company_list=["_Test Company"])
示例#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()
示例#5
0
def make_salary_structure(salary_structure, payroll_frequency, employee=None, dont_submit=False, other_details=None,
	test_tax=False, company=None):
	if test_tax:
		frappe.db.sql("""delete from `tabSalary Structure` where name=%s""",(salary_structure))

	if not frappe.db.exists('Salary Structure', salary_structure):
		details = {
			"doctype": "Salary Structure",
			"name": salary_structure,
			"company": company or erpnext.get_default_company(),
			"earnings": make_earning_salary_component(test_tax=test_tax, company_list=["_Test Company"]),
			"deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]),
			"payroll_frequency": payroll_frequency,
			"payment_account": get_random("Account")
		}
		if other_details and isinstance(other_details, dict):
			details.update(other_details)
		salary_structure_doc = frappe.get_doc(details)
		salary_structure_doc.insert()
		if not dont_submit:
			salary_structure_doc.submit()

	else:
		salary_structure_doc = frappe.get_doc("Salary Structure", salary_structure)

	if employee and not frappe.db.get_value("Salary Structure Assignment",
		{'employee':employee, 'docstatus': 1}) and salary_structure_doc.docstatus==1:
			create_salary_structure_assignment(employee, salary_structure, company=company)

	return salary_structure_doc
示例#6
0
	def setUp(self):
		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'])
		frappe.db.sql("DELETE FROM `tabGratuity`")
		frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")
示例#7
0
def make_salary_structure(
	salary_structure,
	payroll_frequency,
	employee=None,
	from_date=None,
	dont_submit=False,
	other_details=None,
	test_tax=False,
	company=None,
	currency=erpnext.get_default_currency(),
	payroll_period=None,
	include_flexi_benefits=False,
):
	if test_tax:
		frappe.db.sql("""delete from `tabSalary Structure` where name=%s""", (salary_structure))

	if frappe.db.exists("Salary Structure", salary_structure):
		frappe.db.delete("Salary Structure", salary_structure)

	details = {
		"doctype": "Salary Structure",
		"name": salary_structure,
		"company": company or erpnext.get_default_company(),
		"earnings": make_earning_salary_component(
			setup=True,
			test_tax=test_tax,
			company_list=["_Test Company"],
			include_flexi_benefits=include_flexi_benefits,
		),
		"deductions": make_deduction_salary_component(
			setup=True, test_tax=test_tax, company_list=["_Test Company"]
		),
		"payroll_frequency": payroll_frequency,
		"payment_account": get_random("Account", filters={"account_currency": currency}),
		"currency": currency,
	}
	if other_details and isinstance(other_details, dict):
		details.update(other_details)
	salary_structure_doc = frappe.get_doc(details)
	salary_structure_doc.insert()
	if not dont_submit:
		salary_structure_doc.submit()

	filters = {"employee": employee, "docstatus": 1}
	if not from_date and payroll_period:
		from_date = payroll_period.start_date

	if from_date:
		filters["from_date"] = from_date

	if (
		employee
		and not frappe.db.get_value("Salary Structure Assignment", filters)
		and salary_structure_doc.docstatus == 1
	):
		create_salary_structure_assignment(
			employee,
			salary_structure,
			from_date=from_date,
			company=company,
			currency=currency,
			payroll_period=payroll_period,
		)

	return salary_structure_doc