Skip to content

Commit

Permalink
Merge pull request #43336 from frappe/mergify/bp/version-15-hotfix/pr…
Browse files Browse the repository at this point in the history
…-43316

fix: incorrect outstanding on non-pos invoice with write_off_account (backport #43316)
  • Loading branch information
ruthra-kumar authored Sep 23, 2024
2 parents 15baa3f + f89a3db commit 0fd2964
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def validate(self):
):
validate_loyalty_points(self, self.loyalty_points)

self.allow_write_off_only_on_pos()
self.reset_default_field_value("set_warehouse", "items", "warehouse")

def validate_accounts(self):
Expand Down Expand Up @@ -1021,6 +1022,10 @@ def validate_delivery_note(self):
raise_exception=1,
)

def allow_write_off_only_on_pos(self):
if not self.is_pos and self.write_off_account:
self.write_off_account = None

def validate_write_off_account(self):
if flt(self.write_off_amount) and not self.write_off_account:
self.write_off_account = frappe.get_cached_value("Company", self.company, "write_off_account")
Expand Down

0 comments on commit 0fd2964

Please sign in to comment.