fix: incorrect status for fraction of outstanding amount (#20369)
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 703df79..6e3e43e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -1238,24 +1238,27 @@
self.status = 'Draft'
return
+ precision = self.precision("outstanding_amount")
+ outstanding_amount = flt(self.outstanding_amount, precision)
+
if not status:
if self.docstatus == 2:
status = "Cancelled"
elif self.docstatus == 1:
- if flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
+ if outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
self.status = "Overdue and Discounted"
- elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()):
+ elif outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()):
self.status = "Overdue"
- elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
+ elif outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
self.status = "Unpaid and Discounted"
- elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()):
+ elif outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()):
self.status = "Unpaid"
#Check if outstanding amount is 0 due to credit note issued against invoice
- elif flt(self.outstanding_amount) <= 0 and self.is_return == 0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
+ elif outstanding_amount <= 0 and self.is_return == 0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
self.status = "Credit Note Issued"
elif self.is_return == 1:
self.status = "Return"
- elif flt(self.outstanding_amount)<=0:
+ elif outstanding_amount <=0:
self.status = "Paid"
else:
self.status = "Submitted"