mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 23:19:20 +00:00
restructured erpnext and deleted unwanted
This commit is contained in:
0
hr/doctype/__init__.py
Normal file
0
hr/doctype/__init__.py
Normal file
0
hr/doctype/absent_days_detail/__init__.py
Normal file
0
hr/doctype/absent_days_detail/__init__.py
Normal file
137
hr/doctype/absent_days_detail/absent_days_detail.txt
Normal file
137
hr/doctype/absent_days_detail/absent_days_detail.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
# DocType, Absent Days Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Absent Days Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Absent Days Detail',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Absent Days Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Absent Days Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Leave Type',
|
||||
'oldfieldname': 'leave_type',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Leave Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_leave_days',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'No of leave days',
|
||||
'oldfieldname': 'no_of_leave_days',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'From Date',
|
||||
'oldfieldname': 'from_date',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 4,
|
||||
'label': 'To Date',
|
||||
'oldfieldname': 'to_date',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'previous_balance',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Previous Balance',
|
||||
'oldfieldname': 'previous_balance',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'current_balance',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Current Balance',
|
||||
'oldfieldname': 'current_balance',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'max_allowed',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 7,
|
||||
'label': 'Max. Allowed',
|
||||
'oldfieldname': 'max_allowed',
|
||||
'oldfieldtype': 'Data'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/appraisal/__init__.py
Normal file
0
hr/doctype/appraisal/__init__.py
Normal file
145
hr/doctype/appraisal/appraisal.js
Normal file
145
hr/doctype/appraisal/appraisal.js
Normal file
@@ -0,0 +1,145 @@
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
|
||||
if(doc.employee) cur_frm.cscript.employee(doc,cdt,cdn);
|
||||
if(doc.amended_from && doc.__islocal) cur_frm.cscript.refresh_appraisal_details(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if(user == doc.kra_approver && doc.status == 'Submitted') unhide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
else hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
|
||||
if(!doc.docstatus) unhide_field('Fetch Template');
|
||||
else hide_field('Fetch Template');
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.refresh_appraisal_details = function(doc, cdt, cdn){
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
set_multiple('Appraisal Detail', val[i].name, {'target_achieved':'', 'score':'', 'scored_earned':''}, 'appraisal_details');
|
||||
}
|
||||
doc.total_score = '';
|
||||
refresh_field('appraisal_details');
|
||||
refresh_field('total_score');
|
||||
}
|
||||
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
if(doc.employee){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){
|
||||
if(r.message){
|
||||
doc.employee_name = r.message['emp_nm'];
|
||||
get_field(doc.doctype, 'kra_approver' , doc.name).options = r.message['app_lst'];
|
||||
refresh_many(['kra_approver','employee_name']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Calculate Total Score'] = function(doc,cdt,cdn){
|
||||
//get_server_fields('calculate_total','','',doc,cdt,cdn,1);
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned)
|
||||
}
|
||||
doc.total_score = flt(total)
|
||||
refresh_field('total_score')
|
||||
}
|
||||
|
||||
/*cur_frm.cscript['Declare Completed'] = function(doc,cdt,cdn){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'declare_completed','', function(r,rt){
|
||||
if(r.message){
|
||||
refresh_field('Status');
|
||||
cur_frm.cscript.refresh(doc,cdt,cdn);
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
cur_frm.cscript['Declare Completed'] = function(doc,cdt,cdn){
|
||||
var declare_completed_dialog;
|
||||
|
||||
set_declare_completed_dialog = function() {
|
||||
declare_completed_dialog = new Dialog(400, 200, 'Declare Completed');
|
||||
declare_completed_dialog.make_body([
|
||||
['HTML', 'Message', '<div class = "comment">You wont be able to do any changes after declaring this Appraisal as completed. Are you sure, you want to declare it as completed ?</div>'],
|
||||
['HTML', 'Response', '<div class = "comment" id="declare_completed_dialog_response"></div>'],
|
||||
['HTML', 'Declare Completed', '<div></div>']
|
||||
]);
|
||||
|
||||
var declare_completed_btn1 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn1.innerHTML = 'Yes';
|
||||
declare_completed_btn1.onclick = function(){ declare_completed_dialog.add(); }
|
||||
|
||||
var declare_completed_btn2 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn2.innerHTML = 'No';
|
||||
$y(declare_completed_btn2,{marginLeft:'4px'});
|
||||
declare_completed_btn2.onclick = function(){ declare_completed_dialog.hide();}
|
||||
|
||||
declare_completed_dialog.onshow = function() {
|
||||
$i('declare_completed_dialog_response').innerHTML = '';
|
||||
}
|
||||
|
||||
declare_completed_dialog.refresh_dt = function(){
|
||||
cur_frm.cscript.refresh(this.doc, this.cdt, this.cdn);
|
||||
msgprint("refersh done");
|
||||
$c('webnotes.widgets.form.form_header.refresh_labels',this.doc,function(r,rt){});
|
||||
}
|
||||
|
||||
declare_completed_dialog.add = function() {
|
||||
// sending...
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Processing...';
|
||||
var m_arg = user+ '~~' + this.msg_nm_lst;
|
||||
|
||||
$c_obj(make_doclist(this.doc.doctype, this.doc.name),'declare_completed','', function(r,rt){
|
||||
|
||||
if(r.message.status == 'Completed'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Done';
|
||||
refresh_field('status');
|
||||
declare_completed_dialog.refresh_dt();
|
||||
hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
declare_completed_dialog.hide();
|
||||
}
|
||||
else if(r.message.status == 'Incomplete'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Incomplete Appraisal';
|
||||
}
|
||||
else if(r.message.status == 'No Score'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Calculate total score';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(!declare_completed_dialog){
|
||||
set_declare_completed_dialog();
|
||||
}
|
||||
declare_completed_dialog.doc = doc;
|
||||
declare_completed_dialog.cdt = cdt;
|
||||
declare_completed_dialog.cdn = cdn;
|
||||
declare_completed_dialog.show();
|
||||
}
|
||||
|
||||
cur_frm.cscript.score = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.score){
|
||||
total = flt(d.per_weightage*d.score)/100;
|
||||
d.score_earned = total.toPrecision(2);
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
else{
|
||||
d.score_earned = '';
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned);
|
||||
}
|
||||
doc.total_score = flt(total);
|
||||
refresh_field('total_score');
|
||||
}
|
||||
147
hr/doctype/appraisal/appraisal.py
Normal file
147
hr/doctype/appraisal/appraisal.py
Normal file
@@ -0,0 +1,147 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm= emp_nm and emp_nm[0][0] or ''
|
||||
self.doc.employee_name = emp_nm
|
||||
return cstr(emp_nm)
|
||||
|
||||
def fetch_kra(self):
|
||||
if not self.doc.kra_template:
|
||||
msgprint("Please select KRA Template to be be fetched")
|
||||
raise Exception
|
||||
self.doc.clear_table(self.doclist,'appraisal_details')
|
||||
get_obj('DocType Mapper', 'KRA Template-Appraisal').dt_map('KRA Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['KRA Template','Appraisal'],['KRA Sheet', 'Appraisal Detail']]")
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.doc.start_date) > getdate(self.doc.end_date):
|
||||
msgprint("End Date can not be less than Start Date")
|
||||
raise Exception
|
||||
|
||||
def validate_existing_appraisal(self):
|
||||
chk = sql("select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) or (end_date>=%s and end_date<=%s))",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date))
|
||||
if chk:
|
||||
msgprint("You have already created Appraisal "+cstr(chk[0][0])+" in the current date range for employee "+cstr(self.doc.employee_name))
|
||||
raise Exception
|
||||
|
||||
def validate_curr_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.target_achieved or d.score:
|
||||
if self.doc.status == 'Draft':
|
||||
msgprint("Target achieved or Score can be added only for submitted Appraisal")
|
||||
raise Exception
|
||||
elif self.doc.status == 'Submitted' and session['user'] != self.doc.kra_approver:
|
||||
msgprint("Target achieved or Score can be added only by Appraisal Approver")
|
||||
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.start_date) < str(ysd) or str(self.doc.start_date) > str(yed) or str(self.doc.end_date) < str(ysd) or str(self.doc.end_date) > str(yed):
|
||||
msgprint("Appraisal date range is not within the Fiscal Year selected")
|
||||
raise Exception
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_existing_appraisal()
|
||||
self.validate_curr_appraisal()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
def set_approver(self):
|
||||
ret={}
|
||||
approver_lst =[]
|
||||
emp_nm = self.get_employee_name()
|
||||
approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
|
||||
if approver_lst1:
|
||||
approver_lst=approver_lst1
|
||||
else:
|
||||
approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
|
||||
ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
|
||||
return ret
|
||||
|
||||
def calculate_total(self):
|
||||
total = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.score:
|
||||
total = total + flt(d.score_earned)
|
||||
ret={'total_score':flt(total)}
|
||||
return cstr(ret)
|
||||
|
||||
def declare_completed(self):
|
||||
ret={}
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.target_achieved or not d.score or not d.score_earned:
|
||||
msgprint("Please add 'Target Achieved' and 'Score' for all KPI")
|
||||
ret = {'status':'Incomplete'}
|
||||
return ret
|
||||
|
||||
if not self.doc.total_score:
|
||||
msgprint("Please calculate total score using button 'Calculate Total Score'")
|
||||
ret = {'status':'No Score'}
|
||||
return ret
|
||||
self.update_appraisal()
|
||||
#set(self.doc, 'status', 'Completed')
|
||||
ret = {'status':'Completed'}
|
||||
return ret
|
||||
|
||||
def update_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.kra or not d.per_weightage:
|
||||
msgprint("Please remove the extra blank row added")
|
||||
raise Exception
|
||||
d.save()
|
||||
if self.doc.total_score:
|
||||
set(self.doc,'total_score',self.doc.total_score)
|
||||
|
||||
def on_update(self):
|
||||
set(self.doc, 'status', 'Draft')
|
||||
|
||||
def validate_total_weightage(self):
|
||||
total_w = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
total_w = flt(total_w) + flt(d.per_weightage)
|
||||
|
||||
if flt(total_w)>100 or flt(total_w)<100:
|
||||
msgprint("Total of weightage assigned to KPI is "+cstr(total_w)+".It should be 100(%)")
|
||||
raise Exception
|
||||
|
||||
def validate_appraisal_detail(self):
|
||||
if not self.doc.kra_approver:
|
||||
msgprint("Please mention the name of Approver")
|
||||
raise Exception
|
||||
|
||||
if not getlist(self.doclist, 'appraisal_details'):
|
||||
msgprint("Please add KRA Details")
|
||||
raise Exception
|
||||
|
||||
self.validate_total_weightage()
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_appraisal_detail()
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
415
hr/doctype/appraisal/appraisal.txt
Normal file
415
hr/doctype/appraisal/appraisal.txt
Normal file
@@ -0,0 +1,415 @@
|
||||
# DocType, Appraisal
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-27 14:39:10',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308808105',
|
||||
'autoname': 'APRSL.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': 'status, employee, employee_name',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 160
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Appraisal',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Appraisal',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Appraisal
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Appraisal'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 8,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Employee Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Draft',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'status',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Status',
|
||||
'oldfieldname': 'status',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nDraft\nSubmitted\nCompleted\nCancelled',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee',
|
||||
'oldfieldname': 'employee',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee Name',
|
||||
'oldfieldname': 'employee_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 7,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Start Date',
|
||||
'oldfieldname': 'start_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'end_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'End Date',
|
||||
'oldfieldname': 'end_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_approver',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'in_filter': 0,
|
||||
'label': 'Approver',
|
||||
'oldfieldname': 'kra_approver',
|
||||
'oldfieldtype': 'Select',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 11,
|
||||
'label': 'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amended_from',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 12,
|
||||
'label': 'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amendment_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 13,
|
||||
'label': 'Declare Completed',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 14,
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Select template from which you want to fetch KRA',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_template',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 15,
|
||||
'label': 'KRA Template',
|
||||
'oldfieldname': 'kra_template',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'KRA Template',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 16,
|
||||
'label': 'Fetch Template',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'fetch_kra',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'hidden': 1,
|
||||
'idx': 17,
|
||||
'label': 'Update',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'appraisal_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 18,
|
||||
'label': 'Appraisal Details',
|
||||
'oldfieldname': 'appraisal_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Appraisal Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 19,
|
||||
'label': 'Calculate Total Score',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'calculate_total',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_score',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 20,
|
||||
'label': 'Total Score',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_score',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/appraisal_detail/__init__.py
Normal file
0
hr/doctype/appraisal_detail/__init__.py
Normal file
112
hr/doctype/appraisal_detail/appraisal_detail.txt
Normal file
112
hr/doctype/appraisal_detail/appraisal_detail.txt
Normal file
@@ -0,0 +1,112 @@
|
||||
# DocType, Appraisal Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'rahul@webnotestech.com',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'APRSLD.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 13
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Appraisal Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Appraisal Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Appraisal Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Key Responsibility Area',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'KRA',
|
||||
'oldfieldname': 'kra',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_weightage',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Weightage (%)',
|
||||
'oldfieldname': 'per_weightage',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'target_achieved',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 3,
|
||||
'label': 'Target Achieved',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'target_achieved',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'score',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Score (0-5)',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'score',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\n0\n1\n2\n3\n4\n5',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'score_earned',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Score Earned',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'score_earned',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/attendance/__init__.py
Normal file
0
hr/doctype/attendance/__init__.py
Normal file
14
hr/doctype/attendance/attendance.js
Normal file
14
hr/doctype/attendance/attendance.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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` FROM `tabEmployee` WHERE `tabEmployee`.status = "Active" AND `tabEmployee`.`docstatus`!= 2 AND `tabEmployee`.%(key)s LIKE "%s" ORDER BY `tabEmployee`.`name` ASC LIMIT 50';
|
||||
}
|
||||
130
hr/doctype/attendance/attendance.py
Normal file
130
hr/doctype/attendance/attendance.py
Normal file
@@ -0,0 +1,130 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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 str(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
|
||||
|
||||
#validation - leave_type is mandatory for status absent/ half day else not required to entered.
|
||||
def validate_status(self):
|
||||
if self.doc.status == 'Present' and self.doc.leave_type:
|
||||
msgprint("You can not enter leave type for attendance status 'Present'")
|
||||
raise Exception
|
||||
|
||||
elif (self.doc.status == 'Absent' or self.doc.status == 'Half Day') and not self.doc.leave_type:
|
||||
msgprint("Please enter leave type for attendance status 'Absent'")
|
||||
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 Transaction` where employee=%s and (from_date <= %s and to_date >= %s) and status = 'Submitted' and leave_transaction_type = 'Deduction' 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
|
||||
|
||||
#For absent/ half day record - check for leave balances of the employees
|
||||
def validate_leave_type(self):
|
||||
if not self.doc.status =='Present' and self.doc.leave_type not in ('Leave Without Pay','Compensatory Off'):
|
||||
#check for leave allocated to employee from leave transaction
|
||||
ret = sql("select name from `tabLeave Transaction` where employee = '%s' and leave_type = '%s' and leave_transaction_type = 'Allocation' and fiscal_year = '%s'"%(self.doc.employee,self.doc.leave_type,self.doc.fiscal_year))
|
||||
|
||||
#if leave allocation is present then calculate leave balance i.e. sum(allocation) - sum(deduction)
|
||||
if ret:
|
||||
q1 = 'SUM(CASE WHEN leave_transaction_type = "Allocation" THEN total_leave ELSE 0 END)-SUM(CASE WHEN leave_transaction_type = "Deduction" THEN total_leave ELSE 0 END)'
|
||||
q2 = "select %s from `tabLeave Transaction` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1"
|
||||
|
||||
res = sql(q2%(q1,self.doc.employee,self.doc.leave_type,self.doc.fiscal_year))
|
||||
|
||||
if res:
|
||||
if self.doc.status == 'Absent' and flt(res[0][0]) < 1:
|
||||
msgprint("%s balances are insufficient to cover a day absence, please select other leave type."%self.doc.leave_type)
|
||||
raise Exception
|
||||
if self.doc.status == 'Half Day' and flt(res[0][0]) < 0.5:
|
||||
msgprint("%s balances are insufficient to cover a half day absence, please select other leave type."%self.doc.leave_type)
|
||||
raise Exception
|
||||
|
||||
else:
|
||||
msgprint("Leave Allocation for employee %s not done.\n You can allocate leaves from HR -> Leave Transaction OR HR -> Leave Control Panel."%self.doc.employee)
|
||||
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_leave_type()
|
||||
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
|
||||
226
hr/doctype/attendance/attendance.txt
Normal file
226
hr/doctype/attendance/attendance.txt
Normal file
@@ -0,0 +1,226 @@
|
||||
# DocType, Attendance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-23 10:26:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-27 14:39:08',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308808105',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': 'employee, employee_name, att_date, status',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 74
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Attendance',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Attendance',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Attendance
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Attendance'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Attendance Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'naming_series',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'label': 'Naming Series',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'naming_series',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'ATT',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee',
|
||||
'oldfieldname': 'employee',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Employee',
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Employee Name',
|
||||
'oldfieldname': 'employee_name',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'status',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'Status',
|
||||
'oldfieldname': 'status',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nPresent\nAbsent\nHalf Day',
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'shifts',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'label': 'Shifts',
|
||||
'oldfieldname': 'shifts',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nDay\nNight',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_type',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 1,
|
||||
'idx': 7,
|
||||
'label': 'Leave Type',
|
||||
'oldfieldname': 'leave_type',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Leave Type',
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 8,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'att_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Attendance Date',
|
||||
'oldfieldname': 'att_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'link:Company',
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/attendance_control_panel/__init__.py
Normal file
0
hr/doctype/attendance_control_panel/__init__.py
Normal file
@@ -0,0 +1,50 @@
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
cur_frm.log_div = $a(cur_frm.fields_dict['Import Log1'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#DDD',width : '100%', height : '300px', overflow : 'auto'});
|
||||
hide_field('Import Log1')
|
||||
doc.att_fr_date = get_today();
|
||||
doc.file_list = '';
|
||||
doc.overwrite = 0;
|
||||
refresh_many(['att_fr_date','file_list','overwrite']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//download attendance template - csv file
|
||||
cur_frm.cscript['Get Template'] = function(doc,cdt,cdn){
|
||||
|
||||
if(doc.att_to_date && !doc.att_fr_date)
|
||||
alert("Please enter 'Attendance To Date'");
|
||||
else if(doc.att_to_date && doc.att_fr_date && doc.att_to_date < doc.att_fr_date)
|
||||
alert("Attendance to date cannot be less than from date.");
|
||||
else
|
||||
$c_obj_csv(make_doclist(cdt,cdn),'get_att_list','');
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
cur_frm.cscript['Import'] = function(doc,cdt,cdn){
|
||||
if(!doc.file_list){
|
||||
alert("Please upload attendance data CSV file");
|
||||
}
|
||||
else{
|
||||
var call_back = function(r,rt){
|
||||
cur_frm.log_div.innerHTML = '';
|
||||
if(r.message)
|
||||
cur_frm.log_div.innerHTML = r.message;
|
||||
|
||||
cur_frm.cscript.refresh(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
$c_obj(make_doclist(cdt,cdn),'import_att_data','',call_back);
|
||||
}
|
||||
cur_frm.cscript.refresh(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
//====================================================
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if(cur_frm.log_div.innerHTML == '')
|
||||
hide_field('Import Log1');
|
||||
else
|
||||
unhide_field('Import Log1');
|
||||
refresh_field('Import Log1');
|
||||
|
||||
}
|
||||
105
hr/doctype/attendance_control_panel/attendance_control_panel.py
Normal file
105
hr/doctype/attendance_control_panel/attendance_control_panel.py
Normal file
@@ -0,0 +1,105 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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,d,dt):
|
||||
self.doc, self.doclist = d,dt
|
||||
|
||||
#==========================================================================
|
||||
def get_att_list(self):
|
||||
|
||||
lst = [['Attendance','','','Please fill columns which are Mandatory.',' Please do not modify the structure','',''],['','','','','','',''],['[Mandatory]','','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]'],['Employee','Employee Name','Attendance Date','Status','Fiscal Year','Company','Naming Series']]
|
||||
|
||||
dt = self.date_diff_list() # get date list inbetween from date and to date
|
||||
|
||||
att_dt = self.get_att_data() # get default attendance data like fiscal yr, company, naming series
|
||||
|
||||
fy, comp, sr = att_dt['fy'], att_dt['comp'], att_dt['sr']
|
||||
|
||||
res = sql("select name, employee_name from `tabEmployee` where status = 'Active' and docstatus !=2")
|
||||
|
||||
for d in dt:
|
||||
for r in res:
|
||||
lst.append([r[0],r[1],d,'',fy,comp,sr])
|
||||
|
||||
return lst
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# get date list inbetween from date and to date
|
||||
def date_diff_list(self):
|
||||
import datetime
|
||||
#get from date
|
||||
att_fr_date = self.doc.att_fr_date and self.doc.att_fr_date or ''
|
||||
|
||||
#get to date
|
||||
att_to_date = self.doc.att_to_date and self.doc.att_to_date or ''
|
||||
|
||||
if att_to_date:
|
||||
r = (getdate(self.doc.att_to_date)+datetime.timedelta(days=1)-getdate(self.doc.att_fr_date)).days
|
||||
else:
|
||||
r = 1
|
||||
dateList = [getdate(self.doc.att_fr_date)+datetime.timedelta(days=i) for i in range(0,r)]
|
||||
dt=([str(date) for date in dateList])
|
||||
|
||||
return dt
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
def get_att_data(self):
|
||||
|
||||
fy = get_defaults()['fiscal_year'] #get default fiscal year
|
||||
|
||||
comp = get_defaults()['company'] #get default company
|
||||
|
||||
#get naming series of attendance
|
||||
#sr = sql("select series_options from `tabNaming Series Options` where doc_type='Attendance'")
|
||||
sr = sql("select options from `tabDocField` where parent = 'Attendance' and fieldname = 'naming_series'")
|
||||
if not sr:
|
||||
msgprint("Please create naming series for Attendance.\nGo to Setup--> Manage Series.")
|
||||
raise Exception
|
||||
else:
|
||||
sr = sr and sr[0][0]
|
||||
|
||||
return {'fy':fy,'comp':comp,'sr':sr}
|
||||
|
||||
#=================================================================================
|
||||
def import_att_data(self):
|
||||
filename = self.doc.file_list.split(',')
|
||||
|
||||
if not filename:
|
||||
msgprint("Please attach a .CSV File.")
|
||||
raise Exception
|
||||
|
||||
if filename[0].find('.csv') < 0:
|
||||
raise Exception
|
||||
|
||||
if not filename and filename[0] and file[1]:
|
||||
msgprint("Please Attach File. ")
|
||||
raise Exception
|
||||
|
||||
from webnotes.utils import file_manager
|
||||
fn, content = file_manager.get_file(filename[1])
|
||||
|
||||
if not type(content) == str:
|
||||
content = content.tostring()
|
||||
|
||||
import webnotes.model.import_docs
|
||||
im = webnotes.model.import_docs.CSVImport()
|
||||
out = im.import_csv(content,self.doc.import_date_format, cint(self.doc.overwrite))
|
||||
return out
|
||||
|
||||
229
hr/doctype/attendance_control_panel/attendance_control_panel.txt
Normal file
229
hr/doctype/attendance_control_panel/attendance_control_panel.txt
Normal file
@@ -0,0 +1,229 @@
|
||||
# DocType, Attendance Control Panel
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-10-19 11:19:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-04 13:33:33',
|
||||
'modified_by': 'rahul@webnotestech.com',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1294312182',
|
||||
'allow_attach': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'max_attachments': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 122
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Attendance Control Panel',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Attendance Control Panel',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Attendance Control Panel
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Attendance Control Panel'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': "Get the template of the Attendance for which you want to import in CSV (Comma seperated values) format.\nFill data in the template. Save the template in CSV format.\nAll attendance dates inbetween 'Attendance From Date' and 'Attendance To Date' will come in the template with employees list.",
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Download Template',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Selected Attendance date will comes in the attendance template.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'att_fr_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Attendance From Date',
|
||||
'oldfieldname': 'attenadnce_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 3,
|
||||
'label': 'Get Template',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 4,
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'All attendance dates inbetween selected Attendance From Date and Attendance To Date will come in the template with employees list.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'att_to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 5,
|
||||
'label': 'Attendance To Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'To import attendance data, click on "Add" button, select the saved CSV file and click on "Upload".\nSelect the date format as attendance date format in CSV file.\nClick on "Import".',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 6,
|
||||
'label': 'Upload Attendance Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'import_date_format',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 7,
|
||||
'label': 'Import Date Format ',
|
||||
'options': 'yyyy-mm-dd\nmm/dd/yyyy\nmm/dd/yy\ndd-mm-yyyy\ndd/mm/yyyy',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'overwrite',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 8,
|
||||
'label': 'Overwrite',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 9,
|
||||
'label': 'Import',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'file_list',
|
||||
'fieldtype': 'Text',
|
||||
'hidden': 1,
|
||||
'idx': 10,
|
||||
'label': 'File List',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 11,
|
||||
'label': 'Import Log',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'idx': 12,
|
||||
'label': 'Import Log1',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/branch/__init__.py
Normal file
0
hr/doctype/branch/__init__.py
Normal file
0
hr/doctype/branch/branch.js
Normal file
0
hr/doctype/branch/branch.js
Normal file
104
hr/doctype/branch/branch.txt
Normal file
104
hr/doctype/branch/branch.txt
Normal file
@@ -0,0 +1,104 @@
|
||||
# DocType, Branch
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-30 15:24:02',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:branch',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 11
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Branch',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Branch',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Branch
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Branch'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'branch',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Branch',
|
||||
'oldfieldname': 'branch',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/chapter_vi_a_detail/__init__.py
Normal file
0
hr/doctype/chapter_vi_a_detail/__init__.py
Normal file
145
hr/doctype/chapter_vi_a_detail/chapter_vi_a_detail.txt
Normal file
145
hr/doctype/chapter_vi_a_detail/chapter_vi_a_detail.txt
Normal file
@@ -0,0 +1,145 @@
|
||||
# DocType, Chapter VI A Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 9
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Chapter VI A Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Chapter VI A Detail',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Chapter VI A Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Chapter VI A Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'particulars3',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Particulars',
|
||||
'oldfieldname': 'particulars3',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'under_section3',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Under Section',
|
||||
'oldfieldname': 'under_section3',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'max_limit3',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Max. Limit',
|
||||
'oldfieldname': 'max_limit3',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'actual_amount3',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Actual Amount',
|
||||
'oldfieldname': 'actual_amount3',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'eligible_amount3',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Eligible Amount',
|
||||
'oldfieldname': 'eligible_amount3',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'modified_amount3',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Modified Amount',
|
||||
'oldfieldname': 'modified_amount3',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/declaration_detail/__init__.py
Normal file
0
hr/doctype/declaration_detail/__init__.py
Normal file
144
hr/doctype/declaration_detail/declaration_detail.txt
Normal file
144
hr/doctype/declaration_detail/declaration_detail.txt
Normal file
@@ -0,0 +1,144 @@
|
||||
# DocType, Declaration Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Declaration Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Declaration Detail',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Declaration Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Declaration Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'particulars1',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Particulars',
|
||||
'oldfieldname': 'particulars1',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'width': '200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'under_section1',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Under Section',
|
||||
'oldfieldname': 'under_section1',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'max_limit1',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Max. Limit',
|
||||
'oldfieldname': 'max_limit1',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'actual_amount1',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Actual Amount',
|
||||
'oldfieldname': 'actual_amount1',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'eligible_amount1',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Eligible Amount',
|
||||
'oldfieldname': 'eligible_amount1',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'modified_amount1',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Modified Amount',
|
||||
'oldfieldname': 'modified_amount1',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/deduction_detail/__init__.py
Normal file
0
hr/doctype/deduction_detail/__init__.py
Normal file
77
hr/doctype/deduction_detail/deduction_detail.txt
Normal file
77
hr/doctype/deduction_detail/deduction_detail.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
# DocType, Deduction Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-11-02 20:44:58',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 14
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Deduction Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Deduction Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Deduction Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'd_type',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Type',
|
||||
'oldfieldname': 'd_type',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Deduction Type',
|
||||
'reqd': 1,
|
||||
'width': '200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'd_modified_amt',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Amount',
|
||||
'oldfieldname': 'd_modified_amt',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'depend_on_lwp',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 4,
|
||||
'label': 'Depend on LWP',
|
||||
'oldfieldname': 'depend_on_lwp',
|
||||
'oldfieldtype': 'Check'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/deduction_type/__init__.py
Normal file
0
hr/doctype/deduction_type/__init__.py
Normal file
0
hr/doctype/deduction_type/deduction_type.js
Normal file
0
hr/doctype/deduction_type/deduction_type.js
Normal file
115
hr/doctype/deduction_type/deduction_type.txt
Normal file
115
hr/doctype/deduction_type/deduction_type.txt
Normal file
@@ -0,0 +1,115 @@
|
||||
# DocType, Deduction Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-10-12 17:19:47',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:deduction_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 10
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Deduction Type',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Deduction Type',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Deduction Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Deduction Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'deduction_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Name',
|
||||
'oldfieldname': 'deduction_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 3,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0,
|
||||
'width': '300px'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/department/__init__.py
Normal file
0
hr/doctype/department/__init__.py
Normal file
0
hr/doctype/department/department.js
Normal file
0
hr/doctype/department/department.js
Normal file
102
hr/doctype/department/department.txt
Normal file
102
hr/doctype/department/department.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
# DocType, Department
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:department_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Department',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Department',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Department
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Department'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Department',
|
||||
'oldfieldname': 'department_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/designation/__init__.py
Normal file
0
hr/doctype/designation/__init__.py
Normal file
0
hr/doctype/designation/designation.js
Normal file
0
hr/doctype/designation/designation.js
Normal file
102
hr/doctype/designation/designation.txt
Normal file
102
hr/doctype/designation/designation.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
# DocType, Designation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:designation_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Designation',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Designation',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Designation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Designation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Designation',
|
||||
'oldfieldname': 'designation_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/earn_deduction_detail/__init__.py
Normal file
0
hr/doctype/earn_deduction_detail/__init__.py
Normal file
116
hr/doctype/earn_deduction_detail/earn_deduction_detail.txt
Normal file
116
hr/doctype/earn_deduction_detail/earn_deduction_detail.txt
Normal file
@@ -0,0 +1,116 @@
|
||||
# DocType, Earn Deduction Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Earn Deduction Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Earn Deduction Detail',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Earn Deduction Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Earn Deduction Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'earn_deduction_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Earn/Deduction Name',
|
||||
'oldfieldname': 'earn_deduction_name',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mode',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'label': 'Mode',
|
||||
'oldfieldname': 'mode',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\n%\nRs'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Per.(%)',
|
||||
'oldfieldname': 'per',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amount',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Amount',
|
||||
'oldfieldname': 'amount',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Type',
|
||||
'oldfieldname': 'type',
|
||||
'oldfieldtype': 'Data'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/earning_detail/__init__.py
Normal file
0
hr/doctype/earning_detail/__init__.py
Normal file
80
hr/doctype/earning_detail/earning_detail.txt
Normal file
80
hr/doctype/earning_detail/earning_detail.txt
Normal file
@@ -0,0 +1,80 @@
|
||||
# DocType, Earning Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-09 13:02:55',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 26
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Earning Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Earning Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Earning Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'e_type',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Type',
|
||||
'oldfieldname': 'e_type',
|
||||
'oldfieldtype': 'Data',
|
||||
'options': 'Earning Type',
|
||||
'reqd': 1,
|
||||
'width': '200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'modified_value',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Amount',
|
||||
'oldfieldname': 'modified_value',
|
||||
'oldfieldtype': 'Currency',
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'depend_on_lwp',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 3,
|
||||
'label': 'Depend on LWP',
|
||||
'oldfieldname': 'depend_on_lwp',
|
||||
'oldfieldtype': 'Check'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/earning_type/__init__.py
Normal file
0
hr/doctype/earning_type/__init__.py
Normal file
0
hr/doctype/earning_type/earning_type.js
Normal file
0
hr/doctype/earning_type/earning_type.js
Normal file
147
hr/doctype/earning_type/earning_type.txt
Normal file
147
hr/doctype/earning_type/earning_type.txt
Normal file
@@ -0,0 +1,147 @@
|
||||
# DocType, Earning Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-10-12 17:15:46',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:earning_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 13
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Earning Type',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Earning Type',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Earning Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Earning Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'earning_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Name',
|
||||
'oldfieldname': 'earning_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 3,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0,
|
||||
'reqd': 0,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'taxable',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Taxable',
|
||||
'oldfieldname': 'taxable',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': "eval:doc.taxable=='No'",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'exemption_limit',
|
||||
'fieldtype': 'Currency',
|
||||
'hidden': 1,
|
||||
'idx': 5,
|
||||
'label': 'Exemption Limit',
|
||||
'oldfieldname': 'exemption_limit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/educational_qualifications/__init__.py
Normal file
0
hr/doctype/educational_qualifications/__init__.py
Normal file
@@ -0,0 +1,117 @@
|
||||
# DocType, Educational Qualifications
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 11
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Educational Qualifications',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Educational Qualifications
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Educational Qualifications'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'school_univ',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'School/University',
|
||||
'oldfieldname': 'school_univ',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'qualification',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Qualification (Degree/Diploma)',
|
||||
'oldfieldname': 'qualification',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 0,
|
||||
'search_index': 1,
|
||||
'width': '170px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'level',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'label': 'Level',
|
||||
'oldfieldname': 'level',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nGraduate\nPost Graduate\nUnder Graduate',
|
||||
'reqd': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'year_of_passing',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 4,
|
||||
'label': 'Year of Passing',
|
||||
'oldfieldname': 'year_of_passing',
|
||||
'oldfieldtype': 'Int',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'class_percent',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Class / Percentage',
|
||||
'oldfieldname': 'class_percent',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'maj_opt_sub',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Major / Optional Subject',
|
||||
'oldfieldname': 'maj_opt_sub',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 0,
|
||||
'width': '170px'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,109 @@
|
||||
# DocType, Educational Qualifications Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Educational Qualifications Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Educational Qualifications Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Educational Qualifications Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'school_univ',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'School/University',
|
||||
'oldfieldname': 'school_univ',
|
||||
'oldfieldtype': 'Small Text'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'qualification',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Qualification',
|
||||
'oldfieldname': 'qualification',
|
||||
'oldfieldtype': 'Data',
|
||||
'width': '100px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'level',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'label': 'Level',
|
||||
'oldfieldname': 'level',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Graduate\nPost Graduate\nUnder Graduate'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'year_of_passing',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 4,
|
||||
'label': 'Year of Passing',
|
||||
'oldfieldname': 'year_of_passing',
|
||||
'oldfieldtype': 'Int'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'class_per',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Class / Percentage',
|
||||
'oldfieldname': 'class_per',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'maj_opt_subj',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 6,
|
||||
'label': 'Major/Optional Subjects',
|
||||
'oldfieldname': 'maj_opt_subj',
|
||||
'oldfieldtype': 'Text'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/employee/__init__.py
Normal file
0
hr/doctype/employee/__init__.py
Normal file
51
hr/doctype/employee/employee.js
Normal file
51
hr/doctype/employee/employee.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// get retirement date
|
||||
//========================================================
|
||||
cur_frm.cscript.date_of_birth = function(doc, dt, dn) {
|
||||
get_server_fields('get_retirement_date','','',doc,dt,dn,1);
|
||||
}
|
||||
|
||||
// salutation-gender
|
||||
//========================================================
|
||||
cur_frm.cscript.salutation = function(doc,dt,dn) {
|
||||
if(doc.salutation){
|
||||
if(doc.salutation=='Mr')
|
||||
doc.gender='Male';
|
||||
else if(doc.salutation=='Ms')
|
||||
doc.gender='Female';
|
||||
refresh_field('gender');
|
||||
}
|
||||
}
|
||||
|
||||
// On refresh
|
||||
//========================================================
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
if(doc.__islocal!=1){
|
||||
cur_frm.add_custom_button('Make Salary Structure', cur_frm.cscript['Make Salary Structure']);
|
||||
}
|
||||
}
|
||||
|
||||
//Make Salary Structure
|
||||
//========================================================
|
||||
cur_frm.cscript['Make Salary Structure']=function(){
|
||||
$c_obj(make_doclist (doc.doctype,doc.name),'check_sal_structure',cur_frm.doc.name,function(r, rt) {
|
||||
if(r.message)
|
||||
alert("You have already created Active salary structure.\nIf you want to create new one, please ensure that no active salary structure exist.\nTo inactive salary structure select 'Is Active' as 'No'.");
|
||||
else
|
||||
cur_frm.cscript.make_salary_structure(cur_frm.doc);
|
||||
});
|
||||
}
|
||||
|
||||
// Load sal structure
|
||||
//========================================================
|
||||
cur_frm.cscript.make_salary_structure = function(doc,dt,dn,det){
|
||||
var st = LocalDB.create('Salary Structure');
|
||||
st = locals['Salary Structure'][st];
|
||||
st.employee = doc.name;
|
||||
st.employee_name = doc.employee_name;
|
||||
st.branch=doc.branch;
|
||||
st.designation=doc.designation;
|
||||
st.department=doc.department;
|
||||
st.fiscal_year = doc.fiscal_year
|
||||
st.grade=doc.grade;
|
||||
loaddoc('Salary Structure', st.name);
|
||||
}
|
||||
118
hr/doctype/employee/employee.py
Normal file
118
hr/doctype/employee/employee.py
Normal file
@@ -0,0 +1,118 @@
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
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
|
||||
#========================================================================================================
|
||||
def autoname(self):
|
||||
ret = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'emp_created_by'")
|
||||
if not ret:
|
||||
msgprint("To Save Employee, please go to Setup -->Global Defaults. Click on HR and select 'Employee Records to be created by'.")
|
||||
raise Exception
|
||||
else:
|
||||
if ret[0][0]=='Naming Series':
|
||||
self.doc.name = make_autoname(self.doc.naming_series + '.####')
|
||||
elif ret[0][0]=='Employee Number':
|
||||
self.doc.name = make_autoname(self.doc.employee_number)
|
||||
|
||||
# Get retirement date
|
||||
#========================================================================================================
|
||||
def get_retirement_date(self):
|
||||
import datetime
|
||||
ret = {}
|
||||
if self.doc.date_of_birth:
|
||||
dt = getdate(self.doc.date_of_birth) + datetime.timedelta(21915)
|
||||
ret = {'date_of_retirement': dt.strftime('%Y-%m-%d')}
|
||||
return str(ret)
|
||||
|
||||
# check if salary structure exists
|
||||
#========================================================================================================
|
||||
def check_sal_structure(self, nm):
|
||||
ret_sal_struct=sql("select name from `tabSalary Structure` where employee='%s' and is_active = 'Yes'"%nm)
|
||||
return ret_sal_struct and ret_sal_struct[0][0] or ''
|
||||
|
||||
#========================================================================================================
|
||||
def validate(self):
|
||||
self.validate_date()
|
||||
self.validate_email()
|
||||
self.validate_name()
|
||||
self.validate_status()
|
||||
|
||||
# Validate dates
|
||||
#========================================================================================================
|
||||
def validate_date(self):
|
||||
import datetime
|
||||
if self.doc.date_of_birth and self.doc.date_of_joining and getdate(self.doc.date_of_birth) >= getdate(self.doc.date_of_joining):
|
||||
msgprint('Date of Joining must be greater than Date of Birth')
|
||||
raise Exception
|
||||
|
||||
elif self.doc.scheduled_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.scheduled_confirmation_date) < getdate(self.doc.date_of_joining)):
|
||||
msgprint('Scheduled Confirmation Date must be greater than Date of Joining')
|
||||
raise Exception
|
||||
|
||||
elif self.doc.final_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.final_confirmation_date) < getdate(self.doc.date_of_joining)):
|
||||
msgprint('Final Confirmation Date must be greater than Date of Joining')
|
||||
raise Exception
|
||||
|
||||
elif self.doc.date_of_retirement and self.doc.date_of_joining and (getdate(self.doc.date_of_retirement) <= getdate(self.doc.date_of_joining)):
|
||||
msgprint('Date Of Retirement must be greater than Date of Joining')
|
||||
raise Exception
|
||||
|
||||
elif self.doc.relieving_date and self.doc.date_of_joining and (getdate(self.doc.relieving_date) <= getdate(self.doc.date_of_joining)):
|
||||
msgprint('Relieving Date must be greater than Date of Joining')
|
||||
raise Exception
|
||||
|
||||
elif self.doc.contract_end_date and self.doc.date_of_joining and (getdate(self.doc.contract_end_date)<=getdate(self.doc.date_of_joining)):
|
||||
msgprint('Contract End Date must be greater than Date of Joining')
|
||||
raise Exception
|
||||
|
||||
# Validate email id
|
||||
#========================================================================================================
|
||||
def validate_email(self):
|
||||
if self.doc.company_email and not validate_email_add(self.doc.company_email):
|
||||
msgprint("Please enter valid Company Email")
|
||||
raise Exception
|
||||
if self.doc.personal_email and not validate_email_add(self.doc.personal_email):
|
||||
msgprint("Please enter valid Personal Email")
|
||||
raise Exception
|
||||
|
||||
# Validate name
|
||||
#========================================================================================================
|
||||
def validate_name(self):
|
||||
ret = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'emp_created_by'")
|
||||
|
||||
if not ret:
|
||||
msgprint("To Save Employee, please go to Setup -->Global Defaults. Click on HR and select 'Employee Records to be created by'.")
|
||||
raise Exception
|
||||
else:
|
||||
if ret[0][0]=='Naming Series' and not self.doc.naming_series:
|
||||
msgprint("Please select Naming Series.")
|
||||
raise Exception
|
||||
elif ret[0][0]=='Employee Number' and not self.doc.employee_number:
|
||||
msgprint("Please enter Employee Number.")
|
||||
raise Exception
|
||||
|
||||
# Validate status
|
||||
#========================================================================================================
|
||||
def validate_status(self):
|
||||
if self.doc.status == 'Left' and not self.doc.relieving_date:
|
||||
msgprint("Please enter relieving date.")
|
||||
raise Exception
|
||||
1105
hr/doctype/employee/employee.txt
Normal file
1105
hr/doctype/employee/employee.txt
Normal file
File diff suppressed because it is too large
Load Diff
0
hr/doctype/employee_profile/__init__.py
Normal file
0
hr/doctype/employee_profile/__init__.py
Normal file
44
hr/doctype/employee_profile/employee_profile.js
Normal file
44
hr/doctype/employee_profile/employee_profile.js
Normal file
@@ -0,0 +1,44 @@
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'cal_tot_exp','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) { refresh_many(['year','months']); });
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
||||
cur_frm.cscript.employee = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'get_doj','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) { refresh_many(['employee_name','date_of_joining']); });
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
||||
cur_frm.cscript.country1 = function(doc, cdt, cdn) {
|
||||
var mydoc=doc;
|
||||
$c('runserverobj', args={'method':'check_state','arg':doc.country1, 'docs':compress_doclist([doc])},
|
||||
function(r,rt){
|
||||
|
||||
if(r.message) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
doc.state1 = '';
|
||||
get_field(doc.doctype, 'state1' , doc.name).options = r.message;
|
||||
refresh_field('state1');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
cur_frm.cscript.country2 = function(doc, cdt, cdn) {
|
||||
var mydoc=doc;
|
||||
$c('runserverobj', args={'method':'check_state', 'arg':doc.country2,'docs':compress_doclist([doc])},
|
||||
function(r,rt){
|
||||
|
||||
if(r.message) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
doc.state2 = '';
|
||||
get_field(doc.doctype, 'state2' , doc.name).options = r.message;
|
||||
refresh_field('state2');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
73
hr/doctype/employee_profile/employee_profile.py
Normal file
73
hr/doctype/employee_profile/employee_profile.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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:
|
||||
#init function
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
#=============================================================
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname('EMP-'+self.doc.employee)
|
||||
|
||||
#=============================================================
|
||||
def validate(self):
|
||||
if self.doc.personal_email:
|
||||
if not validate_email_add(self.doc.personal_email):
|
||||
msgprint("Please enter valid Personal Email")
|
||||
raise Exception
|
||||
ret = sql("select name from `tabEmployee Profile` where employee = '%s' and name !='%s'"%(self.doc.employee,self.doc.name))
|
||||
if ret:
|
||||
msgprint("Employee Profile is already created for Employee : '%s'"%self.doc.employee)
|
||||
raise Exception
|
||||
|
||||
#=============================================================
|
||||
def get_doj(self):
|
||||
ret_doj = sql("select employee_name,date_of_joining from `tabEmployee` where name = '%s'"%self.doc.employee)
|
||||
if ret_doj:
|
||||
set(self.doc, 'employee_name', cstr(ret_doj[0][0]))
|
||||
set(self.doc,'date_of_joining', ret_doj[0][1].strftime('%Y-%m-%d'))
|
||||
|
||||
#=============================================================
|
||||
#calculate total experience in company - total year and month
|
||||
def cal_tot_exp(self):
|
||||
if not self.doc.date_of_joining:
|
||||
self.get_doj()
|
||||
|
||||
import datetime
|
||||
today = nowdate()
|
||||
|
||||
diff = (getdate(today) - getdate(self.doc.date_of_joining)).days
|
||||
diff1 = cint(diff)/365
|
||||
a = cint(diff)%365
|
||||
diff2 = cint(a)/30
|
||||
if(cint(diff1)<0):
|
||||
set(self.doc,'year', 0)
|
||||
else:
|
||||
set(self.doc,'year', cint(diff1))
|
||||
if(cint(diff1)<0):
|
||||
set(self.doc,'months', 0)
|
||||
else:
|
||||
set(self.doc,'months', cint(diff2))
|
||||
|
||||
#=============================================================
|
||||
def check_state(self,country):
|
||||
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " %country)])
|
||||
1
hr/doctype/employee_profile/employee_profile.txt
Normal file
1
hr/doctype/employee_profile/employee_profile.txt
Normal file
File diff suppressed because one or more lines are too long
0
hr/doctype/employment_type/__init__.py
Normal file
0
hr/doctype/employment_type/__init__.py
Normal file
0
hr/doctype/employment_type/employment_type.js
Normal file
0
hr/doctype/employment_type/employment_type.js
Normal file
102
hr/doctype/employment_type/employment_type.txt
Normal file
102
hr/doctype/employment_type/employment_type.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
# DocType, Employment Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:00',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:employee_type_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 16
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Employment Type',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Employment Type',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Employment Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Employment Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_type_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Employment Type',
|
||||
'oldfieldname': 'employee_type_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 2,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/expense_type/__init__.py
Normal file
0
hr/doctype/expense_type/__init__.py
Normal file
0
hr/doctype/expense_type/expense_type.js
Normal file
0
hr/doctype/expense_type/expense_type.js
Normal file
101
hr/doctype/expense_type/expense_type.txt
Normal file
101
hr/doctype/expense_type/expense_type.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# DocType, Expense Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-03 16:45:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'field:expense_type',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Expense Type',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Expense Type',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Expense Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Expense Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'expense_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'in_filter': 0,
|
||||
'label': 'Expense Type',
|
||||
'oldfieldname': 'expense_type',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 2,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'width': '300px'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/expense_voucher/__init__.py
Normal file
0
hr/doctype/expense_voucher/__init__.py
Normal file
213
hr/doctype/expense_voucher/expense_voucher.js
Normal file
213
hr/doctype/expense_voucher/expense_voucher.js
Normal file
@@ -0,0 +1,213 @@
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
//cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
if(!doc.approval_status) set_multiple(cdt,cdn,{approval_status:'Draft'});
|
||||
if(doc.employee) cur_frm.cscript.employee(doc,cdt,cdn);
|
||||
|
||||
if (doc.__islocal) {
|
||||
if(doc.amended_from) set_multiple(cdt,cdn,{approval_status:'Draft'});
|
||||
var val = getchildren('Expense Voucher Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
val[i].sanctioned_amount ='';
|
||||
}
|
||||
//doc.total_claimed_amount = '';
|
||||
doc.total_sanctioned_amount = '';
|
||||
refresh_many(['sanctioned_amount', 'total_sanctioned_amount']);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if((user == doc.exp_approver && doc.approval_status == 'Submitted') || doc.docstatus == 0) unhide_field('Calculate Total Amount');
|
||||
else hide_field('Calculate Total Amount');
|
||||
|
||||
if(user == doc.exp_approver && doc.approval_status == 'Submitted') unhide_field(['Update Voucher', 'Approve', 'Reject']);
|
||||
|
||||
else hide_field(['Update Voucher', 'Approve', 'Reject']);
|
||||
|
||||
|
||||
if(user == doc.exp_approver && doc.approval_status == 'Submitted') set_field_permlevel('remark', 0);
|
||||
else set_field_permlevel('remark', 1);
|
||||
}
|
||||
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
if(doc.employee){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){
|
||||
if(r.message){
|
||||
doc.employee_name = r.message['emp_nm'];
|
||||
get_field(doc.doctype, 'exp_approver' , doc.name).options = r.message['app_lst'];
|
||||
refresh_many(['exp_approver','employee_name']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
|
||||
if(doc.approval_status == 'Draft'){
|
||||
var val = getchildren('Expense Voucher Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
var total_claim =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total_claim = flt(total_claim)+flt(val[i].claim_amount);
|
||||
}
|
||||
doc.total_claimed_amount = flt(total_claim);
|
||||
refresh_field('total_claimed_amount');
|
||||
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'validate_approver','', function(r,rt){
|
||||
if(r.message){
|
||||
if(r.message['valid_approver'] == 'No'){
|
||||
doc.exp_approver ='';
|
||||
}
|
||||
get_field(doc.doctype, 'exp_approver' , doc.name).options = '';
|
||||
get_field(doc.doctype, 'exp_approver' , doc.name).options = r.message['app_lst'];
|
||||
refresh_field('exp_approver');
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(doc.approval_status == 'Submitted'){
|
||||
var val = getchildren('Expense Voucher Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
var total_sanctioned = 0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total_sanctioned = flt(total_sanctioned)+flt(val[i].sanctioned_amount);
|
||||
}
|
||||
doc.total_sanctioned_amount = flt(total_sanctioned);
|
||||
refresh_field('total_sanctioned_amount');
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Calculate Total Amount'] = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
}
|
||||
cur_frm.cscript.claim_amount = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
}
|
||||
cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript['Approve'] = function(doc,cdt,cdn){
|
||||
|
||||
if(user == doc.exp_approver){
|
||||
var approve_voucher_dialog;
|
||||
|
||||
set_approve_voucher_dialog = function() {
|
||||
approve_voucher_dialog = new Dialog(400, 200, 'Approve Voucher');
|
||||
approve_voucher_dialog.make_body([
|
||||
['HTML', 'Message', '<div class = "comment">You wont be able to do any changes after approving this expense voucher. Are you sure, you want to approve it ?</div>'],
|
||||
['HTML', 'Response', '<div class = "comment" id="approve_voucher_dialog_response"></div>'],
|
||||
['HTML', 'Approve Voucher', '<div></div>']
|
||||
]);
|
||||
|
||||
var approve_voucher_btn1 = $a($i(approve_voucher_dialog.widgets['Approve Voucher']), 'button', 'button');
|
||||
approve_voucher_btn1.innerHTML = 'Yes';
|
||||
approve_voucher_btn1.onclick = function(){ approve_voucher_dialog.add(); }
|
||||
|
||||
var approve_voucher_btn2 = $a($i(approve_voucher_dialog.widgets['Approve Voucher']), 'button', 'button');
|
||||
approve_voucher_btn2.innerHTML = 'No';
|
||||
$y(approve_voucher_btn2,{marginLeft:'4px'});
|
||||
approve_voucher_btn2.onclick = function(){ approve_voucher_dialog.hide();}
|
||||
|
||||
approve_voucher_dialog.onshow = function() {
|
||||
$i('approve_voucher_dialog_response').innerHTML = '';
|
||||
}
|
||||
|
||||
approve_voucher_dialog.add = function() {
|
||||
// sending...
|
||||
$i('approve_voucher_dialog_response').innerHTML = 'Processing...';
|
||||
|
||||
$c_obj(make_doclist(this.doc.doctype, this.doc.name),'approve_voucher','', function(r,rt){
|
||||
if(r.message == 'Approved'){
|
||||
$i('approve_voucher_dialog_response').innerHTML = 'Approved';
|
||||
refresh_field('approval_status');
|
||||
hide_field(['Update Voucher', 'Approve', 'Reject', 'Calculate Total Amount']);
|
||||
approve_voucher_dialog.hide();
|
||||
}
|
||||
else if(r.message == 'Incomplete'){
|
||||
$i('approve_voucher_dialog_response').innerHTML = 'Incomplete Voucher';
|
||||
}
|
||||
else if(r.message == 'No Amount'){
|
||||
$i('approve_voucher_dialog_response').innerHTML = 'Calculate total amount';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(!approve_voucher_dialog){
|
||||
set_approve_voucher_dialog();
|
||||
}
|
||||
approve_voucher_dialog.doc = doc;
|
||||
approve_voucher_dialog.cdt = cdt;
|
||||
approve_voucher_dialog.cdn = cdn;
|
||||
approve_voucher_dialog.show();
|
||||
refresh_field('expense_voucher_details');
|
||||
doc.__unsaved = 0;
|
||||
cur_frm.refresh_header();
|
||||
}else{
|
||||
msgprint("Expense Voucher can be approved by Approver only");
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Reject'] = function(doc,cdt,cdn){
|
||||
if(user == doc.exp_approver){
|
||||
var reject_voucher_dialog;
|
||||
|
||||
set_reject_voucher_dialog = function() {
|
||||
reject_voucher_dialog = new Dialog(400, 200, 'Reject Voucher');
|
||||
reject_voucher_dialog.make_body([
|
||||
['HTML', 'Message', '<div class = "comment">You wont be able to do any changes after rejecting this expense voucher. Are you sure, you want to reject it ?</div>'],
|
||||
['HTML', 'Response', '<div class = "comment" id="reject_voucher_dialog_response"></div>'],
|
||||
['HTML', 'Reject Voucher', '<div></div>']
|
||||
]);
|
||||
|
||||
var reject_voucher_btn1 = $a($i(reject_voucher_dialog.widgets['Reject Voucher']), 'button', 'button');
|
||||
reject_voucher_btn1.innerHTML = 'Yes';
|
||||
reject_voucher_btn1.onclick = function(){ reject_voucher_dialog.add(); }
|
||||
|
||||
var reject_voucher_btn2 = $a($i(reject_voucher_dialog.widgets['Reject Voucher']), 'button', 'button');
|
||||
reject_voucher_btn2.innerHTML = 'No';
|
||||
$y(reject_voucher_btn2,{marginLeft:'4px'});
|
||||
reject_voucher_btn2.onclick = function(){ reject_voucher_dialog.hide();}
|
||||
|
||||
reject_voucher_dialog.onshow = function() {
|
||||
$i('reject_voucher_dialog_response').innerHTML = '';
|
||||
}
|
||||
|
||||
reject_voucher_dialog.add = function() {
|
||||
// sending...
|
||||
$i('reject_voucher_dialog_response').innerHTML = 'Processing...';
|
||||
|
||||
$c_obj(make_doclist(this.doc.doctype, this.doc.name),'reject_voucher','', function(r,rt){
|
||||
if(r.message == 'Rejected'){
|
||||
$i('reject_voucher_dialog_response').innerHTML = 'Rejected';
|
||||
refresh_field('approval_status');
|
||||
hide_field(['Update Voucher', 'Approve', 'Reject', 'Calculate Total Amount']);
|
||||
reject_voucher_dialog.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(!reject_voucher_dialog){
|
||||
set_reject_voucher_dialog();
|
||||
}
|
||||
reject_voucher_dialog.doc = doc;
|
||||
reject_voucher_dialog.cdt = cdt;
|
||||
reject_voucher_dialog.cdn = cdn;
|
||||
reject_voucher_dialog.show();
|
||||
refresh_field('expense_voucher_details');
|
||||
doc.__unsaved = 0;
|
||||
cur_frm.refresh_header();
|
||||
}else{
|
||||
msgprint("Expense Voucher can be rejected by Approver only");
|
||||
}
|
||||
}
|
||||
|
||||
//update follow up
|
||||
//=================================================================================
|
||||
cur_frm.cscript['Update Voucher'] = function(doc){
|
||||
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'update_voucher','',function(r, rt){
|
||||
refresh_field('expense_voucher_details');
|
||||
doc.__unsaved = 0;
|
||||
cur_frm.refresh_header();
|
||||
});
|
||||
}
|
||||
143
hr/doctype/expense_voucher/expense_voucher.py
Normal file
143
hr/doctype/expense_voucher/expense_voucher.py
Normal file
@@ -0,0 +1,143 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_dtl = sql("select employee_name,company_email from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm = emp_dtl and emp_dtl[0][0] or ''
|
||||
self.doc.employee_name = emp_nm
|
||||
self.doc.email_id = emp_dtl and emp_dtl[0][1] or ''
|
||||
|
||||
return cstr(emp_nm)
|
||||
|
||||
def get_approver_lst(self):
|
||||
approver_lst =[]
|
||||
approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
|
||||
if approver_lst1:
|
||||
approver_lst=approver_lst1
|
||||
else:
|
||||
approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
|
||||
return approver_lst
|
||||
|
||||
def set_approver(self):
|
||||
ret={}
|
||||
approver_lst =[]
|
||||
emp_nm = self.get_employee_name()
|
||||
approver_lst = self.get_approver_lst()
|
||||
ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
|
||||
return ret
|
||||
|
||||
def update_voucher(self):
|
||||
sql("delete from `tabExpense Voucher Detail` where parent = '%s'"%self.doc.name)
|
||||
for d in getlist(self.doclist, 'expense_voucher_details'):
|
||||
if not d.expense_type or not d.claim_amount:
|
||||
msgprint("Please remove the extra blank row added")
|
||||
raise Exception
|
||||
d.save(1)
|
||||
if self.doc.total_sanctioned_amount:
|
||||
set(self.doc,'total_sanctioned_amount',self.doc.total_sanctioned_amount)
|
||||
if self.doc.remark:
|
||||
set(self.doc, 'remark', self.doc.remark)
|
||||
|
||||
def approve_voucher(self):
|
||||
for d in getlist(self.doclist, 'expense_voucher_details'):
|
||||
if not d.sanctioned_amount:
|
||||
msgprint("Please add 'Sanctioned Amount' for all expenses")
|
||||
return cstr('Incomplete')
|
||||
|
||||
if not self.doc.total_sanctioned_amount:
|
||||
msgprint("Please calculate total sanctioned amount using button 'Calculate Total Amount'")
|
||||
return cstr('No Amount')
|
||||
self.update_voucher()
|
||||
|
||||
set(self.doc, 'approval_status', 'Approved')
|
||||
# on approval notification
|
||||
get_obj('Notification Control').notify_contact('Expense Voucher Approved', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
|
||||
|
||||
return cstr('Approved')
|
||||
|
||||
def reject_voucher(self):
|
||||
|
||||
if self.doc.remark:
|
||||
set(self.doc, 'remark', self.doc.remark)
|
||||
set(self.doc, 'approval_status', 'Rejected')
|
||||
|
||||
# on approval notification
|
||||
get_obj('Notification Control').notify_contact('Expense Voucher Rejected', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
|
||||
|
||||
return cstr('Rejected')
|
||||
|
||||
def validate_curr_exp(self):
|
||||
for d in getlist(self.doclist, 'expense_voucher_details'):
|
||||
if flt(d.sanctioned_amount) > 0:
|
||||
if self.doc.approval_status == 'Draft':
|
||||
msgprint("Sanctioned amount can be added by Approver person only for submitted Expense Voucher")
|
||||
raise Exception
|
||||
elif self.doc.approval_status == 'Submitted' and session['user'] != self.doc.exp_approver:
|
||||
msgprint("Sanctioned amount can be added only by expense voucher Approver")
|
||||
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.posting_date) < str(ysd) or str(self.doc.posting_date) > str(yed):
|
||||
msgprint("Posting Date is not within the Fiscal Year selected")
|
||||
raise Exception
|
||||
|
||||
def validate(self):
|
||||
self.validate_curr_exp()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
def on_update(self):
|
||||
set(self.doc, 'approval_status', 'Draft')
|
||||
|
||||
def validate_exp_details(self):
|
||||
if not getlist(self.doclist, 'expense_voucher_details'):
|
||||
msgprint("Please add expense voucher details")
|
||||
raise Exception
|
||||
|
||||
if not self.doc.total_claimed_amount:
|
||||
msgprint("Please calculate Total Claimed Amount")
|
||||
raise Exception
|
||||
|
||||
if not self.doc.exp_approver:
|
||||
msgprint("Please select Expense Voucher approver")
|
||||
raise Exception
|
||||
|
||||
def validate_approver(self):
|
||||
app_lst = self.get_approver_lst()
|
||||
if self.doc.exp_approver and self.doc.exp_approver not in app_lst:
|
||||
msgprint("Approver "+self.doc.exp_approver+" is not authorized to approve this expense voucher. Please select another approver")
|
||||
valid_app = 'No'
|
||||
else:
|
||||
valid_app = 'Yes'
|
||||
ret = {'app_lst':("\n" + "\n".join(app_lst)), 'valid_approver':valid_app}
|
||||
return ret
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_exp_details()
|
||||
set(self.doc, 'approval_status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'approval_status', 'Cancelled')
|
||||
439
hr/doctype/expense_voucher/expense_voucher.txt
Normal file
439
hr/doctype/expense_voucher/expense_voucher.txt
Normal file
@@ -0,0 +1,439 @@
|
||||
# DocType, Expense Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-03 16:45:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-27 14:39:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308808105',
|
||||
'autoname': 'EXP.######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': 'approval_status,employee,employee_name',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': 'From %(employee_name)s for %(total_claimed_amount)s (claimed)',
|
||||
'tag_fields': 'approval_status',
|
||||
'version': 134
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Expense Voucher',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Expense Voucher',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Expense Voucher
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Expense Voucher'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Draft',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'approval_status',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Approval Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'approval_status',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nDraft\nSubmitted\nApproved \nRejected\nCancelled',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'From Employee',
|
||||
'oldfieldname': 'employee',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee Name',
|
||||
'oldfieldname': 'employee_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'search_index': 1,
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 7,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Posting Date',
|
||||
'oldfieldname': 'posting_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'exp_approver',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 9,
|
||||
'label': 'Approver',
|
||||
'oldfieldname': 'exp_approver',
|
||||
'oldfieldtype': 'Select',
|
||||
'permlevel': 0,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remark',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 10,
|
||||
'label': 'Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remark',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 11,
|
||||
'label': 'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amended_from',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 12,
|
||||
'label': 'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amendment_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'hidden': 1,
|
||||
'idx': 13,
|
||||
'label': 'Approve',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'hidden': 1,
|
||||
'idx': 14,
|
||||
'label': 'Reject',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 15,
|
||||
'label': 'Expense Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 16,
|
||||
'label': 'Calculate Total Amount',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_claimed_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 17,
|
||||
'in_filter': 0,
|
||||
'label': 'Total Claimed Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_claimed_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'reqd': 0,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_sanctioned_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 18,
|
||||
'in_filter': 0,
|
||||
'label': 'Total Sanctioned Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_sanctioned_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'width': '160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'hidden': 1,
|
||||
'idx': 19,
|
||||
'label': 'Update Voucher',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'expense_voucher_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 20,
|
||||
'label': 'Expense Voucher Details',
|
||||
'oldfieldname': 'expense_voucher_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Expense Voucher Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 21,
|
||||
'label': 'Employees Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/expense_voucher_detail/__init__.py
Normal file
0
hr/doctype/expense_voucher_detail/__init__.py
Normal file
108
hr/doctype/expense_voucher_detail/expense_voucher_detail.txt
Normal file
108
hr/doctype/expense_voucher_detail/expense_voucher_detail.txt
Normal file
@@ -0,0 +1,108 @@
|
||||
# DocType, Expense Voucher Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-03 16:45:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Expense Voucher Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Expense Voucher Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Expense Voucher Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'expense_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 1,
|
||||
'label': 'Expense Date',
|
||||
'oldfieldname': 'expense_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'reqd': 0,
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'expense_type',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'label': 'Expense Type',
|
||||
'oldfieldname': 'expense_type',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Expense Type',
|
||||
'reqd': 1,
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 3,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'claim_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Claim Amount',
|
||||
'oldfieldname': 'claim_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'reqd': 1,
|
||||
'trigger': 'Client',
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sanctioned_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Sanctioned Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'sanctioned_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'trigger': 'Client',
|
||||
'width': '150px'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/experience_in_company_detail/__init__.py
Normal file
0
hr/doctype/experience_in_company_detail/__init__.py
Normal file
@@ -0,0 +1,110 @@
|
||||
# DocType, Experience In Company Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:01',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Experience In Company Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Experience In Company Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Experience In Company Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'branch',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Branch',
|
||||
'oldfieldname': 'branch',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Branch'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'label': 'Department',
|
||||
'oldfieldname': 'department',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Department'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'label': 'Designation',
|
||||
'oldfieldname': 'designation',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Designation'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'grade',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Grade',
|
||||
'oldfieldname': 'grade',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Grade'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 5,
|
||||
'label': 'From Date',
|
||||
'oldfieldname': 'from_date',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 6,
|
||||
'label': 'To Date',
|
||||
'oldfieldname': 'to_date',
|
||||
'oldfieldtype': 'Date'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/grade/__init__.py
Normal file
0
hr/doctype/grade/__init__.py
Normal file
0
hr/doctype/grade/grade.js
Normal file
0
hr/doctype/grade/grade.js
Normal file
103
hr/doctype/grade/grade.txt
Normal file
103
hr/doctype/grade/grade.txt
Normal file
@@ -0,0 +1,103 @@
|
||||
# DocType, Grade
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:grade_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Grade',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Grade',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Grade
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Grade'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'HR User',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'grade_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Grade',
|
||||
'oldfieldname': 'grade_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/holiday_list/__init__.py
Normal file
0
hr/doctype/holiday_list/__init__.py
Normal file
0
hr/doctype/holiday_list/holiday_list.js
Normal file
0
hr/doctype/holiday_list/holiday_list.js
Normal file
116
hr/doctype/holiday_list/holiday_list.py
Normal file
116
hr/doctype/holiday_list/holiday_list.py
Normal file
@@ -0,0 +1,116 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
import datetime
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# ---------
|
||||
# autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.fiscal_year +"/"+ self.doc.holiday_list_name+"/.###")
|
||||
|
||||
|
||||
# *************************************************** utilities ***********************************************
|
||||
# ----------------
|
||||
# validate values
|
||||
# ----------------
|
||||
def validate_values(self):
|
||||
if not self.doc.fiscal_year:
|
||||
msgprint("Please select Fiscal Year")
|
||||
raise Exception
|
||||
if not self.doc.weekly_off:
|
||||
msgprint("Please select weekly off day")
|
||||
raise Exception
|
||||
|
||||
|
||||
# ------------------------------------
|
||||
# get fiscal year start and end dates
|
||||
# ------------------------------------
|
||||
def get_fy_start_end_dates(self):
|
||||
st_date = sql("select year_start_date from `tabFiscal Year` where name = '%s'" %(self.doc.fiscal_year))
|
||||
st_date = st_date and st_date[0][0].strftime('%Y-%m-%d') or ''
|
||||
ed_date = add_days(add_years(st_date,1), -1)
|
||||
return st_date, ed_date
|
||||
|
||||
# -------------------------
|
||||
# get weekly off date list
|
||||
# -------------------------
|
||||
def get_weekly_off_date_list(self, yr_start_date, yr_end_date):
|
||||
days_dict, dt_list, lst_st = {'Monday':0,'Tuesday':1,'Wednesday':2,'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}, [], ''
|
||||
|
||||
w = cint(days_dict[self.doc.weekly_off]) # Weekly Off Day No.
|
||||
|
||||
st_dt_weekday = getdate(yr_start_date).weekday() # Year Start Date weekday()
|
||||
|
||||
if w == st_dt_weekday: # Get Start Date
|
||||
lst_st = yr_start_date
|
||||
dt_list.append(lst_st)
|
||||
elif w > st_dt_weekday:
|
||||
lst_st = add_days(yr_start_date,w - st_dt_weekday)
|
||||
dt_list.append(lst_st)
|
||||
else:
|
||||
lst_st = add_days(yr_start_date,6 - st_dt_weekday + 1)
|
||||
dt_list.append(lst_st)
|
||||
|
||||
while getdate(lst_st) < getdate(yr_end_date): # Get list of dates
|
||||
lst_st = add_days(lst_st,7)
|
||||
if getdate(lst_st) > getdate(yr_end_date):
|
||||
break
|
||||
dt_list.append(lst_st)
|
||||
|
||||
return dt_list
|
||||
|
||||
# ---------------------
|
||||
# get weekly off dates
|
||||
# ---------------------
|
||||
def get_weekly_off_dates(self):
|
||||
self.validate_values()
|
||||
yr_start_date, yr_end_date = self.get_fy_start_end_dates()
|
||||
date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
|
||||
for d in date_list:
|
||||
ch = addchild(self.doc, 'holiday_list_details', 'Holiday List Detail', 1, self.doclist)
|
||||
ch.description = self.doc.weekly_off
|
||||
ch.holiday_date = d
|
||||
|
||||
# ------------
|
||||
# clear table
|
||||
# ------------
|
||||
def clear_table(self):
|
||||
self.doc.clear_table(self.doclist,'holiday_list_details')
|
||||
|
||||
|
||||
# ***************************************** validate *************************************************
|
||||
|
||||
# ---------------------------
|
||||
# check default holiday list
|
||||
# ---------------------------
|
||||
def update_default_holiday_list(self):
|
||||
sql("update `tabHoliday List` set is_default = 0 where ifnull(is_default, 0) = 1 and fiscal_year = '%s'" % (self.doc.fiscal_year))
|
||||
|
||||
|
||||
# ---------
|
||||
# validate
|
||||
# ---------
|
||||
def validate(self):
|
||||
self.update_default_holiday_list()
|
||||
167
hr/doctype/holiday_list/holiday_list.txt
Normal file
167
hr/doctype/holiday_list/holiday_list.txt
Normal file
@@ -0,0 +1,167 @@
|
||||
# DocType, Holiday List
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-12 13:37:12',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 17
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Holiday List',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Holiday List',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocType, Holiday List
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Holiday List'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'holiday_list_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Holiday List Name',
|
||||
'oldfieldname': 'holiday_list_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_default',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 3,
|
||||
'label': 'Default',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'weekly_off',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'label': 'Weekly Off',
|
||||
'no_copy': 1,
|
||||
'options': '\nSunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 6,
|
||||
'label': 'Get Weekly Off Dates',
|
||||
'options': 'get_weekly_off_dates',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'holiday_list_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 7,
|
||||
'label': 'Holiday List Details',
|
||||
'oldfieldname': 'holiday_list_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Holiday List Detail',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 8,
|
||||
'label': 'Clear Table',
|
||||
'options': 'clear_table',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/holiday_list_detail/__init__.py
Normal file
0
hr/doctype/holiday_list_detail/__init__.py
Normal file
65
hr/doctype/holiday_list_detail/holiday_list_detail.txt
Normal file
65
hr/doctype/holiday_list_detail/holiday_list_detail.txt
Normal file
@@ -0,0 +1,65 @@
|
||||
# DocType, Holiday List Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-11 14:23:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Holiday List Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Holiday List Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Holiday List Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'holiday_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'holiday_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Date',
|
||||
'oldfieldname': 'holiday_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'width': '100px'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/invest_80_declaration_detail/__init__.py
Normal file
0
hr/doctype/invest_80_declaration_detail/__init__.py
Normal file
@@ -0,0 +1,143 @@
|
||||
# DocType, Invest 80 Declaration Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 10
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Invest 80 Declaration Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Invest 80 Declaration Detail',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Invest 80 Declaration Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Invest 80 Declaration Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'particulars4',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Particulars',
|
||||
'oldfieldname': 'particulars4',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'under_section4',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Under Section',
|
||||
'oldfieldname': 'under_section4',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'max_limit4',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Max. Limit',
|
||||
'oldfieldname': 'max_limit4',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'actual_amount4',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Actual Amount',
|
||||
'oldfieldname': 'actual_amount4',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'eligible_amount4',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Eligible Amount',
|
||||
'oldfieldname': 'eligible_amount4',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'modified_amount4',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Modified Amount',
|
||||
'oldfieldname': 'modified_amount4',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/it_checklist/__init__.py
Normal file
0
hr/doctype/it_checklist/__init__.py
Normal file
161
hr/doctype/it_checklist/it_checklist.js
Normal file
161
hr/doctype/it_checklist/it_checklist.js
Normal file
@@ -0,0 +1,161 @@
|
||||
cur_frm.cscript.onload=function(doc,cdt,cdn){
|
||||
|
||||
if(doc.employee && doc.__islocal ==1){
|
||||
cur_frm.cscript.employee(doc,cdt,cdn);
|
||||
}
|
||||
if(doc.rent_acc == "Yes") unhide_field('ann_rent');
|
||||
}
|
||||
|
||||
// when user select an employee corresponding basic, gross income and pf is set.
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
var mydoc=doc;
|
||||
$c('runserverobj', args={'method':'set_values','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
|
||||
if(r.message){
|
||||
doc.hra_count = r.message;
|
||||
refresh_field('hra_count')
|
||||
}
|
||||
refresh_many(['employee','employee_name','basic','gross_income','pf']);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['employee'].get_query = function(doc,dt,dn) {
|
||||
return 'SELECT tabEmployee.name FROM tabEmployee WHERE tabEmployee.status = "Active" AND tabEmployee.docstatus !=2 AND tabEmployee.name LIKE "%s" ORDER BY tabEmployee.name DESC LIMIT 50'
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//if rent accomodation is yes then unhide annual rent paid else unhide.
|
||||
cur_frm.cscript.rent_acc = function(doc,cdt,cdn){
|
||||
doc.ann_rent = 0
|
||||
if(doc.rent_acc == 'Yes')
|
||||
unhide_field('ann_rent');
|
||||
else
|
||||
hide_field('ann_rent');
|
||||
refresh_field('ann_rent');
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//On done button click check for all values filled or not, and accordingly add records in child tables
|
||||
|
||||
cur_frm.cscript['Done']=function(doc,cdt,cdn){
|
||||
var mydoc=doc;
|
||||
|
||||
if(doc.employee && doc.fiscal_year && doc.metro && doc.sr_citizen && doc.part_sr_citizen && doc.basic && doc.gross_income){
|
||||
if((doc.rent_acc == "Yes" && doc.ann_rent) || (doc.rent_acc == "No")){
|
||||
|
||||
$c('runserverobj', args={'method':'set_tables', 'arg': doc.hra_count, 'docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
refresh_many(['edu_cess','tax_tot_income','net_tot_tax_income','tax_per_month','applicable_from','rem_months']);
|
||||
refresh_many(['exe_declaration_details','oth_inc_decl_details','chap_via_decl_details','invest_80_decl_details']);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
else if(doc.rent_acc == "Yes" && !doc.ann_rent)
|
||||
alert("Please enter annual rent");
|
||||
}
|
||||
else
|
||||
alert("please fill up all data");
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
//change event of actual amount1 field (exemption declaration detail table) : check for values of actual amount & maximum limit, and accordingly do actions.
|
||||
cur_frm.cscript.actual_amount1= function(doc,cdt,cdn){
|
||||
|
||||
var cl = getchildren('Declaration Detail', doc.name, 'exe_declaration_details');
|
||||
for(var c=0; c<cl.length; c++) {
|
||||
if(cl[c].name == cdn){
|
||||
if(((flt(cl[c].actual_amount1) <= flt(cl[c].max_limit1)) || (flt(cl[c].actual_amount1) == 0)) || ((cl[c].particulars1 != 'House Rent Allowance') && (flt(cl[c].max_limit1) == 0.00)) || ((cl[c].particulars1 == 'House Rent Allowance') && (flt(cl[c].max_limit1) != 0.00) && (flt(cl[c].actual_amount1) <= flt(cl[c].max_limit1)))){
|
||||
cl[c].eligible_amount1 =cl[c].actual_amount1
|
||||
cl[c].modified_amount1 =cl[c].actual_amount1
|
||||
}
|
||||
else {
|
||||
|
||||
cl[c].eligible_amount1 =cl[c].max_limit1
|
||||
cl[c].modified_amount1 =cl[c].max_limit1
|
||||
}
|
||||
|
||||
refresh_field('exe_declaration_details');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
////change event of actual amount2 field (Other Income declaration detail table) : check for values of actual amount & maximum limit, and accordingly do actions.
|
||||
cur_frm.cscript.actual_amount2= function(doc,cdt,cdn){
|
||||
var cl = getchildren('Other Income Detail', doc.name, 'oth_inc_decl_details');
|
||||
for(var c=0; c<cl.length; c++) {
|
||||
if(cl[c].name == cdn){
|
||||
if((flt(cl[c].actual_amount2) <= flt(cl[c].max_limit2)) || flt((cl[c].actual_amount2) ==0) || !(cl[c].max_limit2)){
|
||||
cl[c].eligible_amount2 =cl[c].actual_amount2
|
||||
cl[c].modified_amount2 =cl[c].actual_amount2
|
||||
|
||||
}
|
||||
else {
|
||||
cl[c].eligible_amount2 =cl[c].max_limit2
|
||||
cl[c].modified_amount2 =cl[c].max_limit2
|
||||
}
|
||||
|
||||
|
||||
refresh_field('oth_inc_decl_details');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//change event of actual amount3 field (Chapter VI A declaration detail table) : check for values of actual amount & maximum limit, and accordingly do actions.
|
||||
cur_frm.cscript.actual_amount3= function(doc,cdt,cdn){
|
||||
|
||||
|
||||
var cl = getchildren('Chapter VI A Detail', doc.name, 'chap_via_decl_details');
|
||||
for(var c=0; c<cl.length; c++) {
|
||||
if(cl[c].name == cdn){
|
||||
if((flt(cl[c].actual_amount3) <= flt(cl[c].max_limit3)) || flt((cl[c].actual_amount3) ==0) || !(cl[c].max_limit3)){
|
||||
cl[c].eligible_amount3 =cl[c].actual_amount3
|
||||
cl[c].modified_amount3 =cl[c].actual_amount3
|
||||
|
||||
}
|
||||
else {
|
||||
cl[c].eligible_amount3 =cl[c].max_limit3
|
||||
cl[c].modified_amount3 =cl[c].max_limit3
|
||||
}
|
||||
|
||||
refresh_field('chap_via_decl_details');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//change event of actual amount4 field (Invest 80 declaration detail table) : check for values of actual amount & maximum limit, and accordingly do actions.
|
||||
cur_frm.cscript.actual_amount4= function(doc,cdt,cdn){
|
||||
|
||||
var cl = getchildren('Invest 80 Declaration Detail', doc.name, 'invest_80_decl_details');
|
||||
for(var c=0; c<cl.length; c++) {
|
||||
if(cl[c].name == cdn){
|
||||
if((flt(cl[c].actual_amount4) <= flt(cl[c].max_limit4)) || flt((cl[c].actual_amount4) ==0) || !(cl[c].max_limit4)){
|
||||
cl[c].eligible_amount4 =cl[c].actual_amount4
|
||||
cl[c].modified_amount4 =cl[c].actual_amount4
|
||||
|
||||
}
|
||||
else {
|
||||
cl[c].eligible_amount4 =cl[c].max_limit4
|
||||
cl[c].modified_amount4 =cl[c].max_limit4
|
||||
}
|
||||
|
||||
refresh_field('invest_80_decl_details');
|
||||
}
|
||||
}
|
||||
}
|
||||
cur_frm.cscript.refresh=function(doc,cdt,cdn){
|
||||
|
||||
}
|
||||
419
hr/doctype/it_checklist/it_checklist.py
Normal file
419
hr/doctype/it_checklist/it_checklist.py
Normal file
@@ -0,0 +1,419 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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:
|
||||
#init function
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname('IT Check/' +self.doc.employee + '/.#####')
|
||||
|
||||
#===========================================================
|
||||
#check for already exist IT Checklist for resp. Employee
|
||||
def exist_IT_Check(self):
|
||||
|
||||
#query for return already exist IT Checklist for respective employee
|
||||
exist_ret = sql("select name from `tabIT Checklist` where is_cheklist_active = 'Yes' and employee = '%s' and name!='%s'"%(self.doc.employee,self.doc.name))
|
||||
|
||||
# validation - if exist then raise exception
|
||||
if exist_ret:
|
||||
msgprint("Active IT Checklist '%s' for employee '%s' exist."%(exist_ret[0][0],self.doc.employee))
|
||||
self.doc.employee = ""
|
||||
self.doc.basic = 0
|
||||
self.doc.gross_income = 0
|
||||
self.doc.pf = 0
|
||||
return 0
|
||||
else:
|
||||
flag = self.exist_sal_struct() #check for slaray structure exist or not, if exist then further action can be done.
|
||||
return flag
|
||||
|
||||
#===========================================================
|
||||
#check for salary structure exist or not, if exist then further action can be done.
|
||||
def exist_sal_struct(self):
|
||||
#query return salary structure for particular employee exist or not
|
||||
exist_salstr=sql("select name from `tabSalary Structure` where employee = '%s' and is_active='Yes'"%self.doc.employee)
|
||||
if not exist_salstr:
|
||||
msgprint("Please first create salary structure for employee '%s'"%self.doc.employee)
|
||||
self.doc.employee = ''
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
#===========================================================
|
||||
#get previous salary slip gross income and basic amount
|
||||
def get_info(self):
|
||||
ret_sal_slip = sql("select count(name), sum(gross_pay) from `tabSalary Slip` where docstatus =1 and fiscal_year = '%s' and employee = '%s'"%(self.doc.fiscal_year,self.doc.employee))
|
||||
|
||||
sum_basic = sum_pf = 0
|
||||
|
||||
if ret_sal_slip:
|
||||
#get name of salary slip of resp. employee
|
||||
ret_name =convert_to_lists(sql("select name from `tabSalary Slip` where docstatus =1 and fiscal_year = '%s' and employee = '%s' "%(self.doc.fiscal_year,self.doc.employee)))
|
||||
|
||||
if ret_name:
|
||||
for b in ret_name:
|
||||
#get earning amount of basic
|
||||
ret_basic = sql("select e_amount from `tabSS Earning Detail` where parent = '%s' and e_type = 'Basic'"%(b[0]))
|
||||
sum_basic += ret_basic[0][0] or 0
|
||||
|
||||
#get deduction amount of Provident Fund
|
||||
ret_pf = sql("select d_amount from `tabSS Deduction Detail` where parent = '%s' and d_type = 'Provident Fund'"%(b[0]))
|
||||
|
||||
sum_pf += ret_pf[0][0] or 0
|
||||
|
||||
ret_list = [ret_sal_slip[0][0] or 0,ret_sal_slip[0][1] or 0, sum_basic, sum_pf]
|
||||
return ret_list
|
||||
|
||||
#-------------------------------------------
|
||||
def get_basic_gross(self,ret_list0,ret_list1,ret_list2):
|
||||
|
||||
self.doc.basic = self.doc.gross_income = 0
|
||||
#query return list of earning types and resp. modified amount
|
||||
ret = convert_to_lists(sql("select e.e_type, e.modified_value from `tabEarning Detail` e , `tabSalary Structure` s where s.is_active = 'Yes' and s.employee='%s' and e.parent = s.name" %(self.doc.employee)))
|
||||
hra_count=1
|
||||
if ret:
|
||||
count = 0.0
|
||||
for i in ret:
|
||||
if i[0] == 'Basic':
|
||||
if i[1] == 0:
|
||||
msgprint("Basic is zero in salary structure")
|
||||
|
||||
self.doc.basic = flt(i[1])*(12-int(ret_list0)) + flt(ret_list2)
|
||||
count += flt(i[1])
|
||||
if i[0] =='House Rent Allowance':
|
||||
hra_count = flt(i[1])
|
||||
if count == 0:
|
||||
msgprint("Gross Income is zero in salary structure")
|
||||
|
||||
|
||||
self.doc.gross_income = count*(12-int(ret_list0)) + flt(ret_list1)
|
||||
|
||||
if hra_count == 0 or hra_count == "":
|
||||
hra_count=1
|
||||
|
||||
return hra_count
|
||||
|
||||
#-------------------------------------------
|
||||
def get_pf(self,ret_list0,ret_list3):
|
||||
self.doc.pf = 0.0
|
||||
|
||||
#query returns amount
|
||||
ret_ded = sql("select d.d_modified_amt from `tabDeduction Detail` d , `tabSalary Structure` s where s.is_active = 'Yes' and s.employee='%s' and d.parent = s.name and d.d_type = 'Provident Fund'" %(self.doc.employee))
|
||||
|
||||
if not ret_ded:
|
||||
msgprint("PF Amount in Salary Structure is zero")
|
||||
|
||||
ret_ded = flt(ret_ded[0][0]) or 0
|
||||
|
||||
#annual pf = salary structure * (12 - remaining month to complete fiscal year)- previous salary slip's total pf for current fiscal year
|
||||
self.doc.pf = (ret_ded*(12 - int(ret_list0)))+flt(ret_list3)
|
||||
|
||||
|
||||
#-------------------------------------------
|
||||
def set_values(self):
|
||||
hra_count=1
|
||||
if not self.doc.fiscal_year:
|
||||
msgprint("Please select Fiscal Year")
|
||||
self.doc.employee = ''
|
||||
|
||||
elif self.doc.employee:
|
||||
|
||||
flag = self.exist_IT_Check() #check for already exist IT Checklist for resp. Employee
|
||||
|
||||
if flag == 1:
|
||||
|
||||
ename = sql("select employee_name from `tabEmployee` where name = '%s'"%self.doc.employee)[0][0]
|
||||
set(self.doc,'employee_name',cstr(ename))
|
||||
#call get_info to get values of salary slip's total basic, pf and gross income amount
|
||||
ret_list = self.get_info()
|
||||
|
||||
self.get_pf(ret_list[0],ret_list[3])
|
||||
|
||||
hra_count = self.get_basic_gross(ret_list[0],ret_list[1],ret_list[2])
|
||||
|
||||
return hra_count
|
||||
|
||||
#===========================================================
|
||||
#-------------------------------------------
|
||||
def set_tables(self, hra_count): #set tables values
|
||||
|
||||
self.set_exemption_table(hra_count)
|
||||
self.set_other_income_table()
|
||||
self.set_deduction_via_table()
|
||||
self.set_invest_80c_table()
|
||||
self.doc.edu_cess = self.doc.tax_tot_income = self.doc.net_tot_tax_income = self.doc.tax_per_month = 0
|
||||
self.doc.applicable_from = self.doc.rem_months=''
|
||||
msgprint("Successful")
|
||||
return ''
|
||||
|
||||
#-------------------------------------------
|
||||
def get_month_diff(self):
|
||||
#end_month = get_defaults()['end_month']
|
||||
|
||||
month_dict = {"January" :'01', "February" :'02',"March" :'03',"April":'04',"May":'05',"June":'06',"July":'07',"August":'08',"September":'09',"October":'10',"November":'11',"December":'12'}
|
||||
|
||||
import datetime
|
||||
|
||||
start_month = getdate(get_defaults()['year_start_date']).month
|
||||
end_month = cint(start_month) - 1
|
||||
if end_month <= 0:
|
||||
end_month = 12
|
||||
str_end_month = cstr(end_month)
|
||||
|
||||
if len(str_end_month)==1:
|
||||
str_end_month = '0'+str_end_month
|
||||
|
||||
|
||||
to_month = datetime.date.today().strftime("%B")
|
||||
to_year = datetime.date.today().strftime("%Y")
|
||||
|
||||
fiscal_year = self.doc.fiscal_year
|
||||
|
||||
str_fy =fiscal_year.split("-")
|
||||
|
||||
endym=int(str_fy[1]+str_end_month)
|
||||
startym= int(to_year+month_dict[to_month])
|
||||
|
||||
month_diff =sql("SELECT PERIOD_DIFF(%d,%d);" %(endym,startym))[0][0]+1
|
||||
|
||||
return month_diff
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------
|
||||
def set_exemption_values(self,ann_hra):
|
||||
ret = convert_to_lists(sql("select name, exemption_limit from `tabEarning Type` where taxable = 'No' and docstatus !=2"))
|
||||
|
||||
if ret:
|
||||
for r in ret:
|
||||
|
||||
ch = addchild(self.doc,'exe_declaration_details','Declaration Detail',0, self.doclist)
|
||||
ch.particulars1 = r[0]
|
||||
ch.under_section1 = "U/Sec 10 & 17"
|
||||
|
||||
if r[0] == 'House Rent Allowance':
|
||||
if (self.doc.ann_rent <= 0.00):
|
||||
ch.max_limit1 = 0.00
|
||||
|
||||
else:
|
||||
hra1=0.00
|
||||
if(self.doc.metro == 'Yes'):
|
||||
hra1 = flt(self.doc.basic)*50/100
|
||||
elif(self.doc.metro == 'No'):
|
||||
hra1 = flt(self.doc.basic)*40/100
|
||||
hra2 = flt(ann_hra)
|
||||
hra3 = flt(self.doc.ann_rent) - (flt(self.doc.basic)/10)
|
||||
|
||||
|
||||
if hra1 <= 0 or hra2 <=0 or hra3 <=0:
|
||||
ch.max_limit1 = 0
|
||||
else:
|
||||
ch.max_limit1=min(hra1,min(hra2,hra3))
|
||||
else:
|
||||
ch.max_limit1 = r[1]
|
||||
|
||||
ch.actual_amount1 = 0.00
|
||||
ch.eligible_amount1 = 0.00
|
||||
ch.modified_amount1 = 0.00
|
||||
|
||||
#-------------------------------------------
|
||||
def set_exemption_table(self, hra_count):
|
||||
self.doc.clear_table(self.doclist, 'exe_declaration_details',1)
|
||||
ann_hra = 0
|
||||
if (self.doc.ann_rent > 0):
|
||||
|
||||
#query return sum of earning types amount where earning type = 'HRA'
|
||||
ret_sal_slip = sql("select sum(e.e_amount) from `tabSS Earning Detail` e , `tabSalary Slip` s where s.fiscal_year = '%s' and s.docstatus = 1 and s.employee='%s' and e.parent = s.name and e.e_type = 'House Rent Allowance'" %(self.doc.fiscal_year,self.doc.employee))
|
||||
if not ret_sal_slip:
|
||||
ret_sal_slip = 0.00
|
||||
else:
|
||||
ret_sal_slip = ret_sal_slip[0][0]
|
||||
|
||||
month_diff = self.get_month_diff()
|
||||
|
||||
#ret_sal_slip = ret_sal_slip[0][0] or 0.00
|
||||
ann_hra = (flt(hra_count)*flt(month_diff))+flt(ret_sal_slip);
|
||||
|
||||
self.set_exemption_values(ann_hra)
|
||||
|
||||
#-------------------------------------------
|
||||
def set_other_income_table(self):
|
||||
self.doc.clear_table(self.doclist, 'oth_inc_decl_details',1)
|
||||
other_income =[["Income from Housing","----",0.00],["Relief on interest paid on Housing Loan","U/S 24(1)(Vi)",150000],["Any other Income","----",0.00]]
|
||||
|
||||
for oi in other_income:
|
||||
ch1 = addchild(self.doc,'oth_inc_decl_details','Other Income Detail',0, self.doclist)
|
||||
ch1.particulars2 = oi[0]
|
||||
ch1.under_section2 = oi[1]
|
||||
ch1.max_limit2 = oi[2]
|
||||
ch1.actual_amount2 = 0.00
|
||||
ch1.eligible_amount2 = 0.00
|
||||
ch1.modified_amount2 = 0.00
|
||||
|
||||
|
||||
#---------------------------------------
|
||||
def get_maxlmt_via(self):
|
||||
if(self.doc.part_sr_citizen == 'Yes'):
|
||||
max_lmt1 = 20000
|
||||
else:
|
||||
max_lmt1 = 15000
|
||||
|
||||
if(self.doc.per_dep_dis == "Less than 80% disability"):
|
||||
max_lmt2 = 50000
|
||||
elif(self.doc.per_dep_dis == "More than 80% disability"):
|
||||
max_lmt2 = 100000
|
||||
else:
|
||||
max_lmt2 = 0.00
|
||||
|
||||
if(self.doc.per_self_dis == "Less than 80% disability"):
|
||||
max_lmt3 = 50000
|
||||
elif(self.doc.per_self_dis == "More than 80% disability"):
|
||||
max_lmt3 = 75000
|
||||
else:
|
||||
max_lmt3 = 0.00
|
||||
|
||||
maxlmt_lst=[max_lmt1,max_lmt2,max_lmt3]
|
||||
|
||||
return maxlmt_lst
|
||||
|
||||
#---------------------------------------
|
||||
def set_deduction_via_table(self):
|
||||
self.doc.clear_table(self.doclist, 'chap_via_decl_details',1)
|
||||
|
||||
maxlmt_lst = self.get_maxlmt_via()
|
||||
|
||||
deduct_via = [["Medical Insurance Premium","U/Sec 80D(2A)",15000],["Medical Insurance Premium for parents","U/Sec 80D(2A)", maxlmt_lst[0]],["Medical for handicapped dependents","U/Sec 80DD",maxlmt_lst[1]],["Medical for specified diseases","U/Sec 80DDB",40000],["Higher Education Loan Interest Repayment","U/Sec 80E",0.00],["*Donation to approved Fund and charities","U/sec 80G",0.00],["*Rent deduction only if HRA not received","U/sec 80GG",0.00],["Deduction for permanent disability","U/Sec 80 U",maxlmt_lst[2]],["Any other deductions","----",0.00]]
|
||||
|
||||
|
||||
for dv in deduct_via:
|
||||
ch = addchild(self.doc,'chap_via_decl_details','Chapter VI A Detail',0, self.doclist)
|
||||
ch.particulars3 = dv[0]
|
||||
ch.under_section3 = dv[1]
|
||||
ch.max_limit3 = dv[2]
|
||||
ch.actual_amount3 = 0.00
|
||||
ch.eligible_amount3 = 0.00
|
||||
ch.modified_amount3 = 0.00
|
||||
|
||||
|
||||
#----------------------------------------
|
||||
def set_invest_80c_table(self):
|
||||
self.doc.clear_table(self.doclist, 'invest_80_decl_details',1)
|
||||
invest_lst = [["Employees Provident Fund","U/Sec 80C",0.00],["Voluntary Contribution Provident Fund","U/Sec 80C",0.00],["Investment in Pension Scheme","U/Sec 80 CCC",10000],["Housing Loan Principal Repayment","U/Sec 80C",0.00],["Public Provident Fund (PPF)","U/Sec 80C",0.00],["Life Insurance Premium Paid","U/Sec 80C",0.00],["Unit Linked Insurance Plans","U/Sec 80C",0.00],["NSC - National Saving Certificate","U/Sec 80C",0.00],["Deposite in National Saving Scheme (NSS)","U/Sec 80C",0.00],["Infrastructure Investment in approved Shares, Debentures & Bonds","U/Sec 80C",0.00],["Mutual Funds notified under Section 10 (23D)","U/Sec 80C",0.00],["Equity Link Saving Scheme (ELSS) Mutual Funds notified under Section 10 (23D)","U/Sec 80C",0.00],["Term Deposite with a SCH. Bank in a notified Scheme for a team not less than 5 years ","U/Sec 80C",0.00],["Tution Fees Paid (Only full time education tution fees paid to any Indian Univ, College, School)","U/Sec 80C","24000"],["Senior Citizen Savings Scheme Rules, 2004","U/Sec 80C",0.00],["Post Office Time Deposit Rules, 1981 for a term not less than 5 years","U/Sec 80C",0.00]]
|
||||
|
||||
|
||||
for il in invest_lst:
|
||||
ch = addchild(self.doc,'invest_80_decl_details','Invest 80 Declaration Detail',0, self.doclist)
|
||||
ch.particulars4 = il[0]
|
||||
ch.under_section4 = il[1]
|
||||
ch.max_limit4 = il[2]
|
||||
ch.actual_amount4 = 0.00
|
||||
ch.eligible_amount4 = 0.00
|
||||
ch.modified_amount4 = 0.00
|
||||
|
||||
|
||||
#---------------------------------------
|
||||
def sum_mod_val(self):
|
||||
count = count1 = count2 = 0.0
|
||||
|
||||
for e in getlist(self.doclist,'exe_declaration_details'):
|
||||
count += flt(e.modified_amount1)
|
||||
|
||||
count = round(flt(self.doc.gross_income)) - count
|
||||
|
||||
for oi in getlist(self.doclist,'oth_inc_decl_details'):
|
||||
count += flt(oi.modified_amount2)
|
||||
|
||||
for vi in getlist(self.doclist,'chap_via_decl_details'):
|
||||
count2 += flt(vi.modified_amount3)
|
||||
|
||||
count = count - count2
|
||||
|
||||
for inv in getlist(self.doclist,'invest_80_decl_details'):
|
||||
count1 += flt(inv.modified_amount4)
|
||||
if(count1 >= 100000):
|
||||
break
|
||||
|
||||
if(count1>100000):
|
||||
count1=100000
|
||||
|
||||
count_lst = [count,count1]
|
||||
return count_lst
|
||||
|
||||
#----------------------------------------
|
||||
def calculate_tax(self):
|
||||
|
||||
count_lst = self.sum_mod_val()
|
||||
|
||||
count = round(flt(count_lst[0]) - flt(count_lst[1]))
|
||||
if(count>0):
|
||||
self.doc.net_tot_tax_income = count
|
||||
|
||||
ret_gender = sql("select gender from `tabEmployee` where name = '%s' "%self.doc.employee)[0][0]
|
||||
|
||||
if(self.doc.sr_citizen == 'Yes'):
|
||||
self.calc_tax(count,240000)
|
||||
elif(ret_gender == 'Male'):
|
||||
self.calc_tax(count,160000)
|
||||
elif(ret_gender == 'Female'):
|
||||
self.calc_tax(count,190000)
|
||||
else:
|
||||
self.doc.net_tot_tax_income = 0
|
||||
self.doc.tax_tot_income = 0
|
||||
self.doc.edu_cess = 0
|
||||
#-----------------------------------------------
|
||||
def calc_tax(self,count,upper_limit):
|
||||
balance = 0
|
||||
tax = 0
|
||||
if(count> upper_limit):
|
||||
balance = count - upper_limit
|
||||
if balance > (500000 - upper_limit):
|
||||
balance = balance - (500000 - upper_limit)
|
||||
tax = round(balance/10)
|
||||
if balance > 300000:
|
||||
balance = balance - 300000
|
||||
tax = round(tax+ 60000)
|
||||
if balance > 0:
|
||||
tax = round(tax + (balance * 30 / 100))
|
||||
else:
|
||||
tax = round(balance * 20 / 100 )
|
||||
else:
|
||||
tax = round(balance /10)
|
||||
else:
|
||||
tax = 0
|
||||
|
||||
self.doc.tax_tot_income = tax
|
||||
self.doc.edu_cess = round(tax*3/100)
|
||||
|
||||
#-----------------------------------------------
|
||||
def calc_tax_pm(self):
|
||||
|
||||
ret_income_tax = 0
|
||||
ret_income_tax = sql("select sum(d.d_amount) from `tabSS Deduction Detail` d , `tabSalary Slip` s where s.docstatus = 1 and s.fiscal_year = '%s' and s.employee='%s' and d.parent = s.name and d.d_type = 'Income Tax'" %(self.doc.fiscal_year,self.doc.employee))
|
||||
|
||||
new_tot_income = cint(self.doc.tax_tot_income) + cint(self.doc.edu_cess) - (cint(ret_income_tax[0][0]) or 0)
|
||||
|
||||
self.doc.tax_per_month = new_tot_income/cint(self.doc.rem_months)
|
||||
|
||||
# on update
|
||||
def on_update(self):
|
||||
obj = get_obj('Feed Control', 'Feed Control')
|
||||
|
||||
obj.make_feed(self.doc)
|
||||
637
hr/doctype/it_checklist/it_checklist.txt
Normal file
637
hr/doctype/it_checklist/it_checklist.txt
Normal file
@@ -0,0 +1,637 @@
|
||||
# DocType, IT Checklist
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-30 14:53:02',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tabbed',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 455
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'IT Checklist',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'IT Checklist',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, IT Checklist
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'IT Checklist'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 3,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Yes',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_cheklist_active',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Is IT Cheklist Active?',
|
||||
'oldfieldname': 'is_cheklist_active',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Yes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 5,
|
||||
'label': 'Employee Information',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 6,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Employee',
|
||||
'oldfieldname': 'employee',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'label': 'Employee Name',
|
||||
'oldfieldname': 'employee_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'hra_count',
|
||||
'fieldtype': 'Currency',
|
||||
'hidden': 1,
|
||||
'idx': 9,
|
||||
'label': 'HRA Count',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': 'hra_count',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'metro',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'label': 'Is location a metro city?',
|
||||
'oldfieldname': 'metro',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sr_citizen',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 11,
|
||||
'label': 'Is senior citizen?',
|
||||
'oldfieldname': 'sr_citizen',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'part_sr_citizen',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 12,
|
||||
'label': 'Parents are sr. citizen?',
|
||||
'oldfieldname': 'part_sr_citizen',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'basic',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 13,
|
||||
'label': 'Annual Basic',
|
||||
'oldfieldname': 'basic',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'sum of earning terms',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'gross_income',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 14,
|
||||
'label': 'Annual Gross Income',
|
||||
'oldfieldname': 'gross_income',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Please fill up all data then press "Done"',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 15,
|
||||
'label': 'Done',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 16,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'rent_acc',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 17,
|
||||
'label': 'Having rented accomodation?',
|
||||
'oldfieldname': 'rent_acc',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'ann_rent',
|
||||
'fieldtype': 'Currency',
|
||||
'hidden': 1,
|
||||
'idx': 18,
|
||||
'label': 'Enter annual rent paid',
|
||||
'oldfieldname': 'ann_rent',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Disability % of the Handicapped Dependents',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_dep_dis',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 19,
|
||||
'label': 'Dependents Disability %',
|
||||
'oldfieldname': 'per_dep_dis',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nLess than 80% disability\nMore than 80% disability',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_self_dis',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 20,
|
||||
'label': 'Self disability %',
|
||||
'oldfieldname': 'per_self_dis',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nLess than 80% disability\nMore than 80% disability',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pf',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 21,
|
||||
'label': 'Annual PF',
|
||||
'oldfieldname': 'pf',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 22,
|
||||
'label': 'Exemptions',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'idx': 23,
|
||||
'label': 'Exemptions1',
|
||||
'oldfieldtype': 'HTML',
|
||||
'options': '<b>Exemptions under section 10 & 17</b>',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'exe_declaration_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 24,
|
||||
'label': 'Exemption Detail',
|
||||
'oldfieldname': 'exe_declaration_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Declaration Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 25,
|
||||
'label': 'Other Income',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'oth_inc_decl_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 26,
|
||||
'label': 'Other Income Details',
|
||||
'oldfieldname': 'oth_inc_decl_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Other Income Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 27,
|
||||
'label': 'Chapter VI A',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'idx': 28,
|
||||
'label': 'deduction chap via',
|
||||
'oldfieldtype': 'HTML',
|
||||
'options': '<b>Deduction under Chapter VI A</b>',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'chap_via_decl_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 29,
|
||||
'label': 'Chap VI A Details',
|
||||
'oldfieldname': 'chap_via_decl_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Chapter VI A Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 30,
|
||||
'label': '80 C',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'idx': 31,
|
||||
'label': 'investment 80 C',
|
||||
'oldfieldtype': 'HTML',
|
||||
'options': '<b>Investment under Section 80 C & 80CCC qualifying for deduction upto RS. 1 Lac</b>',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'invest_80_decl_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 32,
|
||||
'label': 'Invest 80 Decl Details',
|
||||
'oldfieldname': 'invest_80_decl_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Invest 80 Declaration Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 33,
|
||||
'label': 'Total Taxable Income',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 34,
|
||||
'label': 'Calculate',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'calculate_tax',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'net_tot_tax_income',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 35,
|
||||
'label': 'Net Total Taxable Income',
|
||||
'oldfieldname': 'net_tot_tax_income',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tax_tot_income',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 36,
|
||||
'label': 'Tax on Total Income',
|
||||
'oldfieldname': 'tax_tot_income',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'edu_cess',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 37,
|
||||
'label': 'Education Cess',
|
||||
'oldfieldname': 'edu_cess',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'applicable_from',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 38,
|
||||
'label': 'Applicable from ',
|
||||
'oldfieldname': 'applicable_from',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nJanuary\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'rem_months',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 39,
|
||||
'label': 'Remaining month in year',
|
||||
'oldfieldname': 'rem_months',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 40,
|
||||
'label': 'Calculate Tax',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 41,
|
||||
'label': 'Calculate Monthly Tax ',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'calc_tax_pm',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tax_per_month',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 42,
|
||||
'label': 'Tax per Month',
|
||||
'oldfieldname': 'tax_per_month',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
hr/doctype/kra_sheet/__init__.py
Normal file
0
hr/doctype/kra_sheet/__init__.py
Normal file
68
hr/doctype/kra_sheet/kra_sheet.txt
Normal file
68
hr/doctype/kra_sheet/kra_sheet.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
# DocType, KRA Sheet
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:06',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'KSHEET.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'KRA Sheet',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocType, KRA Sheet
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'KRA Sheet'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Key Performance Area',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'KRA',
|
||||
'oldfieldname': 'kra',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'width': '200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_weightage',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Weightage (%)',
|
||||
'oldfieldname': 'per_weightage',
|
||||
'oldfieldtype': 'Currency',
|
||||
'width': '100px'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/kra_template/__init__.py
Normal file
0
hr/doctype/kra_template/__init__.py
Normal file
0
hr/doctype/kra_template/kra_template.js
Normal file
0
hr/doctype/kra_template/kra_template.js
Normal file
115
hr/doctype/kra_template/kra_template.txt
Normal file
115
hr/doctype/kra_template/kra_template.txt
Normal file
@@ -0,0 +1,115 @@
|
||||
# DocType, KRA Template
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:06',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'field:kra_title',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'KRA Template',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'KRA Template',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, KRA Template
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'KRA Template'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_title',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'KRA Title',
|
||||
'oldfieldname': 'kra_title',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 2,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_sheet',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 3,
|
||||
'label': 'KRA Sheet',
|
||||
'oldfieldname': 'kra_sheet',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'KRA Sheet'
|
||||
}
|
||||
]
|
||||
0
hr/doctype/leave_allocation/__init__.py
Executable file
0
hr/doctype/leave_allocation/__init__.py
Executable file
64
hr/doctype/leave_allocation/leave_allocation.js
Executable file
64
hr/doctype/leave_allocation/leave_allocation.js
Executable file
@@ -0,0 +1,64 @@
|
||||
// ****************************************** onload ********************************************************
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
}
|
||||
|
||||
|
||||
// ************************************** client triggers ***************************************************
|
||||
// ---------
|
||||
// employee
|
||||
// ---------
|
||||
cur_frm.add_fetch('employee','employee_name','employee_name');
|
||||
|
||||
cur_frm.cscript.employee = function(doc, dt, dn) {
|
||||
calculate_total_leaves_allocated(doc, dt, dn);
|
||||
}
|
||||
|
||||
// -----------
|
||||
// leave type
|
||||
// -----------
|
||||
cur_frm.cscript.leave_type = function(doc, dt, dn) {
|
||||
calculate_total_leaves_allocated(doc, dt, dn);
|
||||
}
|
||||
|
||||
// ------------
|
||||
// fiscal year
|
||||
// ------------
|
||||
cur_frm.cscript.fiscal_year = function(doc, dt, dn) {
|
||||
calculate_total_leaves_allocated(doc, dt, dn);
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// include previous leave balance
|
||||
// -------------------------------
|
||||
cur_frm.cscript.carry_forward = function(doc, dt, dn) {
|
||||
calculate_total_leaves_allocated(doc, dt, dn);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// previous balance leaves
|
||||
// -----------------------
|
||||
cur_frm.cscript.carry_forwarded_leaves = function(doc, dt, dn) {
|
||||
set_multiple(dt,dn,{total_leaves_allocated : flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
// new leaves allocated
|
||||
// ---------------------
|
||||
cur_frm.cscript.new_leaves_allocated = function(doc, dt, dn) {
|
||||
set_multiple(dt,dn,{total_leaves_allocated : flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});
|
||||
}
|
||||
|
||||
|
||||
// ****************************************** utilities ******************************************************
|
||||
// ---------------------------------
|
||||
// calculate total leaves allocated
|
||||
// ---------------------------------
|
||||
calculate_total_leaves_allocated = function(doc, dt, dn) {
|
||||
if(cint(doc.carry_forward) == 1 && doc.leave_type && doc.fiscal_year && doc.employee){
|
||||
get_server_fields('get_carry_forwarded_leaves','','', doc, dt, dn, 1);
|
||||
}
|
||||
else if(cint(doc.carry_forward) == 0){
|
||||
set_multiple(dt,dn,{carry_forwarded_leaves : 0,total_leaves_allocated : flt(doc.new_leaves_allocated)});
|
||||
}
|
||||
}
|
||||
121
hr/doctype/leave_allocation/leave_allocation.py
Executable file
121
hr/doctype/leave_allocation/leave_allocation.py
Executable file
@@ -0,0 +1,121 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
import datetime
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
# ************************************************ utilities *************************************************
|
||||
# --------------
|
||||
# get leave bal
|
||||
# --------------
|
||||
def get_leave_bal(self, prev_fyear):
|
||||
# leaves allocates
|
||||
tot_leaves_all = sql("select SUM(total_leaves_allocated) from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1 and name != '%s'" % (self.doc.employee, self.doc.leave_type, prev_fyear, self.doc.name))
|
||||
tot_leaves_all = tot_leaves_all and flt(tot_leaves_all[0][0]) or 0
|
||||
|
||||
# leaves applied
|
||||
tot_leaves_app = sql("select SUM(total_leave_days) from `tabLeave Application` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, prev_fyear))
|
||||
tot_leaves_app = tot_leaves_app and flt(tot_leaves_app[0][0]) or 0
|
||||
|
||||
return tot_leaves_all - tot_leaves_app
|
||||
|
||||
|
||||
# ******************************************** client triggers ***********************************************
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# check whether carry forward is allowed or not for this leave type
|
||||
# ------------------------------------------------------------------
|
||||
def allow_carry_forward(self):
|
||||
cf = sql("select is_carry_forward from `tabLeave Type` where name = %s" , self.doc.leave_type)
|
||||
cf = cf and cint(cf[0][0]) or 0
|
||||
if not cf:
|
||||
set(self.doc,'carry_forward',0)
|
||||
msgprint("Sorry ! You cannot carry forward %s" % (self.doc.leave_type))
|
||||
raise Exception
|
||||
|
||||
# ---------------------------
|
||||
# get carry forwarded leaves
|
||||
# ---------------------------
|
||||
def get_carry_forwarded_leaves(self):
|
||||
if self.doc.carry_forward: self.allow_carry_forward()
|
||||
prev_fiscal_year = sql("select name from `tabFiscal Year` where name < '%s' order by name desc limit 1" % (self.doc.fiscal_year))
|
||||
prev_fiscal_year = prev_fiscal_year and prev_fiscal_year[0][0] or ''
|
||||
ret = {}
|
||||
prev_bal = 0
|
||||
if prev_fiscal_year and cint(self.doc.carry_forward) == 1:
|
||||
prev_bal = self.get_leave_bal(prev_fiscal_year)
|
||||
ret = {
|
||||
'carry_forwarded_leaves' : prev_bal,
|
||||
'total_leaves_allocated' : flt(prev_bal) + flt(self.doc.new_leaves_allocated)
|
||||
}
|
||||
return str(ret)
|
||||
|
||||
|
||||
# ********************************************** validate *****************************************************
|
||||
|
||||
# ---------------------------
|
||||
# get total allocated leaves
|
||||
# ---------------------------
|
||||
def get_total_allocated_leaves(self):
|
||||
leave_det = eval(self.get_carry_forwarded_leaves())
|
||||
set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves']))
|
||||
set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
# validate leave (i.e. check whether leave for same type is already allocated or not)
|
||||
# ------------------------------------------------------------------------------------
|
||||
def validate_allocated_leave(self):
|
||||
l = sql("select name from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
l = l and l[0][0] or ''
|
||||
if l:
|
||||
msgprint("%s is allocated to Employee: %s for Fiscal Year : %s. Please refer Leave Allocation : %s" % (self.doc.leave_type, self.doc.employee, self.doc.fiscal_year, l))
|
||||
raise Exception
|
||||
|
||||
# ---------
|
||||
# validate
|
||||
# ---------
|
||||
def validate(self):
|
||||
self.validate_allocated_leave()
|
||||
|
||||
# ----------
|
||||
# on update
|
||||
# ----------
|
||||
def on_update(self):
|
||||
self.get_total_allocated_leaves()
|
||||
|
||||
|
||||
# ********************************************** cancel ********************************************************
|
||||
|
||||
# -------------------------
|
||||
# check for applied leaves
|
||||
# -------------------------
|
||||
def check_for_leave_application(self):
|
||||
chk = sql("select name from `tabLeave Application` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
chk = chk and chk[0][0] or ''
|
||||
if chk:
|
||||
msgprint("Cannot cancel this Leave Allocation as Employee : %s has already applied for %s. Please check Leave Application : %s" % (self.doc.employee, self.doc.leave_type, chk))
|
||||
raise Exception
|
||||
|
||||
# -------
|
||||
# cancel
|
||||
# -------
|
||||
def on_cancel(self):
|
||||
self.check_for_leave_application()
|
||||
293
hr/doctype/leave_allocation/leave_allocation.txt
Normal file
293
hr/doctype/leave_allocation/leave_allocation.txt
Normal file
@@ -0,0 +1,293 @@
|
||||
# DocType, Leave Allocation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-02-10 17:24:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-17 13:47:13',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1299063937',
|
||||
'autoname': 'LAL/.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1565
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Allocation',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Allocation',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Allocation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Leave Allocation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break1',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee',
|
||||
'oldfieldname': 'employee',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee Name',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Leave Type',
|
||||
'oldfieldname': 'leave_type',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': '\nCasual Leave\nCompensatory Off\nLeave Without Pay\nPaternity Leave\nPrivilege Leave\nSick Leave',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Today',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 0,
|
||||
'idx': 5,
|
||||
'label': 'Posting Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Data',
|
||||
'options': '\n2010-2011\n2011-2012\n2012-2013',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'hidden': 0,
|
||||
'idx': 7,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break8',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 8,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'carry_forward',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 9,
|
||||
'label': 'Carry Forward',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'carry_forwarded_leaves',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 10,
|
||||
'label': 'Carry Forwarded Leaves',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'new_leaves_allocated',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 11,
|
||||
'label': 'New Leaves Allocated',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_leaves_allocated',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 12,
|
||||
'label': 'Total Leaves Allocated',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 0,
|
||||
'idx': 13,
|
||||
'label': 'Amended From',
|
||||
'oldfieldname': 'amended_from',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry is corrected in the system.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 0,
|
||||
'idx': 14,
|
||||
'label': 'Amendment Date',
|
||||
'oldfieldname': 'amendment_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/leave_application/__init__.py
Executable file
0
hr/doctype/leave_application/__init__.py
Executable file
88
hr/doctype/leave_application/leave_application.js
Executable file
88
hr/doctype/leave_application/leave_application.js
Executable file
@@ -0,0 +1,88 @@
|
||||
// ****************************************** onload ********************************************************
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
}
|
||||
|
||||
|
||||
// ************************************** client triggers ***************************************************
|
||||
// ---------
|
||||
// employee
|
||||
// ---------
|
||||
cur_frm.add_fetch('employee','employee_name','employee_name');
|
||||
|
||||
cur_frm.cscript.employee = function (doc, dt, dn){
|
||||
get_leave_balance(doc, dt, dn);
|
||||
}
|
||||
|
||||
// ------------
|
||||
// fiscal_year
|
||||
// ------------
|
||||
cur_frm.cscript.fiscal_year = function (doc, dt, dn){
|
||||
get_leave_balance(doc, dt, dn);
|
||||
}
|
||||
|
||||
// -----------
|
||||
// leave type
|
||||
// -----------
|
||||
cur_frm.cscript.leave_type = function (doc, dt, dn){
|
||||
get_leave_balance(doc, dt, dn);
|
||||
}
|
||||
|
||||
// ---------
|
||||
// half day
|
||||
// ---------
|
||||
cur_frm.cscript.half_day = function(doc, dt, dn) {
|
||||
if(doc.from_date) {
|
||||
set_multiple(dt,dn,{to_date:doc.from_date});
|
||||
calculate_total_days(doc, dt, dn);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------
|
||||
// from date
|
||||
// ---------
|
||||
cur_frm.cscript.from_date = function(doc, dt, dn) {
|
||||
if(cint(doc.half_day) == 1){
|
||||
set_multiple(dt,dn,{to_date:doc.from_date});
|
||||
}
|
||||
calculate_total_days(doc, dt, dn);
|
||||
}
|
||||
|
||||
// --------
|
||||
// to date
|
||||
// --------
|
||||
cur_frm.cscript.to_date = function(doc, dt, dn) {
|
||||
if(cint(doc.half_day) == 1 && doc.from_date && doc.from_date != doc.to_date){
|
||||
msgprint("To Date should be same as From Date for Half Day leave");
|
||||
return;
|
||||
}
|
||||
if(cint(doc.half_day) == 1){
|
||||
set_multiple(dt,dn,{to_date:doc.from_date});
|
||||
}
|
||||
calculate_total_days(doc, dt, dn);
|
||||
}
|
||||
|
||||
|
||||
// ******************************************* utilities ****************************************************
|
||||
|
||||
// ------------------
|
||||
// get leave balance
|
||||
// ------------------
|
||||
get_leave_balance = function(doc, dt, dn) {
|
||||
if(doc.employee && doc.leave_type && doc.fiscal_year)
|
||||
get_server_fields('get_leave_balance', '','', doc, dt, dn, 1);
|
||||
}
|
||||
|
||||
// ---------------
|
||||
// calculate days
|
||||
// ---------------
|
||||
calculate_total_days = function(doc, dt, dn) {
|
||||
if(doc.from_date && doc.to_date){
|
||||
if(cint(doc.half_day) == 1) set_multiple(dt,dn,{total_leave_days:0.5});
|
||||
else{
|
||||
//d = new DateFn();
|
||||
//set_multiple(dt,dn,{total_leave_days:d.get_diff(d.str_to_obj(doc.to_date),d.str_to_obj(doc.from_date))+1});
|
||||
get_server_fields('get_total_leave_days', '', '', doc, dt, dn, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
124
hr/doctype/leave_application/leave_application.py
Executable file
124
hr/doctype/leave_application/leave_application.py
Executable file
@@ -0,0 +1,124 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
import datetime
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
# ******************************************** client triggers ***********************************************
|
||||
|
||||
# ------------------
|
||||
# get leave balance
|
||||
# ------------------
|
||||
def get_leave_balance(self):
|
||||
leave_all = sql("select total_leaves_allocated from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
leave_all = leave_all and flt(leave_all[0][0]) or 0
|
||||
leave_app = sql("select total_leave_days from `tabLeave Application` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
leave_app = leave_app and flt(leave_app[0][0]) or 0
|
||||
ret = {'leave_balance':leave_all - leave_app}
|
||||
return str(ret)
|
||||
|
||||
|
||||
# ************************************************ utilities *************************************************
|
||||
|
||||
# -------------------
|
||||
# get total holidays
|
||||
# -------------------
|
||||
def get_holidays(self):
|
||||
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2, `tabEmployee` e1 where e1.name = '%s' and h1.parent = h2.name and e1.holiday_list = h2.name and h1.holiday_date between '%s' and '%s'"% (self.doc.employee, self.doc.from_date, self.doc.to_date))
|
||||
if not tot_hol:
|
||||
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between '%s' and '%s' and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s"% (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year))
|
||||
return tot_hol and flt(tot_hol[0][0]) or 0
|
||||
|
||||
|
||||
# ---------------------
|
||||
# get total leave days
|
||||
# ---------------------
|
||||
def get_total_leave_days(self):
|
||||
tot_days = date_diff(self.doc.to_date, self.doc.from_date) + 1
|
||||
holidays = self.get_holidays()
|
||||
ret = {'total_leave_days':flt(tot_days)-flt(holidays)}
|
||||
return str(ret)
|
||||
|
||||
|
||||
# ************************************************ validate *************************************************
|
||||
|
||||
# -----------------
|
||||
# validate to date
|
||||
# -----------------
|
||||
def validate_to_date(self):
|
||||
if (getdate(self.doc.to_date) < getdate(self.doc.from_date)):
|
||||
msgprint("To date cannot be before from date")
|
||||
raise Exception
|
||||
|
||||
# --------------------------------
|
||||
# check whether leave type is lwp
|
||||
# --------------------------------
|
||||
def is_lwp(self):
|
||||
lwp = sql("select is_lwp from `tabLeave Type` where name = %s", self.doc.leave_type)
|
||||
return lwp and cint(lwp[0][0]) or 0
|
||||
|
||||
# ------------------------
|
||||
# validate balance leaves
|
||||
# ------------------------
|
||||
def validate_balance_leaves(self):
|
||||
if not self.is_lwp():
|
||||
bal = self.get_leave_balance()
|
||||
tot_leaves = self.get_total_leave_days()
|
||||
bal, tot_leaves = eval(bal), eval(tot_leaves)
|
||||
set(self.doc,'leave_balance',flt(bal['leave_balance']))
|
||||
set(self.doc,'total_leave_days',flt(tot_leaves['total_leave_days']))
|
||||
if flt(bal['leave_balance']) < flt(tot_leaves['total_leave_days']):
|
||||
msgprint("Employee : %s cannot apply for %s of more than %s days" % (self.doc.employee, self.doc.leave_type, flt(bal['leave_balance'])))
|
||||
raise Exception
|
||||
|
||||
#
|
||||
# validate overlapping leaves
|
||||
#
|
||||
def validate_leave_overlap(self):
|
||||
for d in sql("""select name, leave_type, posting_date, from_date, to_date
|
||||
from `tabLeave Application`
|
||||
where
|
||||
(from_date <= %(to_date)s and to_date >= %(from_date)s)
|
||||
and employee = %(employee)s
|
||||
and docstatus = 1
|
||||
and name != %(name)s""", self.doc.fields, as_dict = 1):
|
||||
|
||||
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name']), raise_exception = 1)
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# validate max days for which leave can be applied for particular type
|
||||
# ---------------------------------------------------------------------
|
||||
def validate_max_days(self):
|
||||
max_days = sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type))
|
||||
max_days = max_days and flt(max_days[0][0]) or 0
|
||||
if max_days and self.doc.total_leave_days > max_days:
|
||||
msgprint("Sorry ! You cannot apply for %s for more than %s days" % (self.doc.leave_type, max_days))
|
||||
raise Exception
|
||||
|
||||
|
||||
# ---------
|
||||
# validate
|
||||
# ---------
|
||||
def validate(self):
|
||||
self.validate_to_date()
|
||||
self.validate_balance_leaves()
|
||||
self.validate_leave_overlap()
|
||||
self.validate_max_days()
|
||||
297
hr/doctype/leave_application/leave_application.txt
Normal file
297
hr/doctype/leave_application/leave_application.txt
Normal file
@@ -0,0 +1,297 @@
|
||||
# DocType, Leave Application
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-02-10 14:10:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-17 13:44:37',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1305714022',
|
||||
'autoname': 'LAP/.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Transaction',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'subject': 'From %(employee_name)s, %(designation)s',
|
||||
'tag_fields': 'leave_type',
|
||||
'version': 18
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Application',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Application',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Application
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Leave Application'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'match': 'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break1',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee',
|
||||
'options': 'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee Name',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Leave Type',
|
||||
'options': 'link:Leave Type',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_balance',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Leave Balance',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Today',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 6,
|
||||
'label': 'Posting Date',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 7,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break8',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 8,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'half_day',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 9,
|
||||
'label': 'Half Day',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 10,
|
||||
'label': 'From Date',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 11,
|
||||
'label': 'To Date',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_leave_days',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 12,
|
||||
'label': 'Total Leave Days',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 13,
|
||||
'label': 'Description',
|
||||
'permlevel': 0,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Amended From',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 15,
|
||||
'label': 'Amendment Date',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
hr/doctype/leave_control_panel/__init__.py
Normal file
0
hr/doctype/leave_control_panel/__init__.py
Normal file
28
hr/doctype/leave_control_panel/leave_control_panel.js
Normal file
28
hr/doctype/leave_control_panel/leave_control_panel.js
Normal file
@@ -0,0 +1,28 @@
|
||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
if(!doc.leave_transaction_type) set_multiple(dt,dn,{leave_transaction_type:'Allocation'});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Validation For To Date
|
||||
// ================================================================================================
|
||||
cur_frm.cscript.to_date = function(doc, cdt, cdn) {
|
||||
$c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist([doc])},
|
||||
function(r, rt) {
|
||||
var doc = locals[cdt][cdn];
|
||||
if (r.message) {
|
||||
alert("To date cannot be before from date");
|
||||
doc.to_date = '';
|
||||
refresh_field('to_date');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Allocation Type
|
||||
// ================================================================================================
|
||||
cur_frm.cscript.allocation_type = function (doc, cdt, cdn){
|
||||
doc.no_of_days = '';
|
||||
refresh_field('no_of_days');
|
||||
}
|
||||
73
hr/doctype/leave_control_panel/leave_control_panel.py
Normal file
73
hr/doctype/leave_control_panel/leave_control_panel.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
# Get Employees
|
||||
# **********************************************************************
|
||||
def get_employees(self):
|
||||
lst1 = [[self.doc.employee_type,"employment_type"],[self.doc.branch,"branch"],[self.doc.designation,"designation"],[self.doc.department, "department"],[self.doc.grade,"grade"]]
|
||||
condition = "where "
|
||||
flag = 0
|
||||
for l in lst1:
|
||||
if(l[0]):
|
||||
if flag == 0:
|
||||
condition += l[1] + "= '" + l[0] +"'"
|
||||
else:
|
||||
condition += " and " + l[1]+ "= '" +l[0] +"'"
|
||||
flag = 1
|
||||
emp_query = "select name from `tabEmployee` "
|
||||
if flag == 1:
|
||||
emp_query += condition
|
||||
e = sql(emp_query)
|
||||
return e
|
||||
|
||||
# ----------------
|
||||
# validate values
|
||||
# ----------------
|
||||
def validate_values(self):
|
||||
val_dict = {self.doc.fiscal_year:'Fiscal Year', self.doc.leave_type:'Leave Type', self.doc.no_of_days:'New Leaves Allocated'}
|
||||
for d in val_dict:
|
||||
if not d:
|
||||
msgprint("Please enter : "+val_dict[d])
|
||||
raise Exception
|
||||
|
||||
|
||||
# Allocation
|
||||
# **********************************************************************
|
||||
def allocate_leave(self):
|
||||
self.validate_values()
|
||||
for d in self.get_employees():
|
||||
la = Document('Leave Allocation')
|
||||
la.employee = cstr(d[0])
|
||||
la.employee_name = get_value('Employee',cstr(d[0]),'employee_name')
|
||||
la.leave_type = self.doc.leave_type
|
||||
la.fiscal_year = self.doc.fiscal_year
|
||||
la.posting_date = nowdate()
|
||||
la.carry_forward = cint(self.doc.carry_forward)
|
||||
la.new_leaves_allocated = flt(self.doc.no_of_days)
|
||||
la_obj = get_obj(doc=la)
|
||||
la_obj.doc.docstatus = 1
|
||||
la_obj.validate()
|
||||
la_obj.on_update()
|
||||
la_obj.doc.save(1)
|
||||
msgprint("Leaves Allocated Successfully")
|
||||
244
hr/doctype/leave_control_panel/leave_control_panel.txt
Normal file
244
hr/doctype/leave_control_panel/leave_control_panel.txt
Normal file
@@ -0,0 +1,244 @@
|
||||
# DocType, Leave Control Panel
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-12 15:42:00',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'issingle': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 161
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Control Panel',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Leave Control Panel',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Control Panel
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Leave Control Panel'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break1',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Leave blank if considered for all employee types',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'label': 'Employee Type',
|
||||
'options': 'link:Employment Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Leave blank if considered for all branches',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'branch',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'label': 'Branch',
|
||||
'options': 'link:Branch'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Leave blank if considered for all departments',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Department',
|
||||
'options': 'link:Department'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Leave blank if considered for all designations',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'label': 'Designation',
|
||||
'options': 'link:Designation'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Leave blank if considered for all grades',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'grade',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'label': 'Grade',
|
||||
'options': 'link:Grade'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'column_break7',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 7,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'options': 'link:Fiscal Year',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'leave_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 9,
|
||||
'label': 'Leave Type',
|
||||
'options': 'link:Leave Type',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': "Please select Carry Forward if you also want to include previous fiscal year's balance leaves to this fiscal year",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'carry_forward',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 10,
|
||||
'label': 'Carry Forward'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_days',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 11,
|
||||
'label': 'New Leaves Allocated (In Days)',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 12,
|
||||
'label': 'Allocate',
|
||||
'options': 'allocate_leave',
|
||||
'trigger': 'Server'
|
||||
}
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user