Payroll Period - fields refactor

This commit is contained in:
Jamsheer 2018-05-22 14:22:42 +05:30
parent 2ee211ad21
commit cf414cc499
4 changed files with 133 additions and 16 deletions

View File

@ -84,10 +84,8 @@ def create_payroll_period():
doctype = 'Payroll Period',
name = "_Test Payroll Period",
company = "_Test Company",
periods = [
dict(start_date = date(date.today().year, 1, 1),
end_date = date(date.today().year, 12, 31))
]
start_date = date(date.today().year, 1, 1),
end_date = date(date.today().year, 12, 31)
)).insert()
def create_exemption_category():

View File

@ -45,6 +45,129 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "start_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Start Date",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "end_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "End Date",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_5",
"fieldtype": "Section Break",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Payroll Periods",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -71,7 +194,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
@ -88,7 +211,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-04-13 19:38:28.013664",
"modified": "2018-05-22 14:15:59.968204",
"modified_by": "Administrator",
"module": "HR",
"name": "Payroll Period",

View File

@ -12,13 +12,10 @@ class PayrollPeriod(Document):
def get_payroll_period_days(start_date, end_date, company):
payroll_period_dates = frappe.db.sql("""
select ppd.start_date, ppd.end_date from `tabPayroll Period Date` ppd, `tabPayroll Period` pp
where pp.company=%(company)s
and ppd.parent = pp.name
select start_date, end_date from `tabPayroll Period`
where company=%(company)s
and (
(%(start_date)s between ppd.start_date and ppd.end_date)
or (%(end_date)s between ppd.start_date and ppd.end_date)
or (ppd.start_date between %(start_date)s and %(end_date)s)
start_date between %(start_date)s and %(end_date)s
)""", {
'company': company,
'start_date': start_date,

View File

@ -236,8 +236,7 @@ def get_leave_period(from_date, to_date, company):
return leave_period
def get_payroll_period(from_date, to_date, company):
payroll_period = frappe.db.sql("""select pp.name, pd.start_date, pd.end_date from
`tabPayroll Period Date` pd join `tabPayroll Period` pp on
pd.parent=pp.name where pd.start_date<=%s and pd.end_date>= %s
and pp.company=%s""", (from_date, to_date, company), as_dict=1)
payroll_period = frappe.db.sql("""select name, start_date, end_date from
`tabPayroll Period`
where start_date<=%s and end_date>= %s and company=%s""", (from_date, to_date, company), as_dict=1)
return payroll_period[0] if payroll_period else None