Example #1
0
    def make_employee_salary_slip(self, user):
        employee = frappe.db.get_value("Employee", {"user_id": user})
        salary_structure = frappe.db.get_value("Salary Structure",
                                               {"employee": employee})
        if not salary_structure:
            salary_structure = make_salary_structure(employee)
            salary_structure.from_date = today()
            salary_structure.insert()
            salary_structure = salary_structure.name

        salary_slip = frappe.db.get_value("Salary Slip",
                                          {"employee": employee})
        if not salary_slip:
            salary_slip = make_salary_slip(salary_structure)
            salary_slip.insert()
            salary_slip.submit()
            salary_slip = salary_slip.name

        salary_slip = frappe.db.get_value("Weekly Salary Slip",
                                          {"employee": employee})
        if not salary_slip:
            salary_slip = make_salary_slip(salary_structure)
            salary_slip.insert()
            salary_slip.submit()
            salary_slip = salary_slip.name

        return salary_slip
Example #2
0
	def pull_sal_struct(self, ss_doc):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
		make_salary_slip(ss_doc.name, self)

		if self.salary_slip_based_on_timesheet:
			self.salary_structure = ss_doc.name
			self.hour_rate = ss_doc.hour_rate
			self.total_working_hours = sum([d.working_hours or 0.0 for d in self.timesheets]) or 0.0
			self.add_earning_for_hourly_wages(ss_doc.salary_component)
Example #3
0
	def pull_sal_struct(self, ss_doc):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
		make_salary_slip(ss_doc.name, self)

		if self.salary_slip_based_on_timesheet:
			self.salary_structure = ss_doc.name
			self.hour_rate = ss_doc.hour_rate
			self.total_working_hours = sum([d.working_hours or 0.0 for d in self.timesheets]) or 0.0
			self.add_earning_for_hourly_wages(ss_doc.salary_component)
	def pull_sal_struct(self):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip

		if self.salary_slip_based_on_timesheet:
			self.salary_structure = self._salary_structure_doc.name
			#self.hour_rate = self._salary_structure_doc.hour_rate
		self.total_working_hour = sum([d.working_hours or 0.0 for d in self.timesheets]) or 0.0
		wages_amount = 0.0
		if self.total_working_hour:
			wages_amount =  self.total_working_hour
			
		self.add_earning_for_hourly_wages(self, self._salary_structure_doc.salary_component, wages_amount)

		make_salary_slip(self._salary_structure_doc.name, self)
Example #5
0
def preview_salary_slip(employee):
    sal_st = get_sal_structure(employee)
    salary_slip = make_salary_slip(sal_st,
                                   employee=employee,
                                   ignore_permissions=True)
    frappe.errprint(salary_slip)
    return salary_slip.gross_pay or 0
Example #6
0
def preview_working_days(employee):
    sal_st = get_sal_structure(employee)
    salary_slip = make_salary_slip(sal_st,
                                   employee=employee,
                                   ignore_permissions=True)
    frappe.errprint(salary_slip)
    return salary_slip.total_working_days or 0
Example #7
0
    def test_salary_structure_deduction_based_on_gross_pay(self):

        emp = make_employee("*****@*****.**")

        sal_struct = make_salary_structure("Salary Structure 2",
                                           "Monthly",
                                           dont_submit=True)

        sal_struct.earnings = [sal_struct.earnings[0]]
        sal_struct.earnings[0].amount_based_on_formula = 1
        sal_struct.earnings[0].formula = "base"

        sal_struct.deductions = [sal_struct.deductions[0]]

        sal_struct.deductions[0].amount_based_on_formula = 1
        sal_struct.deductions[0].condition = "gross_pay > 100"
        sal_struct.deductions[0].formula = "gross_pay * 0.2"

        sal_struct.submit()

        assignment = create_salary_structure_assignment(
            emp, "Salary Structure 2")
        ss = make_salary_slip(sal_struct.name, employee=emp)

        self.assertEqual(assignment.base * 0.2, ss.deductions[0].amount)
