Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index 1c5cccd..206d208 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -27,23 +27,23 @@
for(var i = 0; i<val.length; i++){
val[i].sanctioned_amount ='';
}
- //doc.total_claimed_amount = '';
doc.total_sanctioned_amount = '';
refresh_many(['sanctioned_amount', 'total_sanctioned_amount']);
}
}
cur_frm.cscript.refresh = function(doc,cdt,cdn){
- if((user == doc.exp_approver && doc.approval_status == 'Submitted') || doc.docstatus == 0) unhide_field('calculate_total_amount');
- else hide_field('calculate_total_amount');
-
- if(user == doc.exp_approver && doc.approval_status == 'Submitted') unhide_field(['update_voucher', 'approve', 'reject']);
-
- else hide_field(['update_voucher', 'approve', 'reject']);
-
-
- if(user == doc.exp_approver && doc.approval_status == 'Submitted') set_field_permlevel('remark', 0);
- else set_field_permlevel('remark', 1);
+ 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){
@@ -63,7 +63,9 @@
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');
@@ -72,7 +74,10 @@
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');
@@ -240,4 +245,4 @@
send_to: doc.exp_approver
}
cur_frm.cscript.notify(doc, args);
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index 5f31ffb..94761a1 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -98,20 +98,8 @@
set(self.doc, 'remark', self.doc.remark)
set(self.doc, 'approval_status', 'Rejected')
- # on approval notification
- #get_obj('Notification Control').notify_contact('Expense Claim Rejected', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
-
return cstr('Rejected')
- def validate_curr_exp(self):
- for d in getlist(self.doclist, 'expense_voucher_details'):
- if flt(d.sanctioned_amount) > 0:
- if self.doc.approval_status == 'Draft':
- msgprint("Sanctioned amount can be added by Approver person only for submitted Expense Claim")
- raise Exception
- elif self.doc.approval_status == 'Submitted' and session['user'] != self.doc.exp_approver:
- msgprint("Sanctioned amount can be added only by expense voucher Approver")
- raise Exception
def validate_fiscal_year(self):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
@@ -122,7 +110,6 @@
raise Exception
def validate(self):
- self.validate_curr_exp()
self.validate_fiscal_year()
def on_update(self):