From 2864e1f244bef4043511cecbf9b89f2dc488fa75 Mon Sep 17 00:00:00 2001 From: HarryPaulo Date: Fri, 21 Mar 2025 10:14:16 -0300 Subject: [PATCH] fix: decimal garbage on variable total (#46621) * fix: decimal dirty on variable total * fix: linters * fix: decimal garbage, code improvement (cherry picked from commit b0dccadd26eb4fe9dd20f3e534e72a714c8c7470) --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 9e1eaf25442..2039cdc774f 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -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