mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 04:28:27 +00:00
Merge branch 'master' into edge
Conflicts: accounts/doctype/sales_invoice/sales_invoice.txt stock/doctype/item/item.txt
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
cur_frm.add_fetch('employee','employee_name','employee_name');
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
if(!doc.posting_date)
|
||||
set_multiple(dt,dn,{posting_date:get_today()});
|
||||
@@ -127,4 +126,8 @@ cur_frm.cscript.calculate_total_days = function(doc, dt, dn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;
|
||||
cur_frm.fields_dict.employee.get_query = function() {
|
||||
return {
|
||||
query: "hr.doctype.leave_application.leave_application.query_for_permitted_employees"
|
||||
};
|
||||
}
|
||||
@@ -330,3 +330,20 @@ def add_holidays(events, start, end, employee, company):
|
||||
"title": _("Holiday") + ": " + cstr(holiday.description),
|
||||
"name": holiday.name
|
||||
})
|
||||
|
||||
@webnotes.whitelist()
|
||||
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
|
||||
txt = "%" + cstr(txt) + "%"
|
||||
|
||||
return webnotes.conn.sql("""select name, employee_name from `tabEmployee` emp
|
||||
where status = 'Active' and docstatus < 2 and
|
||||
(`%s` like %s or employee_name like %s) and
|
||||
(exists(select ela.name from `tabEmployee Leave Approver` ela
|
||||
where ela.parent=emp.name and ela.leave_approver=%s) or
|
||||
not exists(select ela.name from `tabEmployee Leave Approver` ela where ela.parent=emp.name)
|
||||
or user_id = %s)
|
||||
order by
|
||||
case when name like %s then 0 else 1 end,
|
||||
case when employee_name like %s then 0 else 1 end,
|
||||
name limit %s, %s""" % tuple([searchfield] + ["%s"]*8),
|
||||
(txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len))
|
||||
|
||||
@@ -18,31 +18,25 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes import msgprint
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
#init function
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
#autoname function
|
||||
#---------------------------------------------------------
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
|
||||
|
||||
#get employee details
|
||||
#---------------------------------------------------------
|
||||
|
||||
def get_employee_details(self):
|
||||
ret = {}
|
||||
det = sql("select employee_name, branch, designation, department, grade from `tabEmployee` where name = '%s'" %self.doc.employee)
|
||||
det = sql("""select employee_name, branch, designation, department, grade
|
||||
from `tabEmployee` where name = %s""", self.doc.employee)
|
||||
if det:
|
||||
ret = {
|
||||
'employee_name': cstr(det[0][0]),
|
||||
@@ -53,20 +47,16 @@ class DocType:
|
||||
'backup_employee': cstr(self.doc.employee)
|
||||
}
|
||||
return ret
|
||||
|
||||
|
||||
# Set Salary structure field values
|
||||
#---------------------------------------------------------
|
||||
def get_ss_values(self,employee):
|
||||
basic_info = sql("select bank_name, bank_ac_no, esic_card_no, pf_number from `tabEmployee` where name ='%s'" % employee)
|
||||
basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
|
||||
from `tabEmployee` where name =%s""", employee)
|
||||
ret = {'bank_name': basic_info and basic_info[0][0] or '',
|
||||
'bank_ac_no': basic_info and basic_info[0][1] or '',
|
||||
'esic_no': basic_info and basic_info[0][2] or '',
|
||||
'pf_no': basic_info and basic_info[0][3] or ''}
|
||||
return ret
|
||||
|
||||
# Make earning and deduction table
|
||||
#---------------------------------------------------------
|
||||
|
||||
def make_table(self, doct_name, tab_fname, tab_name):
|
||||
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
||||
for li in list1:
|
||||
@@ -77,37 +67,31 @@ class DocType:
|
||||
elif(tab_fname == 'deduction_details'):
|
||||
child.d_type = cstr(li[0])
|
||||
child.d_modified_amt = 0
|
||||
|
||||
# add earning & deduction types to table
|
||||
#---------------------------------------------------------
|
||||
|
||||
def make_earn_ded_table(self):
|
||||
#Earning List
|
||||
self.make_table('Earning Type','earning_details','Salary Structure Earning')
|
||||
|
||||
#Deduction List
|
||||
self.make_table('Deduction Type','deduction_details',
|
||||
'Salary Structure Deduction')
|
||||
|
||||
self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
|
||||
|
||||
# Check if another active ss exists
|
||||
#---------------------------------------------------------
|
||||
def check_existing(self):
|
||||
ret = sql("select name from `tabSalary Structure` where is_active = 'Yes' and employee = '%s' and name!='%s'" %(self.doc.employee,self.doc.name))
|
||||
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||
and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
|
||||
if ret and self.doc.is_active=='Yes':
|
||||
msgprint("Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed."%(cstr(ret), self.doc.employee))
|
||||
raise Exception
|
||||
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.
|
||||
Please make its status 'Inactive' to proceed.""") %
|
||||
(cstr(ret), self.doc.employee), raise_exception=1)
|
||||
|
||||
# Validate net pay
|
||||
#---------------------------------------------------------
|
||||
def validate_net_pay(self):
|
||||
def validate_amount(self):
|
||||
if flt(self.doc.ctc) < 12*flt(self.doc.total_earning):
|
||||
msgprint(_("Annual Cost To Company can not be less than 12 months of Total Earning"),
|
||||
raise_exception=1)
|
||||
|
||||
if flt(self.doc.net_pay) < 0:
|
||||
msgprint("Net pay can not be negative")
|
||||
raise Exception
|
||||
elif flt(self.doc.net_pay) > flt(self.doc.ctc):
|
||||
msgprint("Net pay can not be greater than CTC")
|
||||
raise Exception
|
||||
msgprint(_("Net pay can not be negative"), raise_exception=1)
|
||||
elif flt(self.doc.net_pay)*12 > flt(self.doc.ctc):
|
||||
msgprint(_("Net pay can not be greater than 1/12th of Annual Cost To Company"),
|
||||
raise_exception=1)
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.check_existing()
|
||||
self.validate_net_pay()
|
||||
|
||||
self.validate_amount()
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-23 19:57:18",
|
||||
"creation": "2013-03-07 18:50:29",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-29 17:35:34",
|
||||
"modified": "2013-04-22 14:09:04",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -41,6 +41,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -52,6 +53,7 @@
|
||||
"oldfieldname": "employee",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Employee",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -116,6 +118,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -129,6 +132,7 @@
|
||||
"oldfieldname": "is_active",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nYes\nNo",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -139,6 +143,7 @@
|
||||
"label": "From Date",
|
||||
"oldfieldname": "from_date",
|
||||
"oldfieldtype": "Date",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -148,7 +153,8 @@
|
||||
"in_list_view": 1,
|
||||
"label": "To Date",
|
||||
"oldfieldname": "to_date",
|
||||
"oldfieldtype": "Date"
|
||||
"oldfieldtype": "Date",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Cost to Company",
|
||||
@@ -156,10 +162,11 @@
|
||||
"fieldname": "ctc",
|
||||
"fieldtype": "Currency",
|
||||
"in_filter": 1,
|
||||
"label": "CTC",
|
||||
"label": "Annual Cost To Company",
|
||||
"oldfieldname": "ctc",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -169,6 +176,7 @@
|
||||
"in_filter": 1,
|
||||
"label": "Company",
|
||||
"options": "link:Company",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -178,7 +186,8 @@
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Earning & Deduction",
|
||||
"oldfieldname": "earning_deduction",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -188,6 +197,7 @@
|
||||
"label": "Earning",
|
||||
"oldfieldname": "col_brk2",
|
||||
"oldfieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -198,7 +208,8 @@
|
||||
"label": "Earning1",
|
||||
"oldfieldname": "earning_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Salary Structure Earning"
|
||||
"options": "Salary Structure Earning",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -208,6 +219,7 @@
|
||||
"label": "Deduction",
|
||||
"oldfieldname": "col_brk3",
|
||||
"oldfieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -218,18 +230,21 @@
|
||||
"label": "Deduction1",
|
||||
"oldfieldname": "deduction_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Salary Structure Deduction"
|
||||
"options": "Salary Structure Deduction",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
"options": "Simple",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -256,6 +271,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user