コード例 #1
0
    def calculate_variable_based_on_taxable_salary(self, tax_component):
        payroll_period = get_payroll_period(self.start_date, self.end_date,
                                            self.company)
        if not payroll_period:
            frappe.msgprint(
                _("Start and end dates not in a valid Payroll Period, cannot calculate {0}."
                  ).format(tax_component))
            return False, False
        if payroll_period.end_date <= getdate(self.end_date):
            if not self.deduct_tax_for_unsubmitted_tax_exemption_proof \
             or not self.deduct_tax_for_unclaimed_employee_benefits:
                frappe.throw(
                    _("You have to Deduct Tax for Unsubmitted Tax Exemption Proof and Unclaimed Employee Benefits in the last Salary Slip of Payroll Period"
                      ))
            else:
                return self.calculate_tax_for_payroll_period(
                    tax_component, payroll_period)

        benefit_amount_to_tax = 0
        if self.deduct_tax_for_unclaimed_employee_benefits:
            # get all untaxed benefits till date, pass amount to be taxed by later methods
            benefit_amount_to_tax = self.calculate_unclaimed_taxable_benefit(
                payroll_period)
            # flexi's excluded from monthly tax, add flexis in this slip to total_taxable_benefit
            benefit_amount_to_tax += self.get_taxable_earnings(
                only_flexi=True)["taxable_earning"]
        if self.deduct_tax_for_unsubmitted_tax_exemption_proof:
            # calc tax to be paid for the period till date considering prorata taxes paid and proofs submitted
            return self.calculate_unclaimed_taxable_earning(
                payroll_period, tax_component, benefit_amount_to_tax)

        # calc prorata tax to be applied
        return self.calculate_variable_tax(tax_component, payroll_period,
                                           benefit_amount_to_tax)
コード例 #2
0
	def calculate_variable_based_on_taxable_salary(self, tax_component):
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if not payroll_period:
			frappe.msgprint(_("Start and end dates not in a valid Payroll Period, cannot calculate {0}.")
				.format(tax_component))
			return False, False
		if payroll_period.end_date <= getdate(self.end_date):
			if not self.deduct_tax_for_unsubmitted_tax_exemption_proof \
				or not self.deduct_tax_for_unclaimed_employee_benefits:
				frappe.throw(_("You have to Deduct Tax for Unsubmitted Tax Exemption Proof and Unclaimed Employee Benefits in the last Salary Slip of Payroll Period"))
			else:
				return self.calculate_tax_for_payroll_period(tax_component, payroll_period)

		benefit_amount_to_tax = 0
		if self.deduct_tax_for_unclaimed_employee_benefits:
			# get all untaxed benefits till date, pass amount to be taxed by later methods
			benefit_amount_to_tax = self.calculate_unclaimed_taxable_benefit(payroll_period)
			# flexi's excluded from monthly tax, add flexis in this slip to total_taxable_benefit
			benefit_amount_to_tax += self.get_taxable_earnings(only_flexi=True)["taxable_earning"]
		if self.deduct_tax_for_unsubmitted_tax_exemption_proof:
			# calc tax to be paid for the period till date considering prorata taxes paid and proofs submitted
			return self.calculate_unclaimed_taxable_earning(payroll_period, tax_component, benefit_amount_to_tax)

		# calc prorata tax to be applied
		return self.calculate_variable_tax(tax_component, payroll_period, benefit_amount_to_tax)
