Demo updated for new salary structure
This commit is contained in:
parent
4cda566139
commit
db197d593a
@ -290,9 +290,13 @@ def setup_item_price():
|
|||||||
def setup_salary_structure():
|
def setup_salary_structure():
|
||||||
f = frappe.get_doc('Fiscal Year', frappe.defaults.get_global_default('fiscal_year'))
|
f = frappe.get_doc('Fiscal Year', frappe.defaults.get_global_default('fiscal_year'))
|
||||||
|
|
||||||
|
ss = frappe.new_doc('Salary Structure')
|
||||||
|
ss.name = "Sample Salary Structure - " + str(f.year_start_date)
|
||||||
for e in frappe.get_all('Employee', fields=['name', 'date_of_joining']):
|
for e in frappe.get_all('Employee', fields=['name', 'date_of_joining']):
|
||||||
ss = frappe.new_doc('Salary Structure')
|
ss.append('employees', {
|
||||||
ss.employee = e.name
|
'employee': e.name,
|
||||||
|
'base': random.random() * 10000
|
||||||
|
})
|
||||||
|
|
||||||
if not e.date_of_joining:
|
if not e.date_of_joining:
|
||||||
continue
|
continue
|
||||||
@ -300,16 +304,24 @@ def setup_salary_structure():
|
|||||||
ss.from_date = e.date_of_joining if (e.date_of_joining
|
ss.from_date = e.date_of_joining if (e.date_of_joining
|
||||||
and e.date_of_joining > f.year_start_date) else f.year_start_date
|
and e.date_of_joining > f.year_start_date) else f.year_start_date
|
||||||
ss.to_date = f.year_end_date
|
ss.to_date = f.year_end_date
|
||||||
ss.append('earnings', {
|
|
||||||
'salary_component': 'Basic',
|
|
||||||
'amount': random.random() * 10000
|
|
||||||
})
|
|
||||||
ss.append('deductions', {
|
|
||||||
'salary_component': 'Income Tax',
|
|
||||||
'amount': random.random() * 1000
|
|
||||||
})
|
|
||||||
|
|
||||||
ss.insert()
|
ss.append('earnings', {
|
||||||
|
'salary_component': 'Basic',
|
||||||
|
"abbr":'B',
|
||||||
|
'condition': 'base > 5000',
|
||||||
|
'formula': 'base*.2',
|
||||||
|
'amount_based_on_formula': 1,
|
||||||
|
"idx": 1
|
||||||
|
})
|
||||||
|
ss.append('deductions', {
|
||||||
|
'salary_component': 'Income Tax',
|
||||||
|
"abbr":'IT',
|
||||||
|
'condition': 'base > 5000',
|
||||||
|
'amount': random.random() * 1000,
|
||||||
|
"idx": 1
|
||||||
|
})
|
||||||
|
|
||||||
|
ss.insert()
|
||||||
|
|
||||||
def setup_salary_structure_for_timesheet():
|
def setup_salary_structure_for_timesheet():
|
||||||
for e in frappe.get_all('Salary Structure', fields=['name'], filters={'is_active': 'Yes'}, limit=2):
|
for e in frappe.get_all('Salary Structure', fields=['name'], filters={'is_active': 'Yes'}, limit=2):
|
||||||
|
@ -92,13 +92,20 @@ def update_sanctioned_amount(expense_claim):
|
|||||||
expense.sanctioned_amount = sanctioned_amount
|
expense.sanctioned_amount = sanctioned_amount
|
||||||
|
|
||||||
def get_timesheet_based_salary_slip_employee():
|
def get_timesheet_based_salary_slip_employee():
|
||||||
return frappe.get_all('Salary Structure', fields = ["distinct employee as name"],
|
sal_struct = frappe.db.sql("""
|
||||||
filters = {'salary_slip_based_on_timesheet': 1})
|
select name from `tabSalary Structure`
|
||||||
|
where salary_slip_based_on_timesheet = 1
|
||||||
|
and docstatus != 2""")
|
||||||
|
if sal_struct:
|
||||||
|
employees = frappe.db.sql("""
|
||||||
|
select employee from `tabSalary Structure Employee`
|
||||||
|
where parent IN %(sal_struct)s""", {"sal_struct": sal_struct}, as_dict=True)
|
||||||
|
return employees
|
||||||
|
|
||||||
def make_timesheet_records():
|
def make_timesheet_records():
|
||||||
employees = get_timesheet_based_salary_slip_employee()
|
employees = get_timesheet_based_salary_slip_employee()
|
||||||
for employee in employees:
|
for e in employees:
|
||||||
ts = make_timesheet(employee.name, simulate = True, billable = 1, activity_type=get_random("Activity Type"))
|
ts = make_timesheet(e.employee, simulate = True, billable = 1, activity_type=get_random("Activity Type"))
|
||||||
|
|
||||||
rand = random.random()
|
rand = random.random()
|
||||||
if rand >= 0.3:
|
if rand >= 0.3:
|
||||||
|
@ -10,6 +10,7 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
class ProcessPayroll(Document):
|
class ProcessPayroll(Document):
|
||||||
|
|
||||||
|
|
||||||
def get_emp_list(self):
|
def get_emp_list(self):
|
||||||
"""
|
"""
|
||||||
Returns list of active employees based on selected criteria
|
Returns list of active employees based on selected criteria
|
||||||
@ -18,15 +19,23 @@ class ProcessPayroll(Document):
|
|||||||
cond = self.get_filter_condition()
|
cond = self.get_filter_condition()
|
||||||
cond += self.get_joining_releiving_condition()
|
cond += self.get_joining_releiving_condition()
|
||||||
|
|
||||||
|
sal_struct = frappe.db.sql("""
|
||||||
|
select name from `tabSalary Structure`
|
||||||
|
where docstatus != 2 and
|
||||||
|
ifnull(salary_slip_based_on_timesheet,0) = 0""")
|
||||||
|
|
||||||
|
if sal_struct:
|
||||||
|
cond += "and t2.parent IN %(sal_struct)s "
|
||||||
|
|
||||||
emp_list = frappe.db.sql("""
|
emp_list = frappe.db.sql("""
|
||||||
select t1.name
|
select t1.name
|
||||||
from `tabEmployee` t1, `tabSalary Structure` t2
|
from `tabEmployee` t1, `tabSalary Structure Employee` t2
|
||||||
where t1.docstatus!=2 and t2.docstatus != 2 and
|
where t1.docstatus!=2 and t1.name = t2.employee
|
||||||
ifnull(t2.salary_slip_based_on_timesheet,0) = 0 and t1.name = t2.employee
|
%s """% cond, {"sal_struct": sal_struct})
|
||||||
%s """% cond)
|
|
||||||
|
|
||||||
return emp_list
|
return emp_list
|
||||||
|
|
||||||
|
|
||||||
def get_filter_condition(self):
|
def get_filter_condition(self):
|
||||||
self.check_mandatory()
|
self.check_mandatory()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user