Skip to content

Commit

Permalink
fix(FnF): don't fetch outstanding statements on every save (#797)
Browse files Browse the repository at this point in the history
The user cannot leave the receivables tables empty in the doctype. With each save, loans and employee advances are added to the table.

(cherry picked from commit 266f270)
  • Loading branch information
niyazrazak authored and mergify[bot] committed Aug 23, 2023
1 parent 186e882 commit 1c46791
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@


class FullandFinalStatement(Document):
def validate(self):
def before_insert(self):
self.get_outstanding_statements()

def validate(self):
self.get_assets_statements()
if self.docstatus == 1:
self.validate_settlement("payables")
self.validate_settlement("receivables")
Expand All @@ -34,15 +37,17 @@ def get_outstanding_statements(self):
if not len(self.get("receivables", [])):
components = self.get_receivable_component()
self.create_component_row(components, "receivables")

if not len(self.get("assets_allocated", [])):
for data in self.get_assets_movement():
self.append("assets_allocated", data)
self.get_assets_statements()
else:
frappe.throw(
_("Set Relieving Date for Employee: {0}").format(get_link_to_form("Employee", self.employee))
)

def get_assets_statements(self):
if not len(self.get("assets_allocated", [])):
for data in self.get_assets_movement():
self.append("assets_allocated", data)

def create_component_row(self, components, component_type):
for component in components:
self.append(
Expand Down

0 comments on commit 1c46791

Please sign in to comment.