Total valuation for manufactured or repacked item(s) can not be less than total valuation of raw materials #1688
This commit is contained in:
parent
c7253b3a37
commit
7f32cbeb06
@ -41,6 +41,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_return_reference_doc()
|
self.validate_return_reference_doc()
|
||||||
self.validate_with_material_request()
|
self.validate_with_material_request()
|
||||||
self.validate_fiscal_year()
|
self.validate_fiscal_year()
|
||||||
|
self.validate_valuation_rate()
|
||||||
self.set_total_amount()
|
self.set_total_amount()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
@ -170,6 +171,19 @@ class StockEntry(StockController):
|
|||||||
frappe.throw(_("Stock Entries already created for Production Order ")
|
frappe.throw(_("Stock Entries already created for Production Order ")
|
||||||
+ self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
|
+ self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
|
||||||
|
|
||||||
|
def validate_valuation_rate(self):
|
||||||
|
if self.purpose == "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)
|
||||||
|
|
||||||
|
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):
|
def set_total_amount(self):
|
||||||
self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")])
|
self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")])
|
||||||
|
|
||||||
@ -202,9 +216,10 @@ class StockEntry(StockController):
|
|||||||
if self.production_order and self.purpose == "Manufacture/Repack":
|
if self.production_order and self.purpose == "Manufacture/Repack":
|
||||||
for d in self.get("mtn_details"):
|
for d in self.get("mtn_details"):
|
||||||
if d.bom_no:
|
if d.bom_no:
|
||||||
bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1)
|
if not flt(d.incoming_rate):
|
||||||
operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
|
bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1)
|
||||||
d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty))
|
operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
|
||||||
|
d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty))
|
||||||
d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
|
d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
|
||||||
|
|
||||||
def get_incoming_rate(self, args):
|
def get_incoming_rate(self, args):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user