mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-09 16:12:53 +00:00
Merge branch 'develop' into improve_taxes_setup
This commit is contained in:
@@ -6,13 +6,14 @@ from __future__ import unicode_literals
|
||||
import frappe, os, json
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
from frappe.permissions import add_permission, update_permission_property
|
||||
|
||||
from erpnext.payroll.doctype.gratuity_rule.gratuity_rule import get_gratuity_rule
|
||||
|
||||
def setup(company=None, patch=True):
|
||||
make_custom_fields()
|
||||
add_print_formats()
|
||||
add_custom_roles_for_reports()
|
||||
add_permissions()
|
||||
create_gratuity_rule()
|
||||
|
||||
def make_custom_fields():
|
||||
is_zero_rated = dict(fieldname='is_zero_rated', label='Is Zero Rated',
|
||||
@@ -153,3 +154,93 @@ def add_permissions():
|
||||
add_permission(doctype, role, 0)
|
||||
update_permission_property(doctype, role, 0, 'write', 1)
|
||||
update_permission_property(doctype, role, 0, 'create', 1)
|
||||
|
||||
def create_gratuity_rule():
|
||||
rule_1 = rule_2 = rule_3 = None
|
||||
|
||||
# Rule Under Limited Contract
|
||||
slabs = get_slab_for_limited_contract()
|
||||
if not frappe.db.exists("Gratuity Rule", "Rule Under Limited Contract (UAE)"):
|
||||
rule_1 = get_gratuity_rule("Rule Under Limited Contract (UAE)", slabs, calculate_gratuity_amount_based_on="Sum of all previous slabs")
|
||||
|
||||
# Rule Under Unlimited Contract on termination
|
||||
slabs = get_slab_for_unlimited_contract_on_termination()
|
||||
if not frappe.db.exists("Gratuity Rule", "Rule Under Unlimited Contract on termination (UAE)"):
|
||||
rule_2 = get_gratuity_rule("Rule Under Unlimited Contract on termination (UAE)", slabs)
|
||||
|
||||
# Rule Under Unlimited Contract on resignation
|
||||
slabs = get_slab_for_unlimited_contract_on_resignation()
|
||||
if not frappe.db.exists("Gratuity Rule", "Rule Under Unlimited Contract on resignation (UAE)"):
|
||||
rule_3 = get_gratuity_rule("Rule Under Unlimited Contract on resignation (UAE)", slabs)
|
||||
|
||||
#for applicable salary component user need to set this by its own
|
||||
if rule_1:
|
||||
rule_1.flags.ignore_mandatory = True
|
||||
rule_1.save()
|
||||
if rule_2:
|
||||
rule_2.flags.ignore_mandatory = True
|
||||
rule_2.save()
|
||||
if rule_3:
|
||||
rule_3.flags.ignore_mandatory = True
|
||||
rule_3.save()
|
||||
|
||||
|
||||
def get_slab_for_limited_contract():
|
||||
return [{
|
||||
"from_year": 0,
|
||||
"to_year":1,
|
||||
"fraction_of_applicable_earnings": 0
|
||||
},
|
||||
{
|
||||
"from_year": 1,
|
||||
"to_year":5,
|
||||
"fraction_of_applicable_earnings": 21/30
|
||||
},
|
||||
{
|
||||
"from_year": 5,
|
||||
"to_year":0,
|
||||
"fraction_of_applicable_earnings": 1
|
||||
}]
|
||||
|
||||
def get_slab_for_unlimited_contract_on_termination():
|
||||
return [{
|
||||
"from_year": 0,
|
||||
"to_year":1,
|
||||
"fraction_of_applicable_earnings": 0
|
||||
},
|
||||
{
|
||||
"from_year": 1,
|
||||
"to_year":5,
|
||||
"fraction_of_applicable_earnings": 21/30
|
||||
},
|
||||
{
|
||||
"from_year": 5,
|
||||
"to_year":0,
|
||||
"fraction_of_applicable_earnings": 1
|
||||
}]
|
||||
|
||||
def get_slab_for_unlimited_contract_on_resignation():
|
||||
fraction_1 = 1/3 * 21/30
|
||||
fraction_2 = 2/3 * 21/30
|
||||
fraction_3 = 21/30
|
||||
|
||||
return [{
|
||||
"from_year": 0,
|
||||
"to_year":1,
|
||||
"fraction_of_applicable_earnings": 0
|
||||
},
|
||||
{
|
||||
"from_year": 1,
|
||||
"to_year":3,
|
||||
"fraction_of_applicable_earnings": fraction_1
|
||||
},
|
||||
{
|
||||
"from_year": 3,
|
||||
"to_year":5,
|
||||
"fraction_of_applicable_earnings": fraction_2
|
||||
},
|
||||
{
|
||||
"from_year": 5,
|
||||
"to_year":0,
|
||||
"fraction_of_applicable_earnings": fraction_3
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user