예제 #1
0
	def calculate_component_amounts(self):
		if not getattr(self, '_salary_structure_doc', None):
			self._salary_structure_doc = frappe.get_doc('Salary Structure', self.salary_structure)

		data = self.get_data_for_eval()

		for key in ('earnings', 'deductions'):
			for struct_row in self._salary_structure_doc.get(key):
				amount = self.eval_condition_and_formula(struct_row, data)
				if amount and struct_row.statistical_component == 0:
					self.update_component_row(struct_row, amount, key)

				if key=="earnings" and struct_row.is_flexible_benefit == 1:
					self.add_employee_flexi_benefits(struct_row)

		additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date)
		if additional_components:
			for additional_component in additional_components:
				additional_component = frappe._dict(additional_component)
				amount = additional_component.amount
				overwrite = additional_component.overwrite
				key = "earnings"
				if additional_component.type == "Deduction":
					key = "deductions"
				self.update_component_row(frappe._dict(additional_component.struct_row), amount, key, overwrite=overwrite)

		self.get_last_payroll_period_benefit()

		# Calculate variable_based_on_taxable_salary after all components updated in salary slip
		for struct_row in self._salary_structure_doc.get("deductions"):
			if struct_row.variable_based_on_taxable_salary == 1 and not struct_row.formula and not struct_row.amount:
				tax_detail = self.calculate_variable_based_on_taxable_salary(struct_row.salary_component)
				if tax_detail and tax_detail[1]:
					self.update_component_row(frappe._dict(tax_detail[0]), tax_detail[1], "deductions", tax_detail[2], tax_detail[3])
예제 #2
0
	def calculate_component_amounts(self):
		if not getattr(self, '_salary_structure_doc', None):
			self._salary_structure_doc = frappe.get_doc('Salary Structure', self.salary_structure)

		data = self.get_data_for_eval()

		for key in ('earnings', 'deductions'):
			for struct_row in self._salary_structure_doc.get(key):
				amount = self.eval_condition_and_formula(struct_row, data)
				if amount and struct_row.statistical_component == 0 and struct_row.variable_based_on_taxable_salary != 1:
					self.update_component_row(struct_row, amount, key)

				if key=="earnings" and struct_row.is_flexible_benefit == 1:
					self.add_employee_flexi_benefits(struct_row)

		additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date)
		if additional_components:
			for additional_component in additional_components:
				additional_component = frappe._dict(additional_component)
				amount = additional_component.amount
				key = "earnings"
				if additional_component.type == "Deduction":
					key = "deductions"
				self.update_component_row(frappe._dict(additional_component.struct_row), amount, key)

		self.get_last_payroll_period_benefit()

		# Calculate variable_based_on_taxable_salary after all components updated in salary slip
		for struct_row in self._salary_structure_doc.get("deductions"):
			if struct_row.variable_based_on_taxable_salary == 1:
				tax_row, amount = self.calculate_variable_based_on_taxable_salary(struct_row.salary_component)
				if tax_row and amount:
					self.update_component_row(frappe._dict(tax_row), amount, "deductions")
예제 #3
0
	def add_additional_salary_components(self):
		additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date)
		if additional_components:
			for additional_component in additional_components:
				amount = additional_component.amount
				overwrite = additional_component.overwrite
				key = "earnings" if additional_component.type == "Earning" else "deductions"
				self.update_component_row(frappe._dict(additional_component.struct_row), amount, key, overwrite=overwrite)
예제 #4
0
	def add_additional_salary_components(self, component_type):
		additional_components = get_additional_salary_component(self.employee,
			self.start_date, self.end_date, component_type)
		if additional_components:
			for additional_component in additional_components:
				amount = additional_component.amount
				overwrite = additional_component.overwrite
				self.update_component_row(frappe._dict(additional_component.struct_row), amount,
					component_type, overwrite=overwrite)
예제 #5
0
	def add_additional_salary_components(self, component_type):
		salary_components_details, additional_salary_details = get_additional_salary_component(self.employee,
			self.start_date, self.end_date, component_type)
		if salary_components_details and additional_salary_details:
			for additional_salary in additional_salary_details:
				additional_salary =frappe._dict(additional_salary)
				amount = additional_salary.amount
				overwrite = additional_salary.overwrite
				self.update_component_row(frappe._dict(salary_components_details[additional_salary.component]), amount,
					component_type, overwrite=overwrite, additional_salary=additional_salary.name)