mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
moved directory structure
This commit is contained in:
1
hr/Deduction Type/Income Tax/Income Tax.txt
Normal file
1
hr/Deduction Type/Income Tax/Income Tax.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Income Tax', 'parent': None, 'description': 'Income Tax', 'creation': '2010-04-02 10:33:23', 'is_active': 'Yes', 'modified': '2010-04-05 12:53:07', 'module': 'Payroll', 'doctype': 'Deduction Type', 'idx': None, 'parenttype': None, 'deduction_name': 'Income Tax', 'trash_reason': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Deduction Type/Professional Tax/Professional Tax.txt
Normal file
1
hr/Deduction Type/Professional Tax/Professional Tax.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Professional Tax', 'parent': None, 'description': 'Professional Tax', 'creation': '2010-04-02 10:34:14', 'is_active': 'Yes', 'modified': '2010-04-05 12:52:59', 'module': 'Payroll', 'doctype': 'Deduction Type', 'idx': None, 'parenttype': None, 'deduction_name': 'Professional Tax', 'trash_reason': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Deduction Type/Provident Fund/Provident Fund.txt
Normal file
1
hr/Deduction Type/Provident Fund/Provident Fund.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Provident Fund', 'parent': None, 'description': 'Provident fund', 'creation': '2010-04-02 10:32:23', 'is_active': 'Yes', 'modified': '2010-04-05 12:52:52', 'module': 'Payroll', 'doctype': 'Deduction Type', 'idx': None, 'parenttype': None, 'deduction_name': 'Provident Fund', 'trash_reason': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
@@ -0,0 +1,47 @@
|
||||
# DocType Mapper, Appraisal Template-Appraisal
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:47:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'kra_sheet',
|
||||
'from_table': u'Appraisal Template Goal',
|
||||
'match_id': 0,
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal Template-Appraisal',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper',
|
||||
'to_field': u'appraisal_details',
|
||||
'to_table': u'Appraisal Goal',
|
||||
'validation_logic': u'name is not Null'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': u'Appraisal Template',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'to_doctype': u'Appraisal'
|
||||
},
|
||||
|
||||
# DocType Mapper, Appraisal Template-Appraisal
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': u'Appraisal Template-Appraisal'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,131 @@
|
||||
# DocType Mapper, Salary Structure-Salary Slip
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-12-14 10:33:11',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-09-15 15:04:44',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': 'Salary Structure-Salary Slip',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper',
|
||||
'validation_logic': 'name is not null'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'name': '__common__',
|
||||
'parent': 'Salary Structure-Salary Slip',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Salary Structure',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'to_doctype': 'Salary Slip'
|
||||
},
|
||||
|
||||
# DocType Mapper, Salary Structure-Salary Slip
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Salary Structure-Salary Slip'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'total_earning',
|
||||
'match_id': 0,
|
||||
'to_field': 'gross_pay'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'modified_value',
|
||||
'match_id': 1,
|
||||
'to_field': 'e_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'd_modified_amt',
|
||||
'match_id': 2,
|
||||
'to_field': 'd_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'modified_value',
|
||||
'match_id': 1,
|
||||
'to_field': 'e_modified_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'depend_on_lwp',
|
||||
'match_id': 1,
|
||||
'to_field': 'e_depends_on_lwp'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'd_modified_amt',
|
||||
'match_id': 2,
|
||||
'to_field': 'd_modified_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'depend_on_lwp',
|
||||
'match_id': 2,
|
||||
'to_field': 'd_depends_on_lwp'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Salary Structure',
|
||||
'match_id': 0,
|
||||
'to_table': 'Salary Slip'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'earning_details',
|
||||
'from_table': 'Salary Structure Earning',
|
||||
'match_id': 1,
|
||||
'to_field': 'earning_details',
|
||||
'to_table': 'Salary Slip Earning'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'deduction_details',
|
||||
'from_table': 'Salary Structure Deduction',
|
||||
'match_id': 2,
|
||||
'to_field': 'deduction_details',
|
||||
'to_table': 'Salary Slip Deduction'
|
||||
}
|
||||
]
|
||||
1
hr/Earning Type/Basic/Basic.txt
Normal file
1
hr/Earning Type/Basic/Basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Basic', 'parent': None, 'description': 'Basic', 'creation': '2010-04-02 10:29:08', 'is_active': 'Yes', 'modified': '2010-04-05 12:52:35', 'earning_name': 'Basic', 'doctype': 'Earning Type', 'taxable': 'Yes', 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'exemption_limit': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'House Rent Allowance', 'parent': None, 'description': 'House Rent Allowance', 'creation': '2010-04-02 10:29:29', 'is_active': 'Yes', 'modified': '2010-04-05 12:33:19', 'earning_name': 'House Rent Allowance', 'doctype': 'Earning Type', 'taxable': 'No', 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'exemption_limit': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Expense Type/Calls/Calls.txt
Normal file
1
hr/Expense Type/Calls/Calls.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Calls', 'parent': None, 'description': None, 'creation': '2010-08-23 18:26:38', 'modified': '2010-08-23 18:26:38', 'module': 'Payroll', 'doctype': 'Expense Claim Type', 'idx': None, 'parenttype': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'expense_type': 'Calls', 'parentfield': None}]
|
||||
1
hr/Expense Type/Food/Food.txt
Normal file
1
hr/Expense Type/Food/Food.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Food', 'parent': None, 'description': None, 'creation': '2010-08-23 18:26:30', 'modified': '2010-08-23 18:26:30', 'module': 'Payroll', 'doctype': 'Expense Claim Type', 'idx': None, 'parenttype': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'expense_type': 'Food', 'parentfield': None}]
|
||||
1
hr/Expense Type/Medical/Medical.txt
Normal file
1
hr/Expense Type/Medical/Medical.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Medical', 'parent': None, 'description': None, 'creation': '2010-08-23 18:26:49', 'modified': '2010-08-23 18:26:49', 'module': 'Payroll', 'doctype': 'Expense Claim Type', 'idx': None, 'parenttype': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'expense_type': 'Medical', 'parentfield': None}]
|
||||
1
hr/Expense Type/Others/Others.txt
Normal file
1
hr/Expense Type/Others/Others.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Others', 'parent': None, 'description': None, 'creation': '2010-09-20 12:16:45', 'modified': '2010-09-20 12:16:45', 'module': 'Payroll', 'doctype': 'Expense Claim Type', 'idx': None, 'parenttype': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'expense_type': 'Others', 'parentfield': None}]
|
||||
1
hr/Expense Type/Travel/Travel.txt
Normal file
1
hr/Expense Type/Travel/Travel.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'harshada@webnotestech.com', 'name': 'Travel', 'parent': None, 'description': None, 'creation': '2010-09-20 12:16:45', 'modified': '2010-09-20 12:16:45', 'module': 'Payroll', 'doctype': 'Expense Claim Type', 'idx': None, 'parenttype': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'expense_type': 'Travel', 'parentfield': None}]
|
||||
1
hr/Leave Type/Casual Leave/Casual Leave.txt
Normal file
1
hr/Leave Type/Casual Leave/Casual Leave.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'leave_type_name': 'Casual Leave', 'modified_by': 'Administrator', 'name': 'Casual Leave', 'parent': None, 'is_encash': 1, 'creation': '2010-04-02 10:52:32', 'is_active': 'Yes', 'modified': '2010-04-02 10:52:32', 'is_carry_forward': 1, 'doctype': 'Leave Type', 'max_days_allowed': '3', 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Leave Type/Compensatory Off/Compensatory Off.txt
Normal file
1
hr/Leave Type/Compensatory Off/Compensatory Off.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'leave_type_name': 'Compensatory Off', 'modified_by': 'Administrator', 'name': 'Compensatory Off', 'parent': None, 'is_encash': None, 'creation': '2010-04-02 10:59:30', 'is_active': 'Yes', 'modified': '2010-04-02 10:59:30', 'is_carry_forward': None, 'doctype': 'Leave Type', 'max_days_allowed': None, 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Leave Type/Leave Without Pay/Leave Without Pay.txt
Normal file
1
hr/Leave Type/Leave Without Pay/Leave Without Pay.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'leave_type_name': 'Leave Without Pay', 'modified_by': 'Administrator', 'name': 'Leave Without Pay', 'parent': None, 'is_encash': None, 'creation': '2010-04-02 10:57:37', 'is_active': 'Yes', 'modified': '2010-04-02 10:57:37', 'is_carry_forward': None, 'doctype': 'Leave Type', 'max_days_allowed': None, 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Leave Type/Privilege Leave/Privilege Leave.txt
Normal file
1
hr/Leave Type/Privilege Leave/Privilege Leave.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'leave_type_name': 'Privilege Leave', 'modified_by': 'Administrator', 'name': 'Privilege Leave', 'parent': None, 'is_encash': 1, 'creation': '2010-04-02 10:53:16', 'is_active': 'Yes', 'modified': '2010-04-02 10:53:16', 'is_carry_forward': None, 'doctype': 'Leave Type', 'max_days_allowed': None, 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
1
hr/Leave Type/Sick Leave/Sick Leave.txt
Normal file
1
hr/Leave Type/Sick Leave/Sick Leave.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'leave_type_name': 'Sick Leave', 'modified_by': 'Administrator', 'name': 'Sick Leave', 'parent': None, 'is_encash': None, 'creation': '2010-04-02 10:54:12', 'is_active': 'Yes', 'modified': '2010-04-02 10:54:12', 'is_carry_forward': None, 'doctype': 'Leave Type', 'max_days_allowed': None, 'idx': None, 'parenttype': None, 'trash_reason': None, 'module': 'Payroll', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
|
||||
6
hr/__init__.py
Normal file
6
hr/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
install_docs = [
|
||||
{"doctype":"Role", "role_name":"Employee", "name":"Employee"},
|
||||
{"doctype":"Role", "role_name":"HR Manager", "name":"HR Manager"},
|
||||
{"doctype":"Role", "role_name":"HR User", "name":"HR User"},
|
||||
]
|
||||
1
hr/doctype/__init__.py
Normal file
1
hr/doctype/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
1
hr/doctype/appraisal/__init__.py
Normal file
1
hr/doctype/appraisal/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
171
hr/doctype/appraisal/appraisal.js
Normal file
171
hr/doctype/appraisal/appraisal.js
Normal file
@@ -0,0 +1,171 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(!doc.status)
|
||||
set_multiple(cdt,cdn,{status:'Draft'});
|
||||
if(doc.amended_from && doc.__islocal)
|
||||
cur_frm.cscript.refresh_appraisal_details(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc,cdt,cdn){
|
||||
if(doc.employee)
|
||||
cur_frm.cscript.employee(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 Goal', doc.name, 'appraisal_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
set_multiple('Appraisal Goal', 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 Goal', 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);
|
||||
}
|
||||
|
||||
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){
|
||||
if (flt(d.score) > 5) {
|
||||
msgprint("Score must be less than or equal to 5");
|
||||
d.score = 0;
|
||||
refresh_field('score', d.name, 'appraisal_details');
|
||||
}
|
||||
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 Goal', 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');
|
||||
}
|
||||
165
hr/doctype/appraisal/appraisal.py
Normal file
165
hr/doctype/appraisal/appraisal.py
Normal file
@@ -0,0 +1,165 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
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 emp_nm
|
||||
|
||||
def fetch_kra(self):
|
||||
if not self.doc.kra_template:
|
||||
msgprint("Please select Appraisal Template to be be fetched")
|
||||
raise Exception
|
||||
self.doclist = self.doc.clear_table(self.doclist,'appraisal_details')
|
||||
get_obj('DocType Mapper', 'Appraisal Template-Appraisal').dt_map('Appraisal Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['Appraisal Template','Appraisal'],['Appraisal Template Goal', 'Appraisal Goal']]")
|
||||
|
||||
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 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')
|
||||
384
hr/doctype/appraisal/appraisal.txt
Normal file
384
hr/doctype/appraisal/appraisal.txt
Normal file
@@ -0,0 +1,384 @@
|
||||
# DocType, Appraisal
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:46',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1316075905',
|
||||
'autoname': u'APRSL.#####',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'status, employee, employee_name',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 161
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Appraisal
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Appraisal'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Employee Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Draft',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'status',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'status',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nDraft\nSubmitted\nCompleted\nCancelled',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee',
|
||||
'oldfieldname': u'employee',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee Name',
|
||||
'oldfieldname': u'employee_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'start_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Start Date',
|
||||
'oldfieldname': u'start_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'end_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'End Date',
|
||||
'oldfieldname': u'end_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra_approver',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 0,
|
||||
'label': u'Approver',
|
||||
'oldfieldname': u'kra_approver',
|
||||
'oldfieldtype': u'Select',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amended_from',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 1,
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amendment_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'declare_completed',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Declare Completed',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Select template from which you want to fetch KRA',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra_template',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Appraisal Template',
|
||||
'oldfieldname': u'kra_template',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Appraisal Template',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fetch_template',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Fetch Template',
|
||||
'oldfieldtype': u'Button',
|
||||
'options': u'fetch_kra',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update',
|
||||
'fieldtype': u'Button',
|
||||
'hidden': 1,
|
||||
'label': u'Update',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'appraisal_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Appraisal Goals',
|
||||
'oldfieldname': u'appraisal_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Appraisal Goal',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'calculate_total_score',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Calculate Total Score',
|
||||
'oldfieldtype': u'Button',
|
||||
'options': u'calculate_total',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_score',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Score (Out of 5)',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'total_score',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
32
hr/doctype/appraisal/appraisal_list.js
Normal file
32
hr/doctype/appraisal/appraisal_list.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// render
|
||||
wn.doclistviews['Appraisal'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabAppraisal`.employee_name",
|
||||
"`tabAppraisal`.start_date",
|
||||
"`tabAppraisal`.end_date",
|
||||
"`tabAppraisal`.total_score",
|
||||
"`tabAppraisal`.status",
|
||||
]);
|
||||
this.stats = this.stats.concat(['company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.start_date = wn.datetime.str_to_user(data.start_date);
|
||||
data.end_date = wn.datetime.str_to_user(data.end_date);
|
||||
data.date_range = data.start_date + " to " + data.end_date;
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '3%', content: 'docstatus'},
|
||||
{width: '15%', content: 'name'},
|
||||
{width: '25%', content: 'employee_name'},
|
||||
{width: '12%', content: 'status+tags'},
|
||||
{width: '12%', content: 'total_score', css: {'text-align': 'right'}},
|
||||
{width: '30%', content:'date_range',
|
||||
css: {'text-align': 'right', 'color': '#777'}},
|
||||
]
|
||||
});
|
||||
1
hr/doctype/appraisal_goal/__init__.py
Normal file
1
hr/doctype/appraisal_goal/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
109
hr/doctype/appraisal_goal/appraisal_goal.txt
Normal file
109
hr/doctype/appraisal_goal/appraisal_goal.txt
Normal file
@@ -0,0 +1,109 @@
|
||||
# DocType, Appraisal Goal
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:53',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'APRSLD.#####',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 15
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal Goal',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Appraisal Goal
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Appraisal Goal'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Key Responsibility Area',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'KRA',
|
||||
'oldfieldname': u'kra',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'per_weightage',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Weightage (%)',
|
||||
'oldfieldname': u'per_weightage',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'target_achieved',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Target Achieved',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'target_achieved',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'score',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Score (0-5)',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'score',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\n0\n1\n2\n3\n4\n5',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client',
|
||||
'width': u'60px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'score_earned',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Score Earned',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'score_earned',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/appraisal_template/__init__.py
Normal file
1
hr/doctype/appraisal_template/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
111
hr/doctype/appraisal_template/appraisal_template.txt
Normal file
111
hr/doctype/appraisal_template/appraisal_template.txt
Normal file
@@ -0,0 +1,111 @@
|
||||
# DocType, Appraisal Template
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:58',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'field:kra_title',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal Template',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal Template',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Appraisal Template
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Appraisal Template'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra_title',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'KRA Title',
|
||||
'oldfieldname': u'kra_title',
|
||||
'oldfieldtype': u'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra_sheet',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Appraisal Template Goal',
|
||||
'oldfieldname': u'kra_sheet',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Appraisal Template Goal'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/appraisal_template_goal/__init__.py
Normal file
1
hr/doctype/appraisal_template_goal/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,66 @@
|
||||
# DocType, Appraisal Template Goal
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:58',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'KSHEET.#####',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Appraisal Template Goal',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocType, Appraisal Template Goal
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Appraisal Template Goal'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Key Performance Area',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'kra',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'KRA',
|
||||
'oldfieldname': u'kra',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'width': u'200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'per_weightage',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Weightage (%)',
|
||||
'oldfieldname': u'per_weightage',
|
||||
'oldfieldtype': u'Currency',
|
||||
'width': u'100px'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/attendance/__init__.py
Normal file
1
hr/doctype/attendance/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
30
hr/doctype/attendance/attendance.js
Normal file
30
hr/doctype/attendance/attendance.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
//get employee's name based on employee id selected
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
if(doc.employee) get_server_fields('get_emp_name', '', '', doc, cdt, cdn, 1);
|
||||
refresh_field('employee_name');
|
||||
}
|
||||
|
||||
|
||||
//Employee
|
||||
//-----------------------------
|
||||
cur_frm.fields_dict['employee'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabEmployee`.`name`, `tabEmployee`.`employee_name` FROM `tabEmployee` WHERE `tabEmployee`.status = "Active" AND `tabEmployee`.`docstatus`!= 2 AND (`tabEmployee`.`employee_name` LIKE "%s" OR `tabEmployee`.`%(key)s` LIKE "%s") ORDER BY `tabEmployee`.`name` ASC LIMIT 50';
|
||||
}
|
||||
113
hr/doctype/attendance/attendance.py
Normal file
113
hr/doctype/attendance/attendance.py
Normal file
@@ -0,0 +1,113 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
#autoname function
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
#get employee name based on employee id selected
|
||||
def get_emp_name(self):
|
||||
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
|
||||
#this is done because sometimes user entered wrong employee name while uploading employee attendance
|
||||
set(self.doc, 'employee_name', emp_nm and emp_nm[0][0] or '')
|
||||
|
||||
ret = { 'employee_name' : emp_nm and emp_nm[0][0] or ''}
|
||||
return ret
|
||||
|
||||
#validation for duplicate record
|
||||
def validate_duplicate_record(self):
|
||||
res = sql("select name from `tabAttendance` where employee = '%s' and att_date = '%s' and not name = '%s' and docstatus = 1"%(self.doc.employee,self.doc.att_date, self.doc.name))
|
||||
if res:
|
||||
msgprint("Employee's attendance already marked.")
|
||||
raise Exception
|
||||
|
||||
|
||||
#check for already record present in leave transaction for same date
|
||||
def check_leave_record(self):
|
||||
if self.doc.status == 'Present':
|
||||
chk = sql("select name from `tabLeave Application` where employee=%s and (from_date <= %s and to_date >= %s) and docstatus!=2", (self.doc.employee, self.doc.att_date, self.doc.att_date))
|
||||
if chk:
|
||||
msgprint("Leave Application created for employee "+self.doc.employee+" whom you are trying to mark as 'Present' ")
|
||||
raise Exception
|
||||
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"% self.doc.fiscal_year)
|
||||
ysd=fy and fy[0][0] or ""
|
||||
yed=add_days(str(ysd),365)
|
||||
if str(self.doc.att_date) < str(ysd) or str(self.doc.att_date) > str(yed):
|
||||
msgprint("'%s' Not Within The Fiscal Year selected"%(self.doc.att_date))
|
||||
raise Exception
|
||||
|
||||
def validate_att_date(self):
|
||||
import datetime
|
||||
if getdate(self.doc.att_date)>getdate(datetime.datetime.now().date().strftime('%Y-%m-%d')):
|
||||
msgprint("Attendance can not be marked for future dates")
|
||||
raise Exception
|
||||
|
||||
# Validate employee
|
||||
#-------------------
|
||||
def validate_employee(self):
|
||||
emp = sql("select name, status from `tabEmployee` where name = '%s'" % self.doc.employee)
|
||||
if not emp:
|
||||
msgprint("Employee: %s does not exists in the system" % self.doc.employee, raise_exception=1)
|
||||
elif emp[0][1] != 'Active':
|
||||
msgprint("Employee: %s is not Active" % self.doc.employee, raise_exception=1)
|
||||
|
||||
# validate...
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
self.validate_att_date()
|
||||
self.validate_duplicate_record()
|
||||
#self.validate_status()
|
||||
self.check_leave_record()
|
||||
|
||||
def on_update(self):
|
||||
#self.validate()
|
||||
|
||||
#this is done because sometimes user entered wrong employee name while uploading employee attendance
|
||||
x=self.get_emp_name()
|
||||
|
||||
def on_submit(self):
|
||||
#this is done because while uploading attendance chnage docstatus to 1 i.e. submit
|
||||
set(self.doc,'docstatus',1)
|
||||
pass
|
||||
241
hr/doctype/attendance/attendance.txt
Normal file
241
hr/doctype/attendance/attendance.txt
Normal file
@@ -0,0 +1,241 @@
|
||||
# DocType, Attendance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:46',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1317365120',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'employee, employee_name, att_date, status',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 75
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Attendance
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Attendance'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'attendance_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Attendance Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'naming_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Naming Series',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'naming_series',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'ATT',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee',
|
||||
'oldfieldname': u'employee',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Employee Name',
|
||||
'oldfieldname': u'employee_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'status',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'status',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nPresent\nAbsent\nHalf Day',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'label': u'Leave Type',
|
||||
'oldfieldname': u'leave_type',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Leave Type',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'att_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Attendance Date',
|
||||
'oldfieldname': u'att_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:doc.amended_from',
|
||||
'description': u'The date at which current entry is corrected in the system.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'options': u'Sales Invoice',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
29
hr/doctype/attendance/attendance_list.js
Normal file
29
hr/doctype/attendance/attendance_list.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// render
|
||||
wn.doclistviews['Attendance'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabAttendance`.att_date",
|
||||
"`tabAttendance`.employee_name",
|
||||
"`tabAttendance`.`status`",
|
||||
|
||||
]);
|
||||
this.stats = this.stats.concat(['company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.att_date = wn.datetime.str_to_user(data.att_date);
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '3%', content:'docstatus'},
|
||||
{width: '12%', content:'name'},
|
||||
{width: '47%', content:'employee_name'},
|
||||
{width: '13%', content:'status'},
|
||||
{width: '10%', content:'tags'},
|
||||
//{width: '23%', content:'supplier_type', css: {'color': '#aaa'}},
|
||||
{width: '12%', content:'att_date', css: {'text-align': 'right', 'color':'#777'}}
|
||||
]
|
||||
});
|
||||
1
hr/doctype/attendance_control_panel/__init__.py
Normal file
1
hr/doctype/attendance_control_panel/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,66 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.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');
|
||||
|
||||
}
|
||||
119
hr/doctype/attendance_control_panel/attendance_control_panel.py
Normal file
119
hr/doctype/attendance_control_panel/attendance_control_panel.py
Normal file
@@ -0,0 +1,119 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,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=([formatdate(cstr(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
|
||||
import webnotes.model.doctype
|
||||
docfield = webnotes.model.doctype.get('Attendance')
|
||||
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
||||
if not series:
|
||||
msgprint("Please create naming series for Attendance.\nGo to Setup--> Numbering Series.")
|
||||
raise Exception
|
||||
else:
|
||||
sr = series[0] or ''
|
||||
|
||||
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])
|
||||
|
||||
# NOTE: Don't know why this condition exists
|
||||
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
|
||||
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
|
||||
|
||||
219
hr/doctype/attendance_control_panel/attendance_control_panel.txt
Normal file
219
hr/doctype/attendance_control_panel/attendance_control_panel.txt
Normal file
@@ -0,0 +1,219 @@
|
||||
# DocType, Attendance Control Panel
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:53',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1294312182',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'max_attachments': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 122
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance Control Panel',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Attendance Control Panel',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Attendance Control Panel
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Attendance Control Panel'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u"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': u'DocField',
|
||||
'fieldname': u'download_template',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Download Template',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Selected Attendance date will comes in the attendance template.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'att_fr_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Attendance From Date',
|
||||
'oldfieldname': u'attenadnce_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_template',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get Template',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'All attendance dates inbetween selected Attendance From Date and Attendance To Date will come in the template with employees list.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'att_to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Attendance To Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'upload_attendance_data',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Upload Attendance Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'import_date_format',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Import Date Format ',
|
||||
'options': u'yyyy-mm-dd\nmm/dd/yyyy\nmm/dd/yy\ndd-mm-yyyy\ndd/mm/yyyy',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'overwrite',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Overwrite',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'import',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Import',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'file_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'File List',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'import_log',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Import Log',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'import_log1',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Import Log1',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
hr/doctype/branch/__init__.py
Normal file
1
hr/doctype/branch/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
97
hr/doctype/branch/branch.txt
Normal file
97
hr/doctype/branch/branch.txt
Normal file
@@ -0,0 +1,97 @@
|
||||
# DocType, Branch
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:branch',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 11
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Branch',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Branch',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Branch
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Branch'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'branch',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Branch',
|
||||
'oldfieldname': u'branch',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/deduction_type/__init__.py
Normal file
1
hr/doctype/deduction_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
109
hr/doctype/deduction_type/deduction_type.txt
Normal file
109
hr/doctype/deduction_type/deduction_type.txt
Normal file
@@ -0,0 +1,109 @@
|
||||
# DocType, Deduction Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:deduction_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 10
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Deduction Type',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Deduction Type',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Deduction Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Deduction Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'deduction_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Name',
|
||||
'oldfieldname': u'deduction_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0,
|
||||
'width': u'300px'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/department/__init__.py
Normal file
1
hr/doctype/department/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
97
hr/doctype/department/department.txt
Normal file
97
hr/doctype/department/department.txt
Normal file
@@ -0,0 +1,97 @@
|
||||
# DocType, Department
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:department_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Department',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Department',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Department
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Department'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'department_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Department',
|
||||
'oldfieldname': u'department_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/designation/__init__.py
Normal file
1
hr/doctype/designation/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
97
hr/doctype/designation/designation.txt
Normal file
97
hr/doctype/designation/designation.txt
Normal file
@@ -0,0 +1,97 @@
|
||||
# DocType, Designation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:designation_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Designation',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Designation',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Designation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Designation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Designation',
|
||||
'oldfieldname': u'designation_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/earning_type/__init__.py
Normal file
1
hr/doctype/earning_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
139
hr/doctype/earning_type/earning_type.txt
Normal file
139
hr/doctype/earning_type/earning_type.txt
Normal file
@@ -0,0 +1,139 @@
|
||||
# DocType, Earning Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:earning_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 13
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Earning Type',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Earning Type',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Earning Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Earning Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'earning_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Name',
|
||||
'oldfieldname': u'earning_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0,
|
||||
'reqd': 0,
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'taxable',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Taxable',
|
||||
'oldfieldname': u'taxable',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u"eval:doc.taxable=='No'",
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'exemption_limit',
|
||||
'fieldtype': u'Currency',
|
||||
'hidden': 1,
|
||||
'label': u'Exemption Limit',
|
||||
'oldfieldname': u'exemption_limit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
hr/doctype/employee/__init__.py
Normal file
1
hr/doctype/employee/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
67
hr/doctype/employee/employee.js
Normal file
67
hr/doctype/employee/employee.js
Normal file
@@ -0,0 +1,67 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 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);
|
||||
}
|
||||
135
hr/doctype/employee/employee.py
Normal file
135
hr/doctype/employee/employee.py
Normal file
@@ -0,0 +1,135 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
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 = 'Global Defaults' 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 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' and docstatus!= 2"%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 = 'Global Defaults' 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
|
||||
1067
hr/doctype/employee/employee.txt
Normal file
1067
hr/doctype/employee/employee.txt
Normal file
File diff suppressed because it is too large
Load Diff
56
hr/doctype/employee/employee_list.js
Normal file
56
hr/doctype/employee/employee_list.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// render
|
||||
wn.doclistviews['Employee'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabEmployee`.employee_name",
|
||||
"`tabEmployee`.employee_number",
|
||||
"`tabEmployee`.employment_type",
|
||||
"`tabEmployee`.designation",
|
||||
"`tabEmployee`.department",
|
||||
"`tabEmployee`.branch",
|
||||
"`tabEmployee`.company",
|
||||
"`tabEmployee`.reports_to",
|
||||
"`tabEmployee`.date_of_joining",
|
||||
"`tabEmployee`.status",
|
||||
]);
|
||||
this.stats = this.stats.concat(['status', 'company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
|
||||
data.employee_name = data.employee_name
|
||||
+ (data.employee_number ? ' [' + data.employee_number + ']' : '');
|
||||
|
||||
data.date_of_joining = wn.datetime.str_to_user(data.date_of_joining);
|
||||
data.designation = data.designation
|
||||
+ (data.employment_type ? ' [' + data.employment_type + ']' : '');
|
||||
|
||||
var concat_list = [];
|
||||
data.designation && concat_list.push(data.designation);
|
||||
data.department && concat_list.push(data.department);
|
||||
data.company && concat_list.push(data.company);
|
||||
data.branch && concat_list.push(data.branch);
|
||||
data.description = concat_list.join(", ");
|
||||
|
||||
if(data.status=='Left') {
|
||||
data.label_type = 'important';
|
||||
} else if(data.status=='Active') {
|
||||
data.label_type = 'success';
|
||||
}
|
||||
data.status_html = repl('<span class="label label-%(label_type)s" \
|
||||
support_list_status="%(status)s">%(status)s</span>', data);
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '12%', content: 'name'},
|
||||
{width: '25%', content: 'employee_name'},
|
||||
{width: '10%', content: 'status_html'},
|
||||
{width: '38%', content: 'description+tags',
|
||||
css: {'color': '#aaa'}},
|
||||
{width: '12%', content:'date_of_joining',
|
||||
css: {'text-align': 'right', 'color': '#777'}},
|
||||
]
|
||||
});
|
||||
1
hr/doctype/employee_education/__init__.py
Normal file
1
hr/doctype/employee_education/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
103
hr/doctype/employee_education/employee_education.txt
Normal file
103
hr/doctype/employee_education/employee_education.txt
Normal file
@@ -0,0 +1,103 @@
|
||||
# DocType, Employee Education
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:54',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Employee Education',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Employee Education
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Employee Education'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'school_univ',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'School/University',
|
||||
'oldfieldname': u'school_univ',
|
||||
'oldfieldtype': u'Small Text'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'qualification',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Qualification',
|
||||
'oldfieldname': u'qualification',
|
||||
'oldfieldtype': u'Data',
|
||||
'width': u'100px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'level',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Level',
|
||||
'oldfieldname': u'level',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'Graduate\nPost Graduate\nUnder Graduate'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'year_of_passing',
|
||||
'fieldtype': u'Int',
|
||||
'label': u'Year of Passing',
|
||||
'oldfieldname': u'year_of_passing',
|
||||
'oldfieldtype': u'Int'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'class_per',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Class / Percentage',
|
||||
'oldfieldname': u'class_per',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'maj_opt_subj',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Major/Optional Subjects',
|
||||
'oldfieldname': u'maj_opt_subj',
|
||||
'oldfieldtype': u'Text'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/employee_external_work_history/__init__.py
Normal file
1
hr/doctype/employee_external_work_history/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,120 @@
|
||||
# DocType, Employee External Work History
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Employee External Work History',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Employee External Work History',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Employee External Work History
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Employee External Work History'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company_name',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Designation',
|
||||
'oldfieldname': u'designation',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'salary',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Salary',
|
||||
'oldfieldname': u'salary',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Address',
|
||||
'oldfieldname': u'address',
|
||||
'oldfieldtype': u'Small Text'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'contact',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Contact',
|
||||
'oldfieldname': u'contact',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_experience',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Total Experience',
|
||||
'oldfieldname': u'total_experience',
|
||||
'oldfieldtype': u'Data'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/employee_internal_work_history/__init__.py
Normal file
1
hr/doctype/employee_internal_work_history/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,104 @@
|
||||
# DocType, Employee Internal Work History
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:57',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Employee Internal Work History',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Employee Internal Work History
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Employee Internal Work History'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'branch',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Branch',
|
||||
'oldfieldname': u'branch',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Branch'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'department',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Department',
|
||||
'oldfieldname': u'department',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Department'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Designation',
|
||||
'oldfieldname': u'designation',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Designation'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'grade',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Grade',
|
||||
'oldfieldname': u'grade',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Grade'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'from_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'From Date',
|
||||
'oldfieldname': u'from_date',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'To Date',
|
||||
'oldfieldname': u'to_date',
|
||||
'oldfieldtype': u'Date'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/employee_training/__init__.py
Normal file
1
hr/doctype/employee_training/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
95
hr/doctype/employee_training/employee_training.txt
Normal file
95
hr/doctype/employee_training/employee_training.txt
Normal file
@@ -0,0 +1,95 @@
|
||||
# DocType, Employee Training
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Employee Training',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Employee Training
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Employee Training'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'institute',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Institute / Conducted By',
|
||||
'oldfieldname': u'institute',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'nature_of_training',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Program / Seminar Title',
|
||||
'oldfieldname': u'nature_of_training',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'duration',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Duration',
|
||||
'oldfieldname': u'duration',
|
||||
'oldfieldtype': u'Data',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'loc',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Location',
|
||||
'oldfieldname': u'loc',
|
||||
'oldfieldtype': u'Data',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'certificate',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Certificate',
|
||||
'oldfieldname': u'certificate',
|
||||
'oldfieldtype': u'Small Text'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/employment_type/__init__.py
Normal file
1
hr/doctype/employment_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
97
hr/doctype/employment_type/employment_type.txt
Normal file
97
hr/doctype/employment_type/employment_type.txt
Normal file
@@ -0,0 +1,97 @@
|
||||
# DocType, Employment Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:55',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:employee_type_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 16
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Employment Type',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Employment Type',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Employment Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Employment Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_type_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Employment Type',
|
||||
'oldfieldname': u'employee_type_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/expense_claim/__init__.py
Normal file
1
hr/doctype/expense_claim/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
248
hr/doctype/expense_claim/expense_claim.js
Normal file
248
hr/doctype/expense_claim/expense_claim.js
Normal file
@@ -0,0 +1,248 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
cur_frm.cscript.onload = function(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 Claim Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
val[i].sanctioned_amount ='';
|
||||
}
|
||||
doc.total_sanctioned_amount = '';
|
||||
refresh_many(['sanctioned_amount', 'total_sanctioned_amount']);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
hide_field('calculate_total_amount');
|
||||
if(user == doc.exp_approver && doc.approval_status == 'Submitted'){
|
||||
unhide_field(['update_voucher', 'approve', 'reject', 'calculate_total_amount']);
|
||||
cur_frm.fields_dict['expense_voucher_details'].grid.set_column_disp('sanctioned_amount', true);
|
||||
set_field_permlevel('remark', 0);
|
||||
} else {
|
||||
hide_field(['update_voucher', 'approve', 'reject']);
|
||||
cur_frm.fields_dict['expense_voucher_details'].grid.set_column_disp('sanctioned_amount', false);
|
||||
set_field_permlevel('remark', 1);
|
||||
}
|
||||
if (doc.docstatus == 0) unhide_field('calculate_total_amount');
|
||||
}
|
||||
|
||||
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'];
|
||||
wn.meta.get_docfield(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 Claim Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
var total_claim =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
if(!doc.claim_amount) val[i].sanctioned_amount = val[i].claim_amount;
|
||||
total_claim = flt(total_claim)+flt(val[i].claim_amount);
|
||||
refresh_field('sactioned_amount', val[i].name, 'expense_voucher_details');
|
||||
}
|
||||
doc.total_claimed_amount = flt(total_claim);
|
||||
refresh_field('total_claimed_amount');
|
||||
}
|
||||
else if(doc.approval_status == 'Submitted'){
|
||||
var val = getchildren('Expense Claim Detail', doc.name, 'expense_voucher_details', doc.doctype);
|
||||
var total_sanctioned = 0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
if(!doc.claim_amount) val[i].sanctioned_amount = val[i].claim_amount;
|
||||
total_sanctioned = flt(total_sanctioned)+flt(val[i].sanctioned_amount);
|
||||
refresh_field('sactioned_amount', val[i].name, 'expense_voucher_details');
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
|
||||
|
||||
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();
|
||||
var args = {
|
||||
type: 'Expense Claim Approved',
|
||||
doctype: 'Expense Claim',
|
||||
contact_name: doc.employee_name,
|
||||
send_to: doc.email_id
|
||||
}
|
||||
cur_frm.cscript.notify(doc, args);
|
||||
}
|
||||
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 Claim 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();
|
||||
var args = {
|
||||
type: 'Expense Claim Rejected',
|
||||
doctype: 'Expense Claim',
|
||||
contact_name: doc.employee_name,
|
||||
send_to: doc.email_id
|
||||
}
|
||||
cur_frm.cscript.notify(doc, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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 Claim 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();
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
var args = {
|
||||
type: 'Expense Claim',
|
||||
doctype: 'Expense Claim',
|
||||
send_to: doc.exp_approver
|
||||
}
|
||||
cur_frm.cscript.notify(doc, args);
|
||||
}
|
||||
141
hr/doctype/expense_claim/expense_claim.py
Normal file
141
hr/doctype/expense_claim/expense_claim.py
Normal file
@@ -0,0 +1,141 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
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 Claim 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 Claim 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')
|
||||
|
||||
return cstr('Rejected')
|
||||
|
||||
|
||||
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_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 Claim approver")
|
||||
raise Exception
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_exp_details()
|
||||
set(self.doc, 'approval_status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'approval_status', 'Cancelled')
|
||||
|
||||
def get_formatted_message(self, args):
|
||||
""" get formatted message for auto notification"""
|
||||
return get_obj('Notification Control').get_formatted_message(args)
|
||||
390
hr/doctype/expense_claim/expense_claim.txt
Normal file
390
hr/doctype/expense_claim/expense_claim.txt
Normal file
@@ -0,0 +1,390 @@
|
||||
# DocType, Expense Claim
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:48',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1308808105',
|
||||
'autoname': u'EXP.######',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'approval_status,employee,employee_name',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': u'From %(employee_name)s for %(total_claimed_amount)s (claimed)',
|
||||
'tag_fields': u'approval_status',
|
||||
'version': 135
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Expense Claim',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Expense Claim',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Expense Claim
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Expense Claim'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'match': u'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Draft',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'approval_status',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Approval Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'approval_status',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nDraft\nSubmitted\nApproved \nRejected\nCancelled',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'From Employee',
|
||||
'oldfieldname': u'employee',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee Name',
|
||||
'oldfieldname': u'employee_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'search_index': 0,
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Posting Date',
|
||||
'oldfieldname': u'posting_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'exp_approver',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Approver',
|
||||
'oldfieldname': u'exp_approver',
|
||||
'oldfieldtype': u'Select',
|
||||
'permlevel': 0,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'remark',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'remark',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amended_from',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amendment_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'approve',
|
||||
'fieldtype': u'Button',
|
||||
'hidden': 1,
|
||||
'label': u'Approve',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'reject',
|
||||
'fieldtype': u'Button',
|
||||
'hidden': 1,
|
||||
'label': u'Reject',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Expense Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'calculate_total_amount',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Calculate Total Amount',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_claimed_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'in_filter': 0,
|
||||
'label': u'Total Claimed Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'total_claimed_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1,
|
||||
'reqd': 0,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_sanctioned_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'in_filter': 0,
|
||||
'label': u'Total Sanctioned Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'total_sanctioned_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update_voucher',
|
||||
'fieldtype': u'Button',
|
||||
'hidden': 1,
|
||||
'label': u'Update Voucher',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_voucher_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Expense Claim Details',
|
||||
'oldfieldname': u'expense_voucher_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Expense Claim Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'email_id',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Employees Email Id',
|
||||
'oldfieldname': u'email_id',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
42
hr/doctype/expense_claim/expense_claim_list.js
Normal file
42
hr/doctype/expense_claim/expense_claim_list.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// render
|
||||
wn.doclistviews['Expense Claim'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabExpense Claim`.employee_name",
|
||||
"`tabExpense Claim`.posting_date",
|
||||
"`tabExpense Claim`.approval_status",
|
||||
"`tabExpense Claim`.total_claimed_amount",
|
||||
"`tabExpense Claim`.total_sanctioned_amount",
|
||||
"`tabExpense Claim`.company",
|
||||
]);
|
||||
this.stats = this.stats.concat(['company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.posting_date = wn.datetime.str_to_user(data.posting_date);
|
||||
data.employee_name = data.employee_name + 'claimed '
|
||||
+ wn.boot.company[data.company].default_currency + ' '
|
||||
+ fmt_money(data.total_claimed_amount);
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '5%', content: 'avatar'},
|
||||
{width: '3%', content: 'docstatus'},
|
||||
{width: '12%', content: 'name'},
|
||||
{width: '41%', content: 'employee_name+tags'},
|
||||
{width: '10%', content: 'approval_status'},
|
||||
{
|
||||
width: '12%',
|
||||
content: function(parent, data) {
|
||||
$(parent).html(wn.boot.company[data.company].default_currency
|
||||
+ ' ' + fmt_money(data.total_sanctioned_amount));
|
||||
},
|
||||
css: {'text-align': 'right'},
|
||||
},
|
||||
{width: '12%', content: 'posting_date',
|
||||
css: {'text-align': 'right', 'color': '#777'}},
|
||||
]
|
||||
});
|
||||
1
hr/doctype/expense_claim_detail/__init__.py
Normal file
1
hr/doctype/expense_claim_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
103
hr/doctype/expense_claim_detail/expense_claim_detail.txt
Normal file
103
hr/doctype/expense_claim_detail/expense_claim_detail.txt
Normal file
@@ -0,0 +1,103 @@
|
||||
# DocType, Expense Claim Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:56',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Expense Claim Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Expense Claim Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Expense Claim Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Expense Date',
|
||||
'oldfieldname': u'expense_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'reqd': 0,
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_type',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Expense Claim Type',
|
||||
'oldfieldname': u'expense_type',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Expense Claim Type',
|
||||
'reqd': 1,
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'claim_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Claim Amount',
|
||||
'oldfieldname': u'claim_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'reqd': 1,
|
||||
'trigger': u'Client',
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sanctioned_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Sanctioned Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'sanctioned_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'trigger': u'Client',
|
||||
'width': u'150px'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/expense_claim_type/__init__.py
Normal file
1
hr/doctype/expense_claim_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
96
hr/doctype/expense_claim_type/expense_claim_type.txt
Normal file
96
hr/doctype/expense_claim_type/expense_claim_type.txt
Normal file
@@ -0,0 +1,96 @@
|
||||
# DocType, Expense Claim Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:55',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'field:expense_type',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Expense Claim Type',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Expense Claim Type',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Expense Claim Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Expense Claim Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_type',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 0,
|
||||
'label': u'Expense Claim Type',
|
||||
'oldfieldname': u'expense_type',
|
||||
'oldfieldtype': u'Data',
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'width': u'300px'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/grade/__init__.py
Normal file
1
hr/doctype/grade/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
98
hr/doctype/grade/grade.txt
Normal file
98
hr/doctype/grade/grade.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, Grade
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:57',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:grade_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 7
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Grade',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Grade',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Grade
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Grade'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'grade_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Grade',
|
||||
'oldfieldname': u'grade_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/holiday/__init__.py
Normal file
1
hr/doctype/holiday/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
61
hr/doctype/holiday/holiday.txt
Normal file
61
hr/doctype/holiday/holiday.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
# DocType, Holiday
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:57',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 2
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Holiday',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Holiday
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Holiday'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'holiday_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Date',
|
||||
'oldfieldname': u'holiday_date',
|
||||
'oldfieldtype': u'Date'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/holiday_list/__init__.py
Normal file
1
hr/doctype/holiday_list/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
133
hr/doctype/holiday_list/holiday_list.py
Normal file
133
hr/doctype/holiday_list/holiday_list.py
Normal file
@@ -0,0 +1,133 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
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', 1, self.doclist)
|
||||
ch.description = self.doc.weekly_off
|
||||
ch.holiday_date = d
|
||||
|
||||
# ------------
|
||||
# clear table
|
||||
# ------------
|
||||
def clear_table(self):
|
||||
self.doclist = 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()
|
||||
153
hr/doctype/holiday_list/holiday_list.txt
Normal file
153
hr/doctype/holiday_list/holiday_list.txt
Normal file
@@ -0,0 +1,153 @@
|
||||
# DocType, Holiday List
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:57',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 17
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Holiday List',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Holiday List',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Holiday List
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Holiday List'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'holiday_list_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Holiday List Name',
|
||||
'oldfieldname': u'holiday_list_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_default',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Default',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'weekly_off',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Weekly Off',
|
||||
'no_copy': 1,
|
||||
'options': u'\nSunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_weekly_off_dates',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get Weekly Off Dates',
|
||||
'options': u'get_weekly_off_dates',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'holiday_list_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Holidays',
|
||||
'oldfieldname': u'holiday_list_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Holiday',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'clear_table',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Clear Table',
|
||||
'options': u'clear_table',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
hr/doctype/leave_allocation/__init__.py
Executable file
1
hr/doctype/leave_allocation/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
80
hr/doctype/leave_allocation/leave_allocation.js
Executable file
80
hr/doctype/leave_allocation/leave_allocation.js
Executable file
@@ -0,0 +1,80 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// ****************************************** 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)});
|
||||
}
|
||||
}
|
||||
138
hr/doctype/leave_allocation/leave_allocation.py
Executable file
138
hr/doctype/leave_allocation/leave_allocation.py
Executable file
@@ -0,0 +1,138 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
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 ret
|
||||
|
||||
|
||||
# ********************************************** validate *****************************************************
|
||||
|
||||
# ---------------------------
|
||||
# get total allocated leaves
|
||||
# ---------------------------
|
||||
def get_total_allocated_leaves(self):
|
||||
leave_det = 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()
|
||||
279
hr/doctype/leave_allocation/leave_allocation.txt
Normal file
279
hr/doctype/leave_allocation/leave_allocation.txt
Normal file
@@ -0,0 +1,279 @@
|
||||
# DocType, Leave Allocation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:49',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1317365120',
|
||||
'autoname': u'LAL/.#####',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1560
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Allocation',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Allocation',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Allocation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Leave Allocation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'match': u'owner',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'match': u'owner',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee',
|
||||
'oldfieldname': u'employee',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee Name',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Leave Type',
|
||||
'oldfieldname': u'leave_type',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'link:Leave Type',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Today',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 0,
|
||||
'label': u'Posting Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'hidden': 0,
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0,
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'carry_forward',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Carry Forward',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'carry_forwarded_leaves',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Carry Forwarded Leaves',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'new_leaves_allocated',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'New Leaves Allocated',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_leaves_allocated',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Leaves Allocated',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 0,
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amended_from',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry is corrected in the system.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 0,
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amendment_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
1
hr/doctype/leave_application/__init__.py
Executable file
1
hr/doctype/leave_application/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
101
hr/doctype/leave_application/leave_application.js
Executable file
101
hr/doctype/leave_application/leave_application.js
Executable file
@@ -0,0 +1,101 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// ****************************************** 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 && cstr(doc.from_date) && doc.from_date != doc.to_date){
|
||||
msgprint("To Date should be same as From Date for Half Day leave");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
149
hr/doctype/leave_application/leave_application.py
Executable file
149
hr/doctype/leave_application/leave_application.py
Executable file
@@ -0,0 +1,149 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
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 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, self.doc.fiscal_year))
|
||||
leave_app = leave_app and flt(leave_app[0][0]) or 0
|
||||
ret = {'leave_balance':leave_all - leave_app}
|
||||
return ret
|
||||
|
||||
|
||||
# ************************************************ utilities *************************************************
|
||||
|
||||
# -------------------
|
||||
def get_holidays(self):
|
||||
"""
|
||||
get total holidays
|
||||
"""
|
||||
tot_hol = sql("select count(*) from `tabHoliday` 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` 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):
|
||||
"""
|
||||
Calculates total leave days based on input and holidays
|
||||
"""
|
||||
ret = {'total_leave_days' : 0.5}
|
||||
if not self.doc.half_day:
|
||||
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 ret
|
||||
|
||||
|
||||
# ************************************************ validate *************************************************
|
||||
|
||||
# -----------------
|
||||
# validate to date
|
||||
# -----------------
|
||||
def validate_to_date(self):
|
||||
if self.doc.from_date and self.doc.to_date and (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 self.doc.from_date and self.doc.to_date and not self.is_lwp():
|
||||
bal = self.get_leave_balance()
|
||||
tot_leaves = self.get_total_leave_days()
|
||||
bal, tot_leaves = bal, 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()
|
||||
299
hr/doctype/leave_application/leave_application.txt
Normal file
299
hr/doctype/leave_application/leave_application.txt
Normal file
@@ -0,0 +1,299 @@
|
||||
# DocType, Leave Application
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:58',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:45:49',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1310019491',
|
||||
'autoname': u'LAP/.#####',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Transaction',
|
||||
'is_submittable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'search_fields': u'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'subject': u'From %(employee_name)s, %(designation)s',
|
||||
'tag_fields': u'leave_type',
|
||||
'version': 17
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Application',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Application',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Application
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Leave Application'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'match': u'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'match': u'owner',
|
||||
'permlevel': 0,
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Employee Name',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Leave Type',
|
||||
'options': u'link:Leave Type',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_balance',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Leave Balance',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Today',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Posting Date',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'half_day',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Half Day',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'from_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'From Date',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'To Date',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_leave_days',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Leave Days',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'permlevel': 0,
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'letter_head',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Letter Head',
|
||||
'options': u'Letter Head',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Amended From',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Amendment Date',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
37
hr/doctype/leave_application/leave_application_list.js
Normal file
37
hr/doctype/leave_application/leave_application_list.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// render
|
||||
wn.doclistviews['Leave Application'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabLeave Application`.employee_name",
|
||||
"`tabLeave Application`.total_leave_days",
|
||||
"`tabLeave Application`.from_date",
|
||||
"`tabLeave Application`.to_date",
|
||||
|
||||
]);
|
||||
this.stats = this.stats.concat(['company']);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.from_date = wn.datetime.str_to_user(data.from_date);
|
||||
data.to_date = wn.datetime.str_to_user(data.to_date);
|
||||
data.date_range = (data.from_date === data.to_date)
|
||||
? data.from_date
|
||||
: data.from_date + " to " + data.to_date;
|
||||
data.total_leave_days = data.total_leave_days<=1
|
||||
? data.total_leave_days + " day"
|
||||
: data.total_leave_days + " days"
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '5%', content:'avatar'},
|
||||
{width: '3%', content:'docstatus'},
|
||||
{width: '12%', content:'name'},
|
||||
{width: '37%', content:'employee_name+tags'},
|
||||
{width: '10%', content:'total_leave_days',
|
||||
css: {'color':'#777'}},
|
||||
{width: '30%', content:'date_range'},
|
||||
]
|
||||
});
|
||||
1
hr/doctype/leave_control_panel/__init__.py
Normal file
1
hr/doctype/leave_control_panel/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
44
hr/doctype/leave_control_panel/leave_control_panel.js
Normal file
44
hr/doctype/leave_control_panel/leave_control_panel.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.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(make_doclist(doc.doctype, doc.name))},
|
||||
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');
|
||||
}
|
||||
90
hr/doctype/leave_control_panel/leave_control_panel.py
Normal file
90
hr/doctype/leave_control_panel/leave_control_panel.py
Normal file
@@ -0,0 +1,90 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# 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")
|
||||
229
hr/doctype/leave_control_panel/leave_control_panel.txt
Normal file
229
hr/doctype/leave_control_panel/leave_control_panel.txt
Normal file
@@ -0,0 +1,229 @@
|
||||
# DocType, Leave Control Panel
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1297751828',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'issingle': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 162
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Control Panel',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Control Panel',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Control Panel
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Leave Control Panel'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'HR Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Leave blank if considered for all employee types',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee_type',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Employee Type',
|
||||
'options': u'link:Employment Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Leave blank if considered for all branches',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'branch',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Branch',
|
||||
'options': u'link:Branch'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Leave blank if considered for all departments',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'department',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Department',
|
||||
'options': u'link:Department'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Leave blank if considered for all designations',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Designation',
|
||||
'options': u'link:Designation'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Leave blank if considered for all grades',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'grade',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Grade',
|
||||
'options': u'link:Grade'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'options': u'link:Fiscal Year',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Leave Type',
|
||||
'options': u'link:Leave Type',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u"Please select Carry Forward if you also want to include previous fiscal year's balance leaves to this fiscal year",
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'carry_forward',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Carry Forward'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'no_of_days',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'New Leaves Allocated (In Days)',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'allocate',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Allocate',
|
||||
'options': u'allocate_leave',
|
||||
'trigger': u'Server'
|
||||
}
|
||||
]
|
||||
1
hr/doctype/leave_type/__init__.py
Normal file
1
hr/doctype/leave_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
143
hr/doctype/leave_type/leave_type.txt
Normal file
143
hr/doctype/leave_type/leave_type.txt
Normal file
@@ -0,0 +1,143 @@
|
||||
# DocType, Leave Type
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:leave_type_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 23
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Type',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Leave Type',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Leave Type
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Leave Type'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'leave_type_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Leave Type Name',
|
||||
'oldfieldname': u'leave_type_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'max_days_allowed',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Max Days Leave Allowed',
|
||||
'oldfieldname': u'max_days_allowed',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_carry_forward',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Is Carry Forward',
|
||||
'oldfieldname': u'is_carry_forward',
|
||||
'oldfieldtype': u'Check',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_encash',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 1,
|
||||
'label': u'Is Encash',
|
||||
'oldfieldname': u'is_encash',
|
||||
'oldfieldtype': u'Check',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_lwp',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Is LWP',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
hr/doctype/other_income_detail/__init__.py
Normal file
1
hr/doctype/other_income_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
133
hr/doctype/other_income_detail/other_income_detail.txt
Normal file
133
hr/doctype/other_income_detail/other_income_detail.txt
Normal file
@@ -0,0 +1,133 @@
|
||||
# DocType, Other Income Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'HR',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Other Income Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Other Income Detail',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Other Income Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Other Income Detail'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'particulars2',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Particulars',
|
||||
'oldfieldname': u'particulars2',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'width': u'200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'under_section2',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Under Section',
|
||||
'oldfieldname': u'under_section2',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'max_limit2',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Max. Limit',
|
||||
'oldfieldname': u'max_limit2',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'actual_amount2',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Actual Amount',
|
||||
'oldfieldname': u'actual_amount2',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'eligible_amount2',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Eligible Amount',
|
||||
'oldfieldname': u'eligible_amount2',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'modified_amount2',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Modified Amount',
|
||||
'oldfieldname': u'modified_amount2',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
21
hr/doctype/salary_manager/__init__.py
Normal file
21
hr/doctype/salary_manager/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes import ValidationError
|
||||
|
||||
class SalarySlipExistsError(ValidationError): pass
|
||||
|
||||
83
hr/doctype/salary_manager/salary_manager.js
Normal file
83
hr/doctype/salary_manager/salary_manager.js
Normal file
@@ -0,0 +1,83 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
var display_activity_log = function(msg) {
|
||||
if(!pscript.ss_html)
|
||||
pscript.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#CCC'});
|
||||
pscript.ss_html.innerHTML = '<div style="color:#EEE; background-color:#555;"><b><i>Activity Log:</i><br></b></div>';
|
||||
pscript.ss_html.innerHTML += '<div style="color:#666; padding: 5px">'+ msg + '</div>';
|
||||
}
|
||||
|
||||
//Create salary slip
|
||||
//-----------------------
|
||||
cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
|
||||
var callback = function(r, rt){
|
||||
if (r.message)
|
||||
display_activity_log(r.message);
|
||||
}
|
||||
$c('runserverobj', args={'method':'create_sal_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Submit salary slip
|
||||
//-----------------------
|
||||
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
|
||||
var check = confirm("Do you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year);
|
||||
if(check){
|
||||
var callback = function(r, rt){
|
||||
if (r.message)
|
||||
display_activity_log(r.message);
|
||||
}
|
||||
$c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
|
||||
}
|
||||
}
|
||||
|
||||
// Make Bank Voucher
|
||||
//-----------------------
|
||||
cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){
|
||||
if(doc.month && doc.fiscal_year){
|
||||
cur_frm.cscript.make_jv(doc, cdt, cdn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make JV
|
||||
//-----------------------
|
||||
cur_frm.cscript.make_jv = function(doc, dt, dn) {
|
||||
var call_back = function(r,rt){
|
||||
var jv = LocalDB.create('Journal Voucher');
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
jv.user_remark = 'Payment of salary for the month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year;
|
||||
jv.fiscal_year = doc.fiscal_year;
|
||||
jv.company = doc.company;
|
||||
jv.posting_date = dateutil.obj_to_str(new Date());
|
||||
|
||||
// credit to bank
|
||||
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.account = r.message['default_bank_account'];
|
||||
d1.credit = r.message['amount']
|
||||
|
||||
// debit to salary account
|
||||
var d2 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d2.account = r.message['default_salary_account'];
|
||||
d2.debit = r.message['amount']
|
||||
|
||||
loaddoc('Journal Voucher', jv.name);
|
||||
}
|
||||
$c_obj(make_doclist(dt,dn),'get_acc_details','',call_back);
|
||||
}
|
||||
243
hr/doctype/salary_manager/salary_manager.py
Normal file
243
hr/doctype/salary_manager/salary_manager.py
Normal file
@@ -0,0 +1,243 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
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_emp_list(self):
|
||||
"""
|
||||
Returns list of active employees based on selected criteria
|
||||
and for which salary structure exists
|
||||
"""
|
||||
|
||||
cond = self.get_filter_condition()
|
||||
cond += self.get_joining_releiving_condition()
|
||||
|
||||
emp_list = sql("""
|
||||
select t1.name
|
||||
from `tabEmployee` t1, `tabSalary Structure` t2
|
||||
where t1.docstatus!=2 and t2.docstatus != 2
|
||||
and t1.name = t2.employee
|
||||
%s """% cond, debug=1)
|
||||
|
||||
return emp_list
|
||||
|
||||
|
||||
def get_filter_condition(self):
|
||||
self.check_mandatory()
|
||||
|
||||
cond = ''
|
||||
for f in ['company', 'branch', 'department', 'designation', 'grade']:
|
||||
if self.doc.fields.get(f):
|
||||
cond += " and t1." + f + " = '" + self.doc.fields.get(f) + "'"
|
||||
|
||||
return cond
|
||||
|
||||
|
||||
def get_joining_releiving_condition(self):
|
||||
m = self.get_month_details(self.doc.fiscal_year, self.doc.month)
|
||||
cond = """
|
||||
and ifnull(t1.date_of_joining, '0000-00-00') <= '%(month_end_date)s'
|
||||
and ifnull(t1.relieving_date, '2199-12-31') >= '%(month_start_date)s'
|
||||
""" % m
|
||||
return cond
|
||||
|
||||
|
||||
|
||||
def check_mandatory(self):
|
||||
for f in ['company', 'month', 'fiscal_year']:
|
||||
if not self.doc.fields[f]:
|
||||
msgprint("Please select %s to proceed" % f, raise_exception=1)
|
||||
|
||||
|
||||
def get_month_details(self, year, month):
|
||||
ysd = sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
|
||||
if ysd:
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import calendar, datetime
|
||||
diff_mnt = cint(month)-cint(ysd.month)
|
||||
if diff_mnt<0:
|
||||
diff_mnt = 12-int(ysd.month)+cint(month)
|
||||
msd = ysd + relativedelta(months=diff_mnt) # month start date
|
||||
month_days = cint(calendar.monthrange(cint(msd.year) ,cint(month))[1]) # days in month
|
||||
med = datetime.date(msd.year, cint(month), month_days) # month end date
|
||||
return {
|
||||
'year': msd.year,
|
||||
'month_start_date': msd,
|
||||
'month_end_date': med,
|
||||
'month_days': month_days
|
||||
}
|
||||
|
||||
|
||||
|
||||
def create_sal_slip(self):
|
||||
"""
|
||||
Creates salary slip for selected employees if already not created
|
||||
|
||||
"""
|
||||
|
||||
emp_list = self.get_emp_list()
|
||||
ss_list = []
|
||||
for emp in emp_list:
|
||||
if not sql("""select name from `tabSalary Slip`
|
||||
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
|
||||
""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
|
||||
ss = Document('Salary Slip')
|
||||
ss.fiscal_year = self.doc.fiscal_year
|
||||
ss.employee = emp[0]
|
||||
ss.month = self.doc.month
|
||||
ss.email_check = self.doc.send_email
|
||||
ss.company = self.doc.company
|
||||
ss.save(1)
|
||||
|
||||
ss_obj = get_obj('Salary Slip', ss.name, with_children=1)
|
||||
ss_obj.get_emp_and_leave_details()
|
||||
ss_obj.calculate_net_pay()
|
||||
ss_obj.validate()
|
||||
ss_obj.doc.save()
|
||||
|
||||
for d in getlist(ss_obj.doclist, 'earning_details'):
|
||||
d.save()
|
||||
for d in getlist(ss_obj.doclist, 'deduction_details'):
|
||||
d.save()
|
||||
|
||||
ss_list.append(ss.name)
|
||||
|
||||
return self.create_log(ss_list)
|
||||
|
||||
|
||||
def create_log(self, ss_list):
|
||||
log = "<b>No employee for the above selected criteria OR salary slip already created</b>"
|
||||
if ss_list:
|
||||
log = "<b>Created Salary Slip has been created: </b>\
|
||||
<br><br>%s" % '<br>'.join(ss_list)
|
||||
return log
|
||||
|
||||
|
||||
def get_sal_slip_list(self):
|
||||
"""
|
||||
Returns list of salary slips based on selected criteria
|
||||
which are not submitted
|
||||
"""
|
||||
cond = self.get_filter_condition()
|
||||
ss_list = sql("""
|
||||
select t1.name from `tabSalary Slip` t1
|
||||
where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s
|
||||
""" % (self.doc.month, self.doc.fiscal_year, cond))
|
||||
return ss_list
|
||||
|
||||
|
||||
def submit_salary_slip(self):
|
||||
"""
|
||||
Submit all salary slips based on selected criteria
|
||||
"""
|
||||
ss_list = self.get_sal_slip_list()
|
||||
not_submitted_ss = []
|
||||
for ss in ss_list:
|
||||
ss_obj = get_obj("Salary Slip",ss[0],with_children=1)
|
||||
try:
|
||||
webnotes.conn.set(ss_obj.doc, 'email_check', cint(self.doc.send_mail))
|
||||
if cint(self.doc.send_email) == 1:
|
||||
ss_obj.send_mail_funct()
|
||||
|
||||
webnotes.conn.set(ss_obj.doc, 'docstatus', 1)
|
||||
except Exception,e:
|
||||
not_submitted_ss.append(ss[0])
|
||||
msgprint(e)
|
||||
continue
|
||||
|
||||
return self.create_submit_log(ss_list, not_submitted_ss)
|
||||
|
||||
|
||||
def create_submit_log(self, all_ss, not_submitted_ss):
|
||||
log = ''
|
||||
if not all_ss:
|
||||
log = "No salary slip found to submit for the above selected criteria"
|
||||
else:
|
||||
all_ss = [d[0] for d in all_ss]
|
||||
|
||||
submitted_ss = list(set(all_ss) - set(not_submitted_ss))
|
||||
if submitted_ss:
|
||||
mail_sent_msg = self.doc.send_email and " (Mail has been sent to the employee)" or ""
|
||||
log = """
|
||||
<b>Submitted Salary Slips%s:</b>\
|
||||
<br><br> %s <br><br>
|
||||
""" % (mail_sent_msg, '<br>'.join(submitted_ss))
|
||||
|
||||
if not_submitted_ss:
|
||||
log += """
|
||||
<b>Not Submitted Salary Slips: </b>\
|
||||
<br><br> %s <br><br> \
|
||||
Reason: <br>\
|
||||
May be company email id specified in employee master is not valid. <br> \
|
||||
Please mention correct email id in employee master or if you don't want to \
|
||||
send mail, uncheck 'Send Email' checkbox. <br>\
|
||||
Then try to submit Salary Slip again.
|
||||
"""% ('<br>'.join(not_submitted_ss))
|
||||
return log
|
||||
|
||||
|
||||
def get_total_salary(self):
|
||||
"""
|
||||
Get total salary amount from submitted salary slip based on selected criteria
|
||||
"""
|
||||
cond = self.get_filter_condition()
|
||||
tot = sql("""
|
||||
select sum(rounded_total) from `tabSalary Slip` t1
|
||||
where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s
|
||||
""" % (self.doc.month, self.doc.fiscal_year, cond))
|
||||
|
||||
return flt(tot[0][0])
|
||||
|
||||
|
||||
def get_acc_details(self):
|
||||
"""
|
||||
get default bank account,default salary acount from company
|
||||
"""
|
||||
amt = self.get_total_salary()
|
||||
com = sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
|
||||
|
||||
if not com[0][0] or not com[0][1]:
|
||||
msgprint("You can set Default Bank Account in Company master.")
|
||||
|
||||
ret = {
|
||||
'def_bank_acc' : com and com[0][0] or '',
|
||||
'def_sal_acc' : com and com[0][1] or '',
|
||||
'amount' : amt
|
||||
}
|
||||
return ret
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user