Removed validation: target_valuation > source_valuation
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 4f3480c..81a2f59 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -45,7 +45,6 @@
self.validate_warehouse(pro_obj)
self.validate_production_order()
self.get_stock_and_rate()
- self.validate_incoming_rate()
self.validate_bom()
self.validate_finished_goods()
self.validate_return_reference_doc()
@@ -190,16 +189,10 @@
+ self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
def validate_valuation_rate(self):
- if self.purpose in ["Manufacture", "Repack"]:
- valuation_at_source, valuation_at_target = 0, 0
- for d in self.get("mtn_details"):
- if d.s_warehouse and not d.t_warehouse:
- valuation_at_source += flt(d.amount)
- if d.t_warehouse and not d.s_warehouse:
- valuation_at_target += flt(d.amount)
+ for d in self.get('mtn_details'):
+ if d.t_warehouse:
+ self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
- if valuation_at_target < valuation_at_source:
- frappe.throw(_("Total valuation for manufactured or repacked item(s) can not be less than total valuation of raw materials"))
def set_total_amount(self):
self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")])
@@ -241,7 +234,7 @@
incoming_rate = flt(self.get_incoming_rate(args), self.precision("incoming_rate", d))
if incoming_rate > 0:
d.incoming_rate = incoming_rate
- d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+ d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("amount", d))
if not d.t_warehouse:
raw_material_cost += flt(d.amount)
@@ -255,8 +248,9 @@
if d.bom_no:
bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1)
operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
- d.incoming_rate = operation_cost_per_unit + (raw_material_cost + flt(self.total_fixed_cost)) / flt(d.transfer_qty)
- d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+ d.incoming_rate = flt(operation_cost_per_unit +
+ (raw_material_cost + flt(self.total_fixed_cost)) / flt(d.transfer_qty), self.precision("incoming_rate", d))
+ d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("transfer_qty", d))
break
def get_incoming_rate(self, args):
@@ -280,11 +274,6 @@
return incoming_rate
- def validate_incoming_rate(self):
- for d in self.get('mtn_details'):
- if d.t_warehouse:
- self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
-
def validate_bom(self):
for d in self.get('mtn_details'):
if d.bom_no and not frappe.db.sql("""select name from `tabBOM`