def create_salary_slips_for_payroll_period(employee,
                                           salary_structure,
                                           payroll_period,
                                           deduct_random=True):
    deducted_dates = []
    i = 0
    while i < 12:
        slip = frappe.get_doc({
            "doctype": "Salary Slip",
            "employee": employee,
            "salary_structure": salary_structure,
            "frequency": "Monthly"
        })
        if i == 0:
            posting_date = add_days(payroll_period.start_date, 25)
        else:
            posting_date = add_months(posting_date, 1)
        if i == 11:
            slip.deduct_tax_for_unsubmitted_tax_exemption_proof = 1
            slip.deduct_tax_for_unclaimed_employee_benefits = 1
        if deduct_random and not random.randint(0, 2):
            slip.deduct_tax_for_unsubmitted_tax_exemption_proof = 1
            deducted_dates.append(posting_date)
        slip.posting_date = posting_date
        slip.start_date = get_first_day(posting_date)
        slip.end_date = get_last_day(posting_date)
        doc = make_salary_slip(salary_structure, slip, employee)
        doc.submit()
        i += 1
    return deducted_dates
def make_employee_salary_slip(user, payroll_frequency, salary_structure=None):
    from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
    if not salary_structure:
        salary_structure = payroll_frequency + " Salary Structure Test for Salary Slip"
    employee = frappe.db.get_value("Employee", {"user_id": user})
    salary_structure_doc = make_salary_structure(salary_structure,
                                                 payroll_frequency, employee)
    salary_slip = frappe.db.get_value(
        "Salary Slip",
        {"employee": frappe.db.get_value("Employee", {"user_id": user})})

    if not salary_slip:
        salary_slip = make_salary_slip(salary_structure_doc.name,
                                       employee=employee)
        salary_slip.employee_name = frappe.get_value(
            "Employee",
            {"name": frappe.db.get_value("Employee", {"user_id": user})},
            "employee_name")
        salary_slip.payroll_frequency = payroll_frequency
        salary_slip.posting_date = nowdate()
        salary_slip.insert()
        # salary_slip.submit()
        # salary_slip = salary_slip.name

    return salary_slip
Example #10
0
def make_salary_slip_from_salary_structure(employee):
    sal_struct = make_salary_structure('Salary Structure Sample')
    sal_slip = make_salary_slip(sal_struct, employee=employee)
    sal_slip.employee_name = frappe.get_value("Employee", {"name": employee},
                                              "employee_name")
    sal_slip.month = "11"
    sal_slip.fiscal_year = "_Test Fiscal Year 2016"
    sal_slip.insert()
    sal_slip.submit()
    return sal_slip
Example #11
0
def make_salary_slip_from_salary_structure(employee):
	sal_struct = make_salary_structure('Salary Structure Sample')
	sal_slip = make_salary_slip(sal_struct, employee = employee)
	sal_slip.employee_name = frappe.get_value("Employee", {"name":employee}, "employee_name")
	sal_slip.month = "11"
	sal_slip.fiscal_year = "_Test Fiscal Year 2016"
	sal_slip.posting_date = nowdate()
	sal_slip.insert()
	sal_slip.submit()
	return sal_slip	
def make_salary_slip_from_salary_structure(employee):
	sal_struct = make_salary_structure('Salary Structure Sample')
	sal_slip = make_salary_slip(sal_struct, employee = employee)
	sal_slip.employee_name = frappe.get_value("Employee", {"name":employee}, "employee_name")
	sal_slip.start_date = nowdate()
	sal_slip.posting_date = nowdate()
	sal_slip.payroll_frequency =  "Monthly"
	sal_slip.insert()
	sal_slip.submit()
	return sal_slip	
Example #13
0
def make_salary_slip_from_salary_structure(employee):
	sal_struct = make_salary_structure('Salary Structure Sample')
	sal_slip = make_salary_slip(sal_struct, employee = employee)
	sal_slip.employee_name = frappe.get_value("Employee", {"name":employee}, "employee_name")
	sal_slip.start_date = nowdate()
	sal_slip.posting_date = nowdate()
	sal_slip.payroll_frequency =  "Monthly"
	sal_slip.insert()
	sal_slip.submit()
	return sal_slip	
