fix: do not update status to Paid if sanctioned amount is 0

This commit is contained in:
Rucha Mahabal 2022-03-25 20:11:38 +05:30
parent 2d915782cb
commit ffec9516fa
3 changed files with 17 additions and 5 deletions

View File

@ -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':

View File

@ -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,

View File

@ -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()