Merge branch 'edge' of github.com:webnotes/erpnext into edge
diff --git a/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index 980af58..f19df48 100644
--- a/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -66,6 +66,6 @@
 				vouchers.append(d.voucher_id)
 
 		if vouchers:
-			msgprint("Clearance Date updated in %s" % vouchers)
+			msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
 		else:
 			msgprint("Clearance Date not mentioned")
\ No newline at end of file
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index 9b1ca7a..f7d4035 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -43,6 +43,8 @@
 		if not self.doc.is_opening:
 			self.doc.is_opening='No'
 			
+		self.doc.clearance_date = None
+			
 		self.validate_debit_credit()
 		self.validate_cheque_info()
 		self.validate_entries_for_advance()
diff --git a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
index 5767307..619aed1 100644
--- a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
+++ b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-26 06:51:12", 
+  "creation": "2013-04-19 11:00:06", 
   "docstatus": 0, 
-  "modified": "2013-04-17 14:05:19", 
+  "modified": "2013-05-07 11:23:56", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -35,6 +35,7 @@
   "oldfieldname": "category", 
   "oldfieldtype": "Select", 
   "options": "Valuation and Total\nValuation\nTotal", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -45,6 +46,7 @@
   "oldfieldname": "charge_type", 
   "oldfieldtype": "Select", 
   "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -55,6 +57,7 @@
   "oldfieldname": "account_head", 
   "oldfieldtype": "Link", 
   "options": "Account", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -65,7 +68,8 @@
   "label": "Cost Center", 
   "oldfieldname": "cost_center", 
   "oldfieldtype": "Link", 
-  "options": "Cost Center"
+  "options": "Cost Center", 
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -75,17 +79,18 @@
   "oldfieldname": "description", 
   "oldfieldtype": "Small Text", 
   "print_width": "300px", 
+  "read_only": 0, 
   "reqd": 1, 
   "width": "300px"
  }, 
  {
   "doctype": "DocField", 
   "fieldname": "rate", 
-  "fieldtype": "Currency", 
+  "fieldtype": "Float", 
   "label": "Rate", 
   "oldfieldname": "rate", 
   "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
+  "read_only": 0, 
   "reqd": 0
  }, 
  {
@@ -96,6 +101,7 @@
   "oldfieldname": "tax_amount", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
+  "read_only": 0, 
   "reqd": 0
  }, 
  {
@@ -115,7 +121,8 @@
   "hidden": 0, 
   "label": "Enter Row", 
   "oldfieldname": "row_id", 
-  "oldfieldtype": "Data"
+  "oldfieldtype": "Data", 
+  "read_only": 0
  }, 
  {
   "default": "Add", 
@@ -126,6 +133,7 @@
   "oldfieldname": "add_deduct_tax", 
   "oldfieldtype": "Select", 
   "options": "Add\nDeduct", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -149,6 +157,7 @@
   "oldfieldname": "parenttype", 
   "oldfieldtype": "Data", 
   "print_hide": 1, 
+  "read_only": 0, 
   "search_index": 0
  }, 
  {
@@ -163,6 +172,7 @@
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
+  "read_only": 0, 
   "report_hide": 1
  }, 
  {
@@ -177,6 +187,7 @@
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
+  "read_only": 0, 
   "report_hide": 1
  }
 ]
\ No newline at end of file
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index d2b0a0e..c3d4cf1 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -217,6 +217,11 @@
 				route: "query-report/Payment Made With Ageing",
 				doctype: "Journal Voucher"
 			},
+			{
+				"label":wn._("Sales Partners Commission"),
+				route: "query-report/Sales Partners Commission",
+				doctype: "Sales Invoice"
+			},
 		]
 	}
 ]
diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py
index c131c17..d4f2392 100644
--- a/accounts/report/purchase_register/purchase_register.py
+++ b/accounts/report/purchase_register/purchase_register.py
@@ -20,9 +20,10 @@
 
 def execute(filters=None):
 	if not filters: filters = {}
-	columns, expense_accounts, tax_accounts = get_columns()
-	
+
 	invoice_list = get_invoices(filters)
