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: update status of reference documents #2380

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@


class FullandFinalStatement(Document):
def on_change(self):
update_status_of_reference_documents(self, self.status)

def before_insert(self):
self.get_outstanding_statements()

Expand Down Expand Up @@ -310,3 +313,9 @@ def update_full_and_final_statement_status(doc, method=None):
fnf = frappe.get_doc("Full and Final Statement", entry.reference_name)
fnf.db_set("status", status)
fnf.notify_update()


def update_status_of_reference_documents(doc, status="Paid"):
Copy link
Member

@ruchamahabal ruchamahabal Nov 12, 2024

Choose a reason for hiding this comment

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

  • We can encapsulate this function I think. No need to keep it outside the class
  • Gratuity holds a "paid_amount" field. We should update that and call gratuity.set_status to update the status. If we just update the status, paid_amount field will remain 0
  • This should also mark gratuity as unpaid when FnF is cancelled. Current logic will change gratuity status to Cancelled I think.

Copy link
Member

Choose a reason for hiding this comment

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

Also can you add a test 🙈

for payable in doc.payables:
if payable.component == "Gratuity":
frappe.db.set_value("Gratuity", payable.reference_document, "status", status)
Loading