Example #14
0
def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component):
	salary_slip = make_salary_slip(salary_structure, employee=employee, for_preview=1)
	basic_amt, hra_amt = 0, 0
	for earning in salary_slip.earnings:
		if earning.salary_component == basic_component:
			basic_amt = earning.amount
		elif earning.salary_component == hra_component:
			hra_amt = earning.amount
		if basic_amt and hra_amt:
			return basic_amt, hra_amt
	return basic_amt, hra_amt
Example #15
0
def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component):
	salary_slip = make_salary_slip(salary_structure, employee=employee)
	basic_amt, hra_amt = 0, 0
	for earning in salary_slip.earnings:
		if earning.salary_component == basic_component:
			basic_amt = earning.amount
		elif earning.salary_component == hra_component:
			hra_amt = earning.amount
		if basic_amt and hra_amt:
			return basic_amt, hra_amt
	return basic_amt, hra_amt
Example #16
0
	def make_employee_salary_slip(self, user, payroll_frequency):
		employee = frappe.db.get_value("Employee", {"user_id": user})
		salary_structure = make_salary_structure(payroll_frequency + " Salary Structure Test for Salary Slip", payroll_frequency, employee)
		salary_slip = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": user})})

		if not salary_slip:
			salary_slip = make_salary_slip(salary_structure, employee = employee)
			salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
			salary_slip.payroll_frequency = payroll_frequency
			salary_slip.posting_date = nowdate()
			salary_slip.insert()
			# salary_slip.submit()
			salary_slip = salary_slip.name

		return salary_slip
Example #17
0
	def make_employee_salary_slip(self, user, payroll_frequency):
		employee = frappe.db.get_value("Employee", {"user_id": user})
		salary_structure = make_salary_structure(payroll_frequency + " Salary Structure Test for Salary Slip", payroll_frequency, employee)
		salary_slip = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": user})})

		if not salary_slip:
			salary_slip = make_salary_slip(salary_structure, employee = employee)
			salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
			salary_slip.payroll_frequency = payroll_frequency
			salary_slip.posting_date = nowdate()
			salary_slip.insert()
			# salary_slip.submit()
			salary_slip = salary_slip.name

		return salary_slip
Example #18
0
	def make_employee_salary_slip(self, user):
		employee = frappe.db.get_value("Employee", {"user_id": user})
		salary_structure = make_salary_structure("Salary Structure Test for Salary Slip")
		salary_slip = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": user})})
		
		if not salary_slip:
			salary_slip = make_salary_slip(salary_structure, employee = employee)
			salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
			salary_slip.month = "12"
			salary_slip.fiscal_year = "_Test Fiscal Year 2016"
			salary_slip.posting_date = nowdate()
			salary_slip.insert()
			# salary_slip.submit()
			salary_slip = salary_slip.name

		return salary_slip
Example #19
0
    def pull_sal_struct(self, struct):
        from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
        self.update(make_salary_slip(struct, self).as_dict())

        m = frappe.get_doc('Salary Manager').get_month_details(
            self.fiscal_year, self.month)

        drawings_overtime_details = frappe.db.sql(
            """select sum(dd.drawing_amount) as drawings, sum(dd.overtime) as overtime, group_concat(name) as name from `tabDaily Drawing` dd 
				where dd.employee_id = '%(employee)s' 
					and ifnull(dd.flag, 'No') != 'Yes'
					and dd.date between STR_TO_DATE('%(from_date)s','%(format)s') 
						and  STR_TO_DATE('%(to_date)s','%(format)s')""" % {
                'format': '%Y-%m-%d',
                'from_date': m['month_start_date'],
                'to_date': m['month_end_date'],
                'employee': self.employee
            },
            as_dict=1)

        self.deduction = drawings_overtime_details

        mapper = {
            'overtime': [
                'Overtime', drawings_overtime_details[0].get('overtime')
                if len(drawings_overtime_details) > 0 else 0.0
            ]
        }

        for types in mapper:
            d = self.append('earning_details', {})
            d.e_type = mapper.get(types)[0]
            d.e_amount = mapper.get(types)[1]
            d.e_modified_amount = mapper.get(types)[1]

        mapper = {
            'drawings': [
                'Drawing', drawings_overtime_details[0].get('drawings')
                if len(drawings_overtime_details) > 0 else 0.0
            ]
        }

        for types in mapper:
            d = self.append('deduction_details', {})
            d.d_type = mapper.get(types)[0]
            d.d_modified_amount = mapper.get(types)[1]
