Joining date validation removed from Salary Structure

This commit is contained in:
Kanchan Chauhan 2017-02-06 10:48:43 +05:30
parent 6b9902627d
commit 5f5457085e
9 changed files with 131 additions and 116 deletions

View File

@ -156,11 +156,10 @@ class SalarySlip(TransactionBase):
cond = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency} cond = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency}
st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee` st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee`
where employee=%s where employee=%s and (from_date <= %s or from_date <= %s)
and (to_date is null or to_date >= %s or to_date >= %s)
and parent in (select name from `tabSalary Structure` and parent in (select name from `tabSalary Structure`
where is_active = 'Yes' where is_active = 'Yes'%s)
and (from_date <= %s or from_date <= %s)
and (to_date is null or to_date >= %s or to_date >= %s) %s)
"""% ('%s', '%s', '%s','%s','%s', cond),(self.employee, self.start_date, joining_date, self.end_date, relieving_date)) """% ('%s', '%s', '%s','%s','%s', cond),(self.employee, self.start_date, joining_date, self.end_date, relieving_date))
if st_name: if st_name:

View File

@ -7,7 +7,7 @@ import frappe
import erpnext import erpnext
import calendar import calendar
from erpnext.accounts.utils import get_fiscal_year from erpnext.accounts.utils import get_fiscal_year
from frappe.utils import getdate, nowdate, add_days from frappe.utils import getdate, nowdate, add_days, add_months
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account
from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details
@ -257,7 +257,6 @@ def make_salary_structure(sal_struct, payroll_frequency, employee):
"doctype": "Salary Structure", "doctype": "Salary Structure",
"name": sal_struct, "name": sal_struct,
"company": erpnext.get_default_company(), "company": erpnext.get_default_company(),
"from_date": nowdate(),
"employees": get_employee_details(employee), "employees": get_employee_details(employee),
"earnings": get_earnings_component(), "earnings": get_earnings_component(),
"deductions": get_deductions_component(), "deductions": get_deductions_component(),
@ -270,7 +269,8 @@ def make_salary_structure(sal_struct, payroll_frequency, employee):
sal_struct.append("employees", {"employee": employee, sal_struct.append("employees", {"employee": employee,
"employee_name": employee, "employee_name": employee,
"base": 32000, "base": 32000,
"variable": 3200 "variable": 3200,
"from_date": add_months(nowdate(),-1)
}) })
sal_struct.save() sal_struct.save()
sal_struct = sal_struct.name sal_struct = sal_struct.name
@ -279,7 +279,8 @@ def make_salary_structure(sal_struct, payroll_frequency, employee):
def get_employee_details(employee): def get_employee_details(employee):
return [{"employee": employee, return [{"employee": employee,
"base": 25000, "base": 25000,
"variable": 5000 "variable": 5000,
"from_date": add_months(nowdate(),-1)
} }
] ]

View File

@ -95,37 +95,6 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Monthly",
"depends_on": "eval:(!doc.salary_slip_based_on_timesheet)",
"fieldname": "payroll_frequency",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Payroll Frequency",
"length": 0,
"no_copy": 0,
"options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily",
"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,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -184,6 +153,37 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Monthly",
"depends_on": "eval:(!doc.salary_slip_based_on_timesheet)",
"fieldname": "payroll_frequency",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Payroll Frequency",
"length": 0,
"no_copy": 0,
"options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily",
"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,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -214,64 +214,6 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "from_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "From Date",
"length": 0,
"no_copy": 0,
"oldfieldname": "from_date",
"oldfieldtype": "Date",
"permlevel": 0,
"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,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "to_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "To Date",
"length": 0,
"no_copy": 0,
"oldfieldname": "to_date",
"oldfieldtype": "Date",
"permlevel": 0,
"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,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -894,7 +836,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-12-14 02:02:10.848614", "modified": "2017-02-06 01:32:16.815429",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Structure", "name": "Salary Structure",

View File

@ -4,8 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt, getdate, cint from frappe.utils import flt, cint
from frappe.model.naming import make_autoname
from frappe import _ from frappe import _
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.model.document import Document from frappe.model.document import Document
@ -15,7 +14,6 @@ class SalaryStructure(Document):
def validate(self): def validate(self):
self.validate_amount() self.validate_amount()
self.validate_joining_date()
for e in self.get('employees'): for e in self.get('employees'):
set_employee_name(e) set_employee_name(e)
@ -29,12 +27,6 @@ class SalaryStructure(Document):
def validate_amount(self): def validate_amount(self):
if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet: if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet:
frappe.throw(_("Net pay cannot be negative")) frappe.throw(_("Net pay cannot be negative"))
def validate_joining_date(self):
for e in self.get('employees'):
joining_date = getdate(frappe.db.get_value("Employee", e.employee, "date_of_joining"))
if getdate(self.from_date) < joining_date:
frappe.throw(_("From Date in Salary Structure cannot be lesser than Employee Joining Date."))
@frappe.whitelist() @frappe.whitelist()

