fix: do not update status to Paid if sanctioned amount is 0
This commit is contained in:
parent
2d915782cb
commit
ffec9516fa
@ -47,10 +47,12 @@ class ExpenseClaim(AccountsController):
|
||||
if (
|
||||
# set as paid
|
||||
self.is_paid
|
||||
# grand total is reimbursed
|
||||
or (flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1 and flt(self.grand_total, precision) == flt(self.total_amount_reimbursed, precision))
|
||||
# grand total (to be paid) is 0 since linked advances already cover the claimed amount
|
||||
or (flt(self.grand_total, precision) == 0)
|
||||
or (flt(self.total_sanctioned_amount > 0) and (
|
||||
# grand total is reimbursed
|
||||
(self.docstatus == 1 and flt(self.grand_total, precision) == flt(self.total_amount_reimbursed, precision))
|
||||
# grand total (to be paid) is 0 since linked advances already cover the claimed amount
|
||||
or (flt(self.grand_total, precision) == 0)
|
||||
))
|
||||
) and self.approval_status == "Approved":
|
||||
status = "Paid"
|
||||
elif flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||
|
@ -72,6 +72,15 @@ class TestExpenseClaim(unittest.TestCase):
|
||||
expense_claim = frappe.get_doc("Expense Claim", expense_claim.name)
|
||||
self.assertEqual(expense_claim.status, "Unpaid")
|
||||
|
||||
# expense claim without any sanctioned amount should not have status as Paid
|
||||
claim = make_expense_claim(payable_account, 1000, 0, "_Test Company", "Travel Expenses - _TC")
|
||||
self.assertEqual(claim.total_sanctioned_amount, 0)
|
||||
self.assertEqual(claim.status, "Submitted")
|
||||
|
||||
# no gl entries created
|
||||
gl_entry = frappe.get_all('GL Entry', {'voucher_type': 'Expense Claim', 'voucher_no': claim.name})
|
||||
self.assertEqual(len(gl_entry), 0)
|
||||
|
||||
def test_expense_claim_against_fully_paid_advances(self):
|
||||
from erpnext.hr.doctype.employee_advance.test_employee_advance import (
|
||||
get_advances_for_claim,
|
||||
|
@ -16,6 +16,7 @@ def execute():
|
||||
.where(
|
||||
((ExpenseClaim.grand_total == 0) | (ExpenseClaim.grand_total == ExpenseClaim.total_amount_reimbursed))
|
||||
& (ExpenseClaim.approval_status == 'Approved')
|
||||
& (ExpenseClaim.docstatus != 2)
|
||||
& (ExpenseClaim.docstatus == 1)
|
||||
& (ExpenseClaim.total_sanctioned_amount > 0)
|
||||
)
|
||||
).run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user