allow expense claim sanctioned amount to have 0 value
diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js
index 5794429..d8bee8b 100644
--- a/hr/doctype/expense_claim/expense_claim.js
+++ b/hr/doctype/expense_claim/expense_claim.js
@@ -46,6 +46,13 @@
if (doc.docstatus == 0) unhide_field('calculate_total_amount');
}
+cur_frm.cscript.validate = function(doc) {
+ if(cint(doc.docstatus) == 0) {
+ doc.approval_status = "Draft";
+ }
+ cur_frm.cscript.calculate_total(doc);
+}
+
cur_frm.cscript.employee = function(doc,cdt,cdn){
if(doc.employee){
$c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){
diff --git a/hr/doctype/expense_claim/expense_claim.py b/hr/doctype/expense_claim/expense_claim.py
index b8bd41e..2371f3b 100644
--- a/hr/doctype/expense_claim/expense_claim.py
+++ b/hr/doctype/expense_claim/expense_claim.py
@@ -77,10 +77,13 @@
set(self.doc, 'remark', self.doc.remark)
def approve_voucher(self):
+ missing_count = 0
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')
+ missing_count += 1
+ if missing_count == len(getlist(self.doclist, 'expense_voucher_details')):
+ msgprint("Please add 'Sanctioned Amount' for atleast one expense")
+ return cstr('Incomplete')
if not self.doc.total_sanctioned_amount:
msgprint("Please calculate total sanctioned amount using button 'Calculate Total Amount'")
@@ -112,7 +115,7 @@
def validate(self):
self.validate_fiscal_year()
-
+
def on_update(self):
set(self.doc, 'approval_status', 'Draft')