コード例 #3
0
    def calculate_pro_rata_tax(self, salary_component):
        # Calculate total tax payable earnings
        tax_applicable_components = []
        for earning in self._salary_structure_doc.earnings:
            #all tax applicable earnings which are not flexi
            if earning.is_tax_applicable and not earning.is_flexible_benefit:
                tax_applicable_components.append(earning.salary_component)
        total_taxable_earning = 0
        for earning in self.earnings:
            if earning.salary_component in tax_applicable_components:
                total_taxable_earning += earning.amount

        # Get payroll period, prorata frequency
        days = date_diff(self.end_date, self.start_date) + 1
        payroll_period = get_payroll_period(self.start_date, self.end_date,
                                            self.company)
        if not payroll_period:
            frappe.throw(
                _("Start and end dates not in a valid Payroll Period"))
        total_days = date_diff(payroll_period.end_date,
                               payroll_period.start_date) + 1
        prorata_frequency = flt(total_days) / flt(days)
        annual_earning = total_taxable_earning * prorata_frequency

        # Calculate total exemption declaration
        exemption_amount = 0
        if frappe.db.exists(
                "Employee Tax Exemption Declaration", {
                    "employee": self.employee,
                    "payroll_period": payroll_period.name,
                    "docstatus": 1
                }):
            exemption_amount = frappe.db.get_value(
                "Employee Tax Exemption Declaration",
                {
                    "employee": self.employee,
                    "payroll_period": payroll_period.name,
                    "docstatus": 1
                },  #fix period
                "total_exemption_amount")
        annual_earning = annual_earning - exemption_amount

        # Get tax calc by component
        component = frappe.get_doc("Salary Component", salary_component)
        annual_tax = component.calculate_tax(annual_earning)

        # Calc prorata tax
        pro_rata_tax = annual_tax / prorata_frequency

        # Data for update_component_row
        struct_row = {}
        struct_row['depends_on_lwp'] = 0
        struct_row['salary_component'] = component.name
        struct_row['abbr'] = component.salary_component_abbr
        struct_row['do_not_include_in_total'] = 0

        return struct_row, pro_rata_tax
コード例 #4
0
	def validate(self):
		max_benefits = get_max_benefits(self.employee, self.claim_date)
		if not max_benefits or max_benefits <= 0:
			frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
		payroll_period = get_payroll_period(self.claim_date, self.claim_date, frappe.db.get_value("Employee", self.employee, "company"))
		if not payroll_period:
			frappe.throw(_("{0} is not in a valid Payroll Period").format(frappe.format(self.claim_date, dict(fieldtype='Date'))))
		self.validate_max_benefit_for_component(payroll_period)
		self.validate_max_benefit_for_sal_struct(max_benefits)
		self.validate_benefit_claim_amount(max_benefits, payroll_period)
		if self.pay_against_benefit_claim:
			self.validate_non_pro_rata_benefit_claim(max_benefits, payroll_period)
コード例 #5
0
	def validate(self):
		max_benefits = get_max_benefits(self.employee, self.claim_date)
		if not max_benefits or max_benefits <= 0:
			frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
		payroll_period = get_payroll_period(self.claim_date, self.claim_date, frappe.db.get_value("Employee", self.employee, "company"))
		if not payroll_period:
			frappe.throw(_("{0} is not in a valid Payroll Period").format(frappe.format(self.claim_date, dict(fieldtype='Date'))))
		self.validate_max_benefit_for_component(payroll_period)
		self.validate_max_benefit_for_sal_struct(max_benefits)
		self.validate_benefit_claim_amount(max_benefits, payroll_period)
		if self.pay_against_benefit_claim:
			self.validate_non_pro_rata_benefit_claim(max_benefits, payroll_period)
コード例 #6
0
ファイル: salary_slip.py プロジェクト: Aptronics/erpnext
	def calculate_variable_based_on_taxable_salary(self, tax_component):
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if not payroll_period:
			frappe.msgprint(_("Start and end dates not in a valid Payroll Period, cannot calculate {0}.")
				.format(tax_component))
			return False
		if payroll_period.end_date <= getdate(self.end_date):
			if not self.deduct_tax_for_unsubmitted_tax_exemption_proof or not\
				self.deduct_tax_for_unclaimed_employee_benefits:
				frappe.throw(_("You have to Deduct Tax for Unsubmitted Tax Exemption Proof and Unclaimed \
					Employee Benefits in the last Salary Slip of Payroll Period"))
		# calc prorata tax to be applied
		return self.calculate_variable_tax(tax_component, payroll_period)
