leave application fix, print_table Sr fix

This commit is contained in:
Rushabh Mehta 2012-12-05 18:02:13 +05:30
parent 2d05732589
commit bf24581eb2
4 changed files with 15 additions and 17 deletions

View File

@ -56,10 +56,11 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
if(user==doc.exp_approver) {
if(doc.approval_status=="Draft") {
cur_frm.set_intro("You are the Expense Approver for this record. Please Update the 'Status' and Save");
cur_frm.set_df_property("approval_status", "permlevel", 0);
cur_frm.toggle_enable("approval_status", true);
}
} else {
cur_frm.set_intro("Expense Claim is pending approval. Only the Expense Approver can update status.");
cur_frm.toggle_enable("approval_status", false);
}
} else {
if(doc.approval_status=="Approved") {

View File

@ -35,9 +35,10 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
if(doc.status=="Open") {
if(user==doc.leave_approver) {
cur_frm.set_intro("You are the Leave Approver for this record. Please Update the 'Status' and Save");
cur_frm.set_df_property("status", "permlevel", 2);
cur_frm.toggle_enable("status", true);
} else {
cur_frm.set_intro("This Leave Application is pending approval. Only the Leave Apporver can update status.")
cur_frm.toggle_enable("status", false);
}
} else {
if(doc.status=="Approved") {
@ -92,7 +93,7 @@ get_leave_balance = function(doc, dt, dn) {
cur_frm.call({
method: "get_leave_balance",
args: {
employee: doc.name,
employee: doc.employee,
fiscal_year: doc.fiscal_year,
leave_type: doc.leave_type
}

View File

@ -63,7 +63,8 @@ class DocType:
def validate_balance_leaves(self):
if self.doc.from_date and self.doc.to_date and not self.is_lwp():
bal = get_leave_balance(self.doc.leave_type, self.doc.employee, self.doc.fiscal_year)
bal = get_leave_balance(self.doc.leave_type, self.doc.employee,
self.doc.fiscal_year)["leave_balance"]
tot_leaves = self.get_total_leave_days()
bal, tot_leaves = bal, tot_leaves
webnotes.conn.set(self.doc,'leave_balance',flt(bal['leave_balance']))
@ -106,17 +107,18 @@ class DocType:
@webnotes.whitelist()
def get_leave_balance(employee, leave_type, fiscal_year):
leave_all = webnotes.conn.sql("""select total_leaves_allocated
from `tabLeave Allocation` where employee = '%s' and leave_type = '%s'
and fiscal_year = '%s' and docstatus = 1""" % (employee,
from `tabLeave Allocation` where employee = %s and leave_type = %s
and fiscal_year = %s and docstatus = 1""", (employee,
leave_type, fiscal_year))
leave_all = leave_all and flt(leave_all[0][0]) or 0
leave_app = webnotes.conn.sql("""select SUM(total_leave_days)
from `tabLeave Application`
where employee = '%s'
and leave_type = '%s' and fiscal_year = '%s'
and docstatus = 1""" % (employee, leave_type, fiscal_year))
where employee = %s and leave_type = %s and fiscal_year = %s
and docstatus = 1""", (employee, leave_type, fiscal_year))
leave_app = leave_app and flt(leave_app[0][0]) or 0
ret = {'leave_balance':leave_all - leave_app}
return ret

View File

@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-12-03 10:13:48",
"creation": "2012-12-05 14:11:53",
"modified_by": "Administrator",
"modified": "2012-12-05 11:59:15"
"modified": "2012-12-05 17:38:26"
},
{
"is_submittable": 1,
@ -255,11 +255,5 @@
"doctype": "DocPerm",
"role": "All",
"permlevel": 3
},
{
"doctype": "DocPerm",
"write": 1,
"role": "HR User",
"permlevel": 3
}
]