Example #20
0
def make_employee_salary_slip(user, payroll_frequency, salary_structure=None):
	from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
	if not salary_structure:
		salary_structure = payroll_frequency + " Salary Structure Test for Salary Slip"
	employee = frappe.db.get_value("Employee", {"user_id": user})
	salary_structure_doc = make_salary_structure(salary_structure, payroll_frequency, employee)
	salary_slip = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": user})})

	if not salary_slip:
		salary_slip = make_salary_slip(salary_structure_doc.name, employee = employee)
		salary_slip.employee_name = frappe.get_value("Employee",
			{"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
		salary_slip.payroll_frequency = payroll_frequency
		salary_slip.posting_date = nowdate()
		salary_slip.insert()

	return salary_slip
Example #21
0
	def make_employee_salary_slip(self, user):
		employee = frappe.db.get_value("Employee", {"user_id": user})
		salary_structure = frappe.db.get_value("Salary Structure", {"employee": employee})
		if not salary_structure:
			salary_structure = make_salary_structure(employee)
			salary_structure.from_date = today()
			salary_structure.insert()
			salary_structure = salary_structure.name

		salary_slip = frappe.db.get_value("Salary Slip", {"employee": employee})
		if not salary_slip:
			salary_slip = make_salary_slip(salary_structure)
			salary_slip.insert()
			salary_slip.submit()
			salary_slip = salary_slip.name

		return salary_slip
Example #22
0
def create_salary_slips_for_payroll_period(employee, salary_structure, payroll_period, deduct_random=True):
	deducted_dates = []
	i = 0
	while i < 12:
		slip = frappe.get_doc({"doctype": "Salary Slip", "employee": employee,
				"salary_structure": salary_structure, "frequency": "Monthly"})
		if i == 0:
			posting_date = add_days(payroll_period.start_date, 25)
		else:
			posting_date = add_months(posting_date, 1)
		if i == 11:
			slip.deduct_tax_for_unsubmitted_tax_exemption_proof = 1
			slip.deduct_tax_for_unclaimed_employee_benefits = 1
		if deduct_random and not random.randint(0, 2):
			slip.deduct_tax_for_unsubmitted_tax_exemption_proof = 1
			deducted_dates.append(posting_date)
		slip.posting_date = posting_date
		slip.start_date = get_first_day(posting_date)
		slip.end_date = get_last_day(posting_date)
		doc = make_salary_slip(salary_structure, slip, employee)
		doc.submit()
		i += 1
	return deducted_dates
Example #23
0
def preview_salary_slip_for_late_entry(employee):
    sal_st = get_sal_structure(employee)
    salary_slip = make_salary_slip(sal_st,
                                   employee=employee,
                                   ignore_permissions=True)
    return salary_slip
Example #24
0
	def pull_sal_struct(self, struct):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
		self.update(make_salary_slip(struct, self).as_dict())
Example #25
0
	def pull_sal_struct(self, struct):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
		make_salary_slip(struct, self)
Example #26
0
	def pull_sal_struct(self, struct):
		from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
		make_salary_slip(struct, self)
Example #27
0
 def pull_sal_struct(self, struct):
     from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
     self.update(make_salary_slip(struct, self).as_dict())