From 77545042a5e2fa8265763d2df149fb7cdc85a151 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 7 Apr 2026 15:45:34 +0530 Subject: [PATCH 1/4] fix: hardcoded precision causing decimal issues (cherry picked from commit 90fd6f2e40e0fca8a716ed3ad6f9a68b238ded12) # Conflicts: # erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json # erpnext/stock/doctype/delivery_note_item/delivery_note_item.json # erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json --- .../purchase_invoice_item/purchase_invoice_item.json | 5 ++++- .../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 | 5 ++++- .../purchase_receipt_item/purchase_receipt_item.json | 5 ++++- 6 files changed, 22 insertions(+), 10 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 7acb36eca93..a691f8cad93 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -731,7 +731,6 @@ "label": "Valuation Rate", "no_copy": 1, "options": "Company:company:default_currency", - "precision": "6", "print_hide": 1, "read_only": 1 }, @@ -984,7 +983,11 @@ "idx": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2025-10-14 13:01:54.441511", +======= + "modified": "2026-04-07 15:40:45.687554", +>>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) "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 a8fb4ab93a0..147bb76064d 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2917,7 +2917,7 @@ class TestSalesInvoice(FrappeTestCase): 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 20c8a72290b..d5bd3501527 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -616,11 +616,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 e75dd3dacd2..4b6fc4f4054 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -186,8 +186,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 c8fcdb4c5a7..a6696cac254 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 }, @@ -952,7 +951,11 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2025-05-31 18:51:32.651562", +======= + "modified": "2026-04-07 15:43:20.892151", +>>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) "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 463544a9952..d089da00a49 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -734,7 +734,6 @@ "oldfieldname": "valuation_rate", "oldfieldtype": "Currency", "options": "Company:company:default_currency", - "precision": "6", "print_hide": 1, "print_width": "80px", "read_only": 1, @@ -1149,7 +1148,11 @@ "idx": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2025-10-14 12:59:20.384056", +======= + "modified": "2026-04-07 15:40:47.032889", +>>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", From d2c6a8958d6628ef17c1b68c3204dace1e35600b Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 8 Apr 2026 12:28:29 +0530 Subject: [PATCH 2/4] chore: fix conflicts Updated the modified date for the delivery note item. --- .../doctype/delivery_note_item/delivery_note_item.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 a6696cac254..3a82642873d 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -951,11 +951,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2025-05-31 18:51:32.651562", -======= - "modified": "2026-04-07 15:43:20.892151", ->>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) + "modified": "2026-04-07 15:44:20.892151", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", From 39a4760e07a8b107f0be8c09f50f20b7ea007e36 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 8 Apr 2026 12:29:00 +0530 Subject: [PATCH 3/4] chore: fix conflicts --- .../purchase_receipt_item/purchase_receipt_item.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 d089da00a49..8fda1c44702 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -1148,11 +1148,7 @@ "idx": 1, "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2025-10-14 12:59:20.384056", -======= - "modified": "2026-04-07 15:40:47.032889", ->>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) + "modified": "2026-04-07 15:41:47.032889", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", From 21607f39c5f0e644011faae52bd3a1508a05bfbf Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 8 Apr 2026 14:05:04 +0530 Subject: [PATCH 4/4] chore: fix conflicts --- .../purchase_invoice_item/purchase_invoice_item.json | 6 +----- 1 file changed, 1 insertion(+), 5 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 a691f8cad93..e059777dde2 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -983,11 +983,7 @@ "idx": 1, "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2025-10-14 13:01:54.441511", -======= - "modified": "2026-04-07 15:40:45.687554", ->>>>>>> 90fd6f2e40 (fix: hardcoded precision causing decimal issues) + "modified": "2026-04-07 15:41:45.687554", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item",