+	columns, expense_accounts, tax_accounts = get_columns(invoice_list)
+	
 	invoice_expense_map = get_invoice_expense_map(invoice_list)
 	invoice_tax_map = get_invoice_tax_map(invoice_list)
 	invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
@@ -55,7 +56,7 @@
 	return columns, data
 	
 	
-def get_columns():
+def get_columns(invoice_list):
 	"""return columns based on filters"""
 	columns = [
 		"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier:Link/Supplier:120", 
@@ -66,10 +67,14 @@
 	
 	expense_accounts = webnotes.conn.sql_list("""select distinct expense_head 
 		from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != '' 
-		order by expense_head""")
+		and parent in (%s) order by expense_head""" % 
+		', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+		
 	tax_accounts = 	webnotes.conn.sql_list("""select distinct account_head 
 		from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice' 
-		and docstatus = 1 and ifnull(account_head, '') != '' order by account_head""")
+		and docstatus = 1 and ifnull(account_head, '') != '' and parent in (%s) 
+		order by account_head""" % 
+		', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
 	
 	columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
 		["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
diff --git a/accounts/report/sales_partners_commission/__init__.py b/accounts/report/sales_partners_commission/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/report/sales_partners_commission/__init__.py
diff --git a/accounts/report/sales_partners_commission/sales_partners_commission.txt b/accounts/report/sales_partners_commission/sales_partners_commission.txt
new file mode 100644
index 0000000..52bbf3c
--- /dev/null
+++ b/accounts/report/sales_partners_commission/sales_partners_commission.txt
@@ -0,0 +1,22 @@
+[
+ {
+  "creation": "2013-05-06 12:28:23", 
+  "docstatus": 0, 
+  "modified": "2013-05-06 12:41:15", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "name": "__common__", 
+  "query": "SELECT\n    sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"", 
+  "ref_doctype": "Sales Invoice", 
+  "report_name": "Sales Partners Commission", 
+  "report_type": "Query Report"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Sales Partners Commission"
+ }
+]
\ No newline at end of file
diff --git a/accounts/report/sales_register/sales_register.py b/accounts/report/sales_register/sales_register.py
index 23d2227..b150974 100644
--- a/accounts/report/sales_register/sales_register.py
+++ b/accounts/report/sales_register/sales_register.py
@@ -20,9 +20,10 @@
 
 def execute(filters=None):
 	if not filters: filters = {}
-	columns, income_accounts, tax_accounts = get_columns()
 	
 	invoice_list = get_invoices(filters)
+	columns, income_accounts, tax_accounts = get_columns(invoice_list)
+	
 	invoice_income_map = get_invoice_income_map(invoice_list)
 	invoice_tax_map = get_invoice_tax_map(invoice_list)
 	
@@ -59,7 +60,7 @@
 	return columns, data
 	
 	
-def get_columns():
+def get_columns(invoice_list):
 	"""return columns based on filters"""
 	columns = [
 		"Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer:Link/Customer:120", 
@@ -69,11 +70,14 @@
 	]
 	
 	income_accounts = webnotes.conn.sql_list("""select distinct income_account 
-		from `tabSales Invoice Item` where docstatus = 1 order by income_account""")
+		from `tabSales Invoice Item` where docstatus = 1 and parent in (%s) 
+		order by income_account""" % 
+		', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
 	
 	tax_accounts = 	webnotes.conn.sql_list("""select distinct account_head 
 		from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice' 
-		and docstatus = 1 order by account_head""")
+		and docstatus = 1 and parent in (%s) order by account_head""" % 
+		', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
 	
 	columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
 		["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 56328cc..e7532dd 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -107,6 +107,10 @@
 				"label":wn._("Item-wise Purchase History"),
 				route: "query-report/Item-wise Purchase History",
 			},
+			{
+				"label":wn._("Purchase In Transit"),
+				route: "query-report/Purchase In Transit",
+			},
 		]
 	}
 ]
diff --git a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt
index 3f9e702..5d36d94 100644
--- a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt
+++ b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-03 14:55:53", 
   "docstatus": 0, 
-  "modified": "2013-05-03 15:13:34", 
+  "modified": "2013-05-07 11:20:09", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -11,7 +11,7 @@
   "doctype": "Report", 
   "is_standard": "Yes", 
   "name": "__common__", 
