Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Expense Claim): status update on document cancellation #1392

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 19 additions & 24 deletions hrms/hr/doctype/expense_claim/expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,26 @@ def set_status(self, update=False):

precision = self.precision("grand_total")

if (
# set as paid
self.is_paid
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)
if self.docstatus == 1:
if self.approval_status == "Approved":
if (
# set as paid
Comment on lines +57 to +60

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

three levels of nested conditions, dont think is readable @krantheman

self.is_paid
or (
flt(self.total_sanctioned_amount) > 0
and (
# grand total is reimbursed
(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)
)
)
# 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"
):
status = "Unpaid"
elif self.docstatus == 1 and self.approval_status == "Rejected":
status = "Rejected"
):
status = "Paid"
elif flt(self.total_sanctioned_amount) > 0:
status = "Unpaid"
elif self.approval_status == "Rejected":
status = "Rejected"

if update:
self.db_set("status", status)
Expand Down