fix: decimal garbage on variable total (#46621)

* fix: decimal dirty on variable total

* fix: linters

* fix: decimal garbage, code improvement

(cherry picked from commit b0dccadd26)
This commit is contained in:
HarryPaulo
2025-03-21 10:14:16 -03:00
committed by Mergify
parent 2ebea8866a
commit 2864e1f244

View File

@@ -825,14 +825,13 @@ class JournalEntry(AccountsController):
"Debit Note",
"Credit Note",
]:
invoice = frappe.db.get_value(
reference_type, reference_name, ["docstatus", "outstanding_amount"], as_dict=1
)
invoice = frappe.get_doc(reference_type, reference_name)
if invoice.docstatus != 1:
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
if total and flt(invoice.outstanding_amount) < total:
precision = invoice.precision("outstanding_amount")
if total and flt(invoice.outstanding_amount, precision) < flt(total, precision):
frappe.throw(
_("Payment against {0} {1} cannot be greater than Outstanding Amount {2}").format(
reference_type, reference_name, invoice.outstanding_amount