Skip to content

Commit

Permalink
fix(FnF): don't fetch outstanding statements on every save (backport #…
Browse files Browse the repository at this point in the history
…797) (#816)

Co-authored-by: NIYAZ RAZAK <76736615+niyazrazak@users.noreply.github.com>
  • Loading branch information
mergify[bot] and niyazrazak authored Aug 23, 2023
1 parent 186e882 commit 3664517
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 3664517

Please sign in to comment.