From 47c64ec728aed46036e61dbee1aae8e8defe7e86 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 20 Jul 2016 19:31:51 +0530 Subject: [PATCH 1/2] [Fix] Stock entry differnce amount issue. --- .../stock/doctype/stock_entry/stock_entry.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 2fe3bb70e3..5655258db5 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -49,7 +49,7 @@ class StockEntry(StockController): self.validate_batch() self.set_actual_qty() - self.calculate_rate_and_amount() + self.calculate_rate_and_amount(update_finished_item_rate=False) def on_submit(self): self.update_stock_ledger() @@ -234,18 +234,20 @@ class StockEntry(StockController): self.set_actual_qty() self.calculate_rate_and_amount() - def calculate_rate_and_amount(self, force=False): - self.set_basic_rate(force) + def calculate_rate_and_amount(self, force=False, update_finished_item_rate=True): + self.set_basic_rate(force, update_finished_item_rate) self.distribute_additional_costs() self.update_valuation_rate() self.set_total_incoming_outgoing_value() self.set_total_amount() - def set_basic_rate(self, force=False): + def set_basic_rate(self, force=False, update_finished_item_rate=True): """get stock and incoming rate on posting date""" raw_material_cost = 0.0 + fg_basic_rate = 0.0 for d in self.get('items'): + if d.t_warehouse: fg_basic_rate = flt(d.basic_rate) args = frappe._dict({ "item_code": d.item_code, "warehouse": d.s_warehouse or d.t_warehouse, @@ -266,13 +268,14 @@ class StockEntry(StockController): if not d.t_warehouse: raw_material_cost += flt(d.basic_amount) - self.set_basic_rate_for_finished_goods(raw_material_cost) + number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse]) + if (fg_basic_rate == 0.0 and number_of_fg_items == 1) or update_finished_item_rate: + self.set_basic_rate_for_finished_goods(raw_material_cost) def set_basic_rate_for_finished_goods(self, raw_material_cost): if self.purpose in ["Manufacture", "Repack"]: - number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse]) for d in self.get("items"): - if d.bom_no or (d.t_warehouse and number_of_fg_items == 1): + if d.bom_no or d.t_warehouse: d.basic_rate = flt(raw_material_cost / flt(d.transfer_qty), d.precision("basic_rate")) d.basic_amount = flt(raw_material_cost, d.precision("basic_amount")) From 368a314d48e561c84da5a94e6081acfbb98a6123 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 22 Jul 2016 13:28:12 +0600 Subject: [PATCH 2/2] bumped to version 6.27.26 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 769c827ca9..7fcbabee9f 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -__version__ = '6.27.25' \ No newline at end of file +__version__ = '6.27.26' \ No newline at end of file