[Fix] Expense claim status issue
This commit is contained in:
parent
dab1172a18
commit
8333b5754b
@ -96,7 +96,14 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
|
|
||||||
// expense claim
|
// expense claim
|
||||||
if(jvd.reference_type==="Expense Claim") {
|
if(jvd.reference_type==="Expense Claim") {
|
||||||
return {};
|
return {
|
||||||
|
filters: {
|
||||||
|
'approval_status': 'Approved',
|
||||||
|
'total_sanctioned_amount': ['>', 0],
|
||||||
|
'status': ['!=', 'Paid'],
|
||||||
|
'docstatus': 1
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// journal entry
|
// journal entry
|
||||||
|
@ -905,7 +905,7 @@
|
|||||||
"label": "Status",
|
"label": "Status",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Draft\nPaid\nUnpaid\nSubmitted\nCancelled",
|
"options": "Draft\nPaid\nUnpaid\nRejected\nSubmitted\nCancelled",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -964,7 +964,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-06-13 14:29:16.914609",
|
"modified": "2017-07-17 15:47:23.255142",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Expense Claim",
|
"name": "Expense Claim",
|
||||||
|
@ -39,10 +39,13 @@ class ExpenseClaim(AccountsController):
|
|||||||
"2": "Cancelled"
|
"2": "Cancelled"
|
||||||
}[cstr(self.docstatus or 0)]
|
}[cstr(self.docstatus or 0)]
|
||||||
|
|
||||||
if self.total_sanctioned_amount == self.total_amount_reimbursed and self.docstatus == 1:
|
if self.total_sanctioned_amount > 0 and self.total_sanctioned_amount == self.total_amount_reimbursed \
|
||||||
|
and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||||
self.status = "Paid"
|
self.status = "Paid"
|
||||||
elif self.docstatus == 1:
|
elif self.total_sanctioned_amount > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||||
self.status = "Unpaid"
|
self.status = "Unpaid"
|
||||||
|
elif self.docstatus == 1 and self.approval_status == 'Rejected':
|
||||||
|
self.status = 'Rejected'
|
||||||
|
|
||||||
def set_payable_account(self):
|
def set_payable_account(self):
|
||||||
if not self.payable_account and not self.is_paid:
|
if not self.payable_account and not self.is_paid:
|
||||||
@ -157,6 +160,9 @@ class ExpenseClaim(AccountsController):
|
|||||||
self.total_claimed_amount = 0
|
self.total_claimed_amount = 0
|
||||||
self.total_sanctioned_amount = 0
|
self.total_sanctioned_amount = 0
|
||||||
for d in self.get('expenses'):
|
for d in self.get('expenses'):
|
||||||
|
if self.approval_status == 'Rejected':
|
||||||
|
d.sanctioned_amount = 0.0
|
||||||
|
|
||||||
self.total_claimed_amount += flt(d.claim_amount)
|
self.total_claimed_amount += flt(d.claim_amount)
|
||||||
self.total_sanctioned_amount += flt(d.sanctioned_amount)
|
self.total_sanctioned_amount += flt(d.sanctioned_amount)
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@ frappe.listview_settings['Expense Claim'] = {
|
|||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(doc.status == "Paid") {
|
if(doc.status == "Paid") {
|
||||||
return [__("Paid"), "green", "status,=,'Paid'"];
|
return [__("Paid"), "green", "status,=,'Paid'"];
|
||||||
} else {
|
}else if(doc.status == "Unpaid") {
|
||||||
return [__("Unpaid"), "orange"];
|
return [__("Unpaid"), "orange"];
|
||||||
|
} else if(doc.status == "Rejected") {
|
||||||
|
return [__("Rejected"), "grey"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -418,4 +418,5 @@ erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit
|
|||||||
erpnext.patches.v8_1.add_hsn_sac_codes
|
erpnext.patches.v8_1.add_hsn_sac_codes
|
||||||
erpnext.patches.v8_1.update_gst_state #17-07-2017
|
erpnext.patches.v8_1.update_gst_state #17-07-2017
|
||||||
erpnext.patches.v8_1.removed_report_support_hours
|
erpnext.patches.v8_1.removed_report_support_hours
|
||||||
erpnext.patches.v8_1.add_indexes_in_transaction_doctypes
|
erpnext.patches.v8_1.add_indexes_in_transaction_doctypes
|
||||||
|
erpnext.patches.v8_1.update_expense_claim_status
|
23
erpnext/patches/v8_1/update_expense_claim_status.py
Normal file
23
erpnext/patches/v8_1/update_expense_claim_status.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Copyright (c) 2017, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doctype('Expense Claim')
|
||||||
|
|
||||||
|
for data in frappe.db.sql(""" select name from `tabExpense Claim`
|
||||||
|
where (docstatus=1 and total_sanctioned_amount=0 and status = 'Paid') or
|
||||||
|
(docstatus = 1 and approval_status = 'Rejected' and total_sanctioned_amount > 0)""", as_dict=1):
|
||||||
|
doc = frappe.get_doc('Expense Claim', data.name)
|
||||||
|
if doc.approval_status == 'Rejected':
|
||||||
|
for d in doc.expenses:
|
||||||
|
d.db_set("sanctioned_amount", 0, update_modified = False)
|
||||||
|
doc.db_set("total_sanctioned_amount", 0, update_modified = False)
|
||||||
|
|
||||||
|
frappe.db.sql(""" delete from `tabGL Entry` where voucher_type = 'Expense Claim'
|
||||||
|
and voucher_no = %s""", (doc.name))
|
||||||
|
|
||||||
|
doc.set_status()
|
||||||
|
doc.db_set("status", doc.status, update_modified = False)
|
Loading…
x
Reference in New Issue
Block a user