-  "query": "select\n    po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Currency:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Currency:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Currency:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", 
+  "query": "select\n    po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Float:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Float:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Float:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", 
   "ref_doctype": "Purchase Order", 
   "report_name": "Item-wise Purchase History", 
   "report_type": "Query Report"
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index b22042d..80af337 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -59,7 +59,8 @@
 					buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty, 
 						self.doc.doctype, self.doc.name, item.name, stock_ledger_entries, 
 						item_sales_bom)
-					item.buying_amount = buying_amount > 0 and buying_amount or 0
+					
+					item.buying_amount = buying_amount >= 0.01 and buying_amount or 0
 					webnotes.conn.set_value(item.doctype, item.name, "buying_amount", 
 						item.buying_amount)
 						
diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js
index df32645..b2cce73 100644
--- a/hr/page/hr_home/hr_home.js
+++ b/hr/page/hr_home/hr_home.js
@@ -169,6 +169,14 @@
 				"label":wn._("Employee Leave Balance"),
 				route: "query-report/Employee Leave Balance"
 			},
+			{
+				"label":wn._("Employee Birthday"),
+				route: "query-report/Employee Birthday"
+			},
+			{
+				"label":wn._("Employee Information"),
+				route: "Report2/Employee/Employee Information"
+			},
 		]
 	}
 ];
