From 90fd6f2e40e0fca8a716ed3ad6f9a68b238ded12 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 7 Apr 2026 15:45:34 +0530 Subject: [PATCH] fix: hardcoded precision causing decimal issues --- .../purchase_invoice_item/purchase_invoice_item.json | 3 +-- .../doctype/sales_invoice/test_sales_invoice.py | 2 +- erpnext/controllers/selling_controller.py | 10 +++++----- erpnext/controllers/taxes_and_totals.py | 5 ++++- .../doctype/delivery_note_item/delivery_note_item.json | 3 +-- .../purchase_receipt_item/purchase_receipt_item.json | 3 +-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 7a55a5eb141..7399e987fa7 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -740,7 +740,6 @@ "label": "Valuation Rate", "no_copy": 1, "options": "Company:company:default_currency", - "precision": "6", "print_hide": 1, "read_only": 1 }, @@ -1008,7 +1007,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2026-03-25 18:03:33.522195", + "modified": "2026-04-07 15:40:45.687554", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index bdb786bf533..dd45e588137 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2887,7 +2887,7 @@ class TestSalesInvoice(ERPNextTestSuite): si.submit() # Check if adjustment entry is created - self.assertTrue( + self.assertFalse( frappe.db.exists( "GL Entry", { diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 8138a94693c..5a062e19daf 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -634,11 +634,11 @@ class SellingController(StockController): if allow_at_arms_length_price: continue - rate = flt( - flt(d.incoming_rate, d.precision("incoming_rate")) * d.conversion_factor, - d.precision("rate"), - ) - if d.rate != rate: + rate = flt(flt(d.incoming_rate) * flt(d.conversion_factor or 1.0)) + + if flt(d.rate, d.precision("incoming_rate")) != flt( + rate, d.precision("incoming_rate") + ): d.rate = rate frappe.msgprint( _( diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 4d16c5954d0..86cf937ba6c 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -167,8 +167,11 @@ class calculate_taxes_and_totals: bill_for_rejected_quantity_in_purchase_invoice = frappe.get_single_value( "Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice" ) + + do_not_round_fields = ["valuation_rate", "incoming_rate"] + for item in self.doc.items: - self.doc.round_floats_in(item) + self.doc.round_floats_in(item, do_not_round_fields=do_not_round_fields) if item.discount_percentage == 100: item.rate = 0.0 diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index d88af98bca8..0175b790887 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -759,7 +759,6 @@ "label": "Incoming Rate", "no_copy": 1, "options": "Company:company:default_currency", - "precision": "6", "print_hide": 1, "read_only": 1 }, @@ -953,7 +952,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-05-31 19:51:32.651562", + "modified": "2026-04-07 15:43:20.892151", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index e388199c361..b3f2e2eed5c 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -735,7 +735,6 @@ "oldfieldname": "valuation_rate", "oldfieldtype": "Currency", "options": "Company:company:default_currency", - "precision": "6", "print_hide": 1, "print_width": "80px", "read_only": 1, @@ -1150,7 +1149,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2026-02-07 14:42:11.646809", + "modified": "2026-04-07 15:40:47.032889", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item",