fix(pos): error while consolidating pos invoices
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 0d8cffe..26b8db4 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -770,6 +770,18 @@
if (
self.doc.doctype == "Sales Invoice"
and self.doc.get("is_pos")
+ and self.doc.get("pos_profile")
+ and self.doc.get("is_consolidated")
+ ):
+ write_off_limit = flt(
+ frappe.db.get_value("POS Profile", self.doc.pos_profile, "write_off_limit")
+ )
+ if write_off_limit and abs(self.doc.outstanding_amount) <= write_off_limit:
+ self.doc.write_off_outstanding_amount_automatically = 1
+
+ if (
+ self.doc.doctype == "Sales Invoice"
+ and self.doc.get("is_pos")
and self.doc.get("is_return")
and not self.doc.get("is_consolidated")
):