diff --git a/hr/report/employee_birthday/__init__.py b/hr/report/employee_birthday/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hr/report/employee_birthday/__init__.py
diff --git a/hr/report/employee_birthday/employee_birthday.js b/hr/report/employee_birthday/employee_birthday.js
new file mode 100644
index 0000000..f2bc9cb
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.js
@@ -0,0 +1,19 @@
+wn.query_reports["Employee Birthday"] = {
+	"filters": [
+		{
+			"fieldname":"month",
+			"label": "Month",
+			"fieldtype": "Select",
+			"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
+			"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", 
+				"Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
+		},
+		{
+			"fieldname":"company",
+			"label": "Company",
+			"fieldtype": "Link",
+			"options": "Company",
+			"default": wn.defaults.get_user_default("company")
+		}
+	]
+}
\ No newline at end of file
diff --git a/hr/report/employee_birthday/employee_birthday.py b/hr/report/employee_birthday/employee_birthday.py
new file mode 100644
index 0000000..7268055
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.py
@@ -0,0 +1,50 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+	if not filters: filters = {}
+	
+	columns = get_columns()
+	data = get_employees(filters)
+	
+	return columns, data
+	
+def get_columns():
+	return [
+		"Employee:Link/Employee:120", "Date of Birth:Date:100", "Branch:Link/Branch:120", 
+		"Department:Link/Department:120", "Designation:Link/Designation:120", "Gender::60", 
+		"Company:Link/Company:120"
+	]
+	
+def get_employees(filters):
+	conditions = get_conditions(filters)
+	return webnotes.conn.sql("""select name, date_of_birth, branch, department, designation, 
+	gender, company from tabEmployee where status = 'Active' %s""" % conditions, as_list=1)
+	
+def get_conditions(filters):
+	conditions = ""
+	if filters.get("month"):
+		month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", 
+			"Dec"].index(filters["month"]) + 1
+		conditions += " and month(date_of_birth) = '%s'" % month
+	
+	if filters.get("company"): conditions += " and company = '%s'" % filters["company"]
+	
+	return conditions
\ No newline at end of file
diff --git a/hr/report/employee_birthday/employee_birthday.txt b/hr/report/employee_birthday/employee_birthday.txt
new file mode 100644
index 0000000..575ae73
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.txt
@@ -0,0 +1,21 @@
+[
+ {
+  "creation": "2013-05-06 17:56:03", 
+  "docstatus": 0, 
+  "modified": "2013-05-06 17:56:03", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "name": "__common__", 
+  "ref_doctype": "Employee", 
+  "report_name": "Employee Birthday", 
+  "report_type": "Script Report"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Employee Birthday"
+ }
+]
\ No newline at end of file
diff --git a/hr/report/employee_information/__init__.py b/hr/report/employee_information/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hr/report/employee_information/__init__.py
diff --git a/hr/report/employee_information/employee_information.txt b/hr/report/employee_information/employee_information.txt
new file mode 100644
index 0000000..b9d190b
--- /dev/null
+++ b/hr/report/employee_information/employee_information.txt
@@ -0,0 +1,22 @@
+[
+ {
+  "creation": "2013-05-06 18:43:53", 
+  "docstatus": 0, 
+  "modified": "2013-05-06 18:47:43", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"grade\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", 
+  "name": "__common__", 
+  "ref_doctype": "Employee", 
+  "report_name": "Employee Information", 
+  "report_type": "Report Builder"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Employee Information"
+ }
+]
\ No newline at end of file
diff --git a/manufacturing/doctype/bom/bom.js b/manufacturing/doctype/bom/bom.js
index f0c15fa..b1f43f7 100644
--- a/manufacturing/doctype/bom/bom.js
+++ b/manufacturing/doctype/bom/bom.js
@@ -64,9 +64,9 @@
 
 cur_frm.cscript.workstation = function(doc,dt,dn) {
 	var d = locals[dt][dn];
-	wn.model.with_doc("Workstation", d.workstation, function(i, v) {
-		d.hour_rate = v.hour_rate;
-		refresh_field("hour_rate");
+	wn.model.with_doc("Workstation", d.workstation, function(i, r) {
+		d.hour_rate = r.docs[0].hour_rate;
+		refresh_field("hour_rate", dn, "bom_operations");
 		calculate_op_cost(doc);
 		calculate_total(doc);
 	});
diff --git a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
index 177adcd..4c9c42d 100644
--- a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
+++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
@@ -46,11 +46,7 @@
 		webnotes.conn.sql("""update `tabBOM Item` set bom_no=%s, 
 			rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""", 
 			(self.doc.new_bom, current_bom_unitcost, current_bom_unitcost, self.doc.current_bom))
-			
-	def get_parent_boms(bom_no):
-		return [d[0] for d in webnotes.conn.sql("""select distinct parent from
-			`tabBOM Item` where ifnull(bom_no, '')=%s and docstatus < 2""", bom_no)]
-	
+				
 	def get_parent_boms(self):
 		return [d[0] for d in webnotes.conn.sql("""select distinct parent 
 			from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2""",
diff --git a/manufacturing/page/manufacturing_home/manufacturing_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js
index b7f28ed..d4841df 100644
--- a/manufacturing/page/manufacturing_home/manufacturing_home.js
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.js
@@ -58,6 +58,17 @@
 			},
 		]
 	},
+	{
+		title: wn._("Reports"),
+		right: true,
+		icon: "icon-list",
+		items: [
+			{
+				"label":wn._("Issued Items Against Production Order"),
+				route: "query-report/Issued Items Against Production Order",
+			},
+		]
+	}
 ]
 
 pscript['onload_manufacturing-home'] = function(wrapper) {
diff --git a/manufacturing/report/__init__.py b/manufacturing/report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/report/__init__.py
diff --git a/manufacturing/report/issued_items_against_production_order/__init__.py b/manufacturing/report/issued_items_against_production_order/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/report/issued_items_against_production_order/__init__.py
diff --git a/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt
new file mode 100644
index 0000000..a5a03bfa
--- /dev/null
+++ b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt
@@ -0,0 +1,23 @@
+[
+ {
+  "creation": "2013-05-03 17:48:46", 
+  "docstatus": 0, 
+  "modified": "2013-05-07 11:49:56", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "add_total_row": 0, 
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "name": "__common__", 
+  "query": "select\n    ste.production_order as \"Production Order:Link/Production Order:120\",\n    ste.posting_date as \"Issue Date:Date:140\",\n    ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Float:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", 
+  "ref_doctype": "Production Order", 
+  "report_name": "Issued Items Against Production Order", 
+  "report_type": "Query Report"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Issued Items Against Production Order"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt
index cf13bdc..6fee050 100644
--- a/selling/report/item_wise_sales_history/item_wise_sales_history.txt
+++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-03 14:38:34", 
   "docstatus": 0, 
-  "modified": "2013-05-03 15:15:11", 
+  "modified": "2013-05-07 11:19:40", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -11,7 +11,7 @@
   "doctype": "Report", 
   "is_standard": "Yes", 
   "name": "__common__", 
-  "query": "select\n    so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n    so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", 
+  "query": "select\n    so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n    so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", 
   "ref_doctype": "Sales Order", 
   "report_name": "Item-wise Sales History", 
   "report_type": "Query Report"
diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
index 612cb74..23e8819 100644
--- a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
+++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
@@ -32,8 +32,8 @@
 		
 	return [filters["doc_type"] + ":Link/" + filters["doc_type"] + ":140", 
 		"Customer:Link/Customer:140", "Territory:Link/Territory:100", "Posting Date:Date:100", 
-		"Item Code:Link/Item:120", "Qty:Currency:100", "Amount:Currency:120", 
-		"Sales Person:Link/Sales Person:140", "Contribution %:Currency:110", 
+		"Item Code:Link/Item:120", "Qty:Float:100", "Amount:Currency:120", 
+		"Sales Person:Link/Sales Person:140", "Contribution %:Float:110", 
 		"Contribution Amount:Currency:140"]
 	
 def get_entries(filters):
diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py
index be34312..2d98c26 100644
--- a/stock/doctype/bin/bin.py
+++ b/stock/doctype/bin/bin.py
@@ -79,7 +79,7 @@
 		
 		if (flt(args.get("actual_qty")) < 0 or flt(args.get("reserved_qty")) > 0) \
 				and args.get("is_cancelled") == 'No' and args.get("is_amended")=='No':
-			self.reorder_item(args.get("voucher_type"), args.get("voucher_no"))
+			self.reorder_item(args.get("voucher_type"), args.get("voucher_no"), args.get("company"))
 		
 	def get_first_sle(self):
 		sle = sql("""
@@ -92,7 +92,7 @@
 		""", (self.doc.item_code, self.doc.warehouse), as_dict=1)
 		return sle and sle[0] or None
 
-	def reorder_item(self,doc_type,doc_name):
+	def reorder_item(self,doc_type,doc_name, company):
 		""" Reorder item if stock reaches reorder level"""
 		if not hasattr(webnotes, "auto_indent"):
 			webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent')
@@ -111,10 +111,10 @@
 				material_request_type = "Purchase"
 			
 			if flt(reorder_qty) and flt(self.doc.projected_qty) < flt(reorder_level):
-				self.create_material_request(doc_type, doc_name, reorder_level, reorder_qty,
-					material_request_type)
+				self.create_material_request(doc_type, doc_name, reorder_level, reorder_qty, 
+					company, material_request_type)
 
-	def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty,
+	def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty, company, 
 			material_request_type="Purchase"):
 		"""	Create indent on reaching reorder level	"""
 		defaults = webnotes.defaults.get_defaults()
@@ -122,7 +122,7 @@
 		
 		mr = webnotes.bean([{
 			"doctype": "Material Request",
-			"company": defaults.company,
+			"company": company or defaults.company,
 			"fiscal_year": defaults.fiscal_year,
 			"transaction_date": nowdate(),
 			"material_request_type": material_request_type,
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index a344ad3..acc78e7 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -134,11 +134,7 @@
 	erpnext.utils.supplier_query;
 
 cur_frm.cscript.on_remove_attachment = function(doc) {
-	// refresh image list before unsetting image
-	refresh_field("image");
 	if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) {
-		// if the selected image is removed from attachment, unset it
-		cur_frm.set_value("image", "");
 		msgprint(wn._("Attachment removed. You may need to update: ") 
 			+ wn.meta.get_docfield(doc.doctype, "description_html").label);
 	}
@@ -157,3 +153,7 @@
 		cur_frm.refresh();
 	});
 }
+
+cur_frm.cscript.image = function() {
+	refresh_field("image_view");
+}
\ No newline at end of file
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index 6327504..fde532c 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -31,7 +31,9 @@
 		if webnotes.conn.get_default("item_naming_by")=="Naming Series":
 			from webnotes.model.doc import make_autoname
 			self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
-
+		elif not self.doc.item_code:
+			msgprint(_("Item Code is mandatory"), raise_exception=1)
+			
 		self.doc.name = self.doc.item_code
 			
 	def validate(self):
diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt
index 274719e..c799029 100644
--- a/stock/doctype/item/item.txt
+++ b/stock/doctype/item/item.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-04-25 10:56:55", 
+  "creation": "2013-05-03 10:45:46", 
   "docstatus": 0, 
-  "modified": "2013-05-02 15:10:53", 
+  "modified": "2013-05-07 15:58:58", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -28,13 +28,14 @@
   "permlevel": 0
  }, 
  {
-  "amend": 0, 
   "doctype": "DocPerm", 
   "name": "__common__", 
   "parent": "Item", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
+  "permlevel": 0, 
   "read": 1, 
+  "report": 1, 
   "submit": 0
  }, 
  {
@@ -55,7 +56,8 @@
   "fieldname": "naming_series", 
   "fieldtype": "Select", 
   "label": "Naming Series", 
-  "options": "\nITEM"
+  "options": "\nITEM", 
+  "read_only": 0
  }, 
  {
   "description": "Item will be saved by this name in the data base.", 
@@ -64,10 +66,11 @@
   "fieldtype": "Data", 
   "in_filter": 0, 
   "label": "Item Code", 
+  "no_copy": 1, 
   "oldfieldname": "item_code", 
   "oldfieldtype": "Data", 
   "read_only": 0, 
-  "reqd": 1, 
+  "reqd": 0, 
   "search_index": 0
  }, 
  {
@@ -884,75 +887,26 @@
   "read_only": 0
  }, 
  {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material Manager", 
-  "write": 0
- }, 
- {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Material Manager", 
-  "write": 0
- }, 
- {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material User", 
-  "write": 0
- }, 
- {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Material User", 
-  "write": 0
- }, 
- {
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material Master Manager", 
   "write": 1
  }, 
  {
+  "amend": 0, 
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material Master Manager", 
+  "role": "Material Manager", 
   "write": 0
  }, 
  {
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "System Manager", 
-  "write": 1
- }, 
- {
+  "amend": 0, 
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "System Manager", 
+  "role": "Material User", 
   "write": 0
  }
 ]
\ No newline at end of file
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index fa60072..d08deef 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -194,10 +194,10 @@
 		total_valuation_amount = 0
 		for item in self.doclist.get({"parentfield": "mtn_details"}):
 			if item.t_warehouse and not item.s_warehouse:
-				total_valuation_amount += flt(item.incoming_rate) * flt(item.transfer_qty)
+				total_valuation_amount += flt(item.incoming_rate, 2) * flt(item.transfer_qty)
 			
 			if item.s_warehouse and not item.t_warehouse:
-				total_valuation_amount -= flt(item.incoming_rate) * flt(item.transfer_qty)
+				total_valuation_amount -= flt(item.incoming_rate, 2) * flt(item.transfer_qty)
 		
 		return total_valuation_amount
 			
@@ -607,7 +607,7 @@
 			'voucher_no': self.doc.name, 
 			'voucher_detail_no': d.name,
 			'actual_qty': qty,
-			'incoming_rate': flt(d.incoming_rate) or 0,
+			'incoming_rate': flt(d.incoming_rate, 2) or 0,
 			'stock_uom': d.stock_uom,
 			'company': self.doc.company,
 			'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No',
diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js
index db77fce..bfcaf8a 100644
--- a/stock/page/stock_home/stock_home.js
+++ b/stock/page/stock_home/stock_home.js
@@ -197,6 +197,10 @@
 				route: "query-report/Item-Wise Price List",
 				doctype: "Item"
 			},
