sub-contracting rewrite with testcases

This commit is contained in:
Nabin Hait
2013-02-27 18:11:17 +05:30
parent a1d4b78fbe
commit 5418d71fc0
7 changed files with 344 additions and 298 deletions

View File

@@ -320,6 +320,7 @@ class DocType(BuyingController):
self.doc.posting_date,'Posting Date')
self.validate_write_off_account()
self.update_raw_material_cost()
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
@@ -494,3 +495,16 @@ class DocType(BuyingController):
def on_update(self):
pass
def update_raw_material_cost(self):
if self.sub_contracted_items:
for d in self.doclist.get({"parentfield": "entries"}):
rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
and is_active = 1 """, (d.item_code,))
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
d.conversion_factor = d.conversion_factor or webnotes.conn.get_value(
"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
"conversion_factor") or 1
d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor)

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-01-29 20:53:00",
"creation": "2013-02-11 10:54:51",
"docstatus": 0,
"modified": "2013-02-08 14:06:17",
"modified": "2013-02-27 18:10:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -282,6 +282,35 @@
"search_index": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "valuation_rate",
"fieldtype": "Currency",
"hidden": 1,
"label": "Valuation Rate",
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "conversion_factor",
"fieldtype": "Float",
"label": "Conversion Factor",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "rm_supp_cost",
"fieldtype": "Currency",
"hidden": 1,
"label": "Raw Materials Supplied Cost",
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"allow_on_submit": 1,
"doctype": "DocField",