コード例 #7
0
	def calculate_variable_based_on_taxable_salary(self, tax_component):
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if not payroll_period:
			frappe.msgprint(_("Start and end dates not in a valid Payroll Period, cannot calculate {0}.")
				.format(tax_component))
			return False
		if payroll_period.end_date <= getdate(self.end_date):
			if not self.deduct_tax_for_unsubmitted_tax_exemption_proof or not\
				self.deduct_tax_for_unclaimed_employee_benefits:
				frappe.throw(_("You have to Deduct Tax for Unsubmitted Tax Exemption Proof and Unclaimed \
					Employee Benefits in the last Salary Slip of Payroll Period"))
		# calc prorata tax to be applied
		return self.calculate_variable_tax(tax_component, payroll_period)
コード例 #8
0
	def get_last_payroll_period_benefit(self):
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if payroll_period:
			# Check for last payroll period
			if (getdate(payroll_period.end_date) <= getdate(self.end_date)):
				current_flexi_amount = 0
				for d in self.get("earnings"):
					if d.is_flexible_benefit == 1:
						current_flexi_amount += d.amount
				last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,\
				 current_flexi_amount, payroll_period, self._salary_structure_doc)
				if last_benefits:
					for last_benefit in last_benefits:
						last_benefit = frappe._dict(last_benefit)
						amount = last_benefit.amount
						self.update_component_row(frappe._dict(last_benefit.struct_row), amount, "earnings")
コード例 #9
0
	def get_last_payroll_period_benefit(self):
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if payroll_period:
			# Check for last payroll period
			if (getdate(payroll_period.end_date) <= getdate(self.end_date)):
				current_flexi_amount = 0
				for d in self.get("earnings"):
					if d.is_flexible_benefit == 1:
						current_flexi_amount += d.amount
				last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,\
				 current_flexi_amount, payroll_period, self._salary_structure_doc)
				if last_benefits:
					for last_benefit in last_benefits:
						last_benefit = frappe._dict(last_benefit)
						amount = last_benefit.amount
						self.update_component_row(frappe._dict(last_benefit.struct_row), amount, "earnings")
コード例 #10
0
ファイル: salary_slip.py プロジェクト: AmanRawat882/ErpNext-1
	def calculate_pro_rata_tax(self, salary_component):
		# Calculate total tax payable earnings
		tax_applicable_components = []
		for earning in self._salary_structure_doc.earnings:
			#all tax applicable earnings which are not flexi
			if earning.is_tax_applicable and not earning.is_flexible_benefit:
				tax_applicable_components.append(earning.salary_component)
		total_taxable_earning = 0
		for earning in self.earnings:
			if earning.salary_component in tax_applicable_components:
				total_taxable_earning += earning.amount

		# Get payroll period, prorata frequency
		days = date_diff(self.end_date, self.start_date) + 1
		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
		if not payroll_period:
			frappe.throw(_("Start and end dates not in a valid Payroll Period"))
		total_days = date_diff(payroll_period.end_date, payroll_period.start_date) + 1
		prorata_frequency = flt(total_days)/flt(days)
		annual_earning = total_taxable_earning * prorata_frequency

		# Calculate total exemption declaration
		exemption_amount = 0
		if frappe.db.exists("Employee Tax Exemption Declaration", {"employee": self.employee,
		"payroll_period": payroll_period.name, "docstatus": 1}):
			exemption_amount = frappe.db.get_value("Employee Tax Exemption Declaration",
				{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1}, #fix period
				"total_exemption_amount")
		annual_earning = annual_earning - exemption_amount

		# Get tax calc by component
		component = frappe.get_doc("Salary Component", salary_component)
		annual_tax = component.calculate_tax(annual_earning)

		# Calc prorata tax
		pro_rata_tax = annual_tax/prorata_frequency

		# Data for update_component_row
		struct_row = {}
		struct_row['depends_on_lwp'] = 0
		struct_row['salary_component'] = component.name
		struct_row['abbr'] = component.salary_component_abbr
		struct_row['do_not_include_in_total'] = 0

		return struct_row, pro_rata_tax