Skip to content

Commit

Permalink
fix: incorrect outstanding on non-pos invoice with write_off_account
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Sep 21, 2024
1 parent fdd62f7 commit d5e2906
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 @@ -338,6 +338,7 @@ def validate(self):
if self.redeem_loyalty_points and self.loyalty_points and not self.is_consolidated:
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 @@ -1031,6 +1032,10 @@ def validate_delivery_note(self):
),
)

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 d5e2906

Please sign in to comment.