From 1ef9f7f8fd8623bfaf686989c1e21795cd5568a0 Mon Sep 17 00:00:00 2001 From: FATHIH MOHAMMED <99068504+FathihMohammed@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:27:27 +0000 Subject: [PATCH 1/2] fix: precision loss causing process loss variance (cherry picked from commit d84601b2a3a96be811c6360e869b0864857c5fb7) # Conflicts: # erpnext/stock/doctype/stock_entry/stock_entry.py --- erpnext/stock/doctype/stock_entry/stock_entry.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index a4e22a041a6..a773d9cfa45 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -496,10 +496,14 @@ class StockEntry(StockController): if (fg_completed_qty - fg_item_qty) > 0: self.process_loss_qty = fg_completed_qty - fg_item_qty +<<<<<<< HEAD if not self.process_loss_qty: continue if fg_completed_qty != (flt(fg_item_qty) + flt(self.process_loss_qty, precision)): +======= + if self.fg_completed_qty != flt(total, precision): +>>>>>>> d84601b2a3 (fix: precision loss causing process loss variance) frappe.throw( _( "Since there is a process loss of {0} units for the finished good {1}, you should reduce the quantity by {0} units for the finished good {1} in the Items Table." @@ -628,7 +632,9 @@ class StockEntry(StockController): completed_qty = ( d.completed_qty + d.process_loss_qty + (allowance_percentage / 100 * d.completed_qty) ) - if total_completed_qty > flt(completed_qty): + if flt(total_completed_qty, self.precision("fg_completed_qty")) > flt( + completed_qty, self.precision("fg_completed_qty") + ): job_card = frappe.db.get_value("Job Card", {"operation_id": d.name}, "name") if not job_card: frappe.throw( From 5ccf4a1783b887777b430e4cf2b04c1e2635e60e Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 10 Jan 2025 11:25:53 +0530 Subject: [PATCH 2/2] chore: fix conflicts --- erpnext/stock/doctype/stock_entry/stock_entry.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index a773d9cfa45..5e4343add10 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -496,14 +496,10 @@ class StockEntry(StockController): if (fg_completed_qty - fg_item_qty) > 0: self.process_loss_qty = fg_completed_qty - fg_item_qty -<<<<<<< HEAD if not self.process_loss_qty: continue - if fg_completed_qty != (flt(fg_item_qty) + flt(self.process_loss_qty, precision)): -======= - if self.fg_completed_qty != flt(total, precision): ->>>>>>> d84601b2a3 (fix: precision loss causing process loss variance) + if fg_completed_qty != (flt(fg_item_qty, precision) + flt(self.process_loss_qty, precision)): frappe.throw( _( "Since there is a process loss of {0} units for the finished good {1}, you should reduce the quantity by {0} units for the finished good {1} in the Items Table."