+			{
+				"label":wn._("Purchase In Transit"),
+				route: "query-report/Purchase In Transit",
+			},
 		]
 	}
 ]
diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt
index 6c2afad..824c603 100644
--- a/stock/report/item_wise_price_list/item_wise_price_list.txt
+++ b/stock/report/item_wise_price_list/item_wise_price_list.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-01-02 14:22:51", 
+  "creation": "2013-02-22 18:01:55", 
   "docstatus": 0, 
-  "modified": "2013-02-22 15:53:01", 
+  "modified": "2013-05-07 11:50:46", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -10,7 +10,7 @@
   "doctype": "Report", 
   "is_standard": "Yes", 
   "name": "__common__", 
-  "query": "select\n  item.name as \"ID:Link/Item:120\", \n  item.item_name as \"Item Name::120\", \n  item_price.price_list_name as \"Price List::80\",\n  item_price.ref_currency as \"Currency::40\", \n  item_price.ref_rate as \"Rate:Currency:80\",\n  item.description as \"Description::160\",\n  item.item_group as \"Item Group:Link/Item Group:100\",\n  item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n  item_price.parent = item.name", 
+  "query": "select\n  item.name as \"ID:Link/Item:120\", \n  item.item_name as \"Item Name::120\", \n  item_price.price_list_name as \"Price List::80\",\n  item_price.ref_currency as \"Currency::40\", \n  item_price.ref_rate as \"Rate:Float:80\",\n  item.description as \"Description::160\",\n  item.item_group as \"Item Group:Link/Item Group:100\",\n  item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n  item_price.parent = item.name", 
   "ref_doctype": "Item", 
   "report_name": "Item-Wise Price List", 
   "report_type": "Query Report"
