mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
moved directory structure
This commit is contained in:
1
hr/doctype/attendance/__init__.py
Normal file
1
hr/doctype/attendance/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
30
hr/doctype/attendance/attendance.js
Normal file
30
hr/doctype/attendance/attendance.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
//get employee's name based on employee id selected
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
if(doc.employee) get_server_fields('get_emp_name', '', '', doc, cdt, cdn, 1);
|
||||
refresh_field('employee_name');
|
||||
}
|
||||
|
||||
|
||||
//Employee
|
||||
//-----------------------------
|
||||
cur_frm.fields_dict['employee'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabEmployee`.`name`, `tabEmployee`.`employee_name` FROM `tabEmployee` WHERE `tabEmployee`.status = "Active" AND `tabEmployee`.`docstatus`!= 2 AND (`tabEmployee`.`employee_name` LIKE "%s" OR `tabEmployee`.`%(key)s` LIKE "%s") ORDER BY `tabEmployee`.`name` ASC LIMIT 50';
|
||||
}
|
||||
113
hr/doctype/attendance/attendance.py
Normal file
113
hr/doctype/attendance/attendance.py
Normal file
@@ -0,0 +1,113 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
#autoname function
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
#get employee name based on employee id selected
|
||||
def get_emp_name(self):
|
||||
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
|
||||
#this is done because sometimes user entered wrong employee name while uploading employee attendance
|
||||
set(self.doc, 'employee_name', emp_nm and emp_nm[0][0] or '')
|
||||
|
||||
ret = { 'employee_name' : emp_nm and emp_nm[0][0] or ''}
|
||||
return ret
|
||||
|
||||
#validation for duplicate record
|
||||
def validate_duplicate_record(self):
|
||||
res = sql("select name from `tabAttendance` where employee = '%s' and att_date = '%s' and not name = '%s' and docstatus = 1"%(self.doc.employee,self.doc.att_date, self.doc.name))
|
||||
if res:
|
||||
msgprint("Employee's attendance already marked.")
|
||||
raise Exception
|
||||
|
||||
|
||||
#check for already record present in leave transaction for same date
|
||||
def check_leave_record(self):
|
||||
if self.doc.status == 'Present':
|
||||
chk = sql("select name from `tabLeave Application` where employee=%s and (from_date <= %s and to_date >= %s) and docstatus!=2", (self.doc.employee, self.doc.att_date, self.doc.att_date))
|
||||
if chk:
|
||||
msgprint("Leave Application created for employee "+self.doc.employee+" whom you are trying to mark as 'Present' ")
|
||||
raise Exception
|
||||
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"% self.doc.fiscal_year)
|
||||
ysd=fy and fy[0][0] or ""
|
||||
yed=add_days(str(ysd),365)
|
||||
if str(self.doc.att_date) < str(ysd) or str(self.doc.att_date) > str(yed):
|
||||
msgprint("'%s' Not Within The Fiscal Year selected"%(self.doc.att_date))
|
||||
raise Exception
|
||||
|
||||
def validate_att_date(self):
|
||||
import datetime
|
||||
if getdate(self.doc.att_date)>getdate(datetime.datetime.now().date().strftime('%Y-%m-%d')):
|
||||
msgprint("Attendance can not be marked for future dates")
|
||||
raise Exception
|
||||
|
||||
# Validate employee
|
||||
#-------------------
|
||||
def validate_employee(self):
|
||||
emp = sql("select name, status from `tabEmployee` where name = '%s'" % self.doc.employee)
|
||||
if not emp:
|
||||
msgprint("Employee: %s does not exists in the system" % self.doc.employee, raise_exception=1)
|
||||
elif emp[0][1] != 'Active':
|
||||
msgprint("Employee: %s is not Active" % self.doc.employee, raise_exception=1)
|
||||
|
||||
# validate...
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
self.validate_att_date()
|
||||
self.validate_duplicate_record()
|
||||
#self.validate_status()
|
||||
self.check_leave_record()
|
||||
|
||||
def on_update(self):
|
||||
#self.validate()
|
||||
|
||||
#this is done because sometimes user entered wrong employee name while uploading employee attendance
|
||||
x=self.get_emp_name()
|
||||
|
||||
def on_submit(self):
|
||||
#this is done because while uploading attendance chnage docstatus to 1 i.e. submit
|
||||
set(self.doc,'docstatus',1)
|
||||
pass
|
||||
241
hr/doctype/attendance/attendance.txt
Normal file
241
hr/doctype/attendance/attendance.txt
Normal file
@@ -0,0 +1,241 @@
|
||||
# DocType, Attendance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:46',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1317365120',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'employee, employee_name, att_date, status',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 75
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Attendance
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Attendance'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'attendance_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Attendance Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'naming_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Naming Series',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'naming_series',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'ATT',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee',
|
||||
'oldfieldname': u'employee',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Employee Name',
|
||||
'oldfieldname': u'employee_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'status',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'status',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nPresent\nAbsent\nHalf Day',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'label': u'Leave Type',
|
||||
'oldfieldname': u'leave_type',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Leave Type',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'att_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Attendance Date',
|
||||
'oldfieldname': u'att_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:doc.amended_from',
|
||||
'description': u'The date at which current entry is corrected in the system.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'options': u'Sales Invoice',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
29
hr/doctype/attendance/attendance_list.js
Normal file
29
hr/doctype/attendance/attendance_list.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// render
|
||||
wn.doclistviews['Attendance'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabAttendance`.att_date",
|
||||
"`tabAttendance`.employee_name",
|
||||
"`tabAttendance`.`status`",
|
||||
|
||||
]);
|
||||
this.stats = this.stats.concat(['company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.att_date = wn.datetime.str_to_user(data.att_date);
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '3%', content:'docstatus'},
|
||||
{width: '12%', content:'name'},
|
||||
{width: '47%', content:'employee_name'},
|
||||
{width: '13%', content:'status'},
|
||||
{width: '10%', content:'tags'},
|
||||
//{width: '23%', content:'supplier_type', css: {'color': '#aaa'}},
|
||||
{width: '12%', content:'att_date', css: {'text-align': 'right', 'color':'#777'}}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user