restructured erpnext and deleted unwanted

This commit is contained in:
nabinhait
2011-07-01 13:34:41 +05:30
parent c1c54c9400
commit ec097975d0
1280 changed files with 54494 additions and 88652 deletions

View File

View File

@@ -0,0 +1,51 @@
// get retirement date
//========================================================
cur_frm.cscript.date_of_birth = function(doc, dt, dn) {
get_server_fields('get_retirement_date','','',doc,dt,dn,1);
}
// salutation-gender
//========================================================
cur_frm.cscript.salutation = function(doc,dt,dn) {
if(doc.salutation){
if(doc.salutation=='Mr')
doc.gender='Male';
else if(doc.salutation=='Ms')
doc.gender='Female';
refresh_field('gender');
}
}
// On refresh
//========================================================
cur_frm.cscript.refresh = function(doc, dt, dn) {
if(doc.__islocal!=1){
cur_frm.add_custom_button('Make Salary Structure', cur_frm.cscript['Make Salary Structure']);
}
}
//Make Salary Structure
//========================================================
cur_frm.cscript['Make Salary Structure']=function(){
$c_obj(make_doclist (doc.doctype,doc.name),'check_sal_structure',cur_frm.doc.name,function(r, rt) {
if(r.message)
alert("You have already created Active salary structure.\nIf you want to create new one, please ensure that no active salary structure exist.\nTo inactive salary structure select 'Is Active' as 'No'.");
else
cur_frm.cscript.make_salary_structure(cur_frm.doc);
});
}
// Load sal structure
//========================================================
cur_frm.cscript.make_salary_structure = function(doc,dt,dn,det){
var st = LocalDB.create('Salary Structure');
st = locals['Salary Structure'][st];
st.employee = doc.name;
st.employee_name = doc.employee_name;
st.branch=doc.branch;
st.designation=doc.designation;
st.department=doc.department;
st.fiscal_year = doc.fiscal_year
st.grade=doc.grade;
loaddoc('Salary Structure', st.name);
}

View File

@@ -0,0 +1,118 @@
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
# Autoname
#========================================================================================================
def autoname(self):
ret = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'emp_created_by'")
if not ret:
msgprint("To Save Employee, please go to Setup -->Global Defaults. Click on HR and select 'Employee Records to be created by'.")
raise Exception
else:
if ret[0][0]=='Naming Series':
self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif ret[0][0]=='Employee Number':
self.doc.name = make_autoname(self.doc.employee_number)
# Get retirement date
#========================================================================================================
def get_retirement_date(self):
import datetime
ret = {}
if self.doc.date_of_birth:
dt = getdate(self.doc.date_of_birth) + datetime.timedelta(21915)
ret = {'date_of_retirement': dt.strftime('%Y-%m-%d')}
return str(ret)
# check if salary structure exists
#========================================================================================================
def check_sal_structure(self, nm):
ret_sal_struct=sql("select name from `tabSalary Structure` where employee='%s' and is_active = 'Yes'"%nm)
return ret_sal_struct and ret_sal_struct[0][0] or ''
#========================================================================================================
def validate(self):
self.validate_date()
self.validate_email()
self.validate_name()
self.validate_status()
# Validate dates
#========================================================================================================
def validate_date(self):
import datetime
if self.doc.date_of_birth and self.doc.date_of_joining and getdate(self.doc.date_of_birth) >= getdate(self.doc.date_of_joining):
msgprint('Date of Joining must be greater than Date of Birth')
raise Exception
elif self.doc.scheduled_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.scheduled_confirmation_date) < getdate(self.doc.date_of_joining)):
msgprint('Scheduled Confirmation Date must be greater than Date of Joining')
raise Exception
elif self.doc.final_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.final_confirmation_date) < getdate(self.doc.date_of_joining)):
msgprint('Final Confirmation Date must be greater than Date of Joining')
raise Exception
elif self.doc.date_of_retirement and self.doc.date_of_joining and (getdate(self.doc.date_of_retirement) <= getdate(self.doc.date_of_joining)):
msgprint('Date Of Retirement must be greater than Date of Joining')
raise Exception
elif self.doc.relieving_date and self.doc.date_of_joining and (getdate(self.doc.relieving_date) <= getdate(self.doc.date_of_joining)):
msgprint('Relieving Date must be greater than Date of Joining')
raise Exception
elif self.doc.contract_end_date and self.doc.date_of_joining and (getdate(self.doc.contract_end_date)<=getdate(self.doc.date_of_joining)):
msgprint('Contract End Date must be greater than Date of Joining')
raise Exception
# Validate email id
#========================================================================================================
def validate_email(self):
if self.doc.company_email and not validate_email_add(self.doc.company_email):
msgprint("Please enter valid Company Email")
raise Exception
if self.doc.personal_email and not validate_email_add(self.doc.personal_email):
msgprint("Please enter valid Personal Email")
raise Exception
# Validate name
#========================================================================================================
def validate_name(self):
ret = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'emp_created_by'")
if not ret:
msgprint("To Save Employee, please go to Setup -->Global Defaults. Click on HR and select 'Employee Records to be created by'.")
raise Exception
else:
if ret[0][0]=='Naming Series' and not self.doc.naming_series:
msgprint("Please select Naming Series.")
raise Exception
elif ret[0][0]=='Employee Number' and not self.doc.employee_number:
msgprint("Please enter Employee Number.")
raise Exception
# Validate status
#========================================================================================================
def validate_status(self):
if self.doc.status == 'Left' and not self.doc.relieving_date:
msgprint("Please enter relieving date.")
raise Exception

File diff suppressed because it is too large Load Diff