diff --git a/stock/report/purchase_in_transit/__init__.py b/stock/report/purchase_in_transit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/report/purchase_in_transit/__init__.py
diff --git a/stock/report/purchase_in_transit/purchase_in_transit.txt b/stock/report/purchase_in_transit/purchase_in_transit.txt
new file mode 100644
index 0000000..60ce0da
--- /dev/null
+++ b/stock/report/purchase_in_transit/purchase_in_transit.txt
@@ -0,0 +1,22 @@
+[
+ {
+  "creation": "2013-05-06 12:09:05", 
+  "docstatus": 0, 
+  "modified": "2013-05-06 12:22:52", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "name": "__common__", 
+  "query": "SELECT\n    pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc", 
+  "ref_doctype": "Purchase Receipt", 
+  "report_name": "Purchase In Transit", 
+  "report_type": "Query Report"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Purchase In Transit"
+ }
+]
\ No newline at end of file
diff --git a/support/page/support_home/support_home.js b/support/page/support_home/support_home.js
index d397daa..bde5e5c 100644
--- a/support/page/support_home/support_home.js
+++ b/support/page/support_home/support_home.js
@@ -72,6 +72,18 @@
 			},
 		]
 	},
+	{
+		title: wn._("Reports"),
+		right: true,
+		icon: "icon-list",
+		items: [
+			{
+				"label":wn._("Maintenance Schedules"),
+				route: "query-report/Maintenance Schedules",
+				doctype: "Maintenance Schedule"
+			}
+		]
+	}
 ]
 
 pscript['onload_support-home'] = function(wrapper) {
diff --git a/support/report/__init__.py b/support/report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/support/report/__init__.py
diff --git a/support/report/maintenance_schedules/__init__.py b/support/report/maintenance_schedules/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/support/report/maintenance_schedules/__init__.py
diff --git a/support/report/maintenance_schedules/maintenance_schedules.txt b/support/report/maintenance_schedules/maintenance_schedules.txt
new file mode 100644
index 0000000..525f483
--- /dev/null
+++ b/support/report/maintenance_schedules/maintenance_schedules.txt
@@ -0,0 +1,22 @@
+[
+ {
+  "creation": "2013-05-06 14:25:21", 
+  "docstatus": 0, 
+  "modified": "2013-05-06 14:32:47", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "name": "__common__", 
+  "query": "SELECT\n    ms_item.scheduled_date as \"Schedule Date:Date:120\",\n\tms_item.item_code as \"Item Code:Link/Item:120\",\n\tms_item.item_name as \"Item Name::120\",\n\tms_item.serial_no as \"Serial No::120\",\n\tms_item.incharge_name as \"Incharge::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms.sales_order_no as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, `tabMaintenance Schedule Detail` ms_item\nWHERE\n\tms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_item.scheduled_date asc, ms_item.item_code asc", 
+  "ref_doctype": "Maintenance Schedule", 
+  "report_name": "Maintenance Schedules", 
+  "report_type": "Query Report"
+ }, 
+ {
+  "doctype": "Report", 
+  "name": "Maintenance Schedules"
+ }
+]
\ No newline at end of file