View File

@ -6,7 +6,7 @@ import frappe
import unittest import unittest
import erpnext import erpnext
from frappe.utils.make_random import get_random from frappe.utils.make_random import get_random
from frappe.utils import nowdate, add_days, add_years, getdate from frappe.utils import nowdate, add_days, add_years, getdate, add_months
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
from erpnext.hr.doctype.salary_slip.test_salary_slip \ from erpnext.hr.doctype.salary_slip.test_salary_slip \
import make_earning_salary_component, make_deduction_salary_component import make_earning_salary_component, make_deduction_salary_component
@ -94,7 +94,6 @@ def make_salary_structure(sal_struct):
"doctype": "Salary Structure", "doctype": "Salary Structure",
"name": sal_struct, "name": sal_struct,
"company": erpnext.get_default_company(), "company": erpnext.get_default_company(),
"from_date": nowdate(),
"employees": get_employee_details(), "employees": get_employee_details(),
"earnings": get_earnings_component(), "earnings": get_earnings_component(),
"deductions": get_deductions_component(), "deductions": get_deductions_component(),
@ -108,11 +107,13 @@ def get_employee_details():
return [{"employee": frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), return [{"employee": frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"),
"base": 25000, "base": 25000,
"variable": 5000, "variable": 5000,
"from_date": add_months(nowdate(),-1),
"idx": 1 "idx": 1
}, },
{"employee": frappe.get_value("Employee", {"employee_name":"test_employee_2@salary.com"}, "name"), {"employee": frappe.get_value("Employee", {"employee_name":"test_employee_2@salary.com"}, "name"),
"base": 15000, "base": 15000,
"variable": 100, "variable": 100,
"from_date": add_months(nowdate(),-1),
"idx": 2 "idx": 2
} }
] ]

View File

@ -10,11 +10,13 @@
"doctype": "DocType", "doctype": "DocType",
"document_type": "", "document_type": "",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB",
"fields": [ "fields": [
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "employee", "fieldname": "employee",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -22,6 +24,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Employee", "label": "Employee",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -31,6 +34,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -41,6 +45,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "employee_name", "fieldname": "employee_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -48,6 +53,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Employee Name", "label": "Employee Name",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -56,6 +62,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -66,14 +73,16 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "base", "columns": 0,
"fieldtype": "Currency", "fieldname": "from_date",
"fieldtype": "Date",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Base", "in_standard_filter": 0,
"label": "From Date",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -81,6 +90,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -91,6 +101,63 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "to_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "To 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": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "base",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Base",
"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,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "variable", "fieldname": "variable",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@ -98,6 +165,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Variable", "label": "Variable",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -106,6 +174,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -123,7 +192,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-08-11 12:18:14.526977", "modified": "2017-02-06 01:32:38.183131",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Structure Employee", "name": "Salary Structure Employee",

View File

@ -363,4 +363,5 @@ erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_doctype_status erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.set_null_value_to_fields erpnext.patches.v7_2.set_null_value_to_fields
erpnext.patches.v7_2.update_abbr_in_salary_slips erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.move_dates_from_salary_structure_to_employee

View File

@ -0,0 +1,9 @@
import frappe
def execute():
frappe.reload_doc('hr', 'doctype', 'salary_structure_employee')
salary_structures = frappe.db.sql("""select name, to_date, from_date from `tabSalary Structure`""", as_dict=True)
for salary_structure in salary_structures:
frappe.db.sql(""" update `tabSalary Structure Employee` set from_date = %s, to_date = %s
where parent = %s """, (salary_structure.from_date, salary_structure.to_date or 'null', salary_structure.name))

View File

@ -7,7 +7,7 @@ import frappe
import unittest import unittest
import datetime import datetime
from frappe.utils.make_random import get_random from frappe.utils.make_random import get_random
from frappe.utils import now_datetime, nowdate, add_days from frappe.utils import now_datetime, nowdate, add_days, add_months
from erpnext.projects.doctype.timesheet.timesheet import OverlapError from erpnext.projects.doctype.timesheet.timesheet import OverlapError
from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
@ -88,7 +88,8 @@ def make_salary_structure(employee):
es = salary_structure.append('employees', { es = salary_structure.append('employees', {
"employee": employee, "employee": employee,
"base": 1200 "base": 1200,
"from_date": add_months(nowdate(),-1)
}) })