Merge branch 'master' of github.com:webnotes/erpnext into responsive

Conflicts:
	accounts/doctype/purchase_invoice/purchase_invoice.py
diff --git a/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
index d72c847..5aefa81 100644
--- a/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
+++ b/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2013-02-01 14:16:04", 
+  "creation": "2013-04-19 13:30:27", 
   "docstatus": 0, 
-  "modified": "2013-02-26 11:11:20", 
+  "modified": "2013-05-28 17:19:38", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Invoice", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n    \t\t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n    \t\t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Accounts", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
index 97c50fd..2f6251c 100644
--- a/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
+++ b/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-05-15 18:39:02", 
+  "creation": "2013-04-19 13:30:27", 
   "docstatus": 0, 
-  "modified": "2013-02-26 11:10:58", 
+  "modified": "2013-05-28 17:19:52", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Invoice", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Invoice No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n        \t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Invoice No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n        \t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Accounts", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
index 6be83d4..b00b3d8 100644
--- a/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
+++ b/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-05-15 18:39:02", 
+  "creation": "2013-04-19 13:30:27", 
   "docstatus": 0, 
-  "modified": "2013-02-26 11:11:40", 
+  "modified": "2013-05-28 17:19:22", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Invoice", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n        \t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Invoice',\n\t\t\t\tdoc.name,\n\t\t\t\t'entries',\n\t\t\t\t'Sales Invoice Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Invoice') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\n                    <tr>\n        \t\t\t\t<td width=40%><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?\"<b>Invoice Period</b>\"\n                            :\"\";\n    \t\t\t\t\t</script></td>\n\t\t\t\t\t\t<td><script>\n                            (doc.convert_into_recurring_invoice && doc.recurring_id)\n                            ?(date.str_to_user(doc.invoice_period_from_date) +\n                                ' to ' + date.str_to_user(doc.invoice_period_to_date))\n                            :\"\";\n                        </script></td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Accounts", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/accounts/README.md b/accounts/README.md
new file mode 100644
index 0000000..10a99e5
--- /dev/null
+++ b/accounts/README.md
@@ -0,0 +1,13 @@
+Accounts module contains masters and transactions to manage a traditional
+double entry accounting system.
+
+Accounting heads are called "Accounts" and they can be groups in a tree like
+"Chart of Accounts"
+
+Entries are:
+
+- Journal Vouchers
+- Sales Invoice (Itemised)
+- Purchase Invoice (Itemised)
+
+All accounting entries are stored in the `General Ledger`
\ No newline at end of file
diff --git a/accounts/doctype/account/README.md b/accounts/doctype/account/README.md
new file mode 100644
index 0000000..44cdf50
--- /dev/null
+++ b/accounts/doctype/account/README.md
@@ -0,0 +1,11 @@
+Account DocType represents an Accounting Ledger or Group.
+
+Follows a composite model. `parent_account` represents the parent of an Account except
+a root account.
+There can be only 4 root accounts: Income, Expense, Assets and Liabilities in a company.
+
+Other features:
+
+- It can be of type Debit or Credit.
+- A Group is a collection of groups or ledgers
+
diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py
index bdc26e4..45b02a8 100644
--- a/accounts/doctype/account/account.py
+++ b/accounts/doctype/account/account.py
@@ -29,6 +29,7 @@
 		self.nsm_parent_field = 'parent_account'
 
 	def autoname(self):
+		"""Append abbreviation to company on naming"""
 		self.doc.name = self.doc.account_name.strip() + ' - ' + \
 			webnotes.conn.get_value("Company", self.doc.company, "abbr")
 
@@ -37,6 +38,7 @@
 		return {'address': address}
 		
 	def validate_master_name(self):
+		"""Remind to add master name"""
 		if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') \
 				and not self.doc.master_name:
 			msgprint("Message: Please enter Master Name once the account is created.")
@@ -62,6 +64,7 @@
 				self.doc.debit_or_credit = par[0][3]
 
 	def validate_max_root_accounts(self):
+		"""Raise exception if there are more than 4 root accounts"""
 		if webnotes.conn.sql("""select count(*) from tabAccount where
 			company=%s and ifnull(parent_account,'')='' and docstatus != 2""",
 			self.doc.company)[0][0] > 4:
@@ -69,7 +72,6 @@
 				raise_exception=1)
 	
 	def validate_duplicate_account(self):
-		
 		if self.doc.fields.get('__islocal') or not self.doc.name:
 			company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
 			if sql("""select name from tabAccount where name=%s""", 
@@ -134,6 +136,7 @@
 			self.doc.parent_account = ''
 
 	def update_nsm_model(self):
+		"""update lft, rgt indices for nested set model"""
 		import webnotes
 		import webnotes.utils.nestedset
 		webnotes.utils.nestedset.update_nsm(self)
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index a5a4f10..2c5cd4f 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -158,7 +158,7 @@
 		if r:
 			self.doc.remark = ("\n").join(r)
 		else:
-			webnotes.msgprint("Remarks is mandatory", raise_exception=1)
+			webnotes.msgprint("User Remarks is mandatory", raise_exception=1)
 
 	def set_aging_date(self):
 		if self.doc.is_opening != 'Yes':
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index 788af9e..accb29e 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-05-09 13:16:11", 
+  "creation": "2013-05-24 12:15:51", 
   "docstatus": 0, 
-  "modified": "2013-05-23 12:52:09", 
+  "modified": "2013-05-30 12:09:39", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -18,8 +18,7 @@
   "parent": "POS Setting", 
   "parentfield": "fields", 
   "parenttype": "DocType", 
-  "permlevel": 0, 
-  "read_only": 0
+  "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
@@ -44,7 +43,8 @@
   "label": "User", 
   "oldfieldname": "user", 
   "oldfieldtype": "Link", 
-  "options": "Profile"
+  "options": "Profile", 
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -54,6 +54,7 @@
   "oldfieldname": "territory", 
   "oldfieldtype": "Link", 
   "options": "Territory", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -64,6 +65,7 @@
   "no_copy": 1, 
   "oldfieldname": "naming_series", 
   "oldfieldtype": "Select", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -74,6 +76,7 @@
   "oldfieldname": "currency", 
   "oldfieldtype": "Select", 
   "options": "Currency", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -84,6 +87,7 @@
   "label": "Conversion Rate", 
   "oldfieldname": "conversion_rate", 
   "oldfieldtype": "Currency", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -94,6 +98,7 @@
   "oldfieldname": "price_list_name", 
   "oldfieldtype": "Select", 
   "options": "link:Price List", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -105,13 +110,24 @@
   "oldfieldname": "company", 
   "oldfieldtype": "Link", 
   "options": "Company", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
   "doctype": "DocField", 
   "fieldname": "column_break0", 
   "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break"
+  "oldfieldtype": "Column Break", 
+  "read_only": 0
+ }, 
+ {
+  "default": "1", 
+  "description": "Create Stock Ledger Entries when you submit a Sales Invoice", 
+  "doctype": "DocField", 
+  "fieldname": "update_stock", 
+  "fieldtype": "Check", 
+  "label": "Update Stock", 
+  "reqd": 0
  }, 
  {
   "doctype": "DocField", 
@@ -121,6 +137,7 @@
   "oldfieldname": "customer_account", 
   "oldfieldtype": "Link", 
   "options": "Account", 
+  "read_only": 0, 
   "reqd": 0
  }, 
  {
@@ -131,6 +148,7 @@
   "oldfieldname": "cash_bank_account", 
   "oldfieldtype": "Link", 
   "options": "Account", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -141,6 +159,7 @@
   "oldfieldname": "income_account", 
   "oldfieldtype": "Link", 
   "options": "Account", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -152,6 +171,7 @@
   "label": "Expense Account", 
   "options": "Account", 
   "print_hide": 1, 
+  "read_only": 0, 
   "reqd": 0
  }, 
  {
@@ -162,6 +182,7 @@
   "oldfieldname": "warehouse", 
   "oldfieldtype": "Link", 
   "options": "Warehouse", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -172,6 +193,7 @@
   "oldfieldname": "cost_center", 
   "oldfieldtype": "Link", 
   "options": "Cost Center", 
+  "read_only": 0, 
   "reqd": 1
  }, 
  {
@@ -181,7 +203,8 @@
   "label": "Charge", 
   "oldfieldname": "charge", 
   "oldfieldtype": "Link", 
-  "options": "Sales Taxes and Charges Master"
+  "options": "Sales Taxes and Charges Master", 
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -191,7 +214,8 @@
   "oldfieldname": "letter_head", 
   "oldfieldtype": "Select", 
   "options": "link:Letter Head", 
-  "print_hide": 1
+  "print_hide": 1, 
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -200,7 +224,8 @@
   "label": "Terms and Conditions", 
   "oldfieldname": "tc_name", 
   "oldfieldtype": "Link", 
-  "options": "Terms and Conditions"
+  "options": "Terms and Conditions", 
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -210,17 +235,10 @@
   "label": "Select Print Heading", 
   "oldfieldname": "select_print_heading", 
   "oldfieldtype": "Select", 
-  "options": "link:Print Heading"
+  "options": "link:Print Heading", 
+  "read_only": 0
  }, 
  {
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "role": "System Manager", 
-  "write": 1
- }, 
- {
-  "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
   "role": "Accounts Manager", 
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js
index 92f1748..c6a787e 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -17,86 +17,56 @@
 cur_frm.cscript.tname = "Purchase Invoice Item";
 cur_frm.cscript.fname = "entries";
 cur_frm.cscript.other_fname = "purchase_tax_details";
+
+wn.provide("erpnext.accounts");
 wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
 wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 
-erpnext.buying.PurchaseInvoiceController = erpnext.buying.BuyingController.extend({
+erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.extend({
+	onload: function() {
+		this._super();
+		
+		if(!this.frm.doc.__islocal) {
+			// show credit_to in print format
+			if(!this.frm.doc.supplier && this.frm.doc.credit_to) {
+				this.frm.set_df_property("credit_to", "print_hide", 0);
+			}
+		}
+	},
+	
 	refresh: function(doc) {
 		this._super();
 		
 		// Show / Hide button
 		if(doc.docstatus==1 && doc.outstanding_amount > 0)
-			cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
+			this.frm.add_custom_button('Make Payment Entry', this.make_bank_voucher);
 
 		if(doc.docstatus==1) { 
-			cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
+			this.frm.add_custom_button('View Ledger', this.view_ledger_entry);
 		}
 		
-		cur_frm.cscript.is_opening(doc);
+		this.is_opening(doc);
 	},
-	onload_post_render: function(doc, dt, dn) {	
-		var me = this;	
-		var callback1 = function(doc, dt, dn) {
-			var callback2 = function(doc, dt, dn) {
-				if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc, dt, dn);			
-			}
-			me.update_item_details(doc, dt, dn, callback2);
-		}
-		
-		// TODO: improve this
-		if(this.frm.doc.__islocal) {
-			if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) {
-				this.price_list_name(callback1);
-			} else {
-				callback1(doc, dt, dn);
-			}
-		}
+	
+	credit_to: function() {
+		this.supplier();
+	},
+	
+	write_off_amount: function() {
+		this.calculate_outstanding_amount();
+		this.frm.refresh_fields();
+	},
+	
+	allocated_amount: function() {
+		this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
+		this.frm.refresh_fields();
 	}
 });
 
-var new_cscript = new erpnext.buying.PurchaseInvoiceController({frm: cur_frm});
-
 // for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
+$.extend(cur_frm.cscript, new erpnext.accounts.PurchaseInvoiceController({frm: cur_frm}));
 
 
-cur_frm.cscript.onload = function(doc,dt,dn) {
-	if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
-}
-
-cur_frm.cscript.supplier = function(doc,dt,dn) {
-	var callback = function(r,rt) {
-			var doc = locals[cur_frm.doctype][cur_frm.docname];		
-			get_server_fields('get_credit_to','','',doc, dt, dn, 0, callback2);
-	}
-	
-	var callback2 = function(r,rt){
-		var doc = locals[cur_frm.doctype][cur_frm.docname];
-		var el = getchildren('Purchase Invoice Item',doc.name,'entries');
-		for(var i in el){
-			if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
-				args = {
-					item_code: el[i].item_code,
-					expense_head: el[i].expense_head,
-					cost_center: el[i].cost_center
-				};
-				get_server_fields('get_default_values', JSON.stringify(args), 'entries', doc, el[i].doctype, el[i].name, 1);
-			}
-		}
-		cur_frm.cscript.calc_amount(doc, 1);
-	}
-
-	if (doc.supplier) {
-		get_server_fields('get_default_supplier_address',
-			JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function(doc, dt, dn) {
-				cur_frm.refresh();
-				callback(doc, dt, dn);
-			});
-		unhide_field(['supplier_address','contact_person']);
-	}
-
-}
-
 cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
 	if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
 }
@@ -112,23 +82,6 @@
 }
 
 
-cur_frm.cscript.credit_to = function(doc,dt,dn) {
-
-	var callback = function(doc, dt, dn) {
-			var doc = locals[doc.doctype][doc.name];
-			if(doc.supplier) {
-				get_server_fields('get_default_supplier_address',
-					JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1, function() {
-						cur_frm.refresh();
-					});
-				unhide_field(['supplier_address','contact_person']);
-			}
-			cur_frm.refresh();
-	}
-
-	get_server_fields('get_cust', '', '', doc, dt, dn, 1, callback);
-}
-
 cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
 	
 	cl = getchildren('Purchase Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
@@ -152,17 +105,6 @@
 	if (doc.is_opening == 'Yes') unhide_field('aging_date');
 }
 
-cur_frm.cscript.write_off_amount = function(doc) {
-	doc.total_amount_to_pay = flt(doc.grand_total) - flt(doc.write_off_amount);
-	doc.outstanding_amount = flt(doc.total_amount_to_pay) - flt(doc.total_advance);
-	refresh_many(['outstanding_amount', 'total_amount_to_pay']);
-}
-
-cur_frm.cscript.recalculate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calculate_tax(doc,cdt,cdn);
-	calc_total_advance(doc,cdt,cdn);
-}
-
 cur_frm.cscript.get_items = function(doc, dt, dn) {
 	var callback = function(r,rt) { 
 		unhide_field(['supplier_address', 'contact_person']);				
@@ -171,11 +113,6 @@
 	$c_obj(make_doclist(dt,dn),'pull_details','',callback);
 }
 
-cur_frm.cscript.allocated_amount = function(doc,cdt,cdn) {
-	calc_total_advance(doc, cdt, cdn);
-}
-
-
 cur_frm.cscript.make_bank_voucher = function() {
 	wn.call({
 		method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
@@ -261,21 +198,6 @@
 	refresh_field('entries');
 }
 
-calc_total_advance = function(doc,cdt,cdn) {
-	var doc = locals[doc.doctype][doc.name];
-	var el = getchildren('Purchase Invoice Advance',doc.name,'advance_allocation_details')
-	var total_advance = 0;
-	for(var i in el) {
-		if (! el[i].allocated_amount == 0) {
-			total_advance += flt(el[i].allocated_amount);
-		}
-	}
-	doc.total_amount_to_pay = flt(doc.grand_total) - flt(doc.write_off_amount);
-	doc.total_advance = flt(total_advance);
-	doc.outstanding_amount = flt(doc.total_amount_to_pay) - flt(total_advance);
-	refresh_many(['total_advance','outstanding_amount', 'total_amount_to_pay']);
-}
-
 cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
 	var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
 	jv = locals['Journal Voucher'][jv];
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 32a46cf..56d6075 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -33,6 +33,28 @@
 		self.doc, self.doclist = d, dl 
 		self.tname = 'Purchase Invoice Item'
 		self.fname = 'entries'
+		self.status_updater = [{
+			'source_dt': 'Purchase Invoice Item',
+			'target_dt': 'Purchase Order Item',
+			'join_field': 'po_detail',
+			'target_field': 'billed_amt',
+			'target_parent_dt': 'Purchase Order',
+			'target_parent_field': 'per_billed',
+			'target_ref_field': 'import_amount',
+			'source_field': 'import_amount',
+			'percent_join_field': 'purchase_order',
+		},
+		{
+			'source_dt': 'Purchase Invoice Item',
+			'target_dt': 'Purchase Receipt Item',
+			'join_field': 'pr_detail',
+			'target_field': 'billed_amt',
+			'target_parent_dt': 'Purchase Receipt',
+			'target_parent_field': 'per_billed',
+			'target_ref_field': 'import_amount',
+			'source_field': 'import_amount',
+			'percent_join_field': 'purchase_receipt',
+		}]
 		
 	def validate(self):
 		super(DocType, self).validate()
@@ -91,6 +113,11 @@
 			msgprint("%s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company))
 		return ret
 		
+	def set_supplier_defaults(self):
+		self.doc.fields.update(self.get_cust())
+		self.doc.fields.update(self.get_credit_to())
+		super(DocType, self).set_supplier_defaults()
+		
 	def get_cust(self):
 		ret = {}
 		if self.doc.credit_to:
@@ -100,31 +127,6 @@
 			
 		return ret
 		
-	def get_default_values(self, args):
-		if isinstance(args, basestring):
-			import json
-			args = json.loads(args)
-		
-		out = webnotes._dict()
-		
-		item = webnotes.conn.sql("""select name, purchase_account, cost_center,
-			is_stock_item from `tabItem` where name=%s""", args.get("item_code"), as_dict=1)
-		
-		if item and item[0]:
-			item = item[0]
-			
-			if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) and \
-				item.is_stock_item == "Yes":
-					# unset expense head for stock item and auto inventory accounting
-					out.expense_head = out.cost_center = None
-			else:
-				if not args.get("expense_head"):
-					out.expense_head = item.purchase_account
-				if not args.get("cost_center"):
-					out.cost_center = item.cost_center
-		
-		return out
-			
 	def pull_details(self):
 		if self.doc.purchase_receipt_main:
 			self.validate_duplicate_docname('purchase_receipt')
@@ -152,14 +154,6 @@
 	def get_rate(self,arg):
 		return get_obj('Purchase Common').get_rate(arg,self)
 
-	def load_default_taxes(self):
-		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
-	
-	
-	def get_purchase_tax_details(self):
-		self.doclist =  get_obj('Purchase Common').get_purchase_tax_details(self)
-
-
 	def get_rate1(self,acc):
 		rate = sql("select tax_rate from `tabAccount` where name='%s'"%(acc))
 		ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
@@ -411,8 +405,8 @@
 		self.make_gl_entries()
 				
 		self.update_against_document_in_jv()
-		purchase_controller.update_prevdoc_detail(self, is_submit = 1)
-
+		
+		self.update_prevdoc_status()
 
 	def make_gl_entries(self):
 		from accounts.general_ledger import make_gl_entries
@@ -466,8 +460,9 @@
 					# expense will be booked in sales invoice
 					stock_item_and_auto_inventory_accounting = True
 					
-					valuation_amt = (flt(item.amount) + flt(item.item_tax_amount) + 
-						flt(item.rm_supp_cost))
+					valuation_amt = (flt(item.amount, self.precision("amount", item)) + 
+						flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + 
+						flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)))
 					
 					gl_entries.append(
 						self.get_gl_dict({
@@ -522,7 +517,8 @@
 	def on_cancel(self):
 		from accounts.utils import remove_against_link_from_jv
 		remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_voucher")
-		get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 0)
+		
+		self.update_prevdoc_status()
 		
 		self.make_cancel_gl_entries()
 		
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt
index 283c612..e8bce65 100755
--- a/accounts/doctype/purchase_invoice/purchase_invoice.txt
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-05-07 13:50:30", 
+  "creation": "2013-05-21 16:16:39", 
   "docstatus": 0, 
-  "modified": "2013-05-13 11:12:56", 
+  "modified": "2013-06-05 14:57:08", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -89,10 +89,11 @@
   "read_only": 0
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "supplier_name", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Name", 
   "oldfieldname": "supplier_name", 
@@ -100,34 +101,38 @@
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -392,6 +397,7 @@
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_section", 
   "fieldtype": "Section Break", 
@@ -399,7 +405,6 @@
   "read_only": 0
  }, 
  {
-  "depends_on": "eval:doc.supplier", 
   "doctype": "DocField", 
   "fieldname": "supplier_address", 
   "fieldtype": "Link", 
@@ -415,7 +420,6 @@
   "width": "50%"
  }, 
  {
-  "depends_on": "eval:doc.supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_person", 
   "fieldtype": "Link", 
@@ -670,6 +674,32 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "terms_section_break", 
+  "fieldtype": "Section Break", 
+  "label": "Terms and Conditions"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "tc_name", 
+  "fieldtype": "Link", 
+  "label": "Select Terms and Conditions", 
+  "options": "Terms and Conditions", 
+  "print_hide": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "get_terms", 
+  "fieldtype": "Button", 
+  "label": "Get Terms and Conditions"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "terms", 
+  "fieldtype": "Text Editor", 
+  "label": "Terms and Conditions1"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "more_info", 
   "fieldtype": "Section Break", 
   "label": "More Info", 
diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index a70c932..2ae569b 100644
--- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -24,6 +24,7 @@
 import webnotes.defaults
 
 test_dependencies = ["Item", "Cost Center"]
+test_ignore = ["Serial No"]
 
 class TestPurchaseInvoice(unittest.TestCase):
 	def test_gl_entries_without_auto_inventory_accounting(self):
@@ -119,25 +120,6 @@
 		wrapper.insert()
 		wrapper.load_from_db()
 		
-		self.assertEqual(wrapper.doclist[0].net_total, 1250)
-		
-		# tax amounts
-		expected_values = [
-			["_Test Account Shipping Charges - _TC", 100, 1350],
-			["_Test Account Customs Duty - _TC", 125, 1350],
-			["_Test Account Excise Duty - _TC", 140, 1490],
-			["_Test Account Education Cess - _TC", 2.8, 1492.8],
-			["_Test Account S&H Education Cess - _TC", 1.4, 1494.2],
-			["_Test Account CST - _TC", 29.88, 1524.08],
-			["_Test Account VAT - _TC", 156.25, 1680.33],
-			["_Test Account Discount - _TC", 168.03, 1512.30],
-		]
-		
-		for i, tax in enumerate(wrapper.doclist.get({"parentfield": "purchase_tax_details"})):
-			self.assertEqual(tax.account_head, expected_values[i][0])
-			self.assertEqual(tax.tax_amount, expected_values[i][1])
-			self.assertEqual(tax.total, expected_values[i][2])
-
 		expected_values = [
 			["_Test Item Home Desktop 100", 90, 59],
 			["_Test Item Home Desktop 200", 135, 177]
@@ -147,13 +129,41 @@
 			self.assertEqual(item.item_tax_amount, expected_values[i][1])
 			self.assertEqual(item.valuation_rate, expected_values[i][2])
 			
+		self.assertEqual(wrapper.doclist[0].net_total, 1250)
+		
+		# tax amounts
+		expected_values = [
+			["_Test Account Shipping Charges - _TC", 100, 1350],
+			["_Test Account Customs Duty - _TC", 125, 1350],
+			["_Test Account Excise Duty - _TC", 140, 1490],
+			["_Test Account Education Cess - _TC", 2.8, 1492.8],
+			["_Test Account S&H Education Cess - _TC", 1.4, 1494.2],
+			["_Test Account CST - _TC", 29.88, 1524.08],
+			["_Test Account VAT - _TC", 156.25, 1680.33],
+			["_Test Account Discount - _TC", 168.03, 1512.30],
+		]
+		
+		for i, tax in enumerate(wrapper.doclist.get({"parentfield": "purchase_tax_details"})):
+			self.assertEqual(tax.account_head, expected_values[i][0])
+			self.assertEqual(tax.tax_amount, expected_values[i][1])
+			self.assertEqual(tax.total, expected_values[i][2])
+			
 	def test_purchase_invoice_with_subcontracted_item(self):
 		wrapper = webnotes.bean(copy=test_records[0])
 		wrapper.doclist[1].item_code = "_Test FG Item"
 		wrapper.run_method("calculate_taxes_and_totals")
 		wrapper.insert()
 		wrapper.load_from_db()
-
+		
+		expected_values = [
+			["_Test FG Item", 90, 7059],
+			["_Test Item Home Desktop 200", 135, 177]
+		]
+		for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
+			self.assertEqual(item.item_code, expected_values[i][0])
+			self.assertEqual(item.item_tax_amount, expected_values[i][1])
+			self.assertEqual(item.valuation_rate, expected_values[i][2])
+		
 		self.assertEqual(wrapper.doclist[0].net_total, 1250)
 
 		# tax amounts
@@ -172,15 +182,6 @@
 			self.assertEqual(tax.account_head, expected_values[i][0])
 			self.assertEqual(tax.tax_amount, expected_values[i][1])
 			self.assertEqual(tax.total, expected_values[i][2])
-
-		expected_values = [
-			["_Test FG Item", 90, 7059],
-			["_Test Item Home Desktop 200", 135, 177]
-		]
-		for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
-			self.assertEqual(item.item_code, expected_values[i][0])
-			self.assertEqual(item.item_tax_amount, expected_values[i][1])
-			self.assertEqual(item.valuation_rate, expected_values[i][2])
 			
 	def test_purchase_invoice_with_advance(self):
 		from accounts.doctype.journal_voucher.test_journal_voucher \
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 619aed1..d6d2a92 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-04-19 11:00:06", 
+  "creation": "2013-05-21 16:16:04", 
   "docstatus": 0, 
-  "modified": "2013-05-07 11:23:56", 
+  "modified": "2013-05-28 12:02:02", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -101,7 +101,7 @@
   "oldfieldname": "tax_amount", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0
  }, 
  {
@@ -159,35 +159,5 @@
   "print_hide": 1, 
   "read_only": 0, 
   "search_index": 0
- }, 
- {
-  "description": "Cheating Field\nPlease do not delete ", 
-  "doctype": "DocField", 
-  "fieldname": "total_tax_amount", 
-  "fieldtype": "Currency", 
-  "hidden": 1, 
-  "label": "Total +Tax", 
-  "no_copy": 1, 
-  "oldfieldname": "total_tax_amount", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "report_hide": 1
- }, 
- {
-  "description": "Cheating Field\nPlease do not delete ", 
-  "doctype": "DocField", 
-  "fieldname": "total_amount", 
-  "fieldtype": "Currency", 
-  "hidden": 1, 
-  "label": "Tax Amount", 
-  "no_copy": 1, 
-  "oldfieldname": "total_amount", 
-  "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/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index be6ec3d..f776db5 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -22,52 +22,90 @@
 // print heading
 cur_frm.pformat.print_heading = 'Invoice';
 
-wn.require('app/selling/doctype/sales_common/sales_common.js');
 wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/selling/doctype/sales_common/sales_common.js');
 
-// On Load
-// -------
-cur_frm.cscript.onload = function(doc,dt,dn) {
-	cur_frm.cscript.manage_rounded_total();
-	if(!doc.customer && doc.debit_to) wn.meta.get_docfield(dt, 'debit_to', dn).print_hide = 0;
-	if (doc.__islocal) {
-		if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
-		if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
-		if(!doc.currency && sys_defaults.currency) set_multiple(dt,dn,{currency:sys_defaults.currency});
-		if(!doc.price_list_currency) set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
-
-	}
-}
-
-cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	var callback = function(doc, dt, dn) {
-		// called from mapper, update the account names for items and customer
-		var callback2 = function(doc, dt, dn) {
-			if(doc.customer && doc.__islocal) {
-				$c_obj(make_doclist(doc.doctype,doc.name),
-					'load_default_accounts','',
-					function(r,rt) {
-						refresh_field('entries');
-						cur_frm.cscript.customer(doc,dt,dn,onload=true);
-					}
-				);
+wn.provide("erpnext.accounts");
+erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
+	onload: function() {
+		this._super();
+		
+		if(!this.frm.doc.__islocal) {
+			// show debit_to in print format
+			if(!this.frm.doc.customer && this.frm.doc.debit_to) {
+				this.frm.set_df_property("debit_to", "print_hide", 0);
 			}
 		}
-		// defined in sales_common.js
-		var callback1 = function(doc, dt, dn) {
-			//for previously created sales invoice, set required field related to pos	
-			cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
+	},
+	
+	refresh: function(doc, dt, dn) {
+		this._super();
+		
+		cur_frm.cscript.is_opening(doc, dt, dn);
+
+		if(doc.docstatus==1) {
+			cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
+			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
+
+			if(doc.is_pos==1 && doc.update_stock!=1)
+				cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
+
+			if(doc.outstanding_amount!=0)
+				cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
+		}
+		cur_frm.cscript.hide_fields(doc, dt, dn);
+	},
+	
+	is_pos: function() {
+		if(cint(this.frm.doc.is_pos)) {
+			if(!this.frm.doc.company) {
+				this.frm.set_value("is_pos", 0);
+				msgprint(wn._("Please specify Company to proceed"));
+			} else {
+				var me = this;
+				this.frm.call({
+					doc: me.frm.doc,
+					method: "set_missing_values",
+				});
+			}
 		}
 		
-		if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1);
-		else cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
-	}
+		// TODO toggle display of fields
+	},
+	
+	debit_to: function() {
+		this.customer();
+	},
+	
+	allocated_amount: function() {
+		this.calculate_total_advance("Sales Invoice", "advance_adjustment_details");
+		this.frm.refresh_fields();
+	},
+	
+	write_off_outstanding_amount_automatically: function() {
+		if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
+			wn.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
+			// this will make outstanding amount 0
+			this.frm.set_value("write_off_amount", 
+				flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount"));
+		}
+		
+		this.frm.runclientscript("write_off_amount");
+	},
+	
+	write_off_amount: function() {
+		this.calculate_outstanding_amount();
+		this.frm.refresh_fields();
+	},
+	
+	paid_amount: function() {
+		this.write_off_outstanding_amount_automatically();
+	},
+});
 
-	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
-
-}
-
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_frm}));
 
 // Hide Fields
 // ------------
@@ -87,15 +125,12 @@
 		hide_field(par_flds);
 		unhide_field('payments_section');
 		for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], false);
-		for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (doc.update_stock==1?true:false));
 	} else {
 		hide_field('payments_section');
 		unhide_field(par_flds);
 		for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true);
-		for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false);
 	}
-
-	cur_frm.toggle_display("contact_section", doc.customer);
+	for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (cint(doc.update_stock)==1?true:false));
 
 	// India related fields
 	var cp = wn.control_panel;
@@ -104,50 +139,6 @@
 }
 
 
-// Refresh
-// -------
-cur_frm.cscript.refresh = function(doc, dt, dn) {
-	cur_frm.cscript.is_opening(doc, dt, dn);
-	erpnext.hide_naming_series();
-
-	// Show / Hide button
-	cur_frm.clear_custom_buttons();
-	if (!cur_frm.cscript.is_onload)	cur_frm.cscript.hide_price_list_currency(doc, dt, dn); 
-
-	if(doc.docstatus==1) {
-		cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
-		cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
-
-		if(doc.is_pos==1 && doc.update_stock!=1)
-			cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
-
-		if(doc.outstanding_amount!=0)
-			cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
-	}
-	cur_frm.cscript.hide_fields(doc, dt, dn);
-	
-}
-
-//fetch retail transaction related fields
-//--------------------------------------------
-cur_frm.cscript.is_pos = function(doc,dt,dn,callback){
-	cur_frm.cscript.hide_fields(doc, dt, dn);
-	if(doc.is_pos == 1){
-		if (!doc.company) {
-			msgprint("Please select company to proceed");
-			doc.is_pos = 0;
-			refresh_field('is_pos');
-		}
-		else {
-			var callback1 = function(r,rt){
-				if(callback) callback(doc, dt, dn);
-				cur_frm.refresh();
-			}
-			$c_obj(make_doclist(dt,dn),'set_pos_fields','',callback1);
-		}
-	}
-}
-
 cur_frm.cscript.mode_of_payment = function(doc) {
 	cur_frm.call({
 		method: "get_bank_cash_account",
@@ -159,94 +150,10 @@
 	cur_frm.cscript.hide_fields(doc, dt, dn);
 }
 
-cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
-	var d = locals[cdt][cdn];
-	if (!d.item_code) { msgprint("please enter item code first"); return };
-	if (d.warehouse) {
-		arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
-		get_server_fields('get_actual_qty',arg,'entries',doc,cdt,cdn,1);
-	}
-}
-
-
-
-//Customer
-cur_frm.cscript.customer = function(doc,dt,dn,onload) {
-	cur_frm.toggle_display("contact_section", doc.customer);
-	
-	var pl = doc.price_list_name;
-	var callback = function(r,rt) {
-			var callback2 = function(doc, dt, dn) {
-				doc = locals[dt][dn];
-				if(doc.debit_to && doc.posting_date){
-					get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,
-					function(doc, dt, dn) {
-						cur_frm.refresh();
-						if (!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn);
-					});
-					
-				}
-			}
-			var doc = locals[cur_frm.doctype][cur_frm.docname];
-			get_server_fields('get_debit_to','','',doc, dt, dn, 0, callback2);
-	}
-	var args = onload ? 'onload':''
-	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', args, callback);
-	
-}
-
-
-
 cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
 	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
 }
 
-// Set Due Date = posting date + credit days
-cur_frm.cscript.debit_to = function(doc,dt,dn) {
-
-	var callback2 = function(r,rt) {
-			var doc = locals[cur_frm.doctype][cur_frm.docname];
-			cur_frm.refresh();
-	}
-
-	var callback = function(r,rt) {
-			var doc = locals[cur_frm.doctype][cur_frm.docname];
-			if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
-			cur_frm.toggle_display("contact_section", doc.customer);
-			
-			cur_frm.refresh();
-	}
-
-	if(doc.debit_to && doc.posting_date){
-		get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,callback);
-	}
-}
-
-
-
-//refresh advance amount
-//-------------------------------------------------
-
-
-cur_frm.cscript.write_off_outstanding_amount_automatically = function(doc) {
-	if (doc.write_off_outstanding_amount_automatically == 1) 
-		doc.write_off_amount = flt(doc.grand_total) - flt(doc.paid_amount);
-	
-	doc.outstanding_amount = flt(doc.grand_total) - flt(doc.paid_amount) - flt(doc.write_off_amount);
-	refresh_field(['write_off_amount', 'outstanding_amount']);
-}
-
-cur_frm.cscript.paid_amount = function(doc) {
-	cur_frm.cscript.write_off_outstanding_amount_automatically(doc);
-}
-
-cur_frm.cscript.write_off_amount = function(doc) {
-	cur_frm.cscript.write_off_outstanding_amount_automatically(doc);
-}
-
-
-//Set debit and credit to zero on adding new row
-//----------------------------------------------
 cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
 
 	cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
@@ -282,12 +189,6 @@
 
 
 
-// Allocated Amount in advances table
-// -----------------------------------
-cur_frm.cscript.allocated_amount = function(doc,cdt,cdn){
-	cur_frm.cscript.calc_adjustment_amount(doc,cdt,cdn);
-}
-
 //Make Delivery Note Button
 //-----------------------------
 
@@ -452,19 +353,6 @@
 	refresh_field(cur_frm.cscript.fname);
 }
 
-cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
-	var doc = locals[doc.doctype][doc.name];
-	var el = getchildren('Sales Invoice Advance',doc.name,'advance_adjustment_details');
-	var total_adjustment_amt = 0
-	for(var i in el) {
-			total_adjustment_amt += flt(el[i].allocated_amount)
-	}
-	doc.total_advance = flt(total_adjustment_amt);
-	doc.outstanding_amount = flt(doc.grand_total) - flt(total_adjustment_amt) - flt(doc.paid_amount) - flt(doc.write_off_amount);
-	refresh_many(['total_advance','outstanding_amount']);
-}
-
-
 // Make Journal Voucher
 // --------------------
 cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index c17654a..2d4de49 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -38,10 +38,38 @@
 		self.log = []
 		self.tname = 'Sales Invoice Item'
 		self.fname = 'entries'
+		self.status_updater = [{
+			'source_dt': 'Sales Invoice Item',
+			'target_field': 'billed_amt',
+			'target_ref_field': 'export_amount',
+			'target_dt': 'Sales Order Item',
+			'join_field': 'so_detail',
+			'target_parent_dt': 'Sales Order',
+			'target_parent_field': 'per_billed',
+			'source_field': 'export_amount',
+			'join_field': 'so_detail',
+			'percent_join_field': 'sales_order',
+			'status_field': 'billing_status',
+			'keyword': 'Billed'
+		}, 
+		{
+			'source_dt': 'Sales Invoice Item',
+			'target_dt': 'Delivery Note Item',
+			'join_field': 'dn_detail',
+			'target_field': 'billed_amt',
+			'target_parent_dt': 'Delivery Note',
+			'target_parent_field': 'per_billed',
+			'target_ref_field': 'export_amount',
+			'source_field': 'export_amount',
+			'percent_join_field': 'delivery_note',
+			'status_field': 'billing_status',
+			'keyword': 'Billed',
+			'no_tolerance': True,
+		}]
+		
 
 	def validate(self):
 		super(DocType, self).validate()
-		self.fetch_missing_values()
 		self.validate_posting_time()
 		self.so_dn_required()
 		self.validate_proj_cust()
@@ -50,7 +78,6 @@
 		sales_com_obj.check_active_sales_items(self)
 		sales_com_obj.check_conversion_rate(self)
 		sales_com_obj.validate_max_discount(self, 'entries')
-		sales_com_obj.get_allocated_sum(self)
 		sales_com_obj.validate_fiscal_year(self.doc.fiscal_year, 
 			self.doc.posting_date,'Posting Date')
 		self.validate_customer()
@@ -59,18 +86,22 @@
 		self.validate_fixed_asset_account()
 		self.clear_unallocated_advances("Sales Invoice Advance", "advance_adjustment_details")
 		self.add_remarks()
+
 		if cint(self.doc.is_pos):
 			self.validate_pos()
 			self.validate_write_off_account()
-			if cint(self.doc.update_stock):
-				sl = get_obj('Stock Ledger')
-				sl.validate_serial_no(self, 'entries')
-				sl.validate_serial_no(self, 'packing_details')
-				self.validate_item_code()
-				self.update_current_stock()
-				self.validate_delivery_note()
+
+		if cint(self.doc.update_stock):
+			sl = get_obj('Stock Ledger')
+			sl.validate_serial_no(self, 'entries')
+			sl.validate_serial_no(self, 'packing_details')
+			self.validate_item_code()
+			self.update_current_stock()
+			self.validate_delivery_note()
+
 		if not self.doc.is_opening:
 			self.doc.is_opening = 'No'
+
 		self.set_aging_date()
 		self.set_against_income_account()
 		self.validate_c_form()
@@ -80,16 +111,15 @@
 		
 		
 	def on_submit(self):
-		if cint(self.doc.is_pos) == 1:
-			if cint(self.doc.update_stock) == 1:
-				sl_obj = get_obj("Stock Ledger")
-				sl_obj.validate_serial_no_warehouse(self, 'entries')
-				sl_obj.validate_serial_no_warehouse(self, 'packing_details')
-				
-				sl_obj.update_serial_record(self, 'entries', is_submit = 1, is_incoming = 0)
-				sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
-				
-				self.update_stock_ledger(update_stock=1)
+		if cint(self.doc.update_stock) == 1:
+			sl_obj = get_obj("Stock Ledger")
+			sl_obj.validate_serial_no_warehouse(self, 'entries')
+			sl_obj.validate_serial_no_warehouse(self, 'packing_details')
+			
+			sl_obj.update_serial_record(self, 'entries', is_submit = 1, is_incoming = 0)
+			sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
+			
+			self.update_stock_ledger(update_stock=1)
 		else:
 			# Check for Approving Authority
 			if not self.doc.recurring_id:
@@ -98,7 +128,9 @@
 				
 		self.set_buying_amount()
 		self.check_prev_docstatus()
-		get_obj("Sales Common").update_prevdoc_detail(1,self)
+		
+		self.update_status_updater_args()
+		self.update_prevdoc_status()
 		
 		# this sequence because outstanding may get -ve
 		self.make_gl_entries()
@@ -114,13 +146,12 @@
 		self.update_time_log_batch(None)
 
 	def on_cancel(self):
-		if cint(self.doc.is_pos) == 1:
-			if cint(self.doc.update_stock) == 1:
-				sl = get_obj('Stock Ledger')
-				sl.update_serial_record(self, 'entries', is_submit = 0, is_incoming = 0)
-				sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
-				
-				self.update_stock_ledger(update_stock = -1)
+		if cint(self.doc.update_stock) == 1:
+			sl = get_obj('Stock Ledger')
+			sl.update_serial_record(self, 'entries', is_submit = 0, is_incoming = 0)
+			sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
+			
+			self.update_stock_ledger(update_stock = -1)
 		
 		sales_com_obj = get_obj(dt = 'Sales Common')
 		sales_com_obj.check_stop_sales_order(self)
@@ -128,33 +159,44 @@
 		from accounts.utils import remove_against_link_from_jv
 		remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_invoice")
 
-		sales_com_obj.update_prevdoc_detail(0, self)
+		self.update_status_updater_args()
+		self.update_prevdoc_status()
 		
 		self.make_cancel_gl_entries()
 		
+	def update_status_updater_args(self):
+		if cint(self.doc.is_pos) and cint(self.doc.update_stock):
+			self.status_updater.append({
+				'source_dt':'Sales Invoice Item',
+				'target_dt':'Sales Order Item',
+				'target_parent_dt':'Sales Order',
+				'target_parent_field':'per_delivered',
+				'target_field':'delivered_qty',
+				'target_ref_field':'qty',
+				'source_field':'qty',
+				'join_field':'so_detail',
+				'percent_join_field':'sales_order',
+				'status_field':'delivery_status',
+				'keyword':'Delivered',
+				'second_source_dt': 'Delivery Note Item',
+				'second_source_field': 'qty',
+				'second_join_field': 'prevdoc_detail_docname'
+			})
+		
 	def on_update_after_submit(self):
 		self.validate_recurring_invoice()
 		self.convert_to_recurring()
 		
-	def fetch_missing_values(self):
-		# fetch contact and address details for customer, if they are not mentioned
-		if not (self.doc.contact_person and self.doc.customer_address):
-			for fieldname, val in self.get_default_address_and_contact("customer").items():
-				if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
-					self.doc.fields[fieldname] = val
-					
-		# fetch missing item values
-		for item in self.doclist.get({"parentfield": "entries"}):
-			if item.fields.get("item_code"):
-				ret = get_obj('Sales Common').get_item_details(item.fields, self)
-				for fieldname, value in ret.items():
-					if self.meta.get_field(fieldname, parentfield="entries") and \
-						not item.fields.get(fieldname):
-							item.fields[fieldname] = value
+	def set_missing_values(self, for_validate=False):
+		super(DocType, self).set_missing_values(for_validate)
+		self.set_pos_fields(for_validate)
 		
-		# fetch pos details, if they are not fetched
-		if cint(self.doc.is_pos):
-			self.set_pos_fields(for_validate=True)
+	def set_customer_defaults(self):
+		# TODO cleanup these methods
+		self.doc.fields.update(self.get_debit_to())
+		self.get_cust_and_due_date()
+		
+		super(DocType, self).set_customer_defaults()
 			
 	def update_time_log_batch(self, sales_invoice):
 		for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
@@ -175,10 +217,11 @@
 		"""Set retail related fields from pos settings"""
 		if cint(self.doc.is_pos) != 1:
 			return
+		
+		from selling.utils import get_pos_settings, apply_pos_settings	
+		pos = get_pos_settings(self.doc.company)
 			
-		if self.pos_settings:
-			pos = self.pos_settings[0]
-			
+		if pos:
 			self.doc.conversion_rate = flt(pos.conversion_rate)
 			
 			if not self.doc.debit_to:
@@ -191,21 +234,24 @@
 				'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
 					if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
 						self.doc.fields[fieldname] = pos.get(fieldname)
+						
+			if not for_validate:
+				self.doc.update_stock = cint(pos.get("update_stock"))
 
 			# set pos values in items
 			for item in self.doclist.get({"parentfield": "entries"}):
 				if item.fields.get('item_code'):
-					for fieldname, val in self.apply_pos_settings(item.fields).items():
+					for fieldname, val in apply_pos_settings(pos, item.fields).items():
 						if (not for_validate) or (for_validate and not item.fields.get(fieldname)):
 							item.fields[fieldname] = val
 
 			# fetch terms	
 			if self.doc.tc_name and not self.doc.terms:
-				self.get_tc_details()
+				self.doc.terms = webnotes.conn.get_value("Terms and Conditions", self.doc.tc_name, "terms")
 			
 			# fetch charges
 			if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
-				self.get_other_charges()
+				self.set_taxes()
 
 	def get_customer_account(self):
 		"""Get Account Head to which amount needs to be Debited based on Customer"""
@@ -274,86 +320,6 @@
 			
 		ret = self.get_debit_to()
 		self.doc.debit_to = ret.get('debit_to')
-					
-					
-	def load_default_accounts(self):
-		"""
-			Loads default accounts from items, customer when called from mapper
-		"""
-		self.get_income_expense_account('entries')
-		
-		
-	def get_income_expense_account(self,doctype):		
-		for d in getlist(self.doclist, doctype):			
-			if d.item_code:
-				item = webnotes.conn.get_value("Item", d.item_code, ["default_income_account", 
-					"default_sales_cost_center", "purchase_account"], as_dict=True)
-				d.income_account = item['default_income_account'] or ""
-				d.cost_center = item['default_sales_cost_center'] or ""
-				
-				if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \
-						and cint(self.doc.is_pos) and cint(self.doc.update_stock):
-					d.expense_account = item['purchase_account'] or ""
-
-	def get_item_details(self, args=None):
-		import json
-		args = args and json.loads(args) or {}
-		if args.get('item_code'):
-			ret = get_obj('Sales Common').get_item_details(args, self)
-			
-			if cint(self.doc.is_pos) == 1 and self.pos_settings:
-				ret = self.apply_pos_settings(args, ret)
-			
-			return ret
-		
-		elif cint(self.doc.is_pos) == 1 and self.pos_settings:
-			for doc in self.doclist.get({"parentfield": "entries"}):
-				if doc.fields.get('item_code'):
-					ret = self.apply_pos_settings(doc.fields)
-					for r in ret:
-						if not doc.fields.get(r):
-							doc.fields[r] = ret[r]		
-
-	@property
-	def pos_settings(self):
-		if not hasattr(self, "_pos_settings"):
-			dtl = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s 
-				and company = %s""", (webnotes.session['user'], self.doc.company), as_dict=1)			 
-			if not dtl:
-				dtl = webnotes.conn.sql("""select * from `tabPOS Setting` 
-					where ifnull(user,'') = '' and company = %s""", self.doc.company, as_dict=1)
-			self._pos_settings = dtl
-			
-		return self._pos_settings
-
-	def apply_pos_settings(self, args, ret=None):
-		if not ret: ret = {}
-		
-		pos = self.pos_settings[0]
-		
-		item = webnotes.conn.sql("""select default_income_account, default_sales_cost_center, 
-			default_warehouse, purchase_account from tabItem where name = %s""", 
-			args.get('item_code'), as_dict=1)
-		
-		if item:
-			item = item[0]
-			
-			ret.update({
-				"income_account": item.get("default_income_account") \
-					or pos.get("income_account") or args.get("income_account"),
-				"cost_center": item.get("default_sales_cost_center") \
-					or pos.get("cost_center") or args.get("cost_center"),
-				"warehouse": item.get("default_warehouse") \
-					or pos.get("warehouse") or args.get("warehouse"),
-				"expense_account": item.get("purchase_account") \
-					or pos.get("expense_account") or args.get("expense_account")
-			})
-			
-			if ret.get("warehouse"):
-				ret["actual_qty"] = flt(webnotes.conn.get_value("Bin",
-					{"item_code": args.get("item_code"), "warehouse": ret.get("warehouse")},
-					"actual_qty"))
-		return ret
 
 	def get_barcode_details(self, barcode):
 		return get_obj('Sales Common').get_barcode_details(barcode)
@@ -373,19 +339,6 @@
 		"""Get Commission rate of Sales Partner"""
 		return get_obj('Sales Common').get_comm_rate(sales_partner, self)	
 	
-	
-	def get_tc_details(self):
-		return get_obj('Sales Common').get_tc_details(self)
-
-
-	def load_default_taxes(self):
-		self.doclist = get_obj('Sales Common').load_default_taxes(self)
-
-
-	def get_other_charges(self):
-		self.doclist = get_obj('Sales Common').get_other_charges(self)
-
-
 	def get_advances(self):
 		super(DocType, self).get_advances(self.doc.debit_to, 
 			"Sales Invoice Advance", "advance_adjustment_details", "credit")
@@ -534,13 +487,13 @@
 	def validate_item_code(self):
 		for d in getlist(self.doclist, 'entries'):
 			if not d.item_code:
-				msgprint("Please enter Item Code at line no : %s to update stock for POS or remove check from Update Stock in Basic Info Tab." % (d.idx))
-				raise Exception
+				msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx),
+				raise_exception=True)
 				
 	def validate_delivery_note(self):
 		for d in self.doclist.get({"parentfield": "entries"}):
 			if d.delivery_note:
-				msgprint("""POS can not be made against Delivery Note""", raise_exception=1)
+				msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1)
 
 
 	def validate_write_off_account(self):
@@ -606,36 +559,28 @@
 
 
 	def on_update(self):
-		# Set default warehouse from pos setting
-		if cint(self.doc.is_pos) == 1:
-			if cint(self.doc.update_stock) == 1:
+		if cint(self.doc.update_stock) == 1:
+			# Set default warehouse from pos setting
+			if cint(self.doc.is_pos) == 1:
 				w = self.get_warehouse()
 				if w:
 					for d in getlist(self.doclist, 'entries'):
 						if not d.warehouse:
 							d.warehouse = cstr(w)
-							
-				self.make_packing_list()
-			else:
-				self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
 
-			if flt(self.doc.paid_amount) == 0:
-				if self.doc.cash_bank_account: 
-					webnotes.conn.set(self.doc, 'paid_amount', 
-						(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
-				else:
-					# show message that the amount is not paid
-					webnotes.conn.set(self.doc,'paid_amount',0)
-					webnotes.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
+				if flt(self.doc.paid_amount) == 0:
+					if self.doc.cash_bank_account: 
+						webnotes.conn.set(self.doc, 'paid_amount', 
+							(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
+					else:
+						# show message that the amount is not paid
+						webnotes.conn.set(self.doc,'paid_amount',0)
+						webnotes.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
 
+			self.make_packing_list()
 		else:
 			self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
 			webnotes.conn.set(self.doc,'paid_amount',0)
-
-		webnotes.conn.set(self.doc, 'outstanding_amount', 
-			flt(self.doc.grand_total) - flt(self.doc.total_advance) - 
-			flt(self.doc.paid_amount) - flt(self.doc.write_off_amount))
-
 		
 	def check_prev_docstatus(self):
 		for d in getlist(self.doclist,'entries'):
@@ -689,15 +634,6 @@
 		
 		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
 		
-	def get_actual_qty(self,args):
-		args = eval(args)
-		actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
-		ret = {
-			 'actual_qty' : actual_qty and flt(actual_qty[0]['actual_qty']) or 0
-		}
-		return ret
-
-
 	def make_gl_entries(self):
 		from accounts.general_ledger import make_gl_entries, merge_similar_entries
 		
@@ -742,7 +678,7 @@
 						"against": self.doc.debit_to,
 						"credit": flt(tax.tax_amount),
 						"remarks": self.doc.remarks,
-						"cost_center": tax.cost_center_other_charges
+						"cost_center": tax.cost_center
 					})
 				)
 				
@@ -762,7 +698,7 @@
 				
 		# expense account gl entries
 		if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \
-				and cint(self.doc.is_pos) and cint(self.doc.update_stock):
+				and cint(self.doc.update_stock):
 			
 			for item in self.doclist.get({"parentfield": "entries"}):
 				self.check_expense_account(item)
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index a2c422f..f5eb356 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-04-19 11:00:14", 
+  "creation": "2013-05-24 19:29:05", 
   "docstatus": 0, 
-  "modified": "2013-04-22 11:59:28", 
+  "modified": "2013-06-05 18:53:03", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -10,6 +10,7 @@
   "allow_attach": 1, 
   "autoname": "naming_series:", 
   "doctype": "DocType", 
+  "document_type": "Transaction", 
   "is_submittable": 1, 
   "module": "Accounts", 
   "name": "__common__", 
@@ -30,7 +31,9 @@
   "parent": "Sales Invoice", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -46,15 +49,6 @@
   "read_only": 0
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "column_break0", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "print_hide": 0, 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
   "description": "To manage multiple series please go to Setup > Manage Series", 
   "doctype": "DocField", 
   "fieldname": "naming_series", 
@@ -69,27 +63,6 @@
   "reqd": 1
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "is_pos", 
-  "fieldtype": "Check", 
-  "label": "Is POS", 
-  "oldfieldname": "is_pos", 
-  "oldfieldtype": "Check", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "depends_on": "eval:doc.is_pos==1", 
-  "doctype": "DocField", 
-  "fieldname": "update_stock", 
-  "fieldtype": "Check", 
-  "label": "Update Stock", 
-  "oldfieldname": "update_stock", 
-  "oldfieldtype": "Check", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
   "description": "The account to which you will pay (have paid) the money to.", 
   "doctype": "DocField", 
   "fieldname": "debit_to", 
@@ -118,10 +91,11 @@
   "read_only": 0
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "customer_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Name", 
   "oldfieldname": "customer_name", 
@@ -129,34 +103,38 @@
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -169,6 +147,32 @@
   "read_only": 0
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "amended_from", 
+  "fieldtype": "Link", 
+  "label": "Amended From", 
+  "no_copy": 1, 
+  "oldfieldname": "amended_from", 
+  "oldfieldtype": "Link", 
+  "options": "Sales Invoice", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "company", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Company", 
+  "oldfieldname": "company", 
+  "oldfieldtype": "Link", 
+  "options": "Company", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 0
+ }, 
+ {
   "default": "Today", 
   "description": "The date at which current entry will get or has actually executed.", 
   "doctype": "DocField", 
@@ -204,6 +208,7 @@
   "fieldname": "mode_of_payment", 
   "fieldtype": "Select", 
   "label": "Mode of Payment", 
+  "no_copy": 0, 
   "oldfieldname": "mode_of_payment", 
   "oldfieldtype": "Select", 
   "options": "link:Mode of Payment", 
@@ -211,6 +216,99 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "is_pos", 
+  "fieldtype": "Check", 
+  "label": "Is POS", 
+  "oldfieldname": "is_pos", 
+  "oldfieldtype": "Check", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "update_stock", 
+  "fieldtype": "Check", 
+  "label": "Update Stock", 
+  "oldfieldname": "update_stock", 
+  "oldfieldtype": "Check", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "currency_section", 
+  "fieldtype": "Section Break", 
+  "label": "Price List and Currency", 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "currency", 
+  "fieldtype": "Link", 
+  "label": "Currency", 
+  "oldfieldname": "currency", 
+  "oldfieldtype": "Select", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "default": "1.00", 
+  "description": "Rate at which Customer Currency is converted to customer's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Conversion Rate", 
+  "oldfieldname": "conversion_rate", 
+  "oldfieldtype": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break2", 
+  "fieldtype": "Column Break", 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "price_list_name", 
+  "fieldtype": "Select", 
+  "label": "Price List", 
+  "oldfieldname": "price_list_name", 
+  "oldfieldtype": "Select", 
+  "options": "link:Price List", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "description": "Select the currency in which price list is maintained", 
+  "doctype": "DocField", 
+  "fieldname": "price_list_currency", 
+  "fieldtype": "Link", 
+  "label": "Price List Currency", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "description": "Rate at which Price list currency is converted to customer's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "plc_conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Price List Currency Conversion Rate", 
+  "no_copy": 0, 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "items", 
   "fieldtype": "Section Break", 
   "label": "Items", 
@@ -222,10 +320,28 @@
   "doctype": "DocField", 
   "fieldname": "entries", 
   "fieldtype": "Table", 
-  "label": "Entries", 
+  "label": "Sales Invoice Items", 
   "oldfieldname": "entries", 
   "oldfieldtype": "Table", 
   "options": "Sales Invoice Item", 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "packing_list", 
+  "fieldtype": "Section Break", 
+  "label": "Packing List", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "packing_details", 
+  "fieldtype": "Table", 
+  "label": "Packing Details", 
+  "options": "Delivery Note Packing Item", 
+  "print_hide": 1, 
   "read_only": 0
  }, 
  {
@@ -244,42 +360,6 @@
   "read_only": 0
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "col_break26", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "description": "Will be calculated automatically when you enter the details", 
-  "doctype": "DocField", 
-  "fieldname": "net_total", 
-  "fieldtype": "Currency", 
-  "label": "Net Total*", 
-  "oldfieldname": "net_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "reqd": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "recalculate_values", 
-  "fieldtype": "Button", 
-  "label": "Re-Calculate Values", 
-  "oldfieldtype": "Button", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break25", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
   "description": "Select Items from Sales Order", 
   "doctype": "DocField", 
   "fieldname": "sales_order_main", 
@@ -314,85 +394,43 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "currency_section", 
-  "fieldtype": "Section Break", 
-  "label": "Price List and Currency", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break27", 
+  "fieldname": "col_break25", 
   "fieldtype": "Column Break", 
   "read_only": 0, 
   "width": "50%"
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "price_list_name", 
-  "fieldtype": "Select", 
-  "label": "Price List", 
-  "oldfieldname": "price_list_name", 
-  "oldfieldtype": "Select", 
-  "options": "link:Price List", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1
- }, 
- {
-  "description": "Select the currency in which price list is maintained", 
-  "doctype": "DocField", 
-  "fieldname": "price_list_currency", 
-  "fieldtype": "Link", 
-  "label": "Price List Currency", 
-  "options": "Currency", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1
- }, 
- {
-  "description": "Rate at which Price list currency is converted to customer's base currency", 
-  "doctype": "DocField", 
-  "fieldname": "plc_conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Price List Currency Conversion Rate", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1
+  "fieldname": "net_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Net Total (Export)", 
+  "options": "currency", 
+  "print_hide": 0, 
+  "read_only": 1
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break2", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "currency", 
-  "fieldtype": "Link", 
-  "label": "Currency", 
-  "oldfieldname": "currency", 
-  "oldfieldtype": "Select", 
-  "options": "Currency", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1
- }, 
- {
-  "default": "1.00", 
-  "description": "Rate at which Customer Currency is converted to customer's base currency", 
-  "doctype": "DocField", 
-  "fieldname": "conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Conversion Rate", 
-  "oldfieldname": "conversion_rate", 
+  "fieldname": "net_total", 
+  "fieldtype": "Currency", 
+  "label": "Net Total*", 
+  "oldfieldname": "net_total", 
   "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
   "print_hide": 1, 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 1
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "recalculate_values", 
+  "fieldtype": "Button", 
+  "label": "Re-Calculate Values", 
+  "oldfieldtype": "Button", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "taxes", 
   "fieldtype": "Section Break", 
   "label": "Taxes and Charges", 
@@ -412,6 +450,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_38", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_charges", 
   "fieldtype": "Button", 
   "label": "Get Taxes and Charges", 
@@ -420,6 +463,11 @@
   "read_only": 0
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "section_break_40", 
+  "fieldtype": "Section Break"
+ }, 
+ {
   "allow_on_submit": 1, 
   "doctype": "DocField", 
   "fieldname": "other_charges", 
@@ -432,15 +480,29 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "calculate_charges", 
-  "fieldtype": "Button", 
-  "label": "Calculate Taxes and Charges", 
-  "oldfieldtype": "Button", 
+  "fieldname": "other_charges_calculation", 
+  "fieldtype": "HTML", 
+  "label": "Taxes and Charges Calculation", 
+  "oldfieldtype": "HTML", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_43", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "other_charges_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Total Taxes and Charges (Export)", 
+  "options": "currency", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges_total", 
   "fieldtype": "Currency", 
   "label": "Total Taxes and Charges", 
@@ -452,10 +514,15 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "other_charges_calculation", 
-  "fieldtype": "HTML", 
-  "label": "Taxes and Charges Calculation", 
-  "oldfieldtype": "HTML", 
+  "fieldname": "column_break_45", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "calculate_charges", 
+  "fieldtype": "Button", 
+  "label": "Calculate Taxes and Charges", 
+  "oldfieldtype": "Button", 
   "print_hide": 1, 
   "read_only": 0
  }, 
@@ -470,6 +537,61 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "grand_total_export", 
+  "fieldtype": "Currency", 
+  "in_list_view": 1, 
+  "label": "Grand Total (Export)", 
+  "oldfieldname": "grand_total_export", 
+  "oldfieldtype": "Currency", 
+  "options": "currency", 
+  "print_hide": 0, 
+  "read_only": 1, 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rounded_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Rounded Total (Export)", 
+  "oldfieldname": "rounded_total_export", 
+  "oldfieldtype": "Currency", 
+  "options": "currency", 
+  "print_hide": 0, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "in_words_export", 
+  "fieldtype": "Data", 
+  "label": "In Words (Export)", 
+  "oldfieldname": "in_words_export", 
+  "oldfieldtype": "Data", 
+  "print_hide": 0, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "gross_profit", 
+  "fieldtype": "Currency", 
+  "label": "Gross Profit", 
+  "oldfieldname": "gross_profit", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "gross_profit_percent", 
+  "fieldtype": "Float", 
+  "label": "Gross Profit (%)", 
+  "oldfieldname": "gross_profit_percent", 
+  "oldfieldtype": "Currency", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "column_break5", 
   "fieldtype": "Column Break", 
   "oldfieldtype": "Column Break", 
@@ -539,67 +661,33 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break6", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
+  "fieldname": "advances", 
+  "fieldtype": "Section Break", 
+  "label": "Advances", 
+  "oldfieldtype": "Section Break", 
   "print_hide": 1, 
-  "read_only": 0, 
-  "width": "50%"
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "grand_total_export", 
-  "fieldtype": "Currency", 
-  "in_list_view": 1, 
-  "label": "Grand Total (Export)", 
-  "oldfieldname": "grand_total_export", 
-  "oldfieldtype": "Currency", 
-  "options": "currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "reqd": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "rounded_total_export", 
-  "fieldtype": "Currency", 
-  "label": "Rounded Total (Export)", 
-  "oldfieldname": "rounded_total_export", 
-  "oldfieldtype": "Currency", 
-  "options": "currency", 
-  "print_hide": 0, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "in_words_export", 
-  "fieldtype": "Data", 
-  "label": "In Words (Export)", 
-  "oldfieldname": "in_words_export", 
-  "oldfieldtype": "Data", 
-  "print_hide": 0, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "gross_profit", 
-  "fieldtype": "Currency", 
-  "label": "Gross Profit", 
-  "oldfieldname": "gross_profit", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
+  "fieldname": "get_advances_received", 
+  "fieldtype": "Button", 
+  "label": "Get Advances Received", 
+  "oldfieldtype": "Button", 
+  "options": "get_advances", 
   "print_hide": 1, 
-  "read_only": 1
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "gross_profit_percent", 
-  "fieldtype": "Float", 
-  "label": "Gross Profit (%)", 
-  "oldfieldname": "gross_profit_percent", 
-  "oldfieldtype": "Currency", 
+  "fieldname": "advance_adjustment_details", 
+  "fieldtype": "Table", 
+  "label": "Sales Invoice Advance", 
+  "oldfieldname": "advance_adjustment_details", 
+  "oldfieldtype": "Table", 
+  "options": "Sales Invoice Advance", 
   "print_hide": 1, 
-  "read_only": 1
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -700,23 +788,22 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_71", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
   "oldfieldtype": "Button", 
-  "options": "get_tc_details", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1, 
-  "read_only": 0
+  "fieldname": "section_break_73", 
+  "fieldtype": "Section Break"
  }, 
  {
   "doctype": "DocField", 
@@ -728,14 +815,39 @@
   "read_only": 0
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_section", 
   "fieldtype": "Section Break", 
+  "hidden": 0, 
   "label": "Contact Info", 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "territory", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Territory", 
+  "options": "Territory", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "customer_group", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Customer Group", 
+  "options": "Customer Group", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "search_index": 0
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "col_break23", 
   "fieldtype": "Column Break", 
   "read_only": 0, 
@@ -761,36 +873,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "col_break24", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "territory", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Territory", 
-  "options": "Territory", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "customer_group", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Customer Group", 
-  "options": "Customer Group", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "more_info", 
   "fieldtype": "Section Break", 
   "label": "More Info", 
@@ -799,13 +881,40 @@
   "read_only": 0
  }, 
  {
+  "description": "Track this Sales Invoice against any Project", 
   "doctype": "DocField", 
-  "fieldname": "column_break7", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "print_hide": 1, 
+  "fieldname": "project_name", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Project Name", 
+  "oldfieldname": "project_name", 
+  "oldfieldtype": "Link", 
+  "options": "Project", 
   "read_only": 0, 
-  "width": "50%"
+  "search_index": 1
+ }, 
+ {
+  "depends_on": "eval:doc.source == 'Campaign'", 
+  "doctype": "DocField", 
+  "fieldname": "campaign", 
+  "fieldtype": "Link", 
+  "label": "Campaign", 
+  "oldfieldname": "campaign", 
+  "oldfieldtype": "Link", 
+  "options": "Campaign", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "source", 
+  "fieldtype": "Select", 
+  "label": "Source", 
+  "oldfieldname": "source", 
+  "oldfieldtype": "Select", 
+  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
+  "print_hide": 1, 
+  "read_only": 0
  }, 
  {
   "default": "No", 
@@ -823,40 +932,6 @@
   "search_index": 0
  }, 
  {
-  "description": "Actual Invoice Date", 
-  "doctype": "DocField", 
-  "fieldname": "aging_date", 
-  "fieldtype": "Date", 
-  "label": "Aging Date", 
-  "oldfieldname": "aging_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "posting_time", 
-  "fieldtype": "Time", 
-  "label": "Posting Time", 
-  "no_copy": 1, 
-  "oldfieldname": "posting_time", 
-  "oldfieldtype": "Time", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "allow_on_submit": 1, 
-  "doctype": "DocField", 
-  "fieldname": "letter_head", 
-  "fieldtype": "Select", 
-  "label": "Letter Head", 
-  "oldfieldname": "letter_head", 
-  "oldfieldtype": "Select", 
-  "options": "link:Letter Head", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "c_form_applicable", 
   "fieldtype": "Select", 
@@ -878,29 +953,24 @@
   "read_only": 1
  }, 
  {
-  "depends_on": "eval:doc.source == 'Campaign'", 
   "doctype": "DocField", 
-  "fieldname": "campaign", 
-  "fieldtype": "Link", 
-  "label": "Campaign", 
-  "oldfieldname": "campaign", 
-  "oldfieldtype": "Link", 
-  "options": "Campaign", 
+  "fieldname": "column_break8", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
-  "description": "Track this Sales Invoice against any Project", 
+  "allow_on_submit": 1, 
   "doctype": "DocField", 
-  "fieldname": "project_name", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Project Name", 
-  "oldfieldname": "project_name", 
-  "oldfieldtype": "Link", 
-  "options": "Project", 
-  "read_only": 0, 
-  "search_index": 1
+  "fieldname": "letter_head", 
+  "fieldtype": "Select", 
+  "label": "Letter Head", 
+  "oldfieldname": "letter_head", 
+  "oldfieldtype": "Select", 
+  "options": "link:Letter Head", 
+  "print_hide": 1, 
+  "read_only": 0
  }, 
  {
   "allow_on_submit": 1, 
@@ -918,39 +988,28 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break8", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
+  "fieldname": "posting_time", 
+  "fieldtype": "Time", 
+  "label": "Posting Time", 
+  "no_copy": 1, 
+  "oldfieldname": "posting_time", 
+  "oldfieldtype": "Time", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
+  "description": "Actual Invoice Date", 
   "doctype": "DocField", 
-  "fieldname": "source", 
-  "fieldtype": "Select", 
-  "label": "Source", 
-  "oldfieldname": "source", 
-  "oldfieldtype": "Select", 
-  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
+  "fieldname": "aging_date", 
+  "fieldtype": "Date", 
+  "label": "Aging Date", 
+  "oldfieldname": "aging_date", 
+  "oldfieldtype": "Date", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "company", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Company", 
-  "oldfieldname": "company", 
-  "oldfieldtype": "Link", 
-  "options": "Company", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "fiscal_year", 
   "fieldtype": "Select", 
   "in_filter": 1, 
@@ -966,41 +1025,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "amended_from", 
-  "fieldtype": "Link", 
-  "label": "Amended From", 
-  "no_copy": 1, 
-  "oldfieldname": "amended_from", 
-  "oldfieldtype": "Link", 
-  "options": "Sales Invoice", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "description": "The date at which current entry is corrected in the system.", 
-  "doctype": "DocField", 
-  "fieldname": "amendment_date", 
-  "fieldtype": "Date", 
-  "label": "Amendment Date", 
-  "no_copy": 1, 
-  "oldfieldname": "amendment_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "depends_on": "eval:!doc.__islocal", 
-  "doctype": "DocField", 
-  "fieldname": "cancel_reason", 
-  "fieldtype": "Data", 
-  "label": "Cancel Reason", 
-  "oldfieldname": "cancel_reason", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "remarks", 
   "fieldtype": "Small Text", 
   "label": "Remarks", 
@@ -1013,53 +1037,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "advances", 
-  "fieldtype": "Section Break", 
-  "label": "Advances", 
-  "oldfieldtype": "Section Break", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "get_advances_received", 
-  "fieldtype": "Button", 
-  "label": "Get Advances Received", 
-  "oldfieldtype": "Button", 
-  "options": "get_advances", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "advance_adjustment_details", 
-  "fieldtype": "Table", 
-  "label": "Sales Invoice Advance", 
-  "oldfieldname": "advance_adjustment_details", 
-  "oldfieldtype": "Table", 
-  "options": "Sales Invoice Advance", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "packing_list", 
-  "fieldtype": "Section Break", 
-  "label": "Packing List", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "packing_details", 
-  "fieldtype": "Table", 
-  "label": "Packing Details", 
-  "options": "Delivery Note Packing Item", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "sales_team_section_break", 
   "fieldtype": "Section Break", 
   "label": "Sales Team", 
@@ -1288,8 +1265,15 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
+  "role": "Accounts Manager", 
+  "submit": 1, 
+  "write": 1
+ }, 
+ {
+  "amend": 1, 
+  "cancel": 0, 
+  "create": 1, 
+  "doctype": "DocPerm", 
   "role": "Accounts User", 
   "submit": 1, 
   "write": 1
@@ -1297,8 +1281,6 @@
  {
   "doctype": "DocPerm", 
   "match": "customer", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Customer"
- }, 
+ }
 ]
\ No newline at end of file
diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py
index b46cdd1..dfc61eb 100644
--- a/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1,12 +1,226 @@
 import webnotes
-import unittest
+import unittest, json
+from webnotes.utils import flt, cint
 
 class TestSalesInvoice(unittest.TestCase):
 	def make(self):
-		w = webnotes.bean(webnotes.copy_doclist(test_records[0]))
+		w = webnotes.bean(copy=test_records[0])
 		w.insert()
 		w.submit()
 		return w
+		
+	def test_sales_invoice_calculation_base_currency(self):
+		si = webnotes.bean(copy=test_records[2])
+		si.run_method("calculate_taxes_and_totals")
+		si.insert()
+		
+		expected_values = {
+			"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount", 
+				"base_ref_rate", "basic_rate", "amount"],
+			"_Test Item Home Desktop 100": [50, 0, 50, 500, 50, 50, 500],
+			"_Test Item Home Desktop 200": [150, 0, 150, 750, 150, 150, 750],
+		}
+		
+		# check if children are saved
+		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+			len(expected_values)-1)
+		
+		# check if item values are calculated
+		for d in si.doclist.get({"parentfield": "entries"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
+		
+		# check net total
+		self.assertEquals(si.doc.net_total, 1250)
+		self.assertEquals(si.doc.net_total_export, 1250)
+		
+		# check tax calculation
+		expected_values = {
+			"keys": ["tax_amount", "total"],
+			"_Test Account Shipping Charges - _TC": [100, 1350],
+			"_Test Account Customs Duty - _TC": [125, 1475],
+			"_Test Account Excise Duty - _TC": [140, 1615],
+			"_Test Account Education Cess - _TC": [2.8, 1617.8],
+			"_Test Account S&H Education Cess - _TC": [1.4, 1619.2],
+			"_Test Account CST - _TC": [32.38, 1651.58],
+			"_Test Account VAT - _TC": [156.25, 1807.83],
+			"_Test Account Discount - _TC": [-180.78, 1627.05]
+		}
+		
+		for d in si.doclist.get({"parentfield": "other_charges"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
+				
+		self.assertEquals(si.doc.grand_total, 1627.05)
+		self.assertEquals(si.doc.grand_total_export, 1627.05)
+		
+	def test_sales_invoice_calculation_export_currency(self):
+		si = webnotes.bean(copy=test_records[2])
+		si.doc.currency = "USD"
+		si.doc.conversion_rate = 50
+		si.doclist[1].export_rate = 1
+		si.doclist[1].ref_rate = 1
+		si.doclist[2].export_rate = 3
+		si.doclist[2].ref_rate = 3
+		si.run_method("calculate_taxes_and_totals")
+		si.insert()
+		
+		expected_values = {
+			"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount", 
+				"base_ref_rate", "basic_rate", "amount"],
+			"_Test Item Home Desktop 100": [1, 0, 1, 10, 50, 50, 500],
+			"_Test Item Home Desktop 200": [3, 0, 3, 15, 150, 150, 750],
+		}
+		
+		# check if children are saved
+		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+			len(expected_values)-1)
+		
+		# check if item values are calculated
+		for d in si.doclist.get({"parentfield": "entries"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
+		
+		# check net total
+		self.assertEquals(si.doc.net_total, 1250)
+		self.assertEquals(si.doc.net_total_export, 25)
+		
+		# check tax calculation
+		expected_values = {
+			"keys": ["tax_amount", "total"],
+			"_Test Account Shipping Charges - _TC": [100, 1350],
+			"_Test Account Customs Duty - _TC": [125, 1475],
+			"_Test Account Excise Duty - _TC": [140, 1615],
+			"_Test Account Education Cess - _TC": [2.8, 1617.8],
+			"_Test Account S&H Education Cess - _TC": [1.4, 1619.2],
+			"_Test Account CST - _TC": [32.38, 1651.58],
+			"_Test Account VAT - _TC": [156.25, 1807.83],
+			"_Test Account Discount - _TC": [-180.78, 1627.05]
+		}
+		
+		for d in si.doclist.get({"parentfield": "other_charges"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
+				
+		self.assertEquals(si.doc.grand_total, 1627.05)
+		self.assertEquals(si.doc.grand_total_export, 32.54)
+				
+	def test_inclusive_rate_validations(self):
+		si = webnotes.bean(copy=test_records[2])
+		for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
+			tax.idx = i+1
+		
+		si.doclist[1].ref_rate = 62.5
+		si.doclist[1].ref_rate = 191
+		for i in [3, 5, 6, 7, 8, 9]:
+			si.doclist[i].included_in_print_rate = 1
+		
+		# tax type "Actual" cannot be inclusive
+		self.assertRaises(webnotes.ValidationError, si.run_method, "calculate_taxes_and_totals")
+		
+		# taxes above included type 'On Previous Row Total' should also be included
+		si.doclist[3].included_in_print_rate = 0
+		self.assertRaises(webnotes.ValidationError, si.run_method, "calculate_taxes_and_totals")
+		
+	def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
+		# prepare
+		si = webnotes.bean(copy=test_records[3])
+		si.run_method("calculate_taxes_and_totals")
+		si.insert()
+		
+		expected_values = {
+			"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount", 
+				"base_ref_rate", "basic_rate", "amount"],
+			"_Test Item Home Desktop 100": [62.5, 0, 62.5, 625.0, 50, 50, 500],
+			"_Test Item Home Desktop 200": [190.66, 0, 190.66, 953.3, 150, 150, 750],
+		}
+		
+		# check if children are saved
+		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+			len(expected_values)-1)
+		
+		# check if item values are calculated
+		for d in si.doclist.get({"parentfield": "entries"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
+		
+		# check net total
+		self.assertEquals(si.doc.net_total, 1250)
+		self.assertEquals(si.doc.net_total_export, 1578.3)
+		
+		# check tax calculation
+		expected_values = {
+			"keys": ["tax_amount", "total"],
+			"_Test Account Excise Duty - _TC": [140, 1390],
+			"_Test Account Education Cess - _TC": [2.8, 1392.8],
+			"_Test Account S&H Education Cess - _TC": [1.4, 1394.2],
+			"_Test Account CST - _TC": [27.88, 1422.08],
+			"_Test Account VAT - _TC": [156.25, 1578.33],
+			"_Test Account Customs Duty - _TC": [125, 1703.33],
+			"_Test Account Shipping Charges - _TC": [100, 1803.33],
+			"_Test Account Discount - _TC": [-180.33, 1623]
+		}
+		
+		for d in si.doclist.get({"parentfield": "other_charges"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(flt(d.fields.get(k), 6), expected_values[d.account_head][i])
+		
+		self.assertEquals(si.doc.grand_total, 1623)
+		self.assertEquals(si.doc.grand_total_export, 1623)
+		
+	def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
+		# prepare
+		si = webnotes.bean(copy=test_records[3])
+		si.doc.currency = "USD"
+		si.doc.conversion_rate = 50
+		si.doclist[1].ref_rate = 55.56
+		si.doclist[1].adj_rate = 10
+		si.doclist[2].ref_rate = 187.5
+		si.doclist[2].adj_rate = 20
+		si.doclist[9].rate = 5000
+		
+		si.run_method("calculate_taxes_and_totals")
+		si.insert()
+		
+		expected_values = {
+			"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount", 
+				"base_ref_rate", "basic_rate", "amount"],
+			"_Test Item Home Desktop 100": [55.56, 10, 50, 500, 2222.11, 1999.9, 19999.0],
+			"_Test Item Home Desktop 200": [187.5, 20, 150, 750, 7375.66, 5900.53, 29502.65],
+		}
+		
+		# check if children are saved
+		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+			len(expected_values)-1)
+		
+		# check if item values are calculated
+		for d in si.doclist.get({"parentfield": "entries"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
+		
+		# check net total
+		self.assertEquals(si.doc.net_total, 49501.65)
+		self.assertEquals(si.doc.net_total_export, 1250)
+		
+		# check tax calculation
+		expected_values = {
+			"keys": ["tax_amount", "total"],
+			"_Test Account Excise Duty - _TC": [5540.22, 55041.87],
+			"_Test Account Education Cess - _TC": [110.81, 55152.68],
+			"_Test Account S&H Education Cess - _TC": [55.4, 55208.08],
+			"_Test Account CST - _TC": [1104.16, 56312.24],
+			"_Test Account VAT - _TC": [6187.71, 62499.95],
+			"_Test Account Customs Duty - _TC": [4950.17, 67450.12],
+			"_Test Account Shipping Charges - _TC": [5000, 72450.12],
+			"_Test Account Discount - _TC": [-7245.01, 65205.11]
+		}
+		
+		for d in si.doclist.get({"parentfield": "other_charges"}):
+			for i, k in enumerate(expected_values["keys"]):
+				self.assertEquals(flt(d.fields.get(k), 6), expected_values[d.account_head][i])
+		
+		self.assertEquals(si.doc.grand_total, 65205.11)
+		self.assertEquals(si.doc.grand_total_export, 1304.1)
 
 	def test_outstanding(self):
 		w = self.make()
@@ -103,7 +317,7 @@
 		pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
 		pos[0]["paid_amount"] = 600.0
 
-		si = webnotes.bean(pos)
+		si = webnotes.bean(copy=pos)
 		si.insert()
 		si.submit()
 		
@@ -113,7 +327,7 @@
 			si.doc.name, as_dict=1)[0]
 		self.assertTrue(sle)
 		self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], 
-			["_Test Item", "_Test Warehouse", -5.0])
+			["_Test Item", "_Test Warehouse", -1.0])
 		
 		# check gl entries
 		stock_in_hand_account = webnotes.conn.get_value("Company", "_Test Company", 
@@ -126,11 +340,11 @@
 		
 		expected_gl_entries = sorted([
 			[si.doc.debit_to, 630.0, 0.0],
-			[test_records[1][1]["income_account"], 0.0, 500.0],
-			[test_records[1][2]["account_head"], 0.0, 80.0],
-			[test_records[1][3]["account_head"], 0.0, 50.0],
-			[stock_in_hand_account, 0.0, 375.0],
-			[test_records[1][1]["expense_account"], 375.0, 0.0],
+			[pos[1]["income_account"], 0.0, 500.0],
+			[pos[2]["account_head"], 0.0, 80.0],
+			[pos[3]["account_head"], 0.0, 50.0],
+			[stock_in_hand_account, 0.0, 75.0],
+			[pos[1]["expense_account"], 75.0, 0.0],
 			[si.doc.debit_to, 0.0, 600.0],
 			["_Test Account Bank Account - _TC", 600.0, 0.0]
 		])
@@ -444,7 +658,7 @@
 			"description": "VAT", 
 			"doctype": "Sales Taxes and Charges", 
 			"parentfield": "other_charges",
-			"tax_amount": 30.0,
+			"rate": 6,
 		}, 
 		{
 			"account_head": "_Test Account Service Tax - _TC", 
@@ -452,7 +666,7 @@
 			"description": "Service Tax", 
 			"doctype": "Sales Taxes and Charges", 
 			"parentfield": "other_charges",
-			"tax_amount": 31.8,
+			"rate": 6.36,
 		},
 		{
 			"parentfield": "sales_team",
@@ -494,7 +708,7 @@
 			"description": "_Test Item", 
 			"doctype": "Sales Invoice Item", 
 			"parentfield": "entries",
-			"qty": 5.0,
+			"qty": 1.0,
 			"basic_rate": 500.0,
 			"amount": 500.0, 
 			"export_rate": 500.0, 
@@ -509,7 +723,7 @@
 			"description": "VAT", 
 			"doctype": "Sales Taxes and Charges", 
 			"parentfield": "other_charges",
-			"tax_amount": 80.0,
+			"rate": 16,
 		}, 
 		{
 			"account_head": "_Test Account Service Tax - _TC", 
@@ -517,7 +731,270 @@
 			"description": "Service Tax", 
 			"doctype": "Sales Taxes and Charges", 
 			"parentfield": "other_charges",
-			"tax_amount": 50.0,
+			"rate": 10
 		}
 	],
+	[
+		{
+			"naming_series": "_T-Sales Invoice-",
+			"company": "_Test Company", 
+			"conversion_rate": 1.0, 
+			"currency": "INR", 
+			"debit_to": "_Test Customer - _TC",
+			"customer": "_Test Customer",
+			"customer_name": "_Test Customer",
+			"doctype": "Sales Invoice", 
+			"due_date": "2013-01-23", 
+			"fiscal_year": "_Test Fiscal Year 2013", 
+			"grand_total_export": 0, 
+			"plc_conversion_rate": 1.0, 
+			"posting_date": "2013-01-23", 
+			"price_list_currency": "INR", 
+			"price_list_name": "_Test Price List", 
+			"territory": "_Test Territory",
+		},
+		# items
+		{
+			"doctype": "Sales Invoice Item",
+			"parentfield": "entries",
+			"item_code": "_Test Item Home Desktop 100",
+			"item_name": "_Test Item Home Desktop 100",
+			"qty": 10,
+			"ref_rate": 50,
+			"export_rate": 50,
+			"stock_uom": "_Test UOM",
+			"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
+			"income_account": "Sales - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+		
+		},
+		{
+			"doctype": "Sales Invoice Item",
+			"parentfield": "entries",
+			"item_code": "_Test Item Home Desktop 200",
+			"item_name": "_Test Item Home Desktop 200",
+			"qty": 5,
+			"ref_rate": 150,
+			"export_rate": 150,
+			"stock_uom": "_Test UOM",
+			"income_account": "Sales - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+		
+		},
+		# taxes
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "Actual",
+			"account_head": "_Test Account Shipping Charges - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Shipping Charges",
+			"rate": 100
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account Customs Duty - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Customs Duty",
+			"rate": 10
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account Excise Duty - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Excise Duty",
+			"rate": 12
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Amount",
+			"account_head": "_Test Account Education Cess - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Education Cess",
+			"rate": 2,
+			"row_id": 3
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Amount",
+			"account_head": "_Test Account S&H Education Cess - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "S&H Education Cess",
+			"rate": 1,
+			"row_id": 3
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Total",
+			"account_head": "_Test Account CST - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "CST",
+			"rate": 2,
+			"row_id": 5
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account VAT - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "VAT",
+			"rate": 12.5
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Total",
+			"account_head": "_Test Account Discount - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Discount",
+			"rate": -10,
+			"row_id": 7
+		},
+	],
+	[
+		{
+			"naming_series": "_T-Sales Invoice-",
+			"company": "_Test Company", 
+			"conversion_rate": 1.0, 
+			"currency": "INR", 
+			"debit_to": "_Test Customer - _TC",
+			"customer": "_Test Customer",
+			"customer_name": "_Test Customer",
+			"doctype": "Sales Invoice", 
+			"due_date": "2013-01-23", 
+			"fiscal_year": "_Test Fiscal Year 2013", 
+			"grand_total_export": 0, 
+			"plc_conversion_rate": 1.0, 
+			"posting_date": "2013-01-23", 
+			"price_list_currency": "INR", 
+			"price_list_name": "_Test Price List", 
+			"territory": "_Test Territory",
+		},
+		# items
+		{
+			"doctype": "Sales Invoice Item",
+			"parentfield": "entries",
+			"item_code": "_Test Item Home Desktop 100",
+			"item_name": "_Test Item Home Desktop 100",
+			"qty": 10,
+			"ref_rate": 62.5,
+			"export_rate": 62.5,
+			"stock_uom": "_Test UOM",
+			"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
+			"income_account": "Sales - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+		
+		},
+		{
+			"doctype": "Sales Invoice Item",
+			"parentfield": "entries",
+			"item_code": "_Test Item Home Desktop 200",
+			"item_name": "_Test Item Home Desktop 200",
+			"qty": 5,
+			"ref_rate": 190.66,
+			"export_rate": 190.66,
+			"stock_uom": "_Test UOM",
+			"income_account": "Sales - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+		
+		},
+		# taxes
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account Excise Duty - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Excise Duty",
+			"rate": 12,
+			"included_in_print_rate": 1,
+			"idx": 1
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Amount",
+			"account_head": "_Test Account Education Cess - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Education Cess",
+			"rate": 2,
+			"row_id": 1,
+			"included_in_print_rate": 1,
+			"idx": 2
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Amount",
+			"account_head": "_Test Account S&H Education Cess - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "S&H Education Cess",
+			"rate": 1,
+			"row_id": 1,
+			"included_in_print_rate": 1,
+			"idx": 3
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Total",
+			"account_head": "_Test Account CST - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "CST",
+			"rate": 2,
+			"row_id": 3,
+			"included_in_print_rate": 1,
+			"idx": 4
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account VAT - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "VAT",
+			"rate": 12.5,
+			"included_in_print_rate": 1,
+			"idx": 5
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Net Total",
+			"account_head": "_Test Account Customs Duty - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Customs Duty",
+			"rate": 10,
+			"idx": 6
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "Actual",
+			"account_head": "_Test Account Shipping Charges - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Shipping Charges",
+			"rate": 100,
+			"idx": 7
+		},
+		{
+			"doctype": "Sales Taxes and Charges",
+			"parentfield": "other_charges",
+			"charge_type": "On Previous Row Total",
+			"account_head": "_Test Account Discount - _TC",
+			"cost_center": "_Test Cost Center - _TC",
+			"description": "Discount",
+			"rate": -10,
+			"row_id": 7,
+			"idx": 8
+		},
+	],
 ]
\ No newline at end of file
diff --git a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
index 89c86f8..014a9f4 100644
--- a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
+++ b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-04-19 11:00:07", 
   "docstatus": 0, 
-  "modified": "2013-05-22 12:06:15", 
+  "modified": "2013-05-22 12:07:00", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -107,7 +107,7 @@
   "oldfieldtype": "Currency", 
   "options": "currency", 
   "print_hide": 1, 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0
  }, 
  {
@@ -163,7 +163,7 @@
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 1, 
   "search_index": 0
  }, 
diff --git a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt
index 161eb00..ba9f907 100644
--- a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt
+++ b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-02-22 01:27:41", 
+  "creation": "2013-04-24 11:39:32", 
   "docstatus": 0, 
-  "modified": "2013-04-17 14:05:18", 
+  "modified": "2013-05-28 11:59:02", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -50,7 +50,7 @@
  {
   "default": ":Company", 
   "doctype": "DocField", 
-  "fieldname": "cost_center_other_charges", 
+  "fieldname": "cost_center", 
   "fieldtype": "Link", 
   "label": "Cost Center", 
   "oldfieldname": "cost_center_other_charges", 
@@ -85,6 +85,7 @@
   "oldfieldname": "tax_amount", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
+  "read_only": 1, 
   "reqd": 0
  }, 
  {
@@ -129,34 +130,6 @@
   "search_index": 1
  }, 
  {
-  "description": "Cheating Field\nPlease do not delete ", 
-  "doctype": "DocField", 
-  "fieldname": "total_tax_amount", 
-  "fieldtype": "Currency", 
-  "hidden": 1, 
-  "label": "Total Tax Amount", 
-  "no_copy": 1, 
-  "oldfieldname": "total_tax_amount", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "report_hide": 1
- }, 
- {
-  "description": "Cheating Field\nPlease do not delete ", 
-  "doctype": "DocField", 
-  "fieldname": "total_amount", 
-  "fieldtype": "Currency", 
-  "hidden": 1, 
-  "label": "Total Amount", 
-  "no_copy": 1, 
-  "oldfieldname": "total_amount", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "report_hide": 1
- }, 
- {
   "allow_on_submit": 0, 
   "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", 
   "doctype": "DocField", 
diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
index 1e72010..5787427 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
@@ -140,7 +140,7 @@
   return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type in ("Tax", "Chargeable", "Income Account") AND tabAccount.company = "'+doc.company+'" AND  tabAccount.name LIKE "%s"'
 }
 
-cur_frm.fields_dict['other_charges'].grid.get_field("cost_center_other_charges").get_query = function(doc) {
+cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
 	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY	`tabCost Center`.`name` ASC LIMIT 50';
 }
 
diff --git a/accounts/page/accounts_browser/README.md b/accounts/page/accounts_browser/README.md
new file mode 100644
index 0000000..b879561
--- /dev/null
+++ b/accounts/page/accounts_browser/README.md
@@ -0,0 +1 @@
+Tree view browser for Chart of Accounts and Chart of Cost Centers
\ No newline at end of file
diff --git a/accounts/page/accounts_browser/accounts_browser.html b/accounts/page/accounts_browser/accounts_browser.html
deleted file mode 100644
index 91a1e26..0000000
--- a/accounts/page/accounts_browser/accounts_browser.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
-	<div class="appframe-area"></div>
-	<div class="layout-main">
-		<div class="tree-area"></div>
-		<hr>
-		<div class="well">
-			<h4>Quick Help</h4>
-			<ol>
-			<li>To add child nodes, explore tree and click on the node under which you want to add more nodes.
-			<li>Accounting Entries can be made against leaf nodes, called <b>Ledgers</b>. Entries against <b>Groups</b> are not allowed.
-			<li>Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.
-			<li><b>To create a Bank Account:</b> Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts) and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"
-			<li><b>To create a Tax Account:</b> Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties) and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.
-			</ol>
-			<p>Please setup your chart of accounts before you start Accounting Entries</p>
-		</div>
-	</div>
-</div>
\ No newline at end of file
diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js
index 2e8cc82..534201a 100644
--- a/accounts/page/accounts_browser/accounts_browser.js
+++ b/accounts/page/accounts_browser/accounts_browser.js
@@ -21,9 +21,37 @@
 // see ledger
 
 pscript['onload_Accounts Browser'] = function(wrapper){
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
-	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Accounts")
+	wn.ui.make_app_page({
+		parent: wrapper,
+		single_column: true
+	})
+
+	wrapper.appframe.add_module_icon("Accounts");
+
+	var main = $(wrapper).find(".layout-main"),
+		chart_area = $("<div>")
+			.css({"margin-bottom": "15px"})
+			.appendTo(main),
+		help_area = $('<div class="well">\
+		<h4>Quick Help</h4>\
+		<ol>\
+		<li>To add child nodes, explore tree and click on the node under which you \
+			want to add more nodes.\
+		<li>Accounting Entries can be made against leaf nodes, called <b>Ledgers</b>.\
+		 	Entries against <b>Groups</b> are not allowed.\
+		<li>Please do NOT create Account (Ledgers) for Customers and Suppliers. \
+			They are created directly from the Customer / Supplier masters.\
+		<li><b>To create a Bank Account:</b> Go to the appropriate group \
+			(usually Application of Funds > Current Assets > Bank Accounts)\
+			and create a new Account Ledger (by clicking on Add Child) of \
+			type "Bank or Cash"\
+		<li><b>To create a Tax Account:</b> Go to the appropriate group \
+			(usually Source of Funds > Current Liabilities > Taxes and Duties) \
+			and create a new Account Ledger (by clicking on Add Child) of type\
+			 "Tax" and do mention the Tax rate.\
+		</ol>\
+		<p>Please setup your chart of accounts before you start Accounting Entries</p>\
+	</div>').appendTo(main);
 	
 	if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
 		wrapper.appframe.add_button('New Company', function() { newdoc('Company'); },
@@ -35,13 +63,13 @@
 		}, 'icon-refresh');
 
 	// company-select
-	wrapper.$company_select = $('<select class="accbrowser-company-select"></select>')
+	wrapper.$company_select = wrapper.appframe.add_select("Company", [])
 		.change(function() {
 			var ctype = wn.get_route()[1] || 'Account';
-			erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), wrapper);
+			erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), 
+				chart_area.get(0));
 			pscript.set_title(wrapper, ctype, $(this).val());
 		})
-		.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
 		
 	// load up companies
 	wn.call({
@@ -77,7 +105,7 @@
 
 erpnext.AccountsChart = Class.extend({
 	init: function(ctype, company, wrapper) {
-		$(wrapper).find('.tree-area').empty();
+		$(wrapper).empty();
 		var me = this;
 		me.ctype = ctype;
 		me.can_create = wn.model.can_create(this.ctype);
@@ -87,7 +115,7 @@
 		
 		me.company = company;
 		this.tree = new wn.ui.Tree({
-			parent: $(wrapper).find('.tree-area'), 
+			parent: $(wrapper), 
 			label: company,
 			args: {ctype: ctype, comp: company},
 			method: 'accounts.page.accounts_browser.accounts_browser.get_children',
diff --git a/accounts/page/financial_analytics/financial_analytics.js b/accounts/page/financial_analytics/financial_analytics.js
index f714549..aac7076 100644
--- a/accounts/page/financial_analytics/financial_analytics.js
+++ b/accounts/page/financial_analytics/financial_analytics.js
@@ -25,7 +25,7 @@
 	erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Accounts")
+	wrapper.appframe.add_module_icon("Accounts")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/accounts/page/financial_statements/financial_statements.html b/accounts/page/financial_statements/financial_statements.html
index e6735fa..bc2fce0 100644
--- a/accounts/page/financial_statements/financial_statements.html
+++ b/accounts/page/financial_statements/financial_statements.html
@@ -1,28 +1,5 @@
-<div class="layout_wrapper">
+<div class="appframe col col-lg-12">
 <div id="fs_header"></div>
-<!--  table.statement td {    vertical-align: middle;  }  table.statement td select {    width: 100px;  }  table.stmt_table {    table-layout: fixed;    border-collapse: collapse;  }  table.stmt_table td {    vertical-align: middle;    padding: 2px;  }  td.stmt_level0 {    font-weight: bold;    font-size: 14px;    border-bottom: 1px solid #AAA;  }  td.stmt_level1 {    font-weight: bold;    font-size: 12px;  }  td.stmt_level2 {    font-size: 11px;  }  td.stmt_level3 {    font-size: 11px;  }  td.stmt_level4 {    font-size: 12px;    font-weight: bold;    border-bottom: 1px solid #000;  }  td.stmt_level5 {    color: BLUE;    font-size: 11px;  }  --> <!--
-<div style="border: 1px solid #cccccc; padding: 4px; margin-top: 8px; background-color: #eeeeee; width: 98%;">
-<table class="statement" border="0" cellspacing="2px">
-<tbody>
-<tr>
-<td>Statement:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_type"></select></td>
-<td>Company:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_company"></select></td>
-<td>Period Type:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_period"></select></td>
-<td>Fiscal Year:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_fiscal_year"></select></td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;">
-<div id="stmt_new"></div>
-</td>
-</tr>
-</tbody>
-</table>
-</div>
---> <!--
-<div style="margin:10px 0px 10px 0px" mce_style="margin:10px 0px 10px 0px"><button class="button" onclick="pscript.print_statement();">Print</button></div>
--->
 <div id="print_html">
 	<div id="stmt_title1" style="margin:16px 0px 4px 0px; font-size: 16px; font-weight: bold; color: #888;"></div>
 	<div id="stmt_title2" style="margin:0px 0px 8px 0px; font-size: 16px; font-weight: bold;"></div>
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index a462b70..6a7d604 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -24,7 +24,7 @@
 	erpnext.general_ledger = new erpnext.GeneralLedger(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Accounts")
+	wrapper.appframe.add_module_icon("Accounts")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 
 }
diff --git a/accounts/page/trial_balance/trial_balance.js b/accounts/page/trial_balance/trial_balance.js
index c64075f..9c4c50a 100644
--- a/accounts/page/trial_balance/trial_balance.js
+++ b/accounts/page/trial_balance/trial_balance.js
@@ -59,6 +59,6 @@
 	erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance');
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Accounts")
+	wrapper.appframe.add_module_icon("Accounts")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
\ No newline at end of file
diff --git a/accounts/report/gross_profit/gross_profit.py b/accounts/report/gross_profit/gross_profit.py
index 9ccd320..798c718 100644
--- a/accounts/report/gross_profit/gross_profit.py
+++ b/accounts/report/gross_profit/gross_profit.py
@@ -92,7 +92,7 @@
 		timestamp(si.posting_date, si.posting_time) as posting_datetime
 		from `tabSales Invoice` si, `tabSales Invoice Item` item
 		where item.parent = si.name and si.docstatus = 1 %s
-		and si.is_pos = 1 and si.update_stock = 1
+		and si.update_stock = 1
 		order by si.posting_date desc, si.posting_time desc""" % (conditions,), filters, as_dict=1)
 	
 	source = delivery_note_items + sales_invoice_items
diff --git a/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt b/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt
index 7a9ec36..6b3bcf7 100644
--- a/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt
+++ b/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-28 15:54:16", 
   "docstatus": 0, 
-  "modified": "2013-05-28 16:02:57", 
+  "modified": "2013-06-05 13:01:05", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -11,7 +11,7 @@
   "doctype": "Report", 
   "is_standard": "Yes", 
   "name": "__common__", 
-  "query": "select \n    `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n    `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", 
+  "query": "select \n    `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n    `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.amount as \"Amount:Currency:100\",\n\t`tabPurchase Order Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.amount - ifnull(`tabPurchase Order Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_amt, 0) < ifnull(`tabPurchase Order Item`.amount, 0)\norder by `tabPurchase Order`.transaction_date asc", 
   "ref_doctype": "Purchase Invoice", 
   "report_name": "Purchase Order Items To Be Billed", 
   "report_type": "Query Report"
diff --git a/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt b/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
index 554e0f0..90617f8 100644
--- a/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
+++ b/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-28 15:57:59", 
   "docstatus": 0, 
-  "modified": "2013-05-28 17:34:05", 
+  "modified": "2013-06-05 12:59:17", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -11,7 +11,7 @@
   "doctype": "Report", 
   "is_standard": "Yes", 
   "name": "__common__", 
-  "query": "select \n    `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n    `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n    `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n    `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Receipt Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Receipt Item`.qty - ifnull(`tabPurchase Receipt Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_qty, 0) < ifnull(`tabPurchase Receipt Item`.qty, 0)\norder by `tabPurchase Receipt`.posting_date asc", 
+  "query": "select \n    `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n    `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n    `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n    `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.amount as \"Amount:Currency:100\",\n\t`tabPurchase Receipt Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Receipt Item`.amount - ifnull(`tabPurchase Receipt Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_amt, 0) < ifnull(`tabPurchase Receipt Item`.amount, 0)\norder by `tabPurchase Receipt`.posting_date asc", 
   "ref_doctype": "Purchase Invoice", 
   "report_name": "Received Items To Be Billed", 
   "report_type": "Query Report"
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index dacee80..eee7984 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -20,131 +20,330 @@
 // cur_frm.cscript.fname - Details fieldname
 
 wn.provide("erpnext.buying");
+wn.require("app/js/transaction.js");
 
-erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
+erpnext.buying.BuyingController = erpnext.TransactionController.extend({
 	setup: function() {
 		var me = this;
 		
 		if(this.frm.fields_dict.price_list_name) {
-			this.frm.fields_dict.price_list_name.get_query = function() {
+			this.frm.set_query("price_list_name", function() {
 				return repl("select distinct price_list_name from `tabItem Price` \
 					where buying = 1 and price_list_name like \"%s%%\"");
-			};
-		}
-		
-		if(this.frm.fields_dict.price_list_currency) {
-			this.frm.fields_dict.price_list_currency.get_query = function() {
+			});
+			
+			this.frm.set_query("price_list_currency", function() {
 				return repl("select distinct ref_currency from `tabItem Price` \
 					where price_list_name=\"%(price_list_name)s\" and buying = 1 \
 					and ref_currency like \"%s%%\"", 
 					{price_list_name: me.frm.doc.price_list_name});
-			};
+			});
 		}
+		
+		if(this.frm.fields_dict.supplier) {
+			this.frm.set_query("supplier", erpnext.utils.supplier_query);
+		}
+		
+		this.frm.set_query("item_code", this.frm.cscript.fname, function() {
+			if(me.frm.doc.is_subcontracted == "Yes") {
+				return erpnext.queries.item({'ifnull(tabItem.is_sub_contracted_item, "No")': "Yes"});
+			} else {
+				return erpnext.queries.item({'ifnull(tabItem.is_purchase_item, "No")': "Yes"});
+			}
+		});
 	},
 	
-	refresh: function() {
-		this.frm.clear_custom_buttons();
-		erpnext.hide_naming_series();
-		
-		if(this.frm.fields_dict.supplier)
-			this.frm.toggle_display("contact_section", this.frm.doc.supplier);
-		
-		if(this.frm.fields_dict.currency)
-			this.set_dynamic_labels();
-	},
-	
-	price_list_name: function(callback_fn) {
-		var me = this;
-		
-		if(this.frm.doc.price_list_name) {
-			if(!this.frm.doc.price_list_currency) {
-				// set price list currency
+	supplier: function() {
+		if(this.frm.doc.supplier || this.frm.doc.credit_to) {
+			if(!this.frm.doc.company) {
+				this.frm.set_value("supplier", null);
+				msgprint(wn._("Please specify Company"));
+			} else {
+				var me = this;
+				var price_list_name = this.frm.doc.price_list_name;
+
 				this.frm.call({
-					method: "setup.utils.get_price_list_currency",
-					args: {args: {
-						price_list_name: this.frm.doc.price_list_name,
-						use_for: "buying"
-					}},
+					doc: this.frm.doc,
+					method: "set_supplier_defaults",
+					freeze: true,
 					callback: function(r) {
 						if(!r.exc) {
-							me.price_list_currency();
-							if (typeof callback_fn === "function") 
-								callback_fn(me.frm.doc, me.frm.doc.doctype, me.frm.doc.name);
+							me.frm.refresh_fields();
+							if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name();
 						}
 					}
 				});
-			} else {
-				me.price_list_currency();
-				if (typeof callback_fn === "function") 
-					callback_fn(me.frm.doc, me.frm.doc.doctype, me.frm.doc.name);
 			}
-		} 
+		}
 	},
 	
 	item_code: function(doc, cdt, cdn) {
 		var me = this;
-		var item = locals[cdt][cdn];
-		
+		var item = wn.model.get_doc(cdt, cdn);
 		if(item.item_code) {
+			if(!this.validate_company_and_party("supplier")) {
+				item.item_code = null;
+				refresh_field("item_code", item.name, item.parentfield);
+			} else {
+				this.frm.call({
+					method: "buying.utils.get_item_details",
+					child: item,
+					args: {
+						args: {
+							item_code: item.item_code,
+							warehouse: item.warehouse,
+							doctype: me.frm.doc.doctype,
+							docname: me.frm.doc.name,
+							supplier: me.frm.doc.supplier,
+							conversion_rate: me.frm.doc.conversion_rate,
+							price_list_name: me.frm.doc.price_list_name,
+							price_list_currency: me.frm.doc.price_list_currency,
+							plc_conversion_rate: me.frm.doc.plc_conversion_rate,
+							is_subcontracted: me.frm.doc.is_subcontracted,
+							company: me.frm.doc.company,
+							currency: me.frm.doc.currency
+						}
+					},
+					callback: function(r) {
+						if(!r.exc) {
+							me.import_ref_rate(me.frm.doc, cdt, cdn);
+						}
+					}
+				});
+			}
+		}
+	},
+	
+	price_list_name: function() {
+		this._super("buying");
+	},
+	
+	import_ref_rate: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["import_ref_rate", "discount_rate"]);
+		
+		item.import_rate = flt(item.import_ref_rate * (1 - item.discount_rate / 100.0),
+			precision("import_rate", item));
+		
+		this.calculate_taxes_and_totals();
+	},
+	
+	discount_rate: function(doc, cdt, cdn) {
+		this.import_ref_rate(doc, cdt, cdn);
+	},
+	
+	import_rate: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["import_rate", "discount_rate"]);
+		
+		if(item.import_ref_rate) {
+			item.discount_rate = flt((1 - item.import_rate / item.import_ref_rate) * 100.0,
+				precision("discount_rate", item));
+		} else {
+			item.discount_rate = 0.0;
+		}
+		
+		this.calculate_taxes_and_totals();
+	},
+	
+	uom: function(doc, cdt, cdn) {
+		var me = this;
+		var item = wn.model.get_doc(cdt, cdn);
+		if(item.item_code && item.uom) {
 			this.frm.call({
-				method: "buying.utils.get_item_details",
+				method: "buying.utils.get_conversion_factor",
 				child: item,
 				args: {
-					args: {
-						doctype: me.frm.doc.doctype,
-						docname: me.frm.doc.name,
-						item_code: item.item_code,
-						warehouse: item.warehouse,
-						supplier: me.frm.doc.supplier,
-						conversion_rate: me.frm.doc.conversion_rate,
-						price_list_name: me.frm.doc.price_list_name,
-						price_list_currency: me.frm.doc.price_list_currency,
-						plc_conversion_rate: me.frm.doc.plc_conversion_rate
-					}
+					item_code: item.item_code,
+					uom: item.uom
 				},
+				callback: function(r) {
+					if(!r.exc) {
+						me.conversion_factor(me.frm.doc, cdt, cdn);
+					}
+				}
 			});
 		}
 	},
 	
-	update_item_details: function(doc, dt, dn, callback) {
-		if(!this.frm.doc.__islocal) return;
-		
-		var me = this;
-		var children = getchildren(this.tname, this.frm.doc.name, this.fname);
-		if(children && children.length) {
-			this.frm.call({
-				doc: me.frm.doc,
-				method: "update_item_details",
-				callback: function(r) {
-					if(!r.exc) {
-						refresh_field(me.fname);
-						me.load_defaults(me.frm.doc, dt, dn, callback);
-					}
-				}
-			})
-		} else {
-			this.load_taxes(doc, dt, dn, callback);
+	qty: function(doc, cdt, cdn) {
+		this._super(doc, cdt, cdn);
+		this.conversion_factor(doc, cdt, cdn);
+	},
+	
+	conversion_factor: function(doc, cdt, cdn) {
+		if(wn.meta.get_docfield(cdt, "stock_qty", cdn)) {
+			var item = wn.model.get_doc(cdt, cdn);
+			wn.model.round_floats_in(item, ["qty", "conversion_factor"]);
+			item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
+			refresh_field("stock_qty", item.name, item.parentfield);
 		}
 	},
 	
-	currency: function() {
-		this.set_dynamic_labels();
+	warehouse: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		if(item.item_code && item.warehouse) {
+			this.frm.call({
+				method: "buying.utils.get_conversion_factor",
+				child: item,
+				args: {
+					item_code: item.item_code,
+					warehouse: item.warehouse
+				}
+			});
+		}
 	},
 	
-	company: function() {
-		this.set_dynamic_labels();
+	project_name: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		if(item.project_name) {
+			$.each(wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: this.fname}),
+				function(i, other_item) { 
+					if(!other_item.project_name) {
+						other_item.project_name = item.project_name;
+						refresh_field("project_name", other_item.name, other_item.parentfield);
+					}
+				});
+		}
 	},
 	
-	price_list_currency: function() {
-		this.frm.toggle_reqd("plc_conversion_rate",
-			!!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency));
+	category: function(doc, cdt, cdn) {
+		// should be the category field of tax table
+		if(cdt != doc.doctype) {
+			this.calculate_taxes_and_totals();
+		}
+	},
+	
+	calculate_taxes_and_totals: function() {
+		this._super();
+		this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
+		this.frm.refresh_fields();
+	},
+	
+	calculate_item_values: function() {
+		var me = this;
 		
-		this.set_dynamic_labels();
-				
-		if(this.frm.doc.price_list_currency === this.get_company_currency())
-			this.frm.set_value("plc_conversion_rate", 1.0);
-		else if(this.frm.doc.price_list_currency === this.frm.doc.currency)
-			this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0);		
+		if(this.frm.doc.doctype != "Purchase Invoice") {
+			// hack!
+			wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"] = $.extend({}, 
+				wn.meta.docfield_copy[this.tname][this.frm.doc.name]["purchase_rate"]);
+		}
+		
+		$.each(this.frm.item_doclist, function(i, item) {
+			if(me.frm.doc.doctype != "Purchase Invoice") {
+				item.rate = item.purchase_rate;
+			}
+			
+			wn.model.round_floats_in(item);
+			item.import_amount = flt(item.import_rate * item.qty, precision("import_amount", item));
+			item.item_tax_amount = 0.0;
+			
+			me._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate");
+			me._set_in_company_currency(item, "import_rate", "rate");
+			me._set_in_company_currency(item, "import_amount", "amount");
+		});
+		
+	},
+	
+	calculate_net_total: function() {
+		var me = this;
+
+		this.frm.doc.net_total = this.frm.doc.net_total_import = 0.0;
+		$.each(this.frm.item_doclist, function(i, item) {
+			me.frm.doc.net_total += item.amount;
+			me.frm.doc.net_total_import += item.import_amount;
+		});
+		
+		wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_import"]);
+	},
+	
+	calculate_totals: function() {
+		var tax_count = this.frm.tax_doclist.length;
+		this.frm.doc.grand_total = flt(
+			tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
+			precision("grand_total"));
+		this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate,
+			precision("grand_total_import"));
+			
+		this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
+			precision("total_tax"));
+		
+		// rounded totals
+		if(wn.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
+			this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
+		}
+		
+		if(wn.meta.get_docfield(this.frm.doc.doctype, "rounded_total_import", this.frm.doc.name)) {
+			this.frm.doc.rounded_total_import = Math.round(this.frm.doc.grand_total_import);
+		}
+		
+		// other charges added/deducted
+		if(tax_count) {
+			this.frm.doc.other_charges_added = wn.utils.sum($.map(this.frm.tax_doclist, 
+				function(tax) { return tax.add_deduct_tax == "Add" ? tax.tax_amount : 0.0; }));
+		
+			this.frm.doc.other_charges_deducted = wn.utils.sum($.map(this.frm.tax_doclist, 
+				function(tax) { return tax.add_deduct_tax == "Deduct" ? tax.tax_amount : 0.0; }));
+			
+			wn.model.round_floats_in(this.frm.doc, ["other_charges_added", "other_charges_deducted"]);
+			
+			this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / this.frm.doc.conversion_rate,
+				precision("other_charges_added_import"));
+			this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / this.frm.doc.conversion_rate,
+				precision("other_charges_deducted_import"));
+		}
+	},
+	
+	_cleanup: function() {
+		this._super();
+		this.frm.doc.in_words = this.frm.doc.in_words_import = "";
+
+		// except in purchase invoice, rate field is purchase_rate		
+		// reset fieldname of rate
+		if(this.frm.doc.doctype != "Purchase Invoice") {
+			// clear hack
+			delete wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"];
+			
+			$.each(this.frm.item_doclist, function(i, item) {
+				item.purchase_rate = item.rate;
+				delete item["rate"];
+			});
+		}
+		
+		if(!wn.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) {
+			$.each(this.frm.item_doclist, function(i, item) {
+				delete item["item_tax_amount"];
+			});
+		}
+	},
+	
+	calculate_outstanding_amount: function() {
+		if(this.frm.doc.doctype == "Purchase Invoice" && this.frm.doc.docstatus < 2) {
+			wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
+			this.frm.doc.total_amount_to_pay = flt(this.frm.doc.grand_total - this.frm.doc.write_off_amount,
+				precision("total_amount_to_pay"));
+			this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
+				precision("outstanding_amount"));
+		}
+	},
+	
+	set_item_tax_amount: function(item, tax, current_tax_amount) {
+		// item_tax_amount is the total tax amount applied on that item
+		// stored for valuation 
+		// 
+		// TODO: rename item_tax_amount to valuation_tax_amount
+		if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1 &&
+			wn.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) {
+				// accumulate only if tax is for Valuation / Valuation and Total
+				item.item_tax_amount += flt(current_tax_amount, precision("item_tax_amount", item));
+		}
+	},
+	
+	show_item_wise_taxes: function() {
+		if(this.frm.fields_dict.tax_calculation) {
+			$(this.get_item_wise_taxes_html())
+				.appendTo($(this.frm.fields_dict.tax_calculation.wrapper).empty());
+		}
 	},
 	
 	set_dynamic_labels: function(doc, dt, dn) {
@@ -162,11 +361,12 @@
 			$.each(fields_list, function(i, fname) {
 				var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
 				if(docfield) {
-					var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
+					var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
 					field_label_map[fname] = label.trim() + " (" + currency + ")";
 				}
 			});
-		}
+		};
+		
 		
 		setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words",
 			"other_charges_added", "other_charges_deducted", 
@@ -188,6 +388,9 @@
 		this.frm.toggle_display(["conversion_rate", "net_total", "grand_total", 
 			"in_words", "other_charges_added", "other_charges_deducted"],
 			this.frm.doc.currency != company_currency);
+			
+		this.frm.toggle_display(["plc_conversion_rate"], 
+			this.frm.price_list_currency != company_currency);
 		
 		// set labels
 		$.each(field_label_map, function(fname, label) {
@@ -204,11 +407,12 @@
 			$.each(fields_list, function(i, fname) {
 				var docfield = wn.meta.get_docfield(grid_doctype, fname);
 				if(docfield) {
+					var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
 					field_label_map[grid_doctype + "-" + fname] = 
-						docfield.label + " (" + currency + ")";
+						label.trim() + " (" + currency + ")";
 				}
 			});
-		}
+		};
 		
 		setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
 			company_currency, this.fname);
@@ -216,7 +420,9 @@
 		setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
 			this.frm.doc.currency, this.fname);
 		
-		setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
+		if(this.frm.fields_dict[this.other_fname]) {
+			setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
+		}
 		
 		if(this.frm.fields_dict["advance_allocation_details"]) {
 			setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
@@ -237,10 +443,6 @@
 			$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
 		});
 	},
-	
-	get_company_currency: function() {
-		return erpnext.get_currency(this.frm.doc.company);
-	}
 });
 
 // to save previous state of cur_frm.cscript
@@ -254,547 +456,4 @@
 
 
 var tname = cur_frm.cscript.tname;
-var fname = cur_frm.cscript.fname;
-
-cur_frm.cscript.get_default_schedule_date = function(doc) {
-		var ch = getchildren( tname, doc.name, fname);
-		if (flt(ch.length) > 0){
-			$c_obj(make_doclist(doc.doctype, doc.name), 'get_default_schedule_date', '', function(r, rt) { refresh_field(fname); });
-		}
-}
-
-cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
-	// run if this is not executed from dt_map...
-	doc = locals[doc.doctype][doc.name];
-	if(doc.supplier || getchildren('Purchase Taxes and Charges', doc.name, 'purchase_tax_details', doc.doctype).length) {
-		if(callback) {
-			callback(doc, cdt, cdn);
-		}
-	} else {
-		$c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
-			refresh_field('purchase_tax_details');
-			if(callback) callback(doc, cdt, cdn);
-		});
-	}
-}
-
-
-
-// Gets called after existing item details are update to fill in
-// remaining default values
-cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
-	if(!cur_frm.doc.__islocal) { return; }
-
-	doc = locals[doc.doctype][doc.name];
-	var fields_to_refresh = wn.model.set_default_values(doc);
-	if(fields_to_refresh) { refresh_many(fields_to_refresh); }
-
-	fields_to_refresh = null;
-	var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
-	if(!children) { return; }
-	for(var i=0; i<children.length; i++) {
-		wn.model.set_default_values(children[i]);
-	}
-	refresh_field(cur_frm.cscript.fname);
-	cur_frm.cscript.load_taxes(doc, dt, dn, callback);
-}
-
-// ======================== Conversion Rate ==========================================
-cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
-	cur_frm.cscript.calc_amount( doc, 1);
-}
-
-//==================== Item Code Get Query =======================================================
-// Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed.
-cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
-	if (doc.is_subcontracted =="Yes") {
-		return erpnext.queries.item({
-			'ifnull(tabItem.is_sub_contracted_item, "No")': 'Yes'
-		})
-	} else {
-		return erpnext.queries.item({
-			'ifnull(tabItem.is_purchase_item, "No")': 'Yes'
-		})
-	}
-}
-
-//==================== Update Stock Qty ==========================================================
-cur_frm.cscript.update_stock_qty = function(doc,cdt,cdn){
-	d = locals[cdt][cdn]
-	// Step 1:=> Check if qty , uom, conversion_factor
-	if (d.qty && d.uom && d.conversion_factor){
-		// Step 2:=> Set stock_qty = qty * conversion_factor
-		d.stock_qty = flt(flt(d.qty) * flt(d.conversion_factor));
-		// Step 3:=> Refer stock_qty field a that particular row.
-		refresh_field('stock_qty' , d.name,fname);
-	}
-}
-
-//==================== UOM ======================================================================
-cur_frm.cscript.uom = function(doc, cdt, cdn, args) {
-	if(!args) args = {};
-	
-	// args passed can contain conversion_factor
-	var d = locals[cdt][cdn];
-	$.extend(args, {
-		item_code: d.item_code,
-		uom: d.uom,
-		stock_qty: flt(d.stock_qty),
-	});
-	
-	if(d.item_code && d.uom) {
-		cur_frm.call({
-			method: "buying.doctype.purchase_common.purchase_common.get_uom_details",
-			args: { args: args },
-			child: d,
-			callback: function(r) {
-				cur_frm.cscript.calc_amount(doc, 2);
-			}
-		});
-	}
-}
-
-
-//==================== Conversion factor =========================================================
-cur_frm.cscript.conversion_factor = function(doc, cdt, cdn) {
-	var item = locals[cdt][cdn];
-	
-	cur_frm.cscript.uom(doc, cdt, cdn, { conversion_factor: item.conversion_factor });
-}
-
-//==================== stock qty ======================================================================
-cur_frm.cscript.stock_qty = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	if(d.uom && d.qty){
-		d.conversion_factor = flt(d.stock_qty)/flt(d.qty);
-		refresh_field('conversion_factor', d.name, fname);
-	}
-}
-
-//==================== Warehouse ================================================================
-cur_frm.cscript.warehouse = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	if (d.item_code && d.warehouse) {
-		str_arg = "{'item_code':'" +	(d.item_code?d.item_code:'') + "', 'warehouse':'" + (d.warehouse?d.warehouse:'') + "'}"
-		get_server_fields('get_bin_details', str_arg, fname, doc, cdt, cdn, 1);
-	}	
-}
-
-//=================== Quantity ===================================================================
-cur_frm.cscript.qty = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	// Step 1: => Update Stock Qty 
-	cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
-	// Step 2: => Calculate Amount
-	cur_frm.cscript.calc_amount(doc, 2);
-}
-
-
-//=================== Purchase Rate ==============================================================
-cur_frm.cscript.purchase_rate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 2);
-}
-
-//==================== Import Rate ================================================================
-cur_frm.cscript.import_rate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 1);
-}
-
-//==================== Discount Rate ================================================================
-cur_frm.cscript.discount_rate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 4);
-}
-//==================== Purchase Ref Rate ================================================================
-cur_frm.cscript.purchase_ref_rate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 4);
-}
-//==================== Import Ref Rate ================================================================
-cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 5);
-}
-
-//==================== Validate ====================================================================
-cur_frm.cscript.validate = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 1);
-
-	// calculate advances if pv
-	if(doc.docstatus == 0 && doc.doctype == 'Purchase Invoice') calc_total_advance(doc, cdt, cdn);
-}
-
-// **************** RE-CALCULATE VALUES ***************************
-
-cur_frm.cscript.recalculate_values = function(doc, cdt, cdn) {
-	cur_frm.cscript.calculate_tax(doc,cdt,cdn);
-}
-
-cur_frm.cscript.calculate_tax = function(doc, cdt, cdn) {
-	var other_fname	= cur_frm.cscript.other_fname;
-
-	var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname, doc.doctype);
-	for(var i = 0; i<cl.length; i++){
-		cl[i].total_tax_amount = 0;
-		cl[i].total_amount = 0;
-		cl[i].tax_amount = 0;										// this is done to calculate other charges
-		cl[i].total = 0;
-		if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
-			alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
-			validated = false;
-		}
-	}
-	cur_frm.cscript.calc_amount(doc, 1);
-}
-
-
-
-cur_frm.cscript.get_item_wise_tax_detail = function( doc, rate, cl, i, tax, t) {
-	doc = locals[doc.doctype][doc.name];
-	var detail = '';
-	detail = cl[i].item_code + " : " + cstr(rate) + NEWLINE;
-	return detail;
-}
-
-cur_frm.cscript.amount = function(doc, cdt, cdn) {
-	cur_frm.cscript.calc_amount(doc, 3);
-}
-
-
-//====================== Calculate Amount for PO and PR not for PV	============================================================
-cur_frm.cscript.calc_amount = function(doc, n) {
-	// Set defaults
-	doc = locals[doc.doctype][doc.name]
-	var other_fname	= cur_frm.cscript.other_fname;
-	if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
-	if(!n) n=0;
-	var net_total = 0;
-	var net_total_import = 0;
-	
-	var cl = getchildren(tname, doc.name, fname);
-	
-	for(var i=0;i<cl.length;i++) 
-	{
-	var rate_fld = (doc.doctype != 'Purchase Invoice') ? 'purchase_rate': 'rate';
-		var tmp = {};
-	if(!cl[i].discount_rate) cl[i].discount_rate = 0;
-
-		if(n == 1){ 
-			set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
-		set_multiple(tname, cl[i].name, {
-			'discount_rate': flt(cl[i].import_ref_rate) ? 
-				flt(flt( flt( flt(cl[i].import_ref_rate) - flt(cl[i].import_rate) ) * 100 )/ 
-					flt(cl[i].import_ref_rate))	: 0 }, fname);
-		tmp[rate_fld] = flt(doc.conversion_rate) * flt(cl[i].import_rate);
-			set_multiple(tname, cl[i].name, tmp, fname);
-
-			set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(doc.conversion_rate) * flt(cl[i].import_rate))}, fname);
-			set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].import_rate))}, fname);
-
-		}else if(n == 2){
-		set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
-		set_multiple(tname, cl[i].name, {
-			'discount_rate': flt(cl[i].purchase_ref_rate) ? 
-				flt(flt( flt( flt(cl[i].purchase_ref_rate) - flt(cl[i][rate_fld]) ) * 100 )/
-				flt(cl[i].purchase_ref_rate)) : 0 }, fname);
-			set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld])),}, fname);
-		set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate)) }, fname);
-			set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
-
-	}else if(n == 3){
-		tmp[rate_fld] = flt(flt(cl[i].amount) / flt(cl[i].qty));
-			set_multiple(tname, cl[i].name, tmp, fname);
-			set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-			set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
-
-		}else if( n==4){
-
-		set_multiple(tname, cl[i].name, {'import_ref_rate': flt(flt(cl[i].purchase_ref_rate) / flt(doc.conversion_rate))}, fname);
-
-			tmp[rate_fld] = flt( flt(cl[i].purchase_ref_rate) - flt(flt(cl[i].purchase_ref_rate)*flt(cl[i].discount_rate)/100) )
-		set_multiple(tname, cl[i].name, tmp, fname);
-		set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-		set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i][rate_fld]))}, fname);
-		set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-	}else if( n==5){	
-		tmp[rate_fld] = flt( flt(cl[i].import_ref_rate) - flt(flt(cl[i].import_ref_rate)*flt(cl[i].discount_rate)/100) ) * flt(doc.conversion_rate);
-		set_multiple(tname, cl[i].name, {'purchase_ref_rate': flt(flt(cl[i].import_ref_rate) * flt(doc.conversion_rate))}, fname);
-		set_multiple(tname, cl[i].name, tmp, fname);
-		set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-		set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i][rate_fld]))}, fname);
-		set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-	}
-	
-		if (n != 3){
-			net_total += flt(flt(cl[i].qty) * flt(cl[i][rate_fld]));
-			net_total_import += flt(flt(cl[i].qty) * flt(cl[i].import_rate));
-		} else if(n == 3){
-			net_total += flt(cl[i].amount);
-			net_total_import += flt(cl[i].amount) / flt(doc.conversion_rate);
-		}
-		//update stock uom
-		cur_frm.cscript.update_stock_qty(doc, tname, cl[i].name);
-	}
-	doc.net_total = flt(net_total) ;
-	doc.net_total_import = flt(net_total_import) ;
-	refresh_field('net_total');
-	refresh_field('net_total_import');
-	
-	cur_frm.cscript.val_cal_charges(doc, tname, fname, other_fname);
-}
-
-
-//======== Function was broken away from cur_frm.cscript.calc_amount as PV has fieldname 'rate' instead of 'purchase_rate'===========
-cur_frm.cscript.val_cal_charges = function(doc, tname, fname, other_fname){
-
-	doc = locals[doc.doctype][doc.name]
-	if(flt(doc.net_total) > 0) {
-		var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
-		for(var i = 0; i<cl.length; i++){
-			cl[i].total_tax_amount = 0;
-			cl[i].total_amount = 0;
-			cl[i].tax_amount = 0;										// this is done to calculate other charges
-			cl[i].total = 0;
-			cl[i].item_wise_tax_detail = "";
-			if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
-				alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
-				validated = false;
-			}
-		}
-		cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
-	}
-	cur_frm.cscript.calc_doc_values(doc, tname, fname, other_fname); // calculates total amounts
-
-	refresh_many(['net_total', 'grand_total', 'rounded_total', 'grand_total_import', 'rounded_total_import', 'in_words', 'in_words_import', 'purchase_tax_details', 'total_tax', 'other_charges_added', 'other_charges_deducted', 'net_total_import', 'other_charges_added_import', 'other_charges_deducted_import']);
-
-}
-
-
-// ******************************* OTHER CHARGES *************************************
-cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
-	doc = locals[doc.doctype][doc.name];
-	// make display area
-	// ------------------
-
-	
-	cur_frm.fields_dict['tax_calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Taxes, Charges and Landed Cost:</b>';
-	var cl = getchildren(tname, doc.name, fname);
-	var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
-	// make display table
-	// ------------------
-	var otc = make_table(cur_frm.fields_dict['tax_calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
-	$y(otc,{marginTop:'8px'});
-	
-	var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
-	
-	
-	for(var i=0;i<cl.length;i++) {
-		var item_tax = 0;
-		if(doc.doctype != 'Purchase Invoice') net_total += flt(flt(cl[i].qty) * flt(cl[i].purchase_rate));
-		else if(doc.doctype == 'Purchase Invoice') net_total += flt(flt(cl[i].qty) * flt(cl[i].rate));
-
-		var prev_total = flt(cl[i].amount);
-		if(cl[i].item_tax_rate) {
-			try {
-				var check_tax = JSON.parse(cl[i].item_tax_rate);				//to get in dictionary
-			} catch(exception) {
-				var check_tax = eval('var a='+cl[i].item_tax_rate+';a');        //to get in dictionary				 
-			}
-		}
-		
-		// Add Item Code in new Row 
-		//--------------------------
-		$td(otc,i+1,0).innerHTML = cl[i].item_code;
-		
-		var total = net_total;
-		for(var t=0;t<tax.length;t++){
- 
-			var account = tax[t].account_head;
-			$td(otc,0,t+1).innerHTML = account?account:'';
-			//Check For Rate
-			if(cl[i].item_tax_rate && check_tax[account]!=null)	{
-				rate = flt(check_tax[account]);
-			} else {
-				// if particular item doesn't have particular rate it will take other charges rate
-				rate = flt(tax[t].rate);
-			}
-
-			//Check For Rate and get tax amount
-			var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
-			
-			//enter item_wise_tax_detail i.e. tax rate on each item
-			
-			item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail( doc, rate, cl, i, tax, t);
-			
-			
-			if(tax[t].add_deduct_tax == 'Add'){
-				// this is calculation part for all types
-				if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
-				tax[t].total_amount = flt(tax_amount);		 //stores actual tax amount in virtual field
-				tax[t].total_tax_amount = flt(prev_total);			//stores total amount in virtual field
-				tax[t].tax_amount += flt(tax_amount);			 
-				var total_amount = flt(tax[t].tax_amount);
-				total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
-				if(tax[t].category != "Valuation"){
-					set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total)+flt(tax[t].tax_amount), 2)}, other_fname);
-					prev_total += flt(tax[t].total_amount);
-					total += flt(tax[t].tax_amount);	// for adding total to previous amount			 
-				}
-				else{
-					set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total), 2)}, other_fname);
-					prev_total = prev_total;
-				}
-				//prev_total += flt(tax[t].total_amount);	 // for previous row total
-
-				if(tax[t].charge_type == 'Actual')
-					$td(otc,i+1,t+1).innerHTML = format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-				else
-					$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-
-				if (tax[t].category != "Total"){
-					item_tax += tax[t].total_amount;
-				}
-			}
-			else if(tax[t].add_deduct_tax == 'Deduct'){
-				// this is calculation part for all types
-				if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
-				tax[t].total_amount = flt(tax_amount);		 //stores actual tax amount in virtual field
-				tax[t].total_tax_amount = flt(prev_total);			//stores total amount in virtual field
-				tax[t].tax_amount += flt(tax_amount);
-				var total_amount = flt(tax[t].tax_amount);
-				total_tax_amount = flt(tax[t].total_tax_amount) - flt(total_amount);
-				if(tax[t].category != "Valuation"){
-					set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total)-flt(tax[t].tax_amount), 2)}, other_fname);
-					prev_total -= flt(tax[t].total_amount); 
-					total -= flt(tax[t].tax_amount);	// for adding total to previous amount			 
-				}
-				else{
-					set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total), 2)}, other_fname);
-					prev_total = prev_total;
-				}
-				//prev_total += flt(tax[t].total_amount);	 // for previous row total
-
-				if(tax[t].charge_type == 'Actual')
-					$td(otc,i+1,t+1).innerHTML = format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-				else
-					$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-
-				if (tax[t].category != "Total"){
-					item_tax -= tax[t].total_amount;
-				}
-			}			
-			
-			
-		}
-		set_multiple(tname, cl[i].name, {'item_tax_amount': item_tax }, fname);
-	}
-	for(var t=0;t<tax.length;t++){
-		tax[t].tax_amount = roundNumber(tax[t].tax_amount, 2);
-	}
-}
-
-
-cur_frm.cscript.check_charge_type_and_get_tax_amount = function(doc, tax, t, cl, rate, print_amt) {
-	doc = locals[doc.doctype][doc.name];
-
-	var tax_amount = 0;
-	if(tax[t].charge_type == 'Actual') {
-		var value = flt(tax[t].rate) / flt(doc.net_total);	 // this give the ratio in which all items are divided					 
-		return tax_amount = flt(value) * flt(cl.amount);
-	 }	 
-	else if(tax[t].charge_type == 'On Net Total') {
-		return tax_amount = (flt(rate) * flt(cl.amount) / 100);
-	}
-	else if(tax[t].charge_type == 'On Previous Row Amount'){
-		var row_no = (tax[t].row_id).toString();
-		var row = (row_no).split("+");			// splits the values and stores in an array
-		for(var r = 0;r<row.length;r++){
-			var id = cint(row[r].replace(/^\s+|\s+$/g,""));
-			tax_amount += (flt(rate) * flt(tax[id-1].total_amount) / 100);
-		}
-		var row_id = row_no.indexOf("/");
-		if(row_id != -1) {
-			rate = '';
-			var row = (row_no).split("/");			// splits the values and stores in an array
-			if(row.length>2) alert("You cannot enter more than 2 nos. for division");
-			var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
-			var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
-			tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
-		}
-		return tax_amount
-	}
-	else if(tax[t].charge_type == 'On Previous Row Total') {
-		var row = cint(tax[t].row_id);
-		if(tax[row-1].add_deduct_tax == 'Add'){
-			return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
-		 }
-		else if(tax[row-1].add_deduct_tax == 'Deduct'){
-			return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)-flt(tax[row-1].total_amount)) / 100;
-		 }
-	}
-}
-
-// ******* Calculation of total amounts of document (item amount + other charges)****************
-cur_frm.cscript.calc_doc_values = function(doc, tname, fname, other_fname) {
-	doc = locals[doc.doctype][doc.name];
-	var net_total = 0; var total_tax = 0; var other_charges_added = 0; 
-	var other_charges_deducted = 0;
-	var cl = getchildren(tname, doc.name, fname);
-	for(var i = 0; i<cl.length; i++){
-		net_total += flt(cl[i].amount);
-	}
-	var d = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
-	for(var j = 0; j<d.length; j++){
-		if(d[j].category != 'Valuation'){
-			
-			if(d[j].add_deduct_tax == 'Add'){
-				other_charges_added += flt(d[j].tax_amount);
-				total_tax += flt(d[j].tax_amount);
-			}
-			if(d[j].add_deduct_tax == 'Deduct'){
-				other_charges_deducted += flt(d[j].tax_amount);
-				total_tax -= flt(d[j].tax_amount);
-			}
-		}
-	}
-	doc.net_total = flt(net_total);
-	doc.total_tax = flt(total_tax);
-
-	doc.other_charges_added = roundNumber(flt(other_charges_added), 2);
-	doc.other_charges_deducted = roundNumber(flt(other_charges_deducted), 2);
-	doc.grand_total = roundNumber(flt(flt(net_total) + flt(other_charges_added) - flt(other_charges_deducted)), 2);
-	doc.rounded_total = Math.round(doc.grand_total);
-	doc.net_total_import = roundNumber(flt(flt(net_total) / flt(doc.conversion_rate)), 2);
-	doc.other_charges_added_import = roundNumber(flt(flt(other_charges_added) / flt(doc.conversion_rate)), 2);
-	doc.other_charges_deducted_import = roundNumber(flt(flt(other_charges_deducted) / flt(doc.conversion_rate)), 2);
-	doc.grand_total_import = roundNumber(flt(flt(doc.grand_total) / flt(doc.conversion_rate)), 2);
-	doc.rounded_total_import = Math.round(doc.grand_total_import);
-
-	refresh_many(['net_total','total_taxes','grand_total']);
-
-
-	if(doc.doctype == 'Purchase Invoice'){
-		calculate_outstanding(doc);
-	}
-}
-
-var calculate_outstanding = function(doc) {
-	// total amount to pay	
-	doc.total_amount_to_pay = flt(doc.grand_total) - flt(doc.write_off_amount);
-	
-	// outstanding amount 
-	if(doc.docstatus==0) doc.outstanding_amount = doc.total_amount_to_pay - flt(doc.total_advance);
-	
-	refresh_many(['total_amount_to_pay', 'outstanding_amount']);
-}
-
-
-cur_frm.cscript.project_name = function(doc, cdt, cdn) {
-	var item_doc = locals[cdt][cdn];
-	if (item_doc.project_name) {
-		$.each(getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname, doc.doctype),
-			function(i, v) {
-				if (v && !v.project_name) v.project_name = item_doc.project_name;
-			});
-		refresh_field(cur_frm.cscript.fname);
-	}
-}
-
-cur_frm.fields_dict.supplier && (cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query);
\ No newline at end of file
+var fname = cur_frm.cscript.fname;
\ No newline at end of file
diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py
index 2b6ca27..6d2baf6 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -69,17 +69,6 @@
 			msgprint(_("Hey there! You need to put at least one item in \
 				the item table."), raise_exception=True)
 
-
-	def get_default_schedule_date( self, obj):
-		for d in getlist( obj.doclist, obj.fname):
-			item = sql("select lead_time_days from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life >	now())" % cstr(d.item_code) , as_dict = 1)
-			ltd = item and cint(item[0]['lead_time_days']) or 0
-			if ltd and obj.doc.transaction_date:
-				if d.fields.has_key('lead_time_date') or obj.doc.doctype == 'Material Request':
-					d.lead_time_date = cstr(add_days( obj.doc.transaction_date, cint(ltd)))
-				if not d.fields.has_key('prevdoc_docname') or (d.fields.has_key('prevdoc_docname') and not d.prevdoc_docname):
-					d.schedule_date =	cstr( add_days( obj.doc.transaction_date, cint(ltd)))
-				
 	# Client Trigger functions
 	#------------------------------------------------------------------------------------------------
 
@@ -99,13 +88,6 @@
 			msgprint("Supplier : %s does not exists" % (name))
 			raise Exception
 	
-	# Get TERMS AND CONDITIONS
-	# =======================================================================================
-	def get_tc_details(self,obj):
-		r = sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name)
-		if r: obj.doc.terms = r[0][0]
-
-
 	# Get Available Qty at Warehouse
 	def get_bin_details( self, arg = ''):
 		arg = eval(arg)
@@ -213,10 +195,11 @@
 					msgprint("Please check Item %s is not present in %s %s ." % (d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
 					raise Exception
 				
-				# Check if Warehouse has been modified.
-				if not cstr(data[0]['warehouse']) == cstr(d.warehouse):
-					msgprint("Please check warehouse %s of Item %s which is not present in %s %s ." % (d.warehouse, d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
-					raise Exception
+				if cstr(data[0]['warehouse']) and \
+						not cstr(data[0]['warehouse']) == cstr(d.warehouse):
+					msgprint("""Please check warehouse %s of Item %s 
+						which is not present in %s %s""" % (d.warehouse, d.item_code, 
+						d.prevdoc_doctype, d.prevdoc_docname), raise_exception=1)
 				
 				#	Check if UOM has been modified.
 				if not cstr(data[0]['uom']) == cstr(d.uom) and not cstr(d.prevdoc_doctype) == 'Material Request':
@@ -404,39 +387,6 @@
 			msgprint("'%s' Not Within The Fiscal Year"%(dn))
 			raise Exception
 
-	def load_default_taxes(self, obj):
-		return self.get_purchase_tax_details(obj, 1)
-	
-	def get_purchase_tax_details(self,obj, default = 0):
-		obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
-		
-		if default: add_cond = " and ifnull(t2.is_default,0) = 1"
-		else: add_cond = " and t1.parent = '"+cstr(obj.doc.purchase_other_charges)+"'"
-
-		other_charge = sql("""
-			select t1.*
-			from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
-			where t1.parent = t2.name %s
-			order by t1.idx
-		"""% add_cond, as_dict = 1)
-		
-		idx = 0
-		for other in other_charge:
-			d =	addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 
-				obj.doclist)
-			d.category = other['category']
-			d.add_deduct_tax = other['add_deduct_tax']
-			d.charge_type = other['charge_type']
-			d.row_id = other['row_id']
-			d.description = other['description']
-			d.account_head = other['account_head']
-			d.rate = flt(other['rate'])
-			d.tax_amount = flt(other['tax_amount'])
-			d.cost_center = other["cost_center"]
-			d.idx = idx
-			idx += 1
-		return obj.doclist
-
 	def get_rate(self, arg, obj):
 		arg = eval(arg)
 		rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s'" %(arg['account_head']), as_dict=1)
@@ -449,27 +399,3 @@
 			if d.prevdoc_doctype and d.prevdoc_docname:
 				dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
 				d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
-
-@webnotes.whitelist()
-def get_uom_details(args=None):
-	"""fetches details on change of UOM"""
-	if not args:
-		return {}
-		
-	if isinstance(args, basestring):
-		import json
-		args = json.loads(args)
-
-	uom = webnotes.conn.sql("""select conversion_factor
-		from `tabUOM Conversion Detail` where parent = %s and uom = %s""", 
-		(args['item_code'], args['uom']), as_dict=1)
-
-	if not uom: return {}
-
-	conversion_factor = args.get("conversion_factor") or \
-		flt(uom[0]["conversion_factor"])
-	
-	return {
-		"conversion_factor": conversion_factor,
-		"qty": flt(args["stock_qty"]) / conversion_factor,
-	}
diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js
index afe4741..64aa913 100644
--- a/buying/doctype/purchase_order/purchase_order.js
+++ b/buying/doctype/purchase_order/purchase_order.js
@@ -21,8 +21,8 @@
 cur_frm.cscript.other_fname = "purchase_tax_details";
 
 wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
-wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 
 erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
 	refresh: function(doc, cdt, cdn) {
@@ -39,54 +39,10 @@
 			cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
 			
 	},
-	
-	onload_post_render: function(doc, dt, dn) {	
-		var me = this;	
-		var callback1 = function(doc, dt, dn) {
-			var callback2 = function(doc, dt, dn) {
-				if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);				
-			}
-			me.update_item_details(doc, dt, dn, callback2);
-		}
-		
-		// TODO: improve this
-		if(this.frm.doc.__islocal) {
-			if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) {
-				this.price_list_name(callback1);
-			} else {
-				callback1(doc, dt, dn);
-			}
-		}
-	}
-	
 });
 
-var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
-
 // for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
-cur_frm.cscript.onload = function(doc, cdt, cdn) {	
-	// set missing values in parent doc
-	set_missing_values(doc, {
-		fiscal_year: sys_defaults.fiscal_year,
-		conversion_rate: 1,
-		currency: sys_defaults.currency,
-		status: "Draft",
-		transaction_date: get_today(),
-		is_subcontracted: "No"
-	});
-}
-
-cur_frm.cscript.supplier = function(doc,dt,dn) {
-	if (doc.supplier) {
-		get_server_fields('get_default_supplier_address',
-			JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
-				cur_frm.refresh();
-			});
-		$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
-	}
-}
+$.extend(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm}));
 
 cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
 	if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -111,10 +67,6 @@
 	locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
 }
 
-cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
-	if(doc.__islocal){ cur_frm.cscript.get_default_schedule_date(doc); }
-}
-
 cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
 	return 'SELECT `tabProject`.name FROM `tabProject` \
 		WHERE `tabProject`.status not in ("Completed", "Cancelled") \
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index 218d4bf..908df67 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -65,10 +65,6 @@
 		self.validate_for_subcontracting()
 		self.update_raw_materials_supplied("po_raw_material_details")
 		
-
-	def get_default_schedule_date(self):
-		get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
-		
 	def validate_fiscal_year(self):
 		get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'PO Date')
 
@@ -101,16 +97,11 @@
 				"""[['Supplier Quotation', 'Purchase Order'],
 				['Supplier Quotation Item', 'Purchase Order Item'],
 				['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]""")
-			self.get_default_schedule_date()
 			for d in getlist(self.doclist, 'po_details'):
 				if d.prevdoc_detail_docname and not d.schedule_date:
 					d.schedule_date = webnotes.conn.get_value("Material Request Item",
 							d.prevdoc_detail_docname, "schedule_date")
 	
-	def get_tc_details(self):
-		"""get terms & conditions"""
-		return get_obj('Purchase Common').get_tc_details(self)
-
 	def get_last_purchase_rate(self):
 		get_obj('Purchase Common').get_last_purchase_rate(self)
 		
@@ -233,10 +224,4 @@
 		pass
 		
 	def get_rate(self,arg):
-		return get_obj('Purchase Common').get_rate(arg,self)	
-	
-	def load_default_taxes(self):
-		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
-
-	def get_purchase_tax_details(self):
-		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
+		return get_obj('Purchase Common').get_rate(arg,self)
\ No newline at end of file
diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt
index 8a56f26..b8e1cee 100644
--- a/buying/doctype/purchase_order/purchase_order.txt
+++ b/buying/doctype/purchase_order/purchase_order.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-25 16:01:24", 
+  "creation": "2013-05-21 16:16:39", 
   "docstatus": 0, 
-  "modified": "2013-02-18 13:37:11", 
+  "modified": "2013-06-05 14:45:40", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -31,7 +31,9 @@
   "parent": "Purchase Order", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -65,43 +67,48 @@
   "search_index": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "supplier_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Name", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -533,17 +540,7 @@
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
-  "oldfieldtype": "Button", 
-  "options": "get_tc_details"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1
+  "oldfieldtype": "Button"
  }, 
  {
   "doctype": "DocField", 
@@ -554,6 +551,7 @@
   "oldfieldtype": "Text Editor"
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_section", 
   "fieldtype": "Section Break", 
@@ -808,43 +806,15 @@
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
   "role": "Material User", 
   "submit": 0, 
   "write": 0
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Material User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Purchase Manager", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Purchase Manager", 
   "submit": 1, 
   "write": 1
@@ -854,28 +824,13 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Purchase User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "role": "All", 
-  "submit": 0
- }, 
- {
   "doctype": "DocPerm", 
   "match": "supplier", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Supplier"
  }
 ]
\ No newline at end of file
diff --git a/buying/doctype/purchase_order_item/purchase_order_item.txt b/buying/doctype/purchase_order_item/purchase_order_item.txt
index 01a144a..c561ed1 100755
--- a/buying/doctype/purchase_order_item/purchase_order_item.txt
+++ b/buying/doctype/purchase_order_item/purchase_order_item.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-07 11:42:55", 
+  "creation": "2013-05-24 19:29:06", 
   "docstatus": 0, 
-  "modified": "2013-05-22 11:59:52", 
+  "modified": "2013-05-31 14:26:22", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -361,7 +361,7 @@
   "oldfieldtype": "Currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "width": "100px"
  }, 
  {
@@ -377,15 +377,12 @@
   "read_only": 1
  }, 
  {
-  "default": "0.00", 
   "doctype": "DocField", 
-  "fieldname": "billed_qty", 
-  "fieldtype": "Float", 
-  "hidden": 0, 
-  "label": "Billed Quantity", 
+  "fieldname": "billed_amt", 
+  "fieldtype": "Currency", 
+  "label": "Billed Amt", 
   "no_copy": 1, 
-  "oldfieldname": "billed_qty", 
-  "oldfieldtype": "Currency", 
+  "options": "currency", 
   "print_hide": 1, 
   "read_only": 1
  }, 
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js
index 1e4f6cb..20a20ac 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -26,48 +26,15 @@
 erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
 	refresh: function() {
 		this._super();
-		
 
 		if (this.frm.doc.docstatus === 1) {
 			cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
 		}
-	},
-	
-	onload_post_render: function(doc, dt, dn) {	
-		var me = this;
-		var callback = function(doc, dt, dn) {
-			cur_frm.cscript.load_taxes(me.frm.doc);
-		}
-		
-		// TODO: improve this
-		if(this.frm.doc.__islocal) {
-			if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) {
-				this.price_list_name(callback);
-			} else {
-				callback(doc, dt, dn);
-			}
-		}
-	}
-	
+	},	
 });
 
-var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm});
-
 // for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
-
-cur_frm.cscript.onload = function(doc, dt, dn) {
-	// set missing values in parent doc
-	set_missing_values(doc, {
-		fiscal_year: sys_defaults.fiscal_year,
-		conversion_rate: 1,
-		currency: sys_defaults.currency,
-		status: "Draft",
-		transaction_date: get_today(),
-		is_subcontracted: "No"
-	});
-}
+$.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm}));
 
 cur_frm.cscript.make_purchase_order = function() {
 	var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
@@ -82,15 +49,6 @@
 	}, function(r, rt) { loaddoc("Purchase Order", new_po_name) });
 }
 
-cur_frm.cscript.supplier = function(doc, dt, dn) {
-	if (doc.supplier) {
-		get_server_fields('get_default_supplier_address',
-			JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1,
-			function() { cur_frm.refresh(); });
-		cur_frm.cscript.toggle_contact_section(doc);
-	}
-}
-
 cur_frm.cscript.uom = function(doc, cdt, cdn) {
 	// no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation
 }
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.py b/buying/doctype/supplier_quotation/supplier_quotation.py
index 0982fd6..421ecd0 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -63,12 +63,6 @@
 					d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
 					d.import_ref_rate = d.import_rate = 0.0
 	
-	def load_default_taxes(self):
-		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
-	
-	def get_purchase_tax_details(self):
-		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
-
 	def validate_fiscal_year(self):
 		get_obj(dt = 'Purchase Common').validate_fiscal_year( \
 			self.doc.fiscal_year, self.doc.transaction_date, 'Quotation Date')
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt
index dace56a..1882fb6 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.txt
+++ b/buying/doctype/supplier_quotation/supplier_quotation.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-25 16:01:25", 
+  "creation": "2013-05-21 16:16:45", 
   "docstatus": 0, 
-  "modified": "2013-02-18 13:40:17", 
+  "modified": "2013-06-05 14:46:30", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -31,7 +31,9 @@
   "parent": "Supplier Quotation", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -65,43 +67,48 @@
   "search_index": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "supplier_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Name", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -499,17 +506,7 @@
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
-  "oldfieldtype": "Button", 
-  "options": "get_tc_details"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1
+  "oldfieldtype": "Button"
  }, 
  {
   "doctype": "DocField", 
@@ -520,6 +517,7 @@
   "oldfieldtype": "Text Editor"
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_section", 
   "fieldtype": "Section Break", 
@@ -668,8 +666,6 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Manufacturing Manager", 
   "submit": 1, 
   "write": 1
@@ -679,8 +675,6 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Purchase Manager", 
   "submit": 1, 
   "write": 1
@@ -690,8 +684,6 @@
   "cancel": 0, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Purchase User", 
   "submit": 0, 
   "write": 1
@@ -701,8 +693,6 @@
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material User", 
   "submit": 0, 
   "write": 0
@@ -712,22 +702,8 @@
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Supplier", 
   "submit": 0, 
   "write": 0
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "All", 
-  "submit": 0, 
-  "write": 0
  }
 ]
\ No newline at end of file
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 2070fd4..e45e73d 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -13,7 +13,7 @@
 			},
 			{
 				label: wn._("Supplier Quotation"),
-				description: wn._("Track Quotations received from Suppliers."),
+				description: wn._("Quotations received from Suppliers."),
 				doctype:"Supplier Quotation"
 			},
 			{
diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js
index fc082ea..96b88b3 100644
--- a/buying/page/purchase_analytics/purchase_analytics.js
+++ b/buying/page/purchase_analytics/purchase_analytics.js
@@ -24,7 +24,7 @@
 	new erpnext.PurchaseAnalytics(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Buying")
+	wrapper.appframe.add_module_icon("Buying")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
@@ -49,7 +49,7 @@
 				item_key: "supplier",
 				parent_field: "parent_supplier_type", 
 				formatter: function(item) {
-					// return repl('<a href="#Report2/stock-invoices/customer=%(enc_value)s">%(value)s</a>', {
+					// return repl('<a href="#Report/stock-invoices/customer=%(enc_value)s">%(value)s</a>', {
 					// 		value: item.name,
 					// 		enc_value: encodeURIComponent(item.name)
 					// 	});
diff --git a/buying/utils.py b/buying/utils.py
index 0431e64..1aaa5d1 100644
--- a/buying/utils.py
+++ b/buying/utils.py
@@ -16,6 +16,7 @@
 
 from __future__ import unicode_literals
 import webnotes
+from webnotes import msgprint, _
 from webnotes.utils import getdate, flt, add_days
 import json
 
@@ -29,7 +30,11 @@
 			"warehouse": None,
 			"supplier": None,
 			"transaction_date": None,
-			"conversion_rate": 1.0
+			"conversion_rate": 1.0,
+			"price_list_name": None,
+			"price_list_currency": None,
+			"plc_conversion_rate": 1.0,
+			"is_subcontracted": "Yes" / "No"
 		}
 	"""
 	if isinstance(args, basestring):
@@ -37,86 +42,102 @@
 		
 	args = webnotes._dict(args)
 	
-	item_wrapper = webnotes.bean("Item", args.item_code)
-	item = item_wrapper.doc
+	item_bean = webnotes.bean("Item", args.item_code)
+	item = item_bean.doc
 	
-	from stock.utils import validate_end_of_life
-	validate_end_of_life(item.name, item.end_of_life)
+	_validate_item_details(args, item)
 	
-	# fetch basic values
-	out = webnotes._dict()
-	out.update({
-		"item_name": item.item_name,
-		"item_group": item.item_group,
-		"brand": item.brand,
-		"description": item.description,
-		"qty": 0,
-		"stock_uom": item.stock_uom,
-		"uom": item.stock_uom,
-		"conversion_factor": 1.0,
-		"warehouse": args.warehouse or item.default_warehouse,
-		"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in 
-			item_wrapper.doclist.get({"parentfield": "item_tax"})))),
-		"batch_no": None,
-		"expense_head": item.purchase_account,
-		"cost_center": item.cost_center
-	})
+	out = _get_basic_details(args, item_bean)
 	
-	if args.supplier:
-		item_supplier = item_wrapper.doclist.get({"parentfield": "item_supplier_details",
-			"supplier": args.supplier})
-		if item_supplier:
-			out["supplier_part_no"] = item_supplier[0].supplier_part_no
+	out.supplier_part_no = _get_supplier_part_no(args, item_bean)
 	
 	if out.warehouse:
-		out.projected_qty = webnotes.conn.get_value("Bin", {"item_code": item.name, 
-			"warehouse": out.warehouse}, "projected_qty")
+		out.projected_qty = get_projected_qty(item.name, out.warehouse)
 	
 	if args.transaction_date and item.lead_time_days:
 		out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
 			item.lead_time_days)
 			
-	# set zero
-	out.purchase_ref_rate = out.discount_rate = out.purchase_rate = \
-		out.import_ref_rate = out.import_rate = 0.0
+	meta = webnotes.get_doctype(args.doctype)
 	
-	if args.doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt", 
-			"Supplier Quotation"]:
-		# try fetching from price list
-		if args.price_list_name and args.price_list_currency:
-			rates_as_per_price_list = get_rates_as_per_price_list(args, item_wrapper.doclist)
-			if rates_as_per_price_list:
-				out.update(rates_as_per_price_list)
-		
-		# if not found, fetch from last purchase transaction
-		if not out.purchase_rate:
-			last_purchase = get_last_purchase_details(item.name, args.docname, args.conversion_rate)
-			if last_purchase:
-				out.update(last_purchase)
-			
+	if meta.get_field("currency"):
+		out.purchase_ref_rate = out.discount_rate = out.purchase_rate = \
+			out.import_ref_rate = out.import_rate = 0.0
+		out.update(_get_price_list_rate(args, item_bean, meta))
+	
+	if args.doctype == "Material Request":
+		out.min_order_qty = flt(item.min_order_qty)
+	
 	return out
-
-def get_rates_as_per_price_list(args, item_doclist=None):
-	if not item_doclist:
-		item_doclist = webnotes.bean("Item", args.item_code).doclist
 	
-	result = item_doclist.get({"parentfield": "ref_rate_details", 
-		"price_list_name": args.price_list_name, "ref_currency": args.price_list_currency,
-		"buying": 1})
+def _get_basic_details(args, item_bean):
+	item = item_bean.doc
+	
+	out = webnotes._dict({
+		"description": item.description_html or item.description,
+		"qty": 0.0,
+		"uom": item.stock_uom,
+		"conversion_factor": 1.0,
+		"warehouse": args.warehouse or item.default_warehouse,
+		"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in 
+			item_bean.doclist.get({"parentfield": "item_tax"})))),
+		"batch_no": None,
+		"expense_head": item.purchase_account,
+		"cost_center": item.cost_center
+	})
+	
+	for fieldname in ("item_name", "item_group", "brand", "stock_uom"):
+		out[fieldname] = item.fields.get(fieldname)
+	
+	return out
+	
+def _get_price_list_rate(args, item_bean, meta):
+	from utilities.transaction_base import validate_currency
+	item = item_bean.doc
+	out = webnotes._dict()
+	
+	# try fetching from price list
+	if args.price_list_name and args.price_list_currency:
+		price_list_rate = item_bean.doclist.get({
+			"parentfield": "ref_rate_details", 
+			"price_list_name": args.price_list_name, 
+			"ref_currency": args.price_list_currency,
+			"buying": 1})
+		if price_list_rate:
+			out.import_ref_rate = \
+				flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)
 		
-	if result:
-		purchase_ref_rate = flt(result[0].ref_rate) * flt(args.plc_conversion_rate)
-		conversion_rate = flt(args.conversion_rate) or 1.0
-		return webnotes._dict({
-			"purchase_ref_rate": purchase_ref_rate,
-			"purchase_rate": purchase_ref_rate,
-			"rate": purchase_ref_rate,
-			"discount_rate": 0,
-			"import_ref_rate": purchase_ref_rate / conversion_rate,
-			"import_rate": purchase_ref_rate / conversion_rate
-		})
-	else:
-		return webnotes._dict()
+	# if not found, fetch from last purchase transaction
+	if not out.import_ref_rate:
+		last_purchase = get_last_purchase_details(item.name, args.docname, args.conversion_rate)
+		if last_purchase:
+			out.update(last_purchase)
+	
+	if out.import_ref_rate or out.import_rate:
+		validate_currency(args, item, meta)
+	
+	return out
+	
+def _get_supplier_part_no(args, item_bean):
+	item_supplier = item_bean.doclist.get({"parentfield": "item_supplier_details",
+		"supplier": args.supplier})
+	
+	return item_supplier and item_supplier[0].supplier_part_no or None
+
+def _validate_item_details(args, item):
+	from utilities.transaction_base import validate_item_fetch
+	validate_item_fetch(args, item)
+	
+	# validate if purchase item or subcontracted item
+	if item.is_purchase_item != "Yes":
+		msgprint(_("Item") + (" %s: " % item.name) + _("not a purchase item"),
+			raise_exception=True)
+	
+	if args.is_subcontracted == "Yes" and item.is_sub_contracted_item != "Yes":
+		msgprint(_("Item") + (" %s: " % item.name) + 
+			_("not a sub-contracted item.") +
+			_("Please select a sub-contracted item or do not sub-contract the transaction."), 
+			raise_exception=True)
 
 def get_last_purchase_details(item_code, doc_name, conversion_rate=1.0):
 	"""returns last purchase details in stock uom"""
@@ -177,4 +198,14 @@
 		"rate": out.purchase_rate
 	})
 	
-	return out
\ No newline at end of file
+	return out
+	
+@webnotes.whitelist()
+def get_conversion_factor(item_code, uom):
+	return {"conversion_factor": webnotes.conn.get_value("UOM Conversion Detail",
+		{"parent": item_code, "uom": uom})}
+		
+@webnotes.whitelist()
+def get_projected_qty(item_code, warehouse):
+	return webnotes.conn.get_value("Bin", {"item_code": item_code, 
+			"warehouse": warehouse}, "projected_qty")
\ No newline at end of file
diff --git a/config.json b/config.json
index cb1a831..33e898f 100644
--- a/config.json
+++ b/config.json
@@ -2,78 +2,79 @@
 	"modules": {
 		"Selling": {
 			"link": "selling-home",
-			"color": "#3f4901",
+			"color": "#1abc9c",
 			"icon": "icon-tag",
 			"type": "module"
 		},
 		"Accounts": {
 			"link": "accounts-home",
-			"color": "#025770",
+			"color": "#3498db",
 			"icon": "icon-money",
 			"type": "module"
 		},
 		"Stock": {
 			"type": "module",
 			"link": "stock-home",
-			"color": "#a66a02",
+			"color": "#f39c12",
 			"icon": "icon-truck"
 		},
 		"Buying": {
 			"type": "module",
 			"link": "buying-home",
-			"color": "#8F0222",
+			"color": "#c0392b",
 			"icon": "icon-shopping-cart"
 		},
 		"Support": {
 			"type": "module",
 			"link": "support-home",
-			"color": "#410169",
+			"color": "#2c3e50",
 			"icon": "icon-phone"
 		},
 		"Projects": {
 			"type": "module",
 			"link": "projects-home",
-			"color": "#473b7f",
-			"icon": "icon-tasks"
+			"color": "#8e44ad",
+			"icon": "icon-puzzle-piece"
 		},
 		"Manufacturing": {
 			"type": "module",
 			"link": "manufacturing-home",
-			"color": "#590116",
-			"icon": "icon-magic"
+			"color": "#7f8c8d",
+			"icon": "icon-cogs"
 		},
 		"Website": {
 			"type": "module",
 			"link": "website-home",
-			"color": "#968c00",
+			"color": "#16a085",
 			"icon": "icon-globe"
 		},
 		"HR": {
 			"type": "module",
 			"link": "hr-home",
-			"color": "#018d6c",
+			"color": "#2ecc71",
 			"label": "Human Resources",
 			"icon": "icon-group"
 		},
 		"Setup": {
 			"type": "setup",
 			"link": "Setup",
-			"color": "#484848",
+			"color": "#bdc3c7",
 			"icon": "icon-wrench"
 		},
 		"Activity": {
 			"type": "page",
 			"link": "activity",
-			"color": "#633501",
+			"color": "#e67e22",
 			"icon": "icon-play",
 			"label": "Activity"
 		},
-		"Knowledge Base": {
-			"type": "page",
-			"link": "questions",
-			"color": "#01372b",
-			"label": "Knowledge Base",
-			"icon": "icon-question-sign"
+		"Notes": {
+			"type": "list",
+			"doctype": "Note",
+			"link": "List/Note",
+			"color": "#95a5a6",
+			"label": "Notes",
+			"icon": "icon-file-alt"
 		}
 	},
 	"web": {
@@ -126,6 +127,10 @@
 			"profile": {
 				"no_cache": true,
 				"template": "app/website/templates/pages/profile"
+			},
+			"cart": {
+				"no_cache": true,
+				"template": "app/website/templates/pages/cart.html"
 			}
 		},
 		"generators": {
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 04e4bbd..f417b31 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -16,14 +16,262 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import flt
-
-from utilities.transaction_base import TransactionBase
+from webnotes import _, msgprint
+from webnotes.utils import flt, cint
+from setup.utils import get_company_currency, get_price_list_currency
+from utilities.transaction_base import TransactionBase, validate_conversion_rate
+import json
 
 class AccountsController(TransactionBase):
 	def validate(self):
-		if self.meta.get_field("grand_total"):
+		self.set_missing_values(for_validate=True)
+		
+		if self.meta.get_field("currency"):
+			self.company_currency = get_company_currency(self.doc.company)
+			
+			validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
+				self.meta.get_label("conversion_rate"), self.doc.company)
+			
+			self.calculate_taxes_and_totals()
 			self.validate_value("grand_total", ">=", 0)
+			self.set_total_in_words()
+			
+	def set_price_list_currency(self, buying_or_selling):
+		# TODO - change this, since price list now has only one currency allowed
+		if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
+			not self.doc.price_list_currency:
+				self.doc.fields.update(get_price_list_currency({
+					"price_list_name": self.doc.price_list_name, 
+					"use_for": buying_or_selling
+				}))
+				
+	def set_missing_item_details(self, get_item_details):
+		"""set missing item values"""
+		for item in self.doclist.get({"parentfield": self.fname}):
+			if item.fields.get("item_code"):
+				args = item.fields.copy().update(self.doc.fields)
+				ret = get_item_details(args)
+				for fieldname, value in ret.items():
+					if self.meta.get_field(fieldname, parentfield=self.fname) and \
+						not item.fields.get(fieldname):
+							item.fields[fieldname] = value
+							
+	def set_taxes(self, tax_doctype, tax_parentfield, tax_master_field):
+		if not self.meta.get_field(tax_parentfield):
+			return
+			
+		if not self.doclist.get({"parentfield": tax_parentfield}):
+			if not self.doc.fields.get(tax_master_field):
+				# get the default tax master
+				self.doc.fields[tax_master_field] = \
+					webnotes.conn.get_value(tax_doctype + " Master", {"is_default": 1})
+				
+			if self.doc.fields.get(tax_master_field):
+				from webnotes.model import default_fields
+				tax_master = webnotes.bean(tax_doctype + " Master", self.doc.fields.get(tax_master_field))
+				
+				for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})):
+					for fieldname in default_fields:
+						tax.fields[fieldname] = None
+					
+					tax.fields.update({
+						"doctype": tax_doctype,
+						"parentfield": tax_parentfield,
+						"idx": i+1
+					})
+					
+					self.doclist.append(tax)
+					
+	def calculate_taxes_and_totals(self):
+		self.doc.conversion_rate = flt(self.doc.conversion_rate)
+		self.item_doclist = self.doclist.get({"parentfield": self.fname})
+		self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})
+		
+		self.calculate_item_values()
+		self.initialize_taxes()
+		
+		if hasattr(self, "determine_exclusive_rate"):
+			self.determine_exclusive_rate()
+		
+		self.calculate_net_total()
+		self.calculate_taxes()
+		self.calculate_totals()
+		self._cleanup()
+		
+		# TODO
+		# print format: show net_total_export instead of net_total
+		
+	def initialize_taxes(self):
+		for tax in self.tax_doclist:
+			tax.item_wise_tax_detail = {}
+			for fieldname in ["tax_amount", "total", 
+				"tax_amount_for_current_item", "grand_total_for_current_item",
+				"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]:
+					tax.fields[fieldname] = 0.0
+			
+			self.validate_on_previous_row(tax)
+			self.validate_inclusive_tax(tax)
+			self.round_floats_in(tax)
+			
+	def validate_on_previous_row(self, tax):
+		"""
+			validate if a valid row id is mentioned in case of
+			On Previous Row Amount and On Previous Row Total
+		"""
+		if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
+				(not tax.row_id or cint(tax.row_id) >= tax.idx):
+			msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
+				_("Please specify a valid") + " %(row_id_label)s") % {
+					"idx": tax.idx,
+					"taxes_doctype": tax.doctype,
+					"row_id_label": self.meta.get_label("row_id",
+						parentfield=self.other_fname)
+				}, raise_exception=True)
+				
+	def validate_inclusive_tax(self, tax):
+		def _on_previous_row_error(row_range):
+			msgprint((_("Row") + " # %(idx)s [%(doctype)s]: " +
+				_("to be included in Item's rate, it is required that: ") +
+				" [" + _("Row") + " # %(row_range)s] " + _("also be included in Item's rate")) % {
+					"idx": tax.idx,
+					"doctype": tax.doctype,
+					"inclusive_label": self.meta.get_label("included_in_print_rate",
+						parentfield=self.other_fname),
+					"charge_type_label": self.meta.get_label("charge_type",
+						parentfield=self.other_fname),
+					"charge_type": tax.charge_type,
+					"row_range": row_range
+				}, raise_exception=True)
+		
+		if cint(tax.included_in_print_rate):
+			if tax.charge_type == "Actual":
+				# inclusive tax cannot be of type Actual
+				msgprint((_("Row") 
+					+ " # %(idx)s [%(doctype)s]: %(charge_type_label)s = \"%(charge_type)s\" " 
+					+ "cannot be included in Item's rate") % {
+						"idx": tax.idx,
+						"doctype": tax.doctype,
+						"charge_type_label": self.meta.get_label("charge_type",
+							parentfield=self.other_fname),
+						"charge_type": tax.charge_type,
+					}, raise_exception=True)
+			elif tax.charge_type == "On Previous Row Amount" and \
+					not cint(self.tax_doclist[tax.row_id - 1].included_in_print_rate):
+				# referred row should also be inclusive
+				_on_previous_row_error(tax.row_id)
+			elif tax.charge_type == "On Previous Row Total" and \
+					not all([cint(t.included_in_print_rate) for t in self.tax_doclist[:tax.row_id - 1]]):
+				# all rows about the reffered tax should be inclusive
+				_on_previous_row_error("1 - %d" % (tax.row_id,))
+				
+	def calculate_taxes(self):
+		for item in self.item_doclist:
+			item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
+
+			for i, tax in enumerate(self.tax_doclist):
+				# tax_amount represents the amount of tax for the current step
+				current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
+				
+				if hasattr(self, "set_item_tax_amount"):
+					self.set_item_tax_amount(item, tax, current_tax_amount)
+
+				# case when net total is 0 but there is an actual type charge
+				# in this case add the actual amount to tax.tax_amount
+				# and tax.grand_total_for_current_item for the first such iteration
+				if tax.charge_type=="Actual" and \
+						not (current_tax_amount or self.doc.net_total or tax.tax_amount):
+					zero_net_total_adjustment = flt(tax.rate, self.precision("tax_amount", tax))
+					current_tax_amount += zero_net_total_adjustment
+
+				# store tax_amount for current item as it will be used for
+				# charge type = 'On Previous Row Amount'
+				tax.tax_amount_for_current_item = current_tax_amount
+
+				# accumulate tax amount into tax.tax_amount
+				tax.tax_amount += current_tax_amount
+				
+				if tax.category:
+					# if just for valuation, do not add the tax amount in total
+					# hence, setting it as 0 for further steps
+					current_tax_amount = 0.0 if (tax.category == "Valuation") else current_tax_amount
+					
+					current_tax_amount *= -1.0 if (tax.add_deduct_tax == "Deduct") else 1.0
+				
+				# Calculate tax.total viz. grand total till that step
+				# note: grand_total_for_current_item contains the contribution of 
+				# item's amount, previously applied tax and the current tax on that item
+				if i==0:
+					tax.grand_total_for_current_item = flt(item.amount +
+						current_tax_amount, self.precision("total", tax))
+						
+				else:
+					tax.grand_total_for_current_item = \
+						flt(self.tax_doclist[i-1].grand_total_for_current_item +
+							current_tax_amount, self.precision("total", tax))
+							
+				# in tax.total, accumulate grand total of each item
+				tax.total += tax.grand_total_for_current_item
+				
+	def get_current_tax_amount(self, item, tax, item_tax_map):
+		tax_rate = self._get_tax_rate(tax, item_tax_map)
+		current_tax_amount = 0.0
+
+		if tax.charge_type == "Actual":
+			# distribute the tax amount proportionally to each item row
+			actual = flt(tax.rate, self.precision("tax_amount", tax))
+			current_tax_amount = (self.doc.net_total
+				and ((item.amount / self.doc.net_total) * actual)
+				or 0)
+		elif tax.charge_type == "On Net Total":
+			current_tax_amount = (tax_rate / 100.0) * item.amount
+		elif tax.charge_type == "On Previous Row Amount":
+			current_tax_amount = (tax_rate / 100.0) * \
+				self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
+		elif tax.charge_type == "On Previous Row Total":
+			current_tax_amount = (tax_rate / 100.0) * \
+				self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
+		
+		current_tax_amount = flt(current_tax_amount, self.precision("tax_amount", tax))
+		
+		# store tax breakup for each item
+		tax.item_wise_tax_detail[item.item_code or item.item_name] = [tax_rate, current_tax_amount]
+
+		return current_tax_amount
+		
+	def _load_item_tax_rate(self, item_tax_rate):
+		return json.loads(item_tax_rate) if item_tax_rate else {}
+		
+	def _get_tax_rate(self, tax, item_tax_map):
+		if item_tax_map.has_key(tax.account_head):
+			return flt(item_tax_map.get(tax.account_head), self.precision("rate", tax))
+		else:
+			return tax.rate
+	
+	def _cleanup(self):
+		for tax in self.tax_doclist:
+			for fieldname in ("grand_total_for_current_item",
+				"tax_amount_for_current_item",
+				"tax_fraction_for_current_item", 
+				"grand_total_fraction_for_current_item"):
+				if fieldname in tax.fields:
+					del tax.fields[fieldname]
+			
+			tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
+			
+	def _set_in_company_currency(self, item, print_field, base_field):
+		"""set values in base currency"""
+		item.fields[base_field] = flt((flt(item.fields[print_field],
+			self.precision(print_field, item)) * self.doc.conversion_rate),
+			self.precision(base_field, item))
+			
+	def calculate_total_advance(self, parenttype, advance_parentfield):
+		if self.doc.doctype == parenttype and self.doc.docstatus < 2:
+			sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) 
+				for adv in self.doclist.get({"parentfield": advance_parentfield})])
+
+			self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
+			
+			self.calculate_outstanding_amount()
 
 	def get_gl_dict(self, args, cancel=None):
 		"""this method populates the common properties of a gl entry record"""
@@ -97,4 +345,4 @@
 		if not hasattr(self, "_abbr"):
 			self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
 			
-		return self._abbr
\ No newline at end of file
+		return self._abbr
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 3deda02..36ce285 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -17,35 +17,45 @@
 from __future__ import unicode_literals
 import webnotes
 from webnotes import _, msgprint
-from webnotes.utils import flt, cint
-import json
+from webnotes.utils import flt
 
 from buying.utils import get_item_details
 from setup.utils import get_company_currency
-from webnotes.model.utils import round_floats_in_doc
 
 from controllers.stock_controller import StockController
 
 class WrongWarehouseCompany(Exception): pass
 
 class BuyingController(StockController):
+	def onload_post_render(self):
+		self.set_price_list_currency("buying")
+
+		# contact, address, item details
+		self.set_missing_values()
+		
+		self.set_taxes("Purchase Taxes and Charges", "purchase_tax_details", "purchase_other_charges")
+	
 	def validate(self):
 		super(BuyingController, self).validate()
 		self.validate_stock_or_nonstock_items()
 		self.validate_warehouse_belongs_to_company()
-		if self.meta.get_field("currency"):
-			self.company_currency = get_company_currency(self.doc.company)
-			self.validate_conversion_rate("currency", "conversion_rate")
-			
-			if self.doc.price_list_name and self.doc.price_list_currency:
-				self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
-			
-			# IMPORTANT: enable this only when client side code is similar to this one
-			# self.calculate_taxes_and_totals()
+		
+	def set_missing_values(self, for_validate=False):
+		# set contact and address details for supplier, if they are not mentioned
+		if self.doc.supplier and not (self.doc.contact_person and self.doc.supplier_address):
+			for fieldname, val in self.get_default_address_and_contact("supplier").items():
+				if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
+					self.doc.fields[fieldname] = val
+		
+		self.set_missing_item_details(get_item_details)
+		
+	def set_supplier_defaults(self):
+		self.doc.fields.update(self.get_default_supplier_address(self.doc.fields))
 						
-			# set total in words
-			self.set_total_in_words()
-	
+	def get_purchase_tax_details(self):
+		self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
+		self.set_taxes("Purchase Taxes and Charges", "purchase_tax_details", "purchase_other_charges")
+		
 	def validate_warehouse_belongs_to_company(self):
 		for warehouse, company in webnotes.conn.get_values("Warehouse", 
 			self.doclist.get_distinct_values("warehouse"), "company").items():
@@ -71,46 +81,6 @@
 				webnotes.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' 
 					as all items are non-stock items"""), raise_exception=1)
 			
-	def update_item_details(self):
-		for item in self.doclist.get({"parentfield": self.fname}):
-			ret = get_item_details({
-				"doctype": self.doc.doctype,
-				"docname": self.doc.name,
-				"item_code": item.item_code,
-				"warehouse": item.warehouse,
-				"supplier": self.doc.supplier,
-				"transaction_date": self.doc.posting_date,
-				"conversion_rate": self.doc.conversion_rate,
-				"price_list_name": self.doc.price_list_name,
-				"price_list_currency": self.doc.price_list_currency,
-				"plc_conversion_rate": self.doc.plc_conversion_rate
-			})
-			for r in ret:
-				if not item.fields.get(r):
-					item.fields[r] = ret[r]
-	
-	def validate_conversion_rate(self, currency_field, conversion_rate_field):
-		"""common validation for currency and price list currency"""
-		
-		currency = self.doc.fields.get(currency_field)
-		conversion_rate = flt(self.doc.fields.get(conversion_rate_field))
-		conversion_rate_label = self.meta.get_label(conversion_rate_field)
-		
-		if conversion_rate == 0:
-			msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
-		
-		# parenthesis for 'OR' are necessary as we want it to evaluate as 
-		# mandatory valid condition and (1st optional valid condition 
-		# 	or 2nd optional valid condition)
-		valid_conversion_rate = (conversion_rate and 
-			((currency == self.company_currency and conversion_rate == 1.00)
-				or (currency != self.company_currency and conversion_rate != 1.00)))
-
-		if not valid_conversion_rate:
-			msgprint(_('Please enter valid ') + conversion_rate_label + (': ') 
-				+ ("1 %s = [?] %s" % (currency, self.company_currency)),
-				raise_exception=True)
-
 	def set_total_in_words(self):
 		from webnotes.utils import money_in_words
 		company_currency = get_company_currency(self.doc.company)
@@ -121,154 +91,54 @@
 		 		self.doc.currency)
 		
 	def calculate_taxes_and_totals(self):
-		self.doc.conversion_rate = flt(self.doc.conversion_rate)
-		self.item_doclist = self.doclist.get({"parentfield": self.fname})
-		self.tax_doclist = self.doclist.get({"parentfield": "purchase_tax_details"})
-		
-		self.calculate_item_values()
-		self.initialize_taxes()
-		self.calculate_net_total()
-		self.calculate_taxes()
-		self.calculate_totals()
-		self.calculate_outstanding_amount()
-		
-		self._cleanup()
+		self.other_fname = "purchase_tax_details"
+		super(BuyingController, self).calculate_taxes_and_totals()
+		self.calculate_total_advance("Purchase Invoice", "advance_allocation_details")
 		
 	def calculate_item_values(self):
-		def _set_base(item, print_field, base_field):
-			"""set values in base currency"""
-			item.fields[base_field] = flt((flt(item.fields[print_field],
-				self.precision.item[print_field]) * self.doc.conversion_rate),
-				self.precision.item[base_field])
-
-		for item in self.item_doclist:
-			round_floats_in_doc(item, self.precision.item)
+		# hack! - cleaned up in _cleanup()
+		if self.doc.doctype != "Purchase Invoice":
+			df = self.meta.get_field("purchase_rate", parentfield=self.fname)
+			df.fieldname = "rate"
 			
+		for item in self.item_doclist:
 			# hack! - cleaned up in _cleanup()
 			if self.doc.doctype != "Purchase Invoice":
 				item.rate = item.purchase_rate
-				self.precision.item.rate = self.precision.item.purchase_rate
 				
-				item.discount = item.discount_rate
-				self.precision.item.discount = self.precision.item.discount_rate
+			self.round_floats_in(item)
 
-			if item.discount == 100:
-				if not item.import_ref_rate:
-					item.import_ref_rate = item.import_rate
-				item.import_rate = 0
-			else:
-				if item.import_ref_rate:
-					item.import_rate = flt(item.import_ref_rate *
-						(1.0 - (item.discount_rate / 100.0)),
-						self.precision.item.import_rate)
-				else:
-					# assume that print rate and discount are specified
-					item.import_ref_rate = flt(item.import_rate / 
-						(1.0 - (item.discount_rate / 100.0)),
-						self.precision.item.import_ref_rate)
+			if item.discount_rate == 100.0:
+				item.import_rate = 0.0
+			elif item.import_ref_rate:
+				item.import_rate = flt(item.import_ref_rate * (1.0 - (item.discount_rate / 100.0)),
+					self.precision("import_rate", item))
 						
 			item.import_amount = flt(item.import_rate * item.qty,
-				self.precision.item.import_amount)
+				self.precision("import_amount", item))
+			item.item_tax_amount = 0.0;
 				
-			_set_base(item, "import_ref_rate", "purchase_ref_rate")
-			_set_base(item, "import_rate", "rate")
-			_set_base(item, "import_amount", "amount")
-		
-	def initialize_taxes(self):
-		for tax in self.tax_doclist:
-			# initialize totals to 0
-			tax.tax_amount = tax.total = 0.0
+			self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate")
+			self._set_in_company_currency(item, "import_rate", "rate")
+			self._set_in_company_currency(item, "import_amount", "amount")
 			
-			# temporary fields
-			tax.tax_amount_for_current_item = tax.grand_total_for_current_item = 0.0
-			
-			tax.item_wise_tax_detail = {}
-			
-			self.validate_on_previous_row(tax)
-			
-			round_floats_in_doc(tax, self.precision.tax)
-		
 	def calculate_net_total(self):
-		self.doc.net_total = 0
-		self.doc.net_total_import = 0
+		self.doc.net_total = self.doc.net_total_import = 0.0
 
 		for item in self.item_doclist:
 			self.doc.net_total += item.amount
 			self.doc.net_total_import += item.import_amount
 			
-		self.doc.net_total = flt(self.doc.net_total, self.precision.main.net_total)
-		self.doc.net_total_import = flt(self.doc.net_total_import,
-			self.precision.main.net_total_import)
-		
-	def calculate_taxes(self):
-		for item in self.item_doclist:
-			item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
-			item.item_tax_amount = 0
-
-			for i, tax in enumerate(self.tax_doclist):
-				# tax_amount represents the amount of tax for the current step
-				current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
-
-				self.set_item_tax_amount(item, tax, current_tax_amount)
-
-				# case when net total is 0 but there is an actual type charge
-				# in this case add the actual amount to tax.tax_amount
-				# and tax.grand_total_for_current_item for the first such iteration
-				if not (current_tax_amount or self.doc.net_total or tax.tax_amount) and \
-						tax.charge_type=="Actual":
-					zero_net_total_adjustment = flt(tax.rate, self.precision.tax.tax_amount)
-					current_tax_amount += zero_net_total_adjustment
-
-				# store tax_amount for current item as it will be used for
-				# charge type = 'On Previous Row Amount'
-				tax.tax_amount_for_current_item = current_tax_amount
-
-				# accumulate tax amount into tax.tax_amount
-				tax.tax_amount += tax.tax_amount_for_current_item
-
-				if tax.category == "Valuation":
-					# if just for valuation, do not add the tax amount in total
-					# hence, setting it as 0 for further steps
-					current_tax_amount = 0
-				else:
-					current_tax_amount *= tax.add_deduct_tax == "Deduct" and -1.0 or 1.0
-
-				# Calculate tax.total viz. grand total till that step
-				# note: grand_total_for_current_item contains the contribution of 
-				# item's amount, previously applied tax and the current tax on that item
-				if i==0:
-					tax.grand_total_for_current_item = flt(item.amount +
-						current_tax_amount, self.precision.tax.total)
-
-				else:
-					tax.grand_total_for_current_item = \
-						flt(self.tax_doclist[i-1].grand_total_for_current_item +
-							current_tax_amount, self.precision.tax.total)
-
-				# in tax.total, accumulate grand total of each item
-				tax.total += tax.grand_total_for_current_item
-
-				# store tax_breakup for each item
-				# DOUBT: should valuation type amount also be stored?
-				tax.item_wise_tax_detail[item.item_code] = current_tax_amount
+		self.round_floats_in(self.doc, ["net_total", "net_total_import"])
 		
 	def calculate_totals(self):
-		if self.tax_doclist:
-			self.doc.grand_total = flt(self.tax_doclist[-1].total,
-				self.precision.main.grand_total)
-			self.doc.grand_total_import = flt(
-				self.doc.grand_total / self.doc.conversion_rate,
-				self.precision.main.grand_total_import)
-		else:
-			self.doc.grand_total = flt(self.doc.net_total,
-				self.precision.main.grand_total)
-			self.doc.grand_total_import = flt(
-				self.doc.grand_total / self.doc.conversion_rate,
-				self.precision.main.grand_total_import)
+		self.doc.grand_total = flt(self.tax_doclist and \
+			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
+		self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
+			self.precision("grand_total_import"))
 
-		self.doc.total_tax = \
-			flt(self.doc.grand_total - self.doc.net_total,
-			self.precision.main.total_tax)
+		self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
+			self.precision("total_tax"))
 
 		if self.meta.get_field("rounded_total"):
 			self.doc.rounded_total = round(self.doc.grand_total)
@@ -277,75 +147,31 @@
 			self.doc.rounded_total_import = round(self.doc.grand_total_import)
 			
 	def calculate_outstanding_amount(self):
-		if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
+		if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2:
 			self.doc.total_advance = flt(self.doc.total_advance,
-				self.precision.main.total_advance)
+				self.precision("total_advance"))
 			self.doc.total_amount_to_pay = flt(self.doc.grand_total - flt(self.doc.write_off_amount,
-				self.precision.main.write_off_amount), self.precision.main.total_amount_to_pay)
+				self.precision("write_off_amount")), self.precision("total_amount_to_pay"))
 			self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
-				self.precision.main.outstanding_amount)
+				self.precision("outstanding_amount"))
 			
 	def _cleanup(self):
-		for tax in self.tax_doclist:
-			del tax.fields["grand_total_for_current_item"]
-			del tax.fields["tax_amount_for_current_item"]
-			tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
-		
-		# except in purchase invoice, rate field is purchase_rate
+		super(BuyingController, self)._cleanup()
+			
+		# except in purchase invoice, rate field is purchase_rate		
+		# reset fieldname of rate
 		if self.doc.doctype != "Purchase Invoice":
+			df = self.meta.get_field("rate", parentfield=self.fname)
+			df.fieldname = "purchase_rate"
+			
 			for item in self.item_doclist:
 				item.purchase_rate = item.rate
 				del item.fields["rate"]
+		
+		if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
+			for item in self.item_doclist:
+				del item.fields["item_tax_amount"]
 				
-				item.discount_rate = item.discount
-				del item.fields["discount"]
-		
-	def validate_on_previous_row(self, tax):
-		"""
-			validate if a valid row id is mentioned in case of
-			On Previous Row Amount and On Previous Row Total
-		"""
-		if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
-				(not tax.row_id or cint(tax.row_id) >= tax.idx):
-			msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
-				_("Please specify a valid") + " %(row_id_label)s") % {
-					"idx": tax.idx,
-					"taxes_doctype": tax.parenttype,
-					"row_id_label": self.meta.get_label("row_id",
-						parentfield="purchase_tax_details")
-				}, raise_exception=True)
-				
-	def _load_item_tax_rate(self, item_tax_rate):
-		if not item_tax_rate:
-			return {}
-		return json.loads(item_tax_rate)
-		
-	def get_current_tax_amount(self, item, tax, item_tax_map):
-		tax_rate = self._get_tax_rate(tax, item_tax_map)
-
-		if tax.charge_type == "Actual":
-			# distribute the tax amount proportionally to each item row
-			actual = flt(tax.rate, self.precision.tax.tax_amount)
-			current_tax_amount = (self.doc.net_total
-				and ((item.amount / self.doc.net_total) * actual)
-				or 0)
-		elif tax.charge_type == "On Net Total":
-			current_tax_amount = (tax_rate / 100.0) * item.amount
-		elif tax.charge_type == "On Previous Row Amount":
-			current_tax_amount = (tax_rate / 100.0) * \
-				self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
-		elif tax.charge_type == "On Previous Row Total":
-			current_tax_amount = (tax_rate / 100.0) * \
-				self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
-
-		return flt(current_tax_amount, self.precision.tax.tax_amount)
-		
-	def _get_tax_rate(self, tax, item_tax_map):
-		if item_tax_map.has_key(tax.account_head):
-			return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
-		else:
-			return tax.rate
-			
 	def set_item_tax_amount(self, item, tax, current_tax_amount):
 		"""
 			item_tax_amount is the total tax amount applied on that item
@@ -354,28 +180,28 @@
 			TODO: rename item_tax_amount to valuation_tax_amount
 		"""
 		if tax.category in ["Valuation", "Valuation and Total"] and \
-				item.item_code in self.stock_items:
-			item.item_tax_amount += flt(current_tax_amount,
-				self.precision.item.item_tax_amount)
+			self.meta.get_field("item_tax_amount", parentfield=self.fname):
+				item.item_tax_amount += flt(current_tax_amount, self.precision("item_tax_amount", item))
 				
 	# update valuation rate
 	def update_valuation_rate(self, parentfield):
-		for d in self.doclist.get({"parentfield": parentfield}):
-			d.conversion_factor = d.conversion_factor or flt(webnotes.conn.get_value(
-				"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, 
+		for item in self.doclist.get({"parentfield": parentfield}):
+			item.conversion_factor = item.conversion_factor or flt(webnotes.conn.get_value(
+				"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom}, 
 				"conversion_factor")) or 1
-			if d.item_code and d.qty:
+			
+			if item.item_code and item.qty:
+				self.round_floats_in(item)
+				
+				purchase_rate = item.rate if self.doc.doctype == "Purchase Invoice" else item.purchase_rate
+				
 				# if no item code, which is sometimes the case in purchase invoice, 
 				# then it is not possible to track valuation against it
-				d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or 
-					flt(d.rate, self.precision.item.rate)) + 
-					(flt(d.item_tax_amount, self.precision.item.item_tax_amount) + 
-					flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) / 
-					flt(d.qty, self.precision.item.qty)) / 
-					flt(d.conversion_factor, self.precision.item.conversion_factor), 
-					self.precision.item.valuation_rate)	
+				item.valuation_rate = flt((purchase_rate + 
+					(item.item_tax_amount + item.rm_supp_cost) / item.qty) / item.conversion_factor, 
+					self.precision("valuation_rate", item))
 			else:
-				d.valuation_rate = 0.0
+				item.valuation_rate = 0.0
 				
 	def validate_for_subcontracting(self):
 		if not self.doc.is_subcontracted and self.sub_contracted_items:
@@ -437,18 +263,6 @@
 		
 		return bom_items
 
-	
-	@property
-	def precision(self):
-		if not hasattr(self, "_precision"):
-			self._precision = webnotes._dict()
-			self._precision.main = self.meta.get_precision_map()
-			self._precision.item = self.meta.get_precision_map(parentfield = self.fname)
-			if self.meta.get_field("purchase_tax_details"):
-				self._precision.tax = self.meta.get_precision_map(parentfield = \
-					"purchase_tax_details")
-		return self._precision
-
 	@property
 	def sub_contracted_items(self):
 		if not hasattr(self, "_sub_contracted_items"):
@@ -473,4 +287,4 @@
 					from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
 					(", ".join((["%s"]*len(item_codes))),), item_codes)]
 
-		return self._purchase_items
+		return self._purchase_items
\ No newline at end of file
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index 80af337..3adc639 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -16,16 +16,40 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint
+from webnotes.utils import cint, flt, comma_or
 from setup.utils import get_company_currency
+from selling.utils import get_item_details
 from webnotes import msgprint, _
 
 from controllers.stock_controller import StockController
 
 class SellingController(StockController):
-	def validate(self):
-		super(SellingController, self).validate()
-		self.set_total_in_words()
+	def onload_post_render(self):
+		self.set_price_list_currency("selling")
+
+		# contact, address, item details and pos details (if applicable)
+		self.set_missing_values()
+		
+		self.set_taxes("Sales Taxes and Charges", "other_charges", "charge")
+			
+	def set_missing_values(self, for_validate=False):
+		# set contact and address details for customer, if they are not mentioned
+		if self.doc.customer and not (self.doc.contact_person and self.doc.customer_address):
+			for fieldname, val in self.get_default_address_and_contact("customer").items():
+				if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
+					self.doc.fields[fieldname] = val
+					
+		self.set_missing_item_details(get_item_details)
+							
+	def get_other_charges(self):
+		self.doclist = self.doc.clear_table(self.doclist, "other_charges")
+		self.set_taxes("Sales Taxes and Charges", "other_charges", "charge")
+		
+	def set_customer_defaults(self):
+		self.get_default_customer_address()
+		
+		if self.meta.get_field("shipping_address"):
+			self.doc.fields.update(self.get_shipping_address(self.doc.customer))
 		
 	def set_total_in_words(self):
 		from webnotes.utils import money_in_words
@@ -71,4 +95,154 @@
 				
 		if item.buying_amount and not item.cost_center:
 			msgprint(_("""Cost Center is mandatory for item: """) + item.item_code, 
-				raise_exception=1)
\ No newline at end of file
+				raise_exception=1)
+				
+	def calculate_taxes_and_totals(self):
+		self.other_fname = "other_charges"
+		
+		super(SellingController, self).calculate_taxes_and_totals()
+		
+		self.calculate_total_advance("Sales Invoice", "advance_adjustment_details")
+		self.calculate_commission()
+		self.calculate_contribution()
+				
+	def determine_exclusive_rate(self):
+		if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)):
+			# no inclusive tax
+			return
+		
+		for item in self.item_doclist:
+			item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
+			cumulated_tax_fraction = 0
+			for i, tax in enumerate(self.tax_doclist):
+				tax.tax_fraction_for_current_item = self.get_current_tax_fraction(tax, item_tax_map)
+				
+				if i==0:
+					tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item
+				else:
+					tax.grand_total_fraction_for_current_item = \
+						self.tax_doclist[i-1].grand_total_fraction_for_current_item \
+						+ tax.tax_fraction_for_current_item
+						
+				cumulated_tax_fraction += tax.tax_fraction_for_current_item
+			
+			if cumulated_tax_fraction:
+				item.basic_rate = flt((item.export_rate * self.doc.conversion_rate) / 
+					(1 + cumulated_tax_fraction), self.precision("basic_rate", item))
+				
+				item.amount = flt(item.basic_rate * item.qty, self.precision("amount", item))
+				
+				if item.adj_rate == 100:
+					item.base_ref_rate = item.basic_rate
+					item.basic_rate = 0.0
+				else:
+					item.base_ref_rate = flt(item.basic_rate / (1 - (item.adj_rate / 100.0)),
+						self.precision("base_ref_rate", item))
+			
+	def get_current_tax_fraction(self, tax, item_tax_map):
+		"""
+			Get tax fraction for calculating tax exclusive amount
+			from tax inclusive amount
+		"""
+		current_tax_fraction = 0
+		
+		if cint(tax.included_in_print_rate):
+			tax_rate = self._get_tax_rate(tax, item_tax_map)
+			
+			if tax.charge_type == "On Net Total":
+				current_tax_fraction = tax_rate / 100.0
+			
+			elif tax.charge_type == "On Previous Row Amount":
+				current_tax_fraction = (tax_rate / 100.0) * \
+					self.tax_doclist[cint(tax.row_id) - 1].tax_fraction_for_current_item
+			
+			elif tax.charge_type == "On Previous Row Total":
+				current_tax_fraction = (tax_rate / 100.0) * \
+					self.tax_doclist[cint(tax.row_id) - 1].grand_total_fraction_for_current_item
+						
+		return current_tax_fraction
+		
+	def calculate_item_values(self):
+		for item in self.item_doclist:
+			self.round_floats_in(item)
+			
+			if item.adj_rate == 100:
+				item.export_rate = 0
+			elif item.ref_rate:
+				item.export_rate = flt(item.ref_rate * (1.0 - (item.adj_rate / 100.0)),
+					self.precision("export_rate", item))
+						
+			item.export_amount = flt(item.export_rate * item.qty,
+				self.precision("export_amount", item))
+				
+			self._set_in_company_currency(item, "ref_rate", "base_ref_rate")
+			self._set_in_company_currency(item, "export_rate", "basic_rate")
+			self._set_in_company_currency(item, "export_amount", "amount")
+			
+	def calculate_net_total(self):
+		self.doc.net_total = self.doc.net_total_export = 0.0
+
+		for item in self.item_doclist:
+			self.doc.net_total += item.amount
+			self.doc.net_total_export += item.export_amount
+		
+		self.round_floats_in(self.doc, ["net_total", "net_total_export"])
+				
+	def calculate_totals(self):
+		self.doc.grand_total = flt(self.tax_doclist and \
+			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
+		self.doc.grand_total_export = flt(self.doc.grand_total / self.doc.conversion_rate, 
+			self.precision("grand_total_export"))
+			
+		self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
+			self.precision("other_charges_total"))
+		self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
+			self.precision("other_charges_total_export"))
+		
+		self.doc.rounded_total = round(self.doc.grand_total)
+		self.doc.rounded_total_export = round(self.doc.grand_total_export)
+		
+	def calculate_outstanding_amount(self):
+		# NOTE: 
+		# write_off_amount is only for POS Invoice
+		# total_advance is only for non POS Invoice
+		if self.doc.doctype == "Sales Invoice" and self.doc.docstatus < 2:
+			self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount",
+				"paid_amount"])
+			total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount
+			self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
+				self.precision("outstanding_amount"))
+		
+	def calculate_commission(self):
+		if self.meta.get_field("commission_rate"):
+			self.round_floats_in(self.doc, ["net_total", "commission_rate"])
+			if self.doc.commission_rate > 100.0:
+				msgprint(_(self.meta.get_label("commission_rate")) + " " + 
+					_("cannot be greater than 100"), raise_exception=True)
+		
+			self.doc.total_commission = flt(self.doc.net_total * self.doc.commission_rate / 100.0,
+				self.precision("total_commission"))
+
+	def calculate_contribution(self):
+		total = 0.0
+		sales_team = self.doclist.get({"parentfield": "sales_team"})
+		for sales_person in sales_team:
+			self.round_floats_in(sales_person)
+
+			sales_person.allocated_amount = flt(
+				self.doc.net_total * sales_person.allocated_percentage / 100.0,
+				self.precision("allocated_amount", sales_person))
+			
+			total += sales_person.allocated_percentage
+		
+		if sales_team and total != 100.0:
+			msgprint(_("Total") + " " + 
+				_(self.meta.get_label("allocated_percentage", parentfield="sales_team")) + 
+				" " + _("should be 100%"), raise_exception=True)
+			
+	def validate_order_type(self):
+		valid_types = ["Sales", "Maintenance"]
+		if self.doc.order_type not in valid_types:
+			msgprint(_(self.meta.get_label("order_type")) + " " + 
+				_("must be one of") + ": " + comma_or(valid_types),
+				raise_exception=True)
diff --git a/controllers/status_updater.py b/controllers/status_updater.py
new file mode 100644
index 0000000..ac06b2e
--- /dev/null
+++ b/controllers/status_updater.py
@@ -0,0 +1,177 @@
+# 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, cstr
+from webnotes import msgprint
+
+from webnotes.model.controller import DocListController
+
+class StatusUpdater(DocListController):
+	"""
+		Updates the status of the calling records
+		Delivery Note: Update Delivered Qty, Update Percent and Validate over delivery
+		Sales Invoice: Update Billed Amt, Update Percent and Validate over billing
+		Installation Note: Update Installed Qty, Update Percent Qty and Validate over installation
+	"""
+
+	def update_prevdoc_status(self):
+		self.update_qty()
+		self.validate_qty()
+	
+	def validate_qty(self):
+		"""
+			Validates qty at row level
+		"""
+		self.tolerance = {}
+		self.global_tolerance = None
+		
+		for args in self.status_updater:
+			# get unique transactions to update
+			for d in self.doclist:
+				if d.doctype == args['source_dt'] and d.fields.get(args["join_field"]):
+					args['name'] = d.fields[args['join_field']]
+
+					# get all qty where qty > target_field
+					item = webnotes.conn.sql("""select item_code, `%(target_ref_field)s`, 
+						`%(target_field)s`, parenttype, parent from `tab%(target_dt)s` 
+						where `%(target_ref_field)s` < `%(target_field)s` 
+						and name="%(name)s" and docstatus=1""" % args, as_dict=1)
+					if item:
+						item = item[0]
+						item['idx'] = d.idx
+						item['target_ref_field'] = args['target_ref_field'].replace('_', ' ')
+
+						if not item[args['target_ref_field']]:
+							msgprint("""As %(target_ref_field)s for item: %(item_code)s in \
+							%(parenttype)s: %(parent)s is zero, system will not check \
+							over-delivery or over-billed""" % item)
+						elif args.get('no_tolerance'):
+							item['reduce_by'] = item[args['target_field']] - \
+								item[args['target_ref_field']]
+							if item['reduce_by'] > .01:
+								msgprint("""
+									Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item \
+									%(item_code)s</b> against <b>%(parenttype)s %(parent)s</b> \
+									is <b>""" % item + cstr(item[args['target_ref_field']]) +
+									 """</b>.<br>You must reduce the %(target_ref_field)s by \
+									%(reduce_by)s""" % item, raise_exception=1)
+					
+						else:
+							self.check_overflow_with_tolerance(item, args)
+						
+	def check_overflow_with_tolerance(self, item, args):
+		"""
+			Checks if there is overflow condering a relaxation tolerance
+		"""
+	
+		# check if overflow is within tolerance
+		tolerance = self.get_tolerance_for(item['item_code'])
+		overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / 
+		 	item[args['target_ref_field']]) * 100
+	
+		if overflow_percent - tolerance > 0.01:
+			item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100)
+			item['reduce_by'] = item[args['target_field']] - item['max_allowed']
+		
+			msgprint("""
+				Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item %(item_code)s</b> \
+				against <b>%(parenttype)s %(parent)s</b> is <b>%(max_allowed)s</b>. 
+				
+				If you want to increase your overflow tolerance, please increase tolerance %% in \
+				Global Defaults or Item master. 
+				
+				Or, you must reduce the %(target_ref_field)s by %(reduce_by)s
+				
+				Also, please check if the order item has already been billed in the Sales Order""" % 
+				item, raise_exception=1)
+				
+	def get_tolerance_for(self, item_code):
+		"""
+			Returns the tolerance for the item, if not set, returns global tolerance
+		"""
+		if self.tolerance.get(item_code): return self.tolerance[item_code]
+		
+		tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0)
+
+		if not tolerance:
+			if self.global_tolerance == None:
+				self.global_tolerance = flt(webnotes.conn.get_value('Global Defaults', None, 
+					'tolerance'))
+			tolerance = self.global_tolerance
+		
+		self.tolerance[item_code] = tolerance
+		return tolerance
+	
+
+	def update_qty(self, change_modified=True):
+		"""
+			Updates qty at row level
+		"""
+		for args in self.status_updater:
+			# condition to include current record (if submit or no if cancel)
+			if self.doc.docstatus == 1:
+				args['cond'] = ' or parent="%s"' % self.doc.name
+			else:
+				args['cond'] = ' and parent!="%s"' % self.doc.name
+			
+			args['modified_cond'] = ''
+			if change_modified:
+				args['modified_cond'] = ', modified = now()'
+		
+			# update quantities in child table
+			for d in self.doclist:
+				if d.doctype == args['source_dt']:
+					# updates qty in the child table
+					args['detail_id'] = d.fields.get(args['join_field'])
+					
+					args['second_source_condition'] = ""
+					if args.get('second_source_dt') and args.get('second_source_field') \
+							and args.get('second_join_field'):
+						args['second_source_condition'] = """ + (select sum(%(second_source_field)s) 
+							from `tab%(second_source_dt)s` 
+							where `%(second_join_field)s`="%(detail_id)s" 
+							and (docstatus=1))""" % args
+			
+					if args['detail_id']:
+						webnotes.conn.sql("""update `tab%(target_dt)s` 
+							set %(target_field)s = (select sum(%(source_field)s) 
+								from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" 
+								and (docstatus=1 %(cond)s)) %(second_source_condition)s
+							where name='%(detail_id)s'""" % args)
+		
+			# get unique transactions to update
+			for name in set([d.fields.get(args['percent_join_field']) for d in self.doclist 
+					if d.doctype == args['source_dt']]):
+				if name:
+					args['name'] = name
+				
+					# update percent complete in the parent table
+					webnotes.conn.sql("""update `tab%(target_parent_dt)s` 
+						set %(target_parent_field)s = (select sum(if(%(target_ref_field)s > 
+							ifnull(%(target_field)s, 0), %(target_field)s, 
+							%(target_ref_field)s))/sum(%(target_ref_field)s)*100 
+							from `tab%(target_dt)s` where parent="%(name)s") %(modified_cond)s
+						where name='%(name)s'""" % args)
+
+					# update field
+					if args.get('status_field'):
+						webnotes.conn.sql("""update `tab%(target_parent_dt)s` 
+							set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, 
+								'Not %(keyword)s', if(%(target_parent_field)s>=99.99, 
+								'Fully %(keyword)s', 'Partly %(keyword)s'))
+							where name='%(name)s'""" % args)
\ No newline at end of file
diff --git a/docs/docs.dev.md b/docs/docs.dev.md
new file mode 100644
index 0000000..6c46abf
--- /dev/null
+++ b/docs/docs.dev.md
@@ -0,0 +1,15 @@
+---
+{
+	"_label": "Developer API",
+	"_toc": [
+		"docs.dev.quickstart",
+		"docs.dev.framework",
+		"docs.dev.modules"
+	]
+}
+---
+### Is this for me?
+
+To starting hacking into ERPNext, you must have some understanding of how a dynamic web application works. There are hundreds of architectures and frameworks to make web development easier, but at the core there are a few elements that are important to understand.
+
+ERPNext is built on `wnframework` which is primarily developed for ERPNext but can be extended to make similar database driven applications. wnframework uses Python on the server-side and has a javascript based client for entering data, managing workflow and making reports.
\ No newline at end of file
diff --git a/docs/docs.dev.modules.md b/docs/docs.dev.modules.md
new file mode 100644
index 0000000..34fea9a
--- /dev/null
+++ b/docs/docs.dev.modules.md
@@ -0,0 +1,6 @@
+---
+{
+	"_label": "Modules"
+}
+---
+The models used in both `wnframework` (**Core** module) and ERPNext are listed here. The basic element of the model is a `DocType`, which is most often also a database table. The model properties are called `DocFields`, which describe the view and the database columns.
\ No newline at end of file
diff --git a/docs/docs.md b/docs/docs.md
new file mode 100644
index 0000000..7cf47a9
--- /dev/null
+++ b/docs/docs.md
@@ -0,0 +1,24 @@
+---
+{
+	"_label": "ERPNext",
+	"_no_title": 1,
+	"_toc": [
+		"docs.user",
+		"docs.dev",
+		"docs.download",
+		"docs.community",
+		"docs.blog",
+		"docs.about"
+	]
+}
+---
+<div class="jumbotron">
+	<h1>ERPNext</h1>
+	<p>Open Source Organization Management Platform</p>
+</div>
+
+### Is this for me?
+
+To starting hacking into ERPNext, you must have some understanding of how a dynamic web application works. There are hundreds of architectures and frameworks to make web development easier, but at the core there are a few elements that are important to understand.
+
+ERPNext is built on `wnframework` which is primarily developed for ERPNext but can be extended to make similar database driven applications. wnframework uses Python on the server-side and has a javascript based client for entering data, managing workflow and making reports. 
\ No newline at end of file
diff --git a/docs/docs.user.intro.md b/docs/docs.user.intro.md
new file mode 100644
index 0000000..4aada62
--- /dev/null
+++ b/docs/docs.user.intro.md
@@ -0,0 +1,54 @@
+---
+{
+	"_label": "Introduction",
+	"_title_image": "img/why-erpnext.png"
+}
+---
+## What is an ERP and why should I care?
+
+Small business are not so different from large ones. They contain most of the complexities of a large business but with many more constraints. Small businesses have to communicate with customers, do accounts, pay taxes, do payroll, manage timelines, deliver quality, answer questions and keep everyone happy just like large businesses.
+
+And to it *efficiently*.
+
+Large businesses have the advantage of using advanced data systems to manage their process efficiently. Small businesses typically struggle to keep things organized. They are often using a mix of apps like spreadsheets, accounting software, web CRM etc to manage but not everyone is on the same page. An ERP changes that.
+
+---
+
+## What is ERPNext?
+
+ERPNext helps you to manage all your business information in one application and use it to manage operations and take decisions based on data.
+
+Among other things, ERPNext will help you to:
+
+- Track all Invoices and Payments.
+- Know what quantity of what product is available in stock.
+- Identify open customer queries.
+- Manage payroll.
+- Assign tasks and follow up on them.
+- Maintain a database of all your customers, suppliers and their contacts.
+- Prepare quotes.
+- Get reminders on maintenance schedules.
+- Publish you website.
+
+And a lot lot lot more.
+
+---
+
+## Why Should I Use ERPNext?
+
+ERPNext is a modern accounting plus everything system and has many benefits over both traditional accounting as well as ERP applications.
+
+### Benefits over traditional accounting software:
+
+- Do a lot more than just accounting! Manage inventory, billing, quotes, leads, payroll and much much more.
+- All data safe and in one place. Don’t keep hunting for data when you need it across spreadsheets and different computers.
+- Everyone on the same page. All users get the same update data.
+- Stop repetitive work. Don’t enter the same information from your word processor to your accounting tool. Its all integrated.
+- Keep track. Get the entire history of a customer or a deal in one place.
+
+### Benefits over big ERPs
+
+- $$$ - Save money.
+- Easier to configure. Big ERPs are notoriously hard to setup and will ask you a zillion questions before you can do something meaningful.
+- Easier to use. Modern web like user interface will keep your users happy and in familiar territory.
+- Open Source. This software is always free and you can host it anywhere you like.
\ No newline at end of file
diff --git a/docs/docs.user.md b/docs/docs.user.md
new file mode 100644
index 0000000..bb32882
--- /dev/null
+++ b/docs/docs.user.md
@@ -0,0 +1,10 @@
+---
+{
+	"_label": "User Guide",
+	"_toc": [
+		"docs.user.intro",
+		"docs.user.setup"
+	]
+}
+---
+This manual covers all the major processes in setting up and using ERPNext. The manual is written in a way that the user can manage a self-implementation of the ERP. We recommend that the manual be read first before starting implementation.
diff --git a/docs/docs.user.setup.accounting.md b/docs/docs.user.setup.accounting.md
new file mode 100644
index 0000000..b10cf5b
--- /dev/null
+++ b/docs/docs.user.setup.accounting.md
@@ -0,0 +1,129 @@
+---
+{
+	"_label": "Accounting Setup",
+	"_title_image": "img/setup-accounting.png"
+}
+---
+## Chart of Accounts
+
+The Chart of Accounts forms the blueprint of your organization. The overall structure of your Chart of Accounts is based on a system of double entry accounting that has become a standard all over the world to quantify how a company is doing financially. 
+
+The Chart of Accounts helps you answer:
+
+- What is your organization worth?
+- How much debt have you taken?
+- How much profit you are making (and hence paying tax)?
+- How much is are you selling?
+- How are your expenses broken up?
+
+As you can see, it is very valuable to you as a business manager to see how well your business is doing. 
+
+> Tip: If you can’t read a Balance Sheet (I confess it took me a long time to figure this out) its a good opportunity to start learning about this. It will be worth the effort. You can also take the help of your accountant to setup your Chart of Accounts.
+
+To edit your Chart of Accounts in ERPNext go to:
+
+> Accounts  > Chart of Accounts 
+
+Chart of Accounts is a tree view of the names of the Accounts  (Ledgers and Groups) that a Company requires to manage its books of accounts. ERPNext sets up a simple chart of accounts for each Company you create, but you have to modify it according to your needs and legal requirements.
+
+For each company, Chart of Accounts signifies the way to classify the accounting entries, mostly based on statutory (tax, compliance to government regulations) requirements.
+
+Let us understand the main groups of the Chart of Accounts.
+
+### Balance Sheet Accounts
+
+The Balance Sheet has Application of Funds (Assets) and Sources of Funds (Liabilities) that signify the net-worth of your company at any given time. When you begin or end a financial period, all the Assets are equal to the Liabilities.
+
+> Accounting: If you are new to accounting, you might be wondering, how can Assets be equal to Liabilities? That would mean the company has nothing of its own. Thats right. All the “investment” made in the company to buy assets (like land, furniture, machines) is made by the owners and is a liability to the company. If the company would to shut down, it would need to sell all the assets and pay back all the liabilities (including profits) to the owners, leaving itself with nothing.
+
+All the accounts under this represent an asset owned by company like "Bank Account", "Land and Property", "Furniture" or a liability (funds that the company owes to others) like "Owners funds", "Debt" etc.
+
+Two special accounts to note here are Accounts Receivable (money you have to collect from your customers) and Accounts Payable (money you have to pay to your suppliers) under Assets and Liabilities respectively.
+
+### Profit and Loss Accounts
+
+Profit and Loss is the group of Income and Expense accounts that represent your accounting transactions over a period.
+
+Unlike Balance sheet accounts, Profit and Loss accounts (or PL accounts) do not represent net worth (assets), but rather the amount of money spent and collected in servicing customers during the period. Hence at the beginning and end of your Fiscal Year, they become zero.
+
+(On the first day of the year you have not made any profit or loss, but you still have assets, hence balance sheet accounts never become zero at the beginning or end of a period)
+
+### Groups and Ledgers
+
+There are two main kinds of Accounts in ERPNext - Group and Ledger. Groups can have sub-groups and ledgers within them, whereas ledgers are the leaf nodes of your chart and cannot be further classified.
+
+Accounting Transactions can only be made against Ledger Accounts (not Groups)
+
+> Info: The term "Ledger" means a page in an accounting book where entries are made. There is usually one ledger for each account (like a Customer or a Supplier).
+
+> Note: An Account “Ledger” is also sometimes called as Account “Head”.
+
+### Other Account Types
+
+In ERPNext, you can also specify more information when you create a new Account, this is there to help you select that particular account in a scenario like Bank Account or a Tax Account and has no affect on the Chart itself.
+
+You can also tag if an account represents a Customer, Supplier or Employee in "Master Type".
+
+### Creating / Editing Accounts
+
+To create new Accounts, explore your Chart of Accounts and click on an Account group under which you want to create the new Account. On the right side, you will see a options to “Edit” or “Add” a new Account.
+
+Option to create will only appear if you click on a Group (folder) type Account.
+
+ERPNext creates a standard structure for you when the Company is created but it is up to you to modify or add or remove accounts.
+
+Typically, you might want to create Accounts for
+
+- Types of Expenses (travel, salaries, telephone etc) under Expenses.
+- Taxes (VAT, Sales Tax etc based on your country) under Current Liabilities.
+- Types of Sales (for example, Product Sales, Service Sales etc.) under Income.
+- Types of Assets (building, machinery, furniture etc.) under Fixed Assets.
+
+---
+
+## Chart of Cost Centers
+
+Your Chart of Accounts is mainly for reporting your information for governmental purposes and less for how you business actually performs. Though you can tweak it a bit to resemble your business.
+
+Most businesses have multiple activities like different product lines, market segments, areas of business that share some common overheads but should ideally have their own structure to report whether they are profitable or not. For this purpose, there is an alternate structure, called the Chart of Cost Centers.
+
+You can create a tree of Cost Centers to represent your business better. Each Income / Expense entry is also tagged against a Cost Center. 
+
+For example, if you have two types of sales:
+
+- Walk-in Sales
+- Online Sales
+
+You may not have shipping expenses for your walk-in customers, and no shop-rent for your online customers. If you want to get the profitability of each of these separately, you create the two as Cost Centers and you can mark all sales as either "Walk-in" or "Online" and also all your purchases in the same way.
+
+So when you do your analysis you can get a better idea which side of your business is doing better.  Since ERPNext has option to add multiple Companies, you can create Cost Centers for each Company and manage it separately.
+
+To setup your Chart of Cost Centers go to:
+
+> Accounts > Chart of Cost Centers
+
+Cost centers help you in one more activity, budgeting.
+
+### Budgeting
+
+ERPNext will help you set and manage budgets on your Cost Centers. This is useful when, for example, you are doing online sales and you have a budget for search ads and you want ERPNext to stop or warn you from over spending based on that budget. 
+
+Budgets are also great for planning purposes. When you are making your plans for the next financial year, you would typically target a revenue and based on that you would set your expenses. Setting a budget will ensure that your expenses do not get out of hand at any point based on your plans.
+
+You can define it in the Cost Center. If you have seasonal sales you can also define a budget distribution that the budget will follow.
+
+#### Budget Actions
+
+ERPNext allows you to either:
+
+- Stop.
+- Warn or, 
+- Ignore 
+
+if you exceed budgets. 
+
+These can be defined from the Company record.
+
+Even if you choose to “ignore” budget overruns, you will get a wealth of information from the “Budget vs Actual” variance report.
+
+> Note: When you set a budget, it has to be set per Account under the Cost Center. For example if you have a Cost Center “Online Sales”, you can restrict “Advertising Budget” by creating a row with that Account and defining the amount.
\ No newline at end of file
diff --git a/docs/docs.user.setup.before.md b/docs/docs.user.setup.before.md
new file mode 100644
index 0000000..158890f
--- /dev/null
+++ b/docs/docs.user.setup.before.md
@@ -0,0 +1,35 @@
+---
+{
+	"_label": "Before We Start",
+	"_title_image": "img/before-we-start.png"
+}
+---
+## Before We Start
+
+We have seem dozens of ERP implementations over the past few years and we realize that successful implementations are a lot about intangibles and attitude. 
+
+> The Benefits come Later
+
+ERPs are not required.
+
+Like exercise. 
+
+Human body does not require to be exercised today or maybe tomorrow, but in the long run, if you wish to maintain your body and its health, you should get on the treadmill.
+
+In the same way, ERPs improve the health of your organization over a long run by keep it fit and efficient. The more you delay putting things in order, the more time you lose and the closer you get to a major disaster.
+
+So when you start implementing an ERP, keep your sight on the long term benefits. Like exercise, its painful in the short run, but will do wonders if you stay on course.
+
+---
+
+## The Champion
+
+ERP means organization wide change and it does not happen without effort. Every change requires a champion and its the duty of the champion to organize and energize the entire team towards implementation. The champion is all the fall guy (or fall gal) incase something goes wrong and hence needs to be resilient. Who becomes a champion without putting effort anyways?
+
+In many organizations we have seen, the champion is most often the owner or a senior manager. Occasionally, the champion is an outsider who is hired for the purpose.
+
+In either case, you must identify your champion first.
+
+Most likely its **you!** 
+
+Lets Begin!
diff --git a/docs/docs.user.setup.codification.md b/docs/docs.user.setup.codification.md
new file mode 100644
index 0000000..650e173
--- /dev/null
+++ b/docs/docs.user.setup.codification.md
@@ -0,0 +1,64 @@
+---
+{
+	"_label": "Item Codification"
+}
+---
+
+> To Codify or Not To Codify, is the question.
+
+If you already have a running business with a number of physical items, you would have probably coded your items. If you have not, you have a choice. We recommend you should codify, but its your call.
+
+Item codification is always a sensitive topic and wars have been fought on this (not joking). In our experience, when you have items that cross a certain size, life without codification is a nightmare. 
+
+### Benefits
+
+- Standard way of naming things.
+- Less likely to have duplicates.
+- Explicit definition.
+- Help you quickly find if a similar item exists.
+- Item names get longer and longer as more types get introduced. Codes are shorter.
+
+### Pain
+
+- You have to remember the codes!
+- Harder for new team members to pick up.
+- You have to create new codes all the time.
+
+### Example
+
+You should have a simple manual / cheat-sheet to codify your items instead of just numbering them sequentially. Each letter should mean something. Here is an example:
+
+If your business involves wooden furniture, then you may codify as follows:
+
+Item Codification Summary Sheet
+(SAMPLE)
+
+	First letter: "Material"			Third letter: "Size"
+
+	- W - Wood 							- 0 - less than 1mm
+	- H - Hardware 						- 1 - 1mm - 5mm
+	- G - Glass 						- 2 - 5mm - 10mm
+	- U - Upholstery 					- 3 - 10mm - 10cm
+	- P - Plastic
+
+	Second Letter: "Type"
+
+	For Wood:							For Hardware:
+
+	- S - Sheet							- S - Screw
+	- B - Bar							- N - Nut
+	- L - L-section 					- W - Washer
+	- M - Molded 						- B - Bracket
+	- R - Round
+
+The last few letters could be sequential. So by looking at code **WM304** - you know its a wooden molding less than 10cm in size 
+
+### Standardization
+
+If you have more than one person naming items, the style of naming items will change for everyone. Sometimes, even for one person, he or she may forget how did they name the item and may create a duplicate name _"Wooden Sheet 3mm" or "3mm Sheet of Wood"?_
+
+### Rationalizing
+
+It is a good practice to have minimum varieties of items so that you keep minimum stock, housekeeping is simpler etc. When you are planning a new product and you want to know if you are already purchasing a part in some other product, the item codes will help you quickly determine if you are using a similar raw material in another product.
+
+We believe if you do this small investment, it will help you rationalize things as your business grows, though its okay not to codify if you have less items.
\ No newline at end of file
diff --git a/docs/docs.user.setup.customer.md b/docs/docs.user.setup.customer.md
new file mode 100644
index 0000000..829f943
--- /dev/null
+++ b/docs/docs.user.setup.customer.md
@@ -0,0 +1,65 @@
+---
+{
+	"_label": "Foundation: Customer",
+	"_title_image": "img/customers.png"
+}
+---
+You can either directly create your Customers via 
+
+> Selling > Customer
+
+or upload it via the Data Import Tool.
+
+In your normal operations, you can also create Customers from Leads.
+
+> Note: Customers are separate from Contacts and Addresses. A Customer can have multiple Contacts and Addresses.
+
+### Contacts and Addresses
+
+Contacts and Addresses in ERPNext are stored separately so that you can attach multiple Contacts or Addresses to Customers and Suppliers.
+
+To add a Contact or Address directly from the Customer record, click on “New Contact” or “New Address”.
+
+> Tip: When you select a Customer in any transaction, one Contact and Address gets pre-selected. This is the “Default Contact or Address”. So make sure you set your defaults correctly!
+
+To Import multiple Contacts and Addresses from a spreadsheet, use the Data Import Tool.
+
+### Integration with Accounts
+
+In ERPNext, there is a separate Account record for each Customer, for each Company.
+
+When you create a new Customer, ERPNext will automatically create an Account Ledger for the Customer under “Accounts Receivable” in the Company set in the Customer record. 
+
+> Advanced Tip: If you want to change the Account Group under which the Customer Account is created, you can set it in the Company master.
+
+If you want to create an Account in another Company, just change the Company value and “Save” the Customer again.
+
+### Customer Settings
+
+You can link a Price List to a Customer (select “Default Price List”), so that when you select that Customer, the Price List will be automatically selected.
+
+You can set “Credit Days” so that it is automatically set in the Sales Invoices made against this Customer.
+
+You can set how much credit you want to allow for a Customer by adding the “Credit Limit”. You can also set a global “Credit Limit” in the Company master.Classifying Customers
+
+ERPNext allows you to group your Customers and also divide them into Territories. Grouping will help you get better analysis of your data and identify what Customers are profitable and which are not and Territories will help you set sales targets for the territories.
+
+### Customer Group
+
+You can group your Customers so that you can get trend analysis for each group. Typically Customers are grouped by market segment (that is usually based on your domain).
+
+> Tip: If you think all this is too much effort, you can leave it at “Default Customer Group”. But all this effort, will pay off when you start getting reports.
+
+### Territory
+
+If your business operates in multiple Territories (could be countries, states or cities) it is usually a great idea to build your structure in the system. Once you group your Customers by Territories, you can set annual targets for each Item Group and get reports that will show your actual performance in the territory v/s what you had planned.
+
+### Sales Person
+
+Sales Persons behave exactly like Territories. You can great an organization chart of Sales Persons where each Sales Person’s target can be set individually. Again as in Territory, the target has to be set against Item Group.
+
+### Sales Partner
+
+A Sales Partner is a third party distributor / dealer / commission agent / affiliate / reseller who sells the companies products, for a commission. This is useful if you make the end sale to the Customer, involving your Sales Partner.
+
+If you sell to your Sales Partner who in-turn sells it to the Customer, then you must make a Customer instead.
diff --git a/docs/docs.user.setup.first.md b/docs/docs.user.setup.first.md
new file mode 100644
index 0000000..759c14c
--- /dev/null
+++ b/docs/docs.user.setup.first.md
@@ -0,0 +1,14 @@
+---
+{
+	"_label": "Initial Setup"
+}
+---
+After a successful sign-up / installation of ERPNext, on your first sign-in, you will be shown a form to fill. 
+
+This form will create your first **Company** and **Fiscal Year** (accounting or financial year) record. You can create other Companies later.
+
+This will also set the default **Currency** and time zone for your account. Once your complete this, your first **Company** and **Chart of Accounts** will be created.
+
+Congrats! You are already on your way.
+
+The next step is to configure your Chart of Accounts or start adding users and setting their permissions.
diff --git a/docs/docs.user.setup.item.md b/docs/docs.user.setup.item.md
new file mode 100644
index 0000000..e85876b
--- /dev/null
+++ b/docs/docs.user.setup.item.md
@@ -0,0 +1,106 @@
+---
+{
+	"_label": "Foundation: Item",
+	"_title_image": "img/items.png"
+}
+---
+Items, Customers and Suppliers form the foundation of any ERP system.
+
+It is very likely you will have your masters ready in another system or a spread sheet and you would just need to import them. Before importing, it might be a good idea to understand how ERPNext treats them a bit first.
+
+---
+
+## Items
+
+An Item is simply a product or service you sell or buy from your Customers or Suppliers. ERPNext is optimized for itemized management of your sales and purchase though you can skip creating Items. If you are in services, you can create an Item for each service that your offer.
+
+> Items are mandatory if you want to track inventory.
+
+There are two main categories of Items in ERPNext
+
+- Stock Items
+- Non Stock Items
+
+As you may have guessed, inventory balances are tracked for stock items and not for
+non-stock items. Non-stock items could be services or consumables that are not tracked.
+
+### Naming Items
+
+This is a complex topic [coming up next]. In ERPNext you can use item codes or names. If you do not want to codify, you can keep the item name and item code as the same.
+
+### Item Groups
+
+ERPNext allows you to classify items into groups. This will help you in getting reports about various classes of items and also help in cataloging your items for the website.
+
+### Warehouses
+
+In ERPNext you can create Warehouses to identify where your Items reside. 
+
+There are two main Warehouse Types that are significant in ERPNext.
+
+Stores: These are where your incoming Items are kept before they are consumed or sold. You can have as many “Stores” type Warehouses as you wish. Stores type warehouses are significant because if you set an Item for automatic re-order, ERPNext will check its quantities in all “Stores” type Warehouses when deciding whether to re-order or not.
+
+Asset: Items marked as type “Fixed Asset” are maintained in Asset Type Warehouses. This helps you separate them for the Items that are consumed as a part of your regular operations or “Cost of Goods Sold”.
+
+### Item Taxes
+
+These settings are only required if this particular Item has a different tax rate than what is the rate defined in the standard tax Account.
+
+For example, you have a tax Account, “VAT 10%” and this particular item is exempted from this tax, then you select “VAT 10%” in the first column, and set “0” as the tax rate in the second column.
+
+### Inspection
+
+Inspection Required: If an incoming inspection (at the time of delivery from the Supplier) is mandatory for this Item, mention “Inspection Required” as “Yes”. The system will ensure that a Quality Inspection will be prepared and approved before a Purchase Receipt is submitted.
+
+Inspection Criterial: If a Quality Inspection is prepared for this Item, then this template of criteria can will automatically be updated in the Quality Inspection table of the Quality Inspection.

Examples of Criteria are: Weight, Length, Finish etc.
+
+### Item Pricing and Price Lists
+
+ERPNext lets you maintain multiple selling prices for an Item using Price Lists. A Price List is a name you can give to a set of Item prices.
+
+Why would you want Price Lists? You have different prices for different zones (based on the shipping costs), for different currencies, regions etc.
+
+### Item Valuation
+
+How are Items Valued?
+
+One of the major features of any inventory system is that you can find out the value of any item based on its historic or average price. You can also find the value of all your items for your balance sheet. Why is valuation important?
+
+- The buying price fluctuates.
+- The value changes because of some process (value add).
+- The value changes because of decay, loss etc.
+
+You may encounter these terms, so lets clarify:
+
+- Rate: Rate at which the transaction takes place.
+- Valuation Rate: Rate at which the items value is set for your valuation.
+
+There are two major ways in which ERPNext values your items.
+
+- **FIFO (First In First Out):** In this system, ERPNext assumes that you will consume / sell those Items first that you bought first. For example, if you buy an Item at price X and then after a few days at price Y. So when sell your Item, ERPNext will reduce the quantity of the Item priced at X first and then Y.
+
+
+
+- **Moving Average:** In this method, ERPNext assumes that the value of the item at any point is the average price of the units of that Item in stock. For example, if the value of an Item is X in a Warehouse with quantity Y and another quantity Y1 is added to the Warehouse at cost X1, the new value X2 would be:
+
+> New Value X2 = (X * Y + X1 * Y1) / (Y + Y1)
+
+#### Negative Stock
+
+FIFO is the more accurate system of the two but has a disadvantage. You cannot have negative stock in FIFO. This means that you cannot make forward transactions that would make your stock negative. Why is this? Because sequences are so important to FIFO, you cannot track the value of the stock if it does not exist!
+
+In Moving Average, since each item has an “average” value, the value of the negative stock is also based on this “average”.
+
+### Serial Numbers and Batches
+
+In scenarios where you may have to track individual units or batches of Items you sell, ERPNext allows you to manage Serial Numbers and Batches.
+
+Why is this useful?
+
+- To track warranty and returns.
+- To trace individual Items incase they are recalled by the Supplier.
+- To manage expiry.
+
+In ERPNext, Serial Number and Batch are separate entities and all stock transactions for Items that serialized or batches must be tagged with either the Batch or Serial Number.
+
+> Important: Once you mark an item as serialized or batched or neither, you cannot change it after you have make any stock entry.
diff --git a/docs/docs.user.setup.md b/docs/docs.user.setup.md
new file mode 100644
index 0000000..4bc4aee
--- /dev/null
+++ b/docs/docs.user.setup.md
@@ -0,0 +1,19 @@
+---
+{
+	"_label": "Setting Up",
+	"_toc": [
+		"docs.user.setup.before",
+		"docs.user.setup.strategy",
+		"docs.user.setup.first",
+		"docs.user.setup.accounting",
+		"docs.user.setup.item",
+		"docs.user.setup.customer",
+		"docs.user.setup.supplier"
+	]
+}
+---
+Setting up an ERP system is like starting your business all over again, but in the virtual
+world. Thankfully its not as hard as the real thing and you get to do a trial too.
+
+The important thing to note is that if you really want to take benefit out of this project, then you must take a step back and make sometime to do this right. This is usually not couple-of-hours after work kind of a project.
+
diff --git a/docs/docs.user.setup.strategy.md b/docs/docs.user.setup.strategy.md
new file mode 100644
index 0000000..6675536
--- /dev/null
+++ b/docs/docs.user.setup.strategy.md
@@ -0,0 +1,30 @@
+---
+{
+	"_label": "Implementation Strategy"
+}
+---
+Before you start managing your Operations in EPRNext, you must first become familiar with the system and the terms used. For this we recommend implementation should happen in two phases.
+
+- A Test Phase, where you enter dummy records representing your day to day transactions and a - Live Phase, where we start entering live data.
+
+### Test Phase
+
+- Read the Manual
+- Create your first Customer, Supplier and Item. Add a few more so you get familiar.
+- Create Customer Groups, Item Groups, Warehouses, Supplier Groups so that you can classify your Items.
+- Complete a standard sales cycle - Lead > Opportunity > Quotation > Sales Order > Delivery Note > Sales Invoice > Payment (Journal Voucher)
+- Complete a standard purchase cycle - Purchase Request > Purchase Order > Purchase Receipt > Payment (Journal Voucher).
+- Complete a manufacturing cycle (if applicable) - BOM > Production Planning Tool > Production Order > Stock Entry (issue) > Stock Entry (back-flush)
+
+> Tip: Use the 30-day free trial at [erpnext.com](https://erpnext.com) to do your test drive.
+
+### Live Phase
+
+Once you have made yourself familiar with ERPNext, start entering your live data!
+
+- Clean up the account of test data or better, start a fresh install.
+- Setup all the modules with Customer Groups, Item Groups, Warehouses, BOMs etc.
+- Import Customers, Suppliers, Items, Contacts and Addresses using Data Import Tool.
+- Import opening stock using Stock Reconciliation Tool.
+- Create opening accounting entries via Journal Voucher and create outstanding Sales Invoices and Purchase Invoices.
+
diff --git a/home/page/activity/activity.css b/home/page/activity/activity.css
index f3988b2..34562cb 100644
--- a/home/page/activity/activity.css
+++ b/home/page/activity/activity.css
@@ -1,20 +1,20 @@
-#activity-list .label {
+#page-activity .label {
 	display: inline-block;
 	width: 100px;
 	margin-right: 7px;
 }
 
-#activity-list .label-info {
+#page-activity .label-info {
 	cursor: pointer;
 }
 
-#activity-list .user-info {
+#page-activity .user-info {
 	float: right;
 	color: #777;
 	font-size: 10px;
 }
 
-#activity-list .date-sep {
+#page-activity .date-sep {
 	margin-bottom: 11px;
 	padding: 5px 0px;
 	border-bottom: 1px solid #aaa;
diff --git a/home/page/activity/activity.html b/home/page/activity/activity.html
deleted file mode 100644
index 9fb910c..0000000
--- a/home/page/activity/activity.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div class="layout-wrapper layout-wrapper-appframe">
-	<div class="layout-appframe"></div>
-	<div class="layout-main">
-		<div id="activity-list">
-		</div>		
-	</div>
-</div>
\ No newline at end of file
diff --git a/home/page/activity/activity.js b/home/page/activity/activity.js
index 3443cc2..e412a23 100644
--- a/home/page/activity/activity.js
+++ b/home/page/activity/activity.js
@@ -1,13 +1,15 @@
 wn.pages['activity'].onload = function(wrapper) {
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
-	wrapper.appframe.add_home_breadcrumb();
-	wrapper.appframe.add_breadcrumb(wn.modules["Activity"].icon);
-	wrapper.appframe.title('Activity');
+	wn.ui.make_app_page({
+		parent: wrapper,
+		title: "Activity",
+		single_column: true
+	})
+	wrapper.appframe.add_module_icon("Activity");
 	
 	var list = new wn.ui.Listing({
 		appframe: wrapper.appframe,
 		method: 'home.page.activity.activity.get_feed',
-		parent: $('#activity-list'),
+		parent: $(wrapper).find(".layout-main"),
 		render_row: function(row, data) {
 			new erpnext.ActivityFeed(row, data);
 		}
@@ -17,7 +19,7 @@
 	// Build Report Button
 	if(wn.boot.profile.can_get_report.indexOf("Feed")!=-1) {
 		wrapper.appframe.add_button('Build Report', function() {
-			wn.set_route('Report2', "Feed");
+			wn.set_route('Report', "Feed");
 		}, 'icon-th')
 	}
 }
diff --git a/home/page/attributions/attributions.html b/home/page/attributions/attributions.html
index 99deea4..00f6342 100644
--- a/home/page/attributions/attributions.html
+++ b/home/page/attributions/attributions.html
@@ -1,4 +1,4 @@
-<div class="layout-wrapper layout-wrapper-appframe layout-attributions">
+<div class="appframe col col-lg-12 layout-attributions">
 	<div class="layout-appframe"></div>
 	<div class="layout-main">
 	<h3>ERPNext is made using these Awesome Open Source Projects <i class="icon-heart" style="color: red"></i></h3>
@@ -95,6 +95,10 @@
 			<td>Draw Gantt charts with the famous jQuery ease of development.</td>
 		</tr>
 		<tr>
+			<td><a href="http://aehlke.github.io/tag-it/">JQuery Tag-it</a></td>
+			<td>Simple and configurable tag editing widget with autocomplete support.</td>
+		</tr>
+		<tr>
 			<td><a href="http://jscolor.com/">JSColor - Color Picker</a></td>
 			<td>HTML/Javascript Color Picker.</td>
 		</tr>
diff --git a/hr/doctype/job_applicant/job_applicant.js b/hr/doctype/job_applicant/job_applicant.js
index c301250..220ff18 100644
--- a/hr/doctype/job_applicant/job_applicant.js
+++ b/hr/doctype/job_applicant/job_applicant.js
@@ -3,7 +3,7 @@
 cur_frm.cscript = {
 	onload: function(doc, dt, dn) {
 		if(in_list(user_roles,'System Manager')) {
-			cur_frm.page_layout.footer.help_area.innerHTML = '<hr>\
+			cur_frm.footer.help_area.innerHTML = '<hr>\
 				<p><a href="#Form/Jobs Email Settings">Jobs Email Settings</a><br>\
 				<span class="help">Automatically extract Job Applicants from a mail box e.g. "jobs@example.com"</span></p>';
 		}
diff --git a/hr/doctype/leave_application/leave_application_calendar.js b/hr/doctype/leave_application/leave_application_calendar.js
index 398664e..48eb7fa 100644
--- a/hr/doctype/leave_application/leave_application_calendar.js
+++ b/hr/doctype/leave_application/leave_application_calendar.js
@@ -1,4 +1,4 @@
-wn.views.calendar["Leave Application"] = wn.views.Calendar.extend({
+wn.views.calendar["Leave Application"] = {
 	field_map: {
 		"start": "from_date",
 		"end": "to_date",
@@ -14,4 +14,4 @@
 		}
 	},
 	get_events_method: "hr.doctype.leave_application.leave_application.get_events"
-})
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js
index e35a808..bee05f6 100644
--- a/hr/page/hr_home/hr_home.js
+++ b/hr/page/hr_home/hr_home.js
@@ -13,7 +13,7 @@
 			},
 			{
 				label: wn._("Expense Claim"),
-				description: wn._("Claims for expenses made on behalf of the organization."),
+				description: wn._("Claims for company expense."),
 				doctype:"Expense Claim"
 			},
 			{
@@ -33,7 +33,7 @@
 			},
 			{
 				label: wn._("Job Applicant"),
-				description: wn._("Applicant for a Job (extracted from jobs email)."),
+				description: wn._("Applicant for a Job."),
 				doctype:"Job Applicant"
 			},
 		]
@@ -175,7 +175,7 @@
 			},
 			{
 				"label":wn._("Employee Information"),
-				route: "Report2/Employee/Employee Information"
+				route: "Report/Employee/Employee Information"
 			},
 			{
 				"label":wn._("Monthly Salary Register"),
diff --git a/patches/april_2013/p05_update_file_data.py b/patches/april_2013/p05_update_file_data.py
index 39449a6..0168de6 100644
--- a/patches/april_2013/p05_update_file_data.py
+++ b/patches/april_2013/p05_update_file_data.py
@@ -1,5 +1,4 @@
 import webnotes, webnotes.utils, os
-from webnotes.modules.export_file import export_to_files
 
 def execute():
 	webnotes.reload_doc("core", "doctype", "file_data")
@@ -71,4 +70,4 @@
 					pass
 		else:
 			webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
-				fileid)
\ No newline at end of file
+				fileid)
diff --git a/patches/april_2013/p06_default_cost_center.py b/patches/april_2013/p06_default_cost_center.py
index 4f80d95..4aaa7d5 100644
--- a/patches/april_2013/p06_default_cost_center.py
+++ b/patches/april_2013/p06_default_cost_center.py
@@ -1,10 +1,10 @@
 import webnotes
 
 def execute():
-	for dt, fieldname in \
-		(("Journal Voucher Detail", "cost_center"), 
-		("Sales Taxes and Charges", "cost_center_other_charges"), 
-		("Purchase Taxes and Charges", "cost_center"), ("Delivery Note Item", "cost_center"),
-		("Purchase Invoice Item", "cost_center"), ("Sales Invoice Item", "cost_center")):
-			webnotes.conn.sql_ddl("""alter table `tab%s` alter `%s` drop default""" % (dt, fieldname))
+    webnotes.reload_doc("Stock", "DocType", "Delivery Note Item")
+    for dt in ("Journal Voucher Detail", "Sales Taxes and Charges", 
+		"Purchase Taxes and Charges", "Delivery Note Item", 
+		"Purchase Invoice Item", "Sales Invoice Item"):
+			webnotes.conn.sql_ddl("""alter table `tab%s` alter `cost_center` drop default""" \
+				% (dt,))
 			webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
diff --git a/patches/april_2013/p07_rename_cost_center_other_charges.py b/patches/april_2013/p07_rename_cost_center_other_charges.py
new file mode 100644
index 0000000..c3c9491
--- /dev/null
+++ b/patches/april_2013/p07_rename_cost_center_other_charges.py
@@ -0,0 +1,9 @@
+import webnotes
+
+def execute():
+	webnotes.reload_doc("Accounts", "DocType", "Sales Taxes and Charges")
+	webnotes.conn.sql("""update `tabSales Taxes and Charges`
+		set cost_center = cost_center_other_charges""")
+	webnotes.conn.sql_ddl("""alter table `tabSales Taxes and Charges`
+		drop column cost_center_other_charges""")
+	
\ No newline at end of file
diff --git a/patches/june_2013/p02_update_project_completed.py b/patches/june_2013/p02_update_project_completed.py
new file mode 100644
index 0000000..4bc5d6d
--- /dev/null
+++ b/patches/june_2013/p02_update_project_completed.py
@@ -0,0 +1,6 @@
+import webnotes
+
+def execute():
+	webnotes.reload_doc("projects", "doctype", "project")
+	for p in webnotes.conn.sql_list("""select name from tabProject"""):
+		webnotes.bean("Project", p).controller.update_percent_complete()
\ No newline at end of file
diff --git a/patches/may_2013/p01_selling_net_total_export.py b/patches/may_2013/p01_selling_net_total_export.py
new file mode 100644
index 0000000..eb6da23
--- /dev/null
+++ b/patches/may_2013/p01_selling_net_total_export.py
@@ -0,0 +1,16 @@
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cint
+
+def execute():
+	for module, doctype in (("Accounts", "Sales Invoice"), ("Selling", "Sales Order"), ("Selling", "Quotation"), 
+		("Stock", "Delivery Note")):
+			webnotes.reload_doc(module, "DocType", doctype)
+			webnotes.conn.sql("""update `tab%s` 
+				set net_total_export = round(net_total / if(conversion_rate=0, 1, ifnull(conversion_rate, 1)), 2),
+				other_charges_total_export = round(grand_total_export - net_total_export, 2)""" %
+				(doctype,))
+	
+	for module, doctype in (("Accounts", "Sales Invoice Item"), ("Selling", "Sales Order Item"), ("Selling", "Quotation Item"), 
+		("Stock", "Delivery Note Item")):
+			webnotes.reload_doc(module, "DocType", doctype)
\ No newline at end of file
diff --git a/patches/may_2013/p06_make_notes.py b/patches/may_2013/p06_make_notes.py
new file mode 100644
index 0000000..597468a
--- /dev/null
+++ b/patches/may_2013/p06_make_notes.py
@@ -0,0 +1,28 @@
+import webnotes, markdown2
+
+def execute():
+	webnotes.reload_doc("utilities", "doctype", "note")
+	webnotes.reload_doc("utilities", "doctype", "note_user")
+	
+	for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
+		if question.question:
+			name = question.question[:180]
+			if webnotes.conn.exists("Note", name):
+				webnotes.delete_doc("Note", name)
+			note = webnotes.bean({
+				"doctype":"Note",
+				"title": name,
+				"content": "<hr>".join([markdown2.markdown(c) for c in webnotes.conn.sql_list("""
+					select answer from tabAnswer where question=%s""", question.name)]),
+				"owner": question.owner,
+				"creation": question.creation,
+				"public": 1
+			}).insert()
+
+	webnotes.delete_doc("DocType", "Question")
+	webnotes.delete_doc("DocType", "Answer")
+	webnotes.bean("Style Settings").save()
+	
+	# update comment delete
+	webnotes.conn.sql("""update tabDocPerm \
+		set cancel=1 where parent='Comment' and role='System Manager'""")
diff --git a/utilities/doctype/question/question.py b/patches/may_2013/p06_update_billed_amt_po_pr.py
similarity index 67%
rename from utilities/doctype/question/question.py
rename to patches/may_2013/p06_update_billed_amt_po_pr.py
index 6a6fd5b..5084e98 100644
--- a/utilities/doctype/question/question.py
+++ b/patches/may_2013/p06_update_billed_amt_po_pr.py
@@ -15,11 +15,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from __future__ import unicode_literals
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
-	def on_trash(self):
-		import webnotes
-		webnotes.conn.sql("delete from tabAnswer where question=%s", self.doc.name)
-		
\ No newline at end of file
+def execute():
+	import webnotes
+	webnotes.reload_doc("buying", "doctype", "purchase_order_item")
+	webnotes.reload_doc("stock", "doctype", "purchase_receipt_item")
+	for pi in webnotes.conn.sql("""select name from `tabPurchase Invoice` where docstatus = 1"""):
+		webnotes.get_obj("Purchase Invoice", pi[0], 
+			with_children=1).update_qty(change_modified=False)
\ No newline at end of file
diff --git a/patches/may_2013/p07_move_update_stock_to_pos.py b/patches/may_2013/p07_move_update_stock_to_pos.py
new file mode 100644
index 0000000..7928728
--- /dev/null
+++ b/patches/may_2013/p07_move_update_stock_to_pos.py
@@ -0,0 +1,23 @@
+import webnotes, webnotes.defaults
+from webnotes.utils import cint
+
+def execute():
+	webnotes.reload_doc("accounts", "doctype", "pos_setting")
+	
+	webnotes.conn.sql("""update `tabPOS Setting` set update_stock=%s""", 
+		cint(webnotes.defaults.get_global_default("update_stock")))
+	
+	webnotes.conn.sql("""delete from `tabSingles`
+		where doctype='Global Defaults' and field='update_stock'""")
+
+	webnotes.conn.sql("""delete from `tabDefaultValue` 
+		where parent='Control Panel' and defkey="update_stock" """)
+
+	webnotes.defaults.clear_cache("Control Panel")
+
+	webnotes.reload_doc("setup", "doctype", "global_defaults")
+	
+	# previously, update_stock was valid only when is_pos was checked
+	# henceforth it is valid, and hence the patch
+	webnotes.conn.sql("""update `tabSales Invoice` set update_stock=0 
+		where ifnull(is_pos, 0)=0""")
\ No newline at end of file
diff --git a/patches/may_2013/p08_change_item_wise_tax.py b/patches/may_2013/p08_change_item_wise_tax.py
new file mode 100644
index 0000000..dbb949e
--- /dev/null
+++ b/patches/may_2013/p08_change_item_wise_tax.py
@@ -0,0 +1,23 @@
+import webnotes
+import json
+from webnotes.utils import flt
+
+def execute():
+	for doctype in ["Purchase Taxes and Charges", "Sales Taxes and Charges"]:
+		for tax_name, item_wise_tax_detail in \
+			webnotes.conn.sql("""select name, item_wise_tax_detail from `tab%s`""" % doctype):
+				if not item_wise_tax_detail or not isinstance(item_wise_tax_detail, basestring):
+					continue
+				
+				try:
+					json.loads(item_wise_tax_detail)
+				except ValueError:
+					out = {}
+					for t in item_wise_tax_detail.split("\n"):
+						if ":" in t:
+							account_head, amount = t.split(":")
+							out[account_head.strip()] = flt(amount.strip())
+							
+					if out:
+						webnotes.conn.sql("""update `tab%s` set item_wise_tax_detail=%s
+							where name=%s""" % (doctype, "%s", "%s"), (json.dumps(out), tax_name))
\ No newline at end of file
diff --git a/patches/november_2012/add_theme_to_profile.py b/patches/november_2012/add_theme_to_profile.py
index 648c1d1..89710a4 100644
--- a/patches/november_2012/add_theme_to_profile.py
+++ b/patches/november_2012/add_theme_to_profile.py
@@ -3,11 +3,12 @@
 def execute():
 	webnotes.clear_perms("Profile")
 	webnotes.reload_doc("core", "doctype", "profile")
+	webnotes.conn.sql("""delete from `tabDefaultValue` where defkey='theme'""")
+	webnotes.delete_doc("Page", "profile-settings")
+	return
 
 	for name in webnotes.conn.sql("""select name from tabProfile"""):
 		theme = webnotes.conn.get_default("theme", name[0])
 		if theme:
 			webnotes.conn.set_value("Profile", name[0], "theme", theme)
 			
-	webnotes.conn.sql("""delete from `tabDefaultValue` where defkey='theme'""")
-	webnotes.delete_doc("Page", "profile-settings")
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 6b88955..52b3e29 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -240,19 +240,25 @@
 	"patches.april_2013.p06_update_file_size",
 	"patches.april_2013.p05_fixes_in_reverse_modules",
 	"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')",
-    "execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
+	"patches.april_2013.p07_rename_cost_center_other_charges",
 	"patches.april_2013.p06_default_cost_center",
 	"execute:webnotes.reset_perms('File Data')",
 	"patches.april_2013.p07_update_file_data_2",
 	"patches.april_2013.rebuild_sales_browser",
 	"patches.april_2013.p08_price_list_country",
+	"patches.may_2013.p01_selling_net_total_export",
 	"patches.may_2013.repost_stock_for_no_posting_time",
 	"patches.may_2013.p01_conversion_factor_and_aii",
 	"patches.may_2013.p02_update_valuation_rate",
 	"patches.may_2013.p03_update_support_ticket",
 	"patches.may_2013.p04_reorder_level",
 	"patches.may_2013.p05_update_cancelled_gl_entries",
+	"patches.may_2013.p06_make_notes",
+	"patches.may_2013.p06_update_billed_amt_po_pr",
+	"patches.may_2013.p07_move_update_stock_to_pos",
+	"patches.may_2013.p08_change_item_wise_tax",
 	"patches.june_2013.p01_update_bom_exploded_items",
+	"patches.june_2013.p02_update_project_completed",
 	"execute:webnotes.delete_doc('DocType', 'System Console')",
 	"patches.june_2013.p04_fix_event_for_lead_oppty_project",
 ]
\ No newline at end of file
diff --git a/projects/doctype/project/project.js b/projects/doctype/project/project.js
index d4a034f..a6f32cb 100644
--- a/projects/doctype/project/project.js
+++ b/projects/doctype/project/project.js
@@ -15,20 +15,16 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 // show tasks
-wn.require("public/app/js/gantt_task.js");
-
 cur_frm.cscript.refresh = function(doc) {
 	if(!doc.__islocal) {
-		// refresh gantt chart
-		wn.require('app/projects/gantt_task.js');
-		if(!cur_frm.gantt_area)
-			cur_frm.gantt_area = $('<div>')
-				.appendTo(cur_frm.fields_dict.project_tasks.wrapper);
-		cur_frm.gantt_area.empty();
-		erpnext.show_task_gantt(cur_frm.gantt_area, cur_frm.docname);		
-	} else {
-		if(cur_frm.gantt_area)
-			cur_frm.gantt_area.empty();
+		cur_frm.add_custom_button("Gantt Chart", function() {
+			wn.route_options = {"project": doc.name}
+			wn.set_route("Gantt", "Task");
+		}, "icon-tasks");
+		cur_frm.add_custom_button("Tasks", function() {
+			wn.route_options = {"project": doc.name}
+			wn.set_route("List", "Task");
+		}, "icon-list");
 	}
 }
 
diff --git a/projects/doctype/project/project.py b/projects/doctype/project/project.py
index 94b6787..62714b8 100644
--- a/projects/doctype/project/project.py
+++ b/projects/doctype/project/project.py
@@ -25,29 +25,6 @@
 		self.doc = doc
 		self.doclist = doclist
 	
-	# Get Customer Details along with its primary contact details
-	# ==============================================================
-	def get_customer_details(self):
-		details =webnotes.conn.sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
-		if details:
-			ret = {
-				'customer_address'	:	details and details[0]['address'] or '',
-				'territory'			 :	details and details[0]['territory'] or '',
-				'customer_group'		:	details and details[0]['customer_group'] or '',
-	'customer_name'		 :	details and details[0]['customer_name'] or ''
-			}
-			#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
-			contact_det = webnotes.conn.sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
-			ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
-			ret['contact_no'] = contact_det and contact_det[0]['phone'] or ''
-			ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''		
-			return ret
-		else:
-			msgprint("Customer : %s does not exist in system." % (self.doc.customer))
-			raise Exception	
-		
-	#calculate gross profit
-	#=============================================
 	def get_gross_profit(self):
 		pft, per_pft =0, 0
 		pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost)
@@ -56,9 +33,8 @@
 		ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft}
 		return ret
 		
-	# validate
-	#================================================
 	def validate(self):
+		"""validate start date before end date"""
 		if self.doc.project_start_date and self.doc.completion_date:
 			if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date):
 				msgprint("Expected Completion Date can not be less than Project Start Date")
@@ -66,6 +42,15 @@
 				
 	def on_update(self):
 		self.add_calendar_event()
+		
+	def update_percent_complete(self):
+		total = webnotes.conn.sql("""select count(*) from tabTask where project=%s""", 
+			self.doc.name)[0][0]
+		if total:
+			completed = webnotes.conn.sql("""select count(*) from tabTask where
+				project=%s and status in ('Closed', 'Cancelled')""", self.doc.name)[0][0]
+			webnotes.conn.set_value("Project", self.doc.name, "percent_complete",
+			 	int(float(completed) / total * 100))
 
 	def add_calendar_event(self):
 		# delete any earlier event for this project
@@ -91,4 +76,4 @@
 			
 	def delete_events(self):
 		webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent` 
-			where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
\ No newline at end of file
+			where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
diff --git a/projects/doctype/project/project.txt b/projects/doctype/project/project.txt
index 326a47a..88dfb97 100644
--- a/projects/doctype/project/project.txt
+++ b/projects/doctype/project/project.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-01-29 19:25:50", 
+  "creation": "2013-03-07 11:55:07", 
   "docstatus": 0, 
-  "modified": "2013-02-22 11:06:22", 
+  "modified": "2013-06-07 12:38:37", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -25,13 +25,15 @@
   "permlevel": 0
  }, 
  {
+  "amend": 0, 
   "doctype": "DocPerm", 
   "name": "__common__", 
   "parent": "Project", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
   "read": 1, 
-  "role": "Projects User"
+  "report": 1, 
+  "submit": 0
  }, 
  {
   "doctype": "DocType", 
@@ -159,19 +161,6 @@
   "search_index": 0
  }, 
  {
-  "description": "Tasks belonging to this Project.", 
-  "doctype": "DocField", 
-  "fieldname": "sb_tasks", 
-  "fieldtype": "Section Break", 
-  "label": "Tasks"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "project_tasks", 
-  "fieldtype": "HTML", 
-  "label": "Project Tasks"
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "section_break0", 
   "fieldtype": "Section Break", 
@@ -191,6 +180,14 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "percent_complete", 
+  "fieldtype": "Percent", 
+  "in_list_view": 1, 
+  "label": "Percent Complete", 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "company", 
   "fieldtype": "Link", 
   "label": "Company", 
@@ -283,38 +280,18 @@
   "search_index": 1
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "trash_reason", 
-  "fieldtype": "Small Text", 
-  "hidden": 1, 
-  "label": "Trash Reason", 
-  "no_copy": 0, 
-  "oldfieldname": "trash_reason", 
-  "oldfieldtype": "Small Text", 
-  "print_hide": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "file_list", 
-  "fieldtype": "Small Text", 
-  "hidden": 1, 
-  "label": "File List", 
-  "no_copy": 1, 
-  "print_hide": 1, 
-  "search_index": 0
- }, 
- {
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
   "permlevel": 0, 
-  "report": 1, 
-  "submit": 0, 
+  "role": "Projects User", 
   "write": 1
  }, 
  {
+  "cancel": 0, 
+  "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 1
+  "permlevel": 1, 
+  "role": "All"
  }
 ]
\ No newline at end of file
diff --git a/projects/doctype/task/task.js b/projects/doctype/task/task.js
index 8493920..131b5fd 100644
--- a/projects/doctype/task/task.js
+++ b/projects/doctype/task/task.js
@@ -34,7 +34,7 @@
 		}
 	},
 
-	after_save: function() {
+	validate: function() {
 		this.frm.doc.project && wn.model.remove_from_locals("Project",
 			this.frm.doc.project);
 	},
diff --git a/projects/doctype/task/task.py b/projects/doctype/task/task.py
index ad2303e..a76dc9b 100644
--- a/projects/doctype/task/task.py
+++ b/projects/doctype/task/task.py
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from __future__ import unicode_literals
-import webnotes
+import webnotes, json
 
 from webnotes.utils import getdate, today
 from webnotes.model import db_exists
@@ -59,4 +59,35 @@
 			
 		if self.doc.status=="Closed" and status != "Closed" and not self.doc.act_end_date:
 			self.doc.act_end_date = today()
-		
\ No newline at end of file
+			
+	def on_update(self):
+		"""update percent complete in project"""
+		if self.doc.project:
+			webnotes.bean("Project", self.doc.project).controller.update_percent_complete()
+
+@webnotes.whitelist()
+def get_events(start, end, filters=None):
+	from webnotes.widgets.reportview import build_match_conditions
+	if not webnotes.has_permission("Task"):
+		webnotes.msgprint(_("No Permission"), raise_exception=1)
+
+	conditions = build_match_conditions("Task")
+	conditions and (" and " + conditions) or ""
+	
+	if filters:
+		filters = json.loads(filters)
+		for key in filters:
+			if filters[key]:
+				conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
+	
+	data = webnotes.conn.sql("""select name, exp_start_date, exp_end_date, 
+		subject, status, project from `tabTask`
+		where ((exp_start_date between '%(start)s' and '%(end)s') \
+			or (exp_end_date between '%(start)s' and '%(end)s'))
+		%(conditions)s""" % {
+			"start": start,
+			"end": end,
+			"conditions": conditions
+		}, as_dict=True, update={"allDay": 0})
+
+	return data
diff --git a/projects/doctype/task/task_calendar.js b/projects/doctype/task/task_calendar.js
new file mode 100644
index 0000000..94d7cc5
--- /dev/null
+++ b/projects/doctype/task/task_calendar.js
@@ -0,0 +1,19 @@
+wn.views.calendar["Task"] = {
+	field_map: {
+		"start": "exp_start_date",
+		"end": "exp_end_date",
+		"id": "name",
+		"title": "subject",
+		"allDay": "allDay"
+	},
+	gantt: true,
+	filters: [
+		{
+			"fieldtype": "Link", 
+			"fieldname": "project", 
+			"options": "Project", 
+			"label": "Project"
+		}
+	],
+	get_events_method: "projects.doctype.task.task.get_events"
+}
\ No newline at end of file
diff --git a/projects/doctype/time_log/time_log.py b/projects/doctype/time_log/time_log.py
index 8ab46c1..0a5adba 100644
--- a/projects/doctype/time_log/time_log.py
+++ b/projects/doctype/time_log/time_log.py
@@ -5,7 +5,6 @@
 from webnotes import _
 from webnotes.utils import cstr
 
-from webnotes.widgets.reportview import build_match_conditions
 
 class OverlapError(webnotes.ValidationError): pass
 
@@ -60,6 +59,10 @@
 				
 @webnotes.whitelist()
 def get_events(start, end):
+	from webnotes.widgets.reportview import build_match_conditions
+	if not webnotes.has_permission("Time Log"):
+		webnotes.msgprint(_("No Permission"), raise_exception=1)
+
 	match = build_match_conditions("Time Log")
 	data = webnotes.conn.sql("""select name, from_time, to_time, 
 		activity_type, task, project from `tabTime Log`
diff --git a/projects/doctype/time_log/time_log_calendar.js b/projects/doctype/time_log/time_log_calendar.js
index e5bb774..52338a9 100644
--- a/projects/doctype/time_log/time_log_calendar.js
+++ b/projects/doctype/time_log/time_log_calendar.js
@@ -1,4 +1,4 @@
-wn.views.calendar["Time Log"] = wn.views.Calendar.extend({
+wn.views.calendar["Time Log"] = {
 	field_map: {
 		"start": "from_time",
 		"end": "to_time",
@@ -7,4 +7,4 @@
 		"allDay": "allDay"
 	},
 	get_events_method: "projects.doctype.time_log.time_log.get_events"
-})
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/__init__.py b/projects/doctype/timesheet/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/projects/doctype/timesheet/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/doctype/timesheet/locale/_messages_doc.json b/projects/doctype/timesheet/locale/_messages_doc.json
deleted file mode 100644
index fab2534..0000000
--- a/projects/doctype/timesheet/locale/_messages_doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-[
- "Status", 
- "Timesheet By", 
- "Notes", 
- "Timesheet", 
- "Timesheet Date", 
- "Amendment Date", 
- "Cancelled", 
- "Draft", 
- "Submitted", 
- "Timesheet Details", 
- "Amended From", 
- "Projects"
-]
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/ar-doc.json b/projects/doctype/timesheet/locale/ar-doc.json
deleted file mode 100644
index 335b3a9..0000000
--- a/projects/doctype/timesheet/locale/ar-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "\u0639\u062f\u0644 \u0645\u0646", 
- "Amendment Date": "\u0627\u0644\u062a\u0639\u062f\u064a\u0644 \u062a\u0627\u0631\u064a\u062e", 
- "Cancelled": "\u0625\u0644\u063a\u0627\u0621", 
- "Draft": "\u0645\u0633\u0648\u062f\u0629", 
- "Notes": "\u062a\u0644\u0627\u062d\u0638", 
- "Projects": "\u0645\u0634\u0627\u0631\u064a\u0639", 
- "Status": "\u062d\u0627\u0644\u0629", 
- "Submitted": "\u0627\u0644\u0645\u0642\u062f\u0645\u0629", 
- "Timesheet": "\u0633\u0627\u0639\u0627\u062a \u0627\u0644\u0639\u0645\u0644", 
- "Timesheet By": "\u0627\u0644\u062c\u062f\u0648\u0644 \u0627\u0644\u0632\u0645\u0646\u064a \u0628\u0648\u0627\u0633\u0637\u0629", 
- "Timesheet Date": "\u0627\u0644\u062c\u062f\u0648\u0644 \u0627\u0644\u0632\u0645\u0646\u064a \u062a\u0627\u0631\u064a\u062e", 
- "Timesheet Details": "\u0627\u0644\u062c\u062f\u0648\u0644 \u0627\u0644\u0632\u0645\u0646\u064a \u062a\u0641\u0627\u0635\u064a\u0644"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/de-doc.json b/projects/doctype/timesheet/locale/de-doc.json
deleted file mode 100644
index e070b21..0000000
--- a/projects/doctype/timesheet/locale/de-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "Ge\u00e4ndert von", 
- "Amendment Date": "\u00c4nderung Datum", 
- "Cancelled": "Abgesagt", 
- "Draft": "Entwurf", 
- "Notes": "Aufzeichnungen", 
- "Projects": "Projekte", 
- "Status": "Status", 
- "Submitted": "Eingereicht", 
- "Timesheet": "Timesheet", 
- "Timesheet By": "Timesheet By", 
- "Timesheet Date": "Timesheet Datum", 
- "Timesheet Details": "Timesheet Einzelheiten"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/es-doc.json b/projects/doctype/timesheet/locale/es-doc.json
deleted file mode 100644
index a769174..0000000
--- a/projects/doctype/timesheet/locale/es-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "De modificada", 
- "Amendment Date": "Enmienda Fecha", 
- "Cancelled": "Cancelado", 
- "Draft": "Borrador", 
- "Notes": "Notas", 
- "Projects": "Proyectos", 
- "Status": "Estado", 
- "Submitted": "Enviado", 
- "Timesheet": "Parte de horas", 
- "Timesheet By": "Por parte de horas", 
- "Timesheet Date": "Fecha de parte de horas", 
- "Timesheet Details": "Detalles del parte de horas"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/fr-doc.json b/projects/doctype/timesheet/locale/fr-doc.json
deleted file mode 100644
index 7fe0e38..0000000
--- a/projects/doctype/timesheet/locale/fr-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "De modifi\u00e9e", 
- "Amendment Date": "Date de la modification", 
- "Cancelled": "Annul\u00e9", 
- "Draft": "Avant-projet", 
- "Notes": "Remarques", 
- "Projects": "Projets", 
- "Status": "Statut", 
- "Submitted": "Soumis", 
- "Timesheet": "Feuille de pr\u00e9sence", 
- "Timesheet By": "Feuille de temps par", 
- "Timesheet Date": "Date de feuille de temps", 
- "Timesheet Details": "D\u00e9tails des feuilles de temps"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/hi-doc.json b/projects/doctype/timesheet/locale/hi-doc.json
deleted file mode 100644
index 18e02b7..0000000
--- a/projects/doctype/timesheet/locale/hi-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "\u0938\u0947 \u0938\u0902\u0936\u094b\u0927\u093f\u0924", 
- "Amendment Date": "\u0938\u0902\u0936\u094b\u0927\u0928 \u0924\u093f\u0925\u093f", 
- "Cancelled": "Cancelled", 
- "Draft": "\u092e\u0938\u094c\u0926\u093e", 
- "Notes": "\u0928\u094b\u091f\u094d\u0938", 
- "Projects": "\u092a\u0930\u093f\u092f\u094b\u091c\u0928\u093e\u0913\u0902", 
- "Status": "\u0939\u0948\u0938\u093f\u092f\u0924", 
- "Submitted": "\u092a\u0947\u0936", 
- "Timesheet": "Timesheet", 
- "Timesheet By": "\u0926\u094d\u0935\u093e\u0930\u093e Timesheet", 
- "Timesheet Date": "Timesheet \u0924\u093f\u0925\u093f", 
- "Timesheet Details": "Timesheet \u0935\u093f\u0935\u0930\u0923"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/hr-doc.json b/projects/doctype/timesheet/locale/hr-doc.json
deleted file mode 100644
index 5f7e1d6..0000000
--- a/projects/doctype/timesheet/locale/hr-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "Izmijenjena Od", 
- "Amendment Date": "Amandman Datum", 
- "Cancelled": "Otkazan", 
- "Draft": "Skica", 
- "Notes": "Bilje\u0161ke", 
- "Projects": "Projekti", 
- "Status": "Status", 
- "Submitted": "Prijavljen", 
- "Timesheet": "Kontrolna kartica", 
- "Timesheet By": "Timesheet Do", 
- "Timesheet Date": "Timesheet Datum", 
- "Timesheet Details": "Timesheet Detalji"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/nl-doc.json b/projects/doctype/timesheet/locale/nl-doc.json
deleted file mode 100644
index 035df4c..0000000
--- a/projects/doctype/timesheet/locale/nl-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "Gewijzigd Van", 
- "Amendment Date": "Wijziging Datum", 
- "Cancelled": "Geannuleerd", 
- "Draft": "Ontwerp", 
- "Notes": "Opmerkingen", 
- "Projects": "Projecten", 
- "Status": "Staat", 
- "Submitted": "Ingezonden", 
- "Timesheet": "Rooster", 
- "Timesheet By": "Timesheet Door", 
- "Timesheet Date": "Timesheet Datum", 
- "Timesheet Details": "Timesheet Details"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/pt-BR-doc.json b/projects/doctype/timesheet/locale/pt-BR-doc.json
deleted file mode 100644
index 5ad54cf..0000000
--- a/projects/doctype/timesheet/locale/pt-BR-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "Corrigido De", 
- "Amendment Date": "Data da Corre\u00e7\u00e3o", 
- "Cancelled": "Cancelado", 
- "Draft": "Rascunho", 
- "Notes": "Notas", 
- "Projects": "Projetos", 
- "Status": "Estado", 
- "Submitted": "Enviado", 
- "Timesheet": "Quadro de Hor\u00e1rios", 
- "Timesheet By": "Quadro de Hor\u00e1rios Por", 
- "Timesheet Date": "Data do Quadro de Hor\u00e1rios", 
- "Timesheet Details": "Detalhes do Quadro de Hor\u00e1rios"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/pt-doc.json b/projects/doctype/timesheet/locale/pt-doc.json
deleted file mode 100644
index f31ce7e..0000000
--- a/projects/doctype/timesheet/locale/pt-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "Alterado De", 
- "Amendment Date": "Data emenda", 
- "Cancelled": "Cancelado", 
- "Draft": "Rascunho", 
- "Notes": "Notas", 
- "Projects": "Projetos", 
- "Status": "Estado", 
- "Submitted": "Enviado", 
- "Timesheet": "Quadro de Hor\u00e1rios", 
- "Timesheet By": "Por Timesheet", 
- "Timesheet Date": "Data Timesheet", 
- "Timesheet Details": "Detalhes quadro de hor\u00e1rios"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/sr-doc.json b/projects/doctype/timesheet/locale/sr-doc.json
deleted file mode 100644
index c9f9d9f..0000000
--- a/projects/doctype/timesheet/locale/sr-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "\u0418\u0437\u043c\u0435\u045a\u0435\u043d\u0430 \u043e\u0434", 
- "Amendment Date": "\u0410\u043c\u0430\u043d\u0434\u043c\u0430\u043d \u0414\u0430\u0442\u0443\u043c", 
- "Cancelled": "\u041e\u0442\u043a\u0430\u0437\u0430\u043d", 
- "Draft": "\u041d\u0430\u0446\u0440\u0442", 
- "Notes": "\u0411\u0435\u043b\u0435\u0448\u043a\u0435", 
- "Projects": "\u041f\u0440\u043e\u0458\u0435\u043a\u0442\u0438", 
- "Status": "\u0421\u0442\u0430\u0442\u0443\u0441", 
- "Submitted": "\u041f\u043e\u0434\u043d\u0435\u0442", 
- "Timesheet": "\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u0446\u0430", 
- "Timesheet By": "\u041f\u043e \u0422\u0438\u043c\u0435\u0441\u0445\u0435\u0435\u0442", 
- "Timesheet Date": "\u0414\u0430\u0442\u0443\u043c \u0422\u0438\u043c\u0435\u0441\u0445\u0435\u0435\u0442", 
- "Timesheet Details": "\u0422\u0438\u043c\u0435\u0441\u0445\u0435\u0435\u0442 \u0414\u0435\u0442\u0430\u0459\u0438"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/ta-doc.json b/projects/doctype/timesheet/locale/ta-doc.json
deleted file mode 100644
index cb4cc25..0000000
--- a/projects/doctype/timesheet/locale/ta-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "\u0bae\u0bc1\u0ba4\u0bb2\u0bcd \u0ba4\u0bbf\u0bb0\u0bc1\u0ba4\u0bcd\u0ba4\u0baa\u0bcd\u0baa\u0b9f\u0bcd\u0b9f", 
- "Amendment Date": "\u0ba4\u0bbf\u0bb0\u0bc1\u0ba4\u0bcd\u0ba4\u0ba4\u0bcd\u0ba4\u0bc8 \u0ba4\u0bc7\u0ba4\u0bbf", 
- "Cancelled": "\u0bb0\u0ba4\u0bcd\u0ba4\u0bc1", 
- "Draft": "\u0b95\u0bbe\u0bb1\u0bcd\u0bb1\u0bc1 \u0bb5\u0bc0\u0b9a\u0bcd\u0b9a\u0bc1", 
- "Notes": "\u0b95\u0bc1\u0bb1\u0bbf\u0baa\u0bcd\u0baa\u0bc1\u0b95\u0bb3\u0bcd", 
- "Projects": "\u0ba4\u0bbf\u0b9f\u0bcd\u0b9f\u0b99\u0bcd\u0b95\u0bb3\u0bcd", 
- "Status": "\u0b85\u0ba8\u0bcd\u0ba4\u0bb8\u0bcd\u0ba4\u0bc1", 
- "Submitted": "\u0b9a\u0bae\u0bb0\u0bcd\u0baa\u0bcd\u0baa\u0bbf\u0b95\u0bcd\u0b95\u0baa\u0bcd\u0baa\u0b9f\u0bcd\u0b9f\u0ba4\u0bc1", 
- "Timesheet": "Timesheet", 
- "Timesheet By": "By Timesheet", 
- "Timesheet Date": "Timesheet \u0ba4\u0bc7\u0ba4\u0bbf", 
- "Timesheet Details": "Timesheet \u0bb5\u0bbf\u0bb5\u0bb0\u0bae\u0bcd"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/locale/th-doc.json b/projects/doctype/timesheet/locale/th-doc.json
deleted file mode 100644
index 6003a4c..0000000
--- a/projects/doctype/timesheet/locale/th-doc.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "Amended From": "\u0e41\u0e01\u0e49\u0e44\u0e02\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21", 
- "Amendment Date": "\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e41\u0e01\u0e49\u0e44\u0e02", 
- "Cancelled": "\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01", 
- "Draft": "\u0e23\u0e48\u0e32\u0e07", 
- "Notes": "\u0e2b\u0e21\u0e32\u0e22\u0e40\u0e2b\u0e15\u0e38", 
- "Projects": "\u0e42\u0e04\u0e23\u0e07\u0e01\u0e32\u0e23", 
- "Status": "\u0e2a\u0e16\u0e32\u0e19\u0e30", 
- "Submitted": "Submitted", 
- "Timesheet": "timesheet", 
- "Timesheet By": "timesheet \u0e42\u0e14\u0e22", 
- "Timesheet Date": "\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 timesheet", 
- "Timesheet Details": "\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14 Timesheet"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet/timesheet.js b/projects/doctype/timesheet/timesheet.js
deleted file mode 100644
index ab2e05b..0000000
--- a/projects/doctype/timesheet/timesheet.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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/>.
-
-
-// ======================= OnLoad =============================================
-cur_frm.cscript.onload = function(doc,cdt,cdn){  
-  if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
-  if(!doc.timesheet_date) set_multiple(cdt,cdn,{timesheet_date:get_today()});
-}
-
-cur_frm.cscript.refresh = function(doc,cdt,cdn){
-	cur_frm.set_intro("Timesheets will soon be removed. Please create a new Time Log. To create \
-	 a new Time Log, to to Projects > Time Log > New Time Log. This will be removed in a few days.")
-}
-
-
-cur_frm.fields_dict['timesheet_details'].grid.get_field("project_name").get_query = function(doc,cdt,cdn){
-  var cond=cond1='';
-  var d = locals[cdt][cdn];
-  //if(d.customer_name) cond = 'ifnull(`tabProject`.customer_name, "") = "'+d.customer_name+'" AND';
-  if(d.task_id) cond1 = 'ifnull(`tabTask`.project, "") = `tabProject`.name AND `tabTask`.name = "'+d.task_id+'" AND';
-  
-  return repl('SELECT distinct `tabProject`.`name` FROM `tabProject`, `tabTask` WHERE %(cond1)s `tabProject`.`name` LIKE "%s" ORDER BY `tabProject`.`name` ASC LIMIT 50', {cond1:cond1});
-}
-
-cur_frm.cscript.task_name = function(doc, cdt, cdn){
-  var d = locals[cdt][cdn];
-  if(d.task_name) get_server_fields('get_task_details', d.task_name, 'timesheet_details', doc, cdt, cdn, 1);
-}
-
-cur_frm.fields_dict['timesheet_details'].grid.get_field("task_name").get_query = function(doc,cdt,cdn){
-  var cond='';
-  var d = locals[cdt][cdn];
-  if(d.project_name) cond = 'ifnull(`tabTask`.project, "") = "'+d.project_name+'" AND';
-  
-  return repl('SELECT distinct `tabTask`.`subject` FROM `tabTask` WHERE %(cond)s `tabTask`.`subject` LIKE "%s" ORDER BY `tabTask`.`subject` ASC LIMIT 50', {cond:cond});
-}
-
-cur_frm.fields_dict.timesheet_details.grid.get_field("customer_name").get_query = 
-	erpnext.utils.customer_query;
\ No newline at end of file
diff --git a/projects/doctype/timesheet/timesheet.py b/projects/doctype/timesheet/timesheet.py
deleted file mode 100644
index 8123278..0000000
--- a/projects/doctype/timesheet/timesheet.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# 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
-import time, datetime
-
-from webnotes.utils import cint, cstr, getdate, now, nowdate
-from webnotes.model import db_exists
-from webnotes.model.bean import getlist, copy_doclist
-from webnotes import msgprint
-
-sql = webnotes.conn.sql
-
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
-	
-	def get_customer_details(self, project_name):
-		cust = sql("select customer, customer_name from `tabProject` where name = %s", project_name)
-		if cust:
-			ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
-			return (ret)
-	
-	def get_task_details(self, task_sub):
-		tsk = sql("select name, project, customer, customer_name from `tabTask` where subject = %s", task_sub)
-		if tsk:
-			ret = {'task_id': tsk and tsk[0][0] or '', 'project_name': tsk and tsk[0][1] or '', 'customer_name': tsk and tsk[0][3] or ''}
-			return ret
-	
-	def get_time(self, timestr):
-		if len(timestr.split(":"))==2:
-			format = "%H:%M"
-		else:
-			format = "%H:%M:%S"
-			
-		return time.strptime(timestr, format)
-	
-	def validate(self):
-		msgprint("Please create a new Time Log", raise_exception=True)
-		
-		if getdate(self.doc.timesheet_date) > getdate(nowdate()):
-			msgprint("You can not prepare timesheet for future date")
-			raise Exception
-		
-		chk = sql("select name from `tabTimesheet` where timesheet_date=%s and owner=%s and status!='Cancelled' and name!=%s", (self.doc.timesheet_date, self.doc.owner, self.doc.name))
-		if chk:
-			msgprint("You have already created timesheet "+ cstr(chk and chk[0][0] or '')+" for this date.")
-			raise Exception
-
-		for d in getlist(self.doclist, 'timesheet_details'):
-			if d.act_start_time and d.act_end_time:
-				d1 = self.get_time(d.act_start_time)
-				d2 = self.get_time(d.act_end_time)
-				
-				if d1 > d2:
-					msgprint("Start time can not be greater than end time. Check for Task Id : "+cstr(d.task_id))
-					raise Exception
-				elif d1 == d2:
-					msgprint("Start time and end time can not be same. Check for Task Id : "+cstr(d.task_id))
-					raise Exception
-	
-	def calculate_total_hr(self):
-		for d in getlist(self.doclist, 'timesheet_details'):
-			x1 = d.act_start_time.split(":")
-			x2 = d.act_end_time.split(":")
-			
-			d1 = datetime.timedelta(minutes=cint(x1[1]), hours=cint(x1[0]))			
-			d2 = datetime.timedelta(minutes=cint(x2[1]), hours=cint(x2[0]))
-			d3 = (d2 - d1).seconds
-			d.act_total_hrs = time.strftime("%H:%M:%S", time.gmtime(d3))
-			sql("update `tabTimesheet Detail` set act_total_hrs = %s where parent=%s and name=%s", (d.act_total_hrs,self.doc.name,d.name))
-	
-	def on_update(self):
-		self.calculate_total_hr()
-		webnotes.conn.set(self.doc, 'status', 'Draft')
-	
-	def on_submit(self):
-		webnotes.conn.set(self.doc, 'status', 'Submitted')
-	
-	def on_cancel(self):
-		webnotes.conn.set(self.doc, 'status', 'Cancelled')
-			
\ No newline at end of file
diff --git a/projects/doctype/timesheet/timesheet.txt b/projects/doctype/timesheet/timesheet.txt
deleted file mode 100644
index d64a3e1..0000000
--- a/projects/doctype/timesheet/timesheet.txt
+++ /dev/null
@@ -1,180 +0,0 @@
-[
- {
-  "creation": "2013-01-29 19:25:50", 
-  "docstatus": 0, 
-  "modified": "2013-02-26 13:44:35", 
-  "modified_by": "Administrator", 
-  "owner": "ashwini@webnotestech.com"
- }, 
- {
-  "autoname": "TimeSheet.#####", 
-  "doctype": "DocType", 
-  "is_submittable": 1, 
-  "module": "Projects", 
-  "name": "__common__", 
-  "search_fields": "status, owner, timesheet_date"
- }, 
- {
-  "doctype": "DocField", 
-  "name": "__common__", 
-  "parent": "Timesheet", 
-  "parentfield": "fields", 
-  "parenttype": "DocType", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocPerm", 
-  "name": "__common__", 
-  "parent": "Timesheet", 
-  "parentfield": "permissions", 
-  "parenttype": "DocType", 
-  "read": 1
- }, 
- {
-  "doctype": "DocType", 
-  "name": "Timesheet"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "timesheet_details_section_break", 
-  "fieldtype": "Section Break", 
-  "label": "Timesheet Details"
- }, 
- {
-  "default": "Today", 
-  "doctype": "DocField", 
-  "fieldname": "timesheet_date", 
-  "fieldtype": "Date", 
-  "in_filter": 1, 
-  "label": "Timesheet Date", 
-  "oldfieldname": "timesheet_date", 
-  "oldfieldtype": "Date", 
-  "reqd": 1, 
-  "search_index": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "column_break_3", 
-  "fieldtype": "Column Break"
- }, 
- {
-  "default": "Draft", 
-  "doctype": "DocField", 
-  "fieldname": "status", 
-  "fieldtype": "Select", 
-  "in_filter": 0, 
-  "in_list_view": 1, 
-  "label": "Status", 
-  "oldfieldname": "status", 
-  "oldfieldtype": "Select", 
-  "options": "\nDraft\nSubmitted\nCancelled", 
-  "read_only": 1, 
-  "reqd": 1, 
-  "search_index": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "section_break0", 
-  "fieldtype": "Section Break", 
-  "options": "Simple"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "timesheet_details", 
-  "fieldtype": "Table", 
-  "label": "Timesheet Details", 
-  "oldfieldname": "timesheet_details", 
-  "oldfieldtype": "Table", 
-  "options": "Timesheet Detail"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "section_break_7", 
-  "fieldtype": "Section Break"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "notes", 
-  "fieldtype": "Text", 
-  "in_list_view": 1, 
-  "label": "Notes"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "owner", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Timesheet By", 
-  "oldfieldname": "owner", 
-  "oldfieldtype": "Link", 
-  "options": "Profile", 
-  "reqd": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "amended_from", 
-  "fieldtype": "Data", 
-  "hidden": 1, 
-  "label": "Amended From", 
-  "oldfieldname": "amended_from", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "amendment_date", 
-  "fieldtype": "Date", 
-  "hidden": 1, 
-  "label": "Amendment Date", 
-  "oldfieldname": "amendment_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Projects User", 
-  "submit": 0, 
-  "write": 1
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Projects User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "System Manager", 
-  "submit": 1, 
-  "write": 1
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "System Manager", 
-  "submit": 0, 
-  "write": 0
- }
-]
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/__init__.py b/projects/doctype/timesheet_detail/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/projects/doctype/timesheet_detail/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/doctype/timesheet_detail/locale/_messages_doc.json b/projects/doctype/timesheet_detail/locale/_messages_doc.json
deleted file mode 100644
index a51a3e2..0000000
--- a/projects/doctype/timesheet_detail/locale/_messages_doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-[
- "Task Id", 
- "Activity Type", 
- "Actual End Time", 
- "Actual Start Time", 
- "Project", 
- "Total Hours (Actual)", 
- "Customer Name", 
- "Additional Info", 
- "Timesheet Detail", 
- "Task Name", 
- "Projects"
-]
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/ar-doc.json b/projects/doctype/timesheet_detail/locale/ar-doc.json
deleted file mode 100644
index b4d1ce2..0000000
--- a/projects/doctype/timesheet_detail/locale/ar-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "\u0627\u0644\u0646\u0634\u0627\u0637 \u0646\u0648\u0639", 
- "Actual End Time": "\u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0648\u0642\u062a \u0627\u0644\u0641\u0639\u0644\u064a", 
- "Actual Start Time": "\u0648\u0642\u062a \u0627\u0644\u0628\u062f\u0621 \u0627\u0644\u0641\u0639\u0644\u064a", 
- "Additional Info": "\u0645\u0639\u0644\u0648\u0645\u0627\u062a \u0625\u0636\u0627\u0641\u064a\u0629", 
- "Customer Name": "\u0627\u0633\u0645 \u0627\u0644\u0639\u0645\u064a\u0644", 
- "Project": "\u0645\u0634\u0631\u0648\u0639", 
- "Projects": "\u0645\u0634\u0627\u0631\u064a\u0639", 
- "Task Id": "\u0627\u0644\u0645\u0647\u0645\u0629 \u0631\u0642\u0645", 
- "Task Name": "\u0627\u0633\u0645 \u0627\u0644\u0645\u0647\u0645\u0629", 
- "Timesheet Detail": "\u0627\u0644\u062c\u062f\u0648\u0644 \u0627\u0644\u0632\u0645\u0646\u064a \u0627\u0644\u062a\u0641\u0627\u0635\u064a\u0644", 
- "Total Hours (Actual)": "\u0645\u062c\u0645\u0648\u0639 \u0633\u0627\u0639\u0627\u062a (\u0627\u0644\u0641\u0639\u0644\u064a\u0629)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/de-doc.json b/projects/doctype/timesheet_detail/locale/de-doc.json
deleted file mode 100644
index 9a29d33..0000000
--- a/projects/doctype/timesheet_detail/locale/de-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Art der T\u00e4tigkeit", 
- "Actual End Time": "Tats\u00e4chliche Endzeit", 
- "Actual Start Time": "Tats\u00e4chliche Startzeit", 
- "Additional Info": "Zus\u00e4tzliche Informationen", 
- "Customer Name": "Name des Kunden", 
- "Project": "Projekt", 
- "Projects": "Projekte", 
- "Task Id": "Task-Id", 
- "Task Name": "Task-Name", 
- "Timesheet Detail": "Timesheet Details", 
- "Total Hours (Actual)": "Total Hours (Actual)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/es-doc.json b/projects/doctype/timesheet_detail/locale/es-doc.json
deleted file mode 100644
index 0a28e7f..0000000
--- a/projects/doctype/timesheet_detail/locale/es-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Tipo de actividad", 
- "Actual End Time": "Hora de finalizaci\u00f3n real", 
- "Actual Start Time": "Tiempo real de inicio", 
- "Additional Info": "Informaci\u00f3n adicional", 
- "Customer Name": "Nombre del cliente", 
- "Project": "Proyecto", 
- "Projects": "Proyectos", 
- "Task Id": "Tarea Id", 
- "Task Name": "Nombre de tarea", 
- "Timesheet Detail": "Detalle de parte de horas", 
- "Total Hours (Actual)": "Horas totales (real)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/fr-doc.json b/projects/doctype/timesheet_detail/locale/fr-doc.json
deleted file mode 100644
index 269ede8..0000000
--- a/projects/doctype/timesheet_detail/locale/fr-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Type d&#39;activit\u00e9", 
- "Actual End Time": "Heure de fin r\u00e9elle", 
- "Actual Start Time": "Heure de d\u00e9but r\u00e9elle", 
- "Additional Info": "Informations additionnelles \u00e0", 
- "Customer Name": "Nom du client", 
- "Project": "Projet", 
- "Projects": "Projets", 
- "Task Id": "T\u00e2che Id", 
- "Task Name": "Nom de la t\u00e2che", 
- "Timesheet Detail": "D\u00e9tail des feuilles de temps", 
- "Total Hours (Actual)": "Total des heures (r\u00e9elles)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/hi-doc.json b/projects/doctype/timesheet_detail/locale/hi-doc.json
deleted file mode 100644
index 4d34871..0000000
--- a/projects/doctype/timesheet_detail/locale/hi-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "\u0917\u0924\u093f\u0935\u093f\u0927\u093f \u092a\u094d\u0930\u0915\u093e\u0930", 
- "Actual End Time": "\u0935\u093e\u0938\u094d\u0924\u0935\u093f\u0915 \u0905\u0902\u0924 \u0938\u092e\u092f", 
- "Actual Start Time": "\u0935\u093e\u0938\u094d\u0924\u0935\u093f\u0915 \u092a\u094d\u0930\u093e\u0930\u0902\u092d \u0938\u092e\u092f", 
- "Additional Info": "\u0905\u0924\u093f\u0930\u093f\u0915\u094d\u0924 \u091c\u093e\u0928\u0915\u093e\u0930\u0940", 
- "Customer Name": "\u0917\u094d\u0930\u093e\u0939\u0915 \u0915\u093e \u0928\u093e\u092e", 
- "Project": "\u092a\u0930\u093f\u092f\u094b\u091c\u0928\u093e", 
- "Projects": "\u092a\u0930\u093f\u092f\u094b\u091c\u0928\u093e\u0913\u0902", 
- "Task Id": "\u091f\u093e\u0938\u094d\u0915 \u0906\u0908\u0921\u0940", 
- "Task Name": "\u0915\u093e\u0930\u094d\u092f \u0915\u093e \u0928\u093e\u092e", 
- "Timesheet Detail": "Timesheet \u0935\u093f\u0938\u094d\u0924\u093e\u0930", 
- "Total Hours (Actual)": "\u0915\u0941\u0932 \u0918\u0902\u091f\u0947 (\u0935\u093e\u0938\u094d\u0924\u0935\u093f\u0915)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/hr-doc.json b/projects/doctype/timesheet_detail/locale/hr-doc.json
deleted file mode 100644
index d19276a..0000000
--- a/projects/doctype/timesheet_detail/locale/hr-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Aktivnost Tip", 
- "Actual End Time": "Stvarni Vrijeme zavr\u0161etka", 
- "Actual Start Time": "Stvarni Vrijeme po\u010detka", 
- "Additional Info": "Dodatne informacije", 
- "Customer Name": "Naziv klijenta", 
- "Project": "Projekt", 
- "Projects": "Projekti", 
- "Task Id": "Zadatak Id", 
- "Task Name": "Zadatak Ime", 
- "Timesheet Detail": "Timesheet Detalj", 
- "Total Hours (Actual)": "Ukupno vrijeme (Stvarni)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/nl-doc.json b/projects/doctype/timesheet_detail/locale/nl-doc.json
deleted file mode 100644
index 8305440..0000000
--- a/projects/doctype/timesheet_detail/locale/nl-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Activiteit Type", 
- "Actual End Time": "Werkelijke Eindtijd", 
- "Actual Start Time": "Werkelijke Starttijd", 
- "Additional Info": "Extra informatie", 
- "Customer Name": "Klantnaam", 
- "Project": "Project", 
- "Projects": "Projecten", 
- "Task Id": "Taak-id", 
- "Task Name": "Taaknaam", 
- "Timesheet Detail": "Timesheet Detail", 
- "Total Hours (Actual)": "Totaal uren (werkelijke)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/pt-BR-doc.json b/projects/doctype/timesheet_detail/locale/pt-BR-doc.json
deleted file mode 100644
index b11f35a..0000000
--- a/projects/doctype/timesheet_detail/locale/pt-BR-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Tipo da Atividade", 
- "Actual End Time": "Tempos Final Real", 
- "Actual Start Time": "Hor\u00e1rio de In\u00edcio Real", 
- "Additional Info": "Informa\u00e7\u00f5es Adicionais", 
- "Customer Name": "Nome do cliente", 
- "Project": "Projeto", 
- "Projects": "Projetos", 
- "Task Id": "ID da Tarefa", 
- "Task Name": "Nome da Tarefa", 
- "Timesheet Detail": "Detalhe do Quadro de Hor\u00e1rios", 
- "Total Hours (Actual)": "Total de Horas (Real)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/pt-doc.json b/projects/doctype/timesheet_detail/locale/pt-doc.json
deleted file mode 100644
index b2dcf2b..0000000
--- a/projects/doctype/timesheet_detail/locale/pt-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "Tipo de Atividade", 
- "Actual End Time": "Fim dos Tempos real", 
- "Actual Start Time": "Hor\u00e1rio de in\u00edcio real", 
- "Additional Info": "Informa\u00e7\u00f5es Adicionais", 
- "Customer Name": "Nome do cliente", 
- "Project": "Projeto", 
- "Projects": "Projetos", 
- "Task Id": "Tarefa Id", 
- "Task Name": "Nome da Tarefa", 
- "Timesheet Detail": "Detalhe de quadro de hor\u00e1rios", 
- "Total Hours (Actual)": "Total de Horas (Real)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/sr-doc.json b/projects/doctype/timesheet_detail/locale/sr-doc.json
deleted file mode 100644
index b29f234..0000000
--- a/projects/doctype/timesheet_detail/locale/sr-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442 \u0422\u0438\u043f", 
- "Actual End Time": "\u0421\u0443\u043d\u0446\u0435 \u041a\u0440\u0430\u0458\u045a\u0435 \u0432\u0440\u0435\u043c\u0435", 
- "Actual Start Time": "\u0421\u0443\u043d\u0446\u0435 \u0421\u0442\u0430\u0440\u0442 \u0422\u0438\u043c\u0435", 
- "Additional Info": "\u0414\u043e\u0434\u0430\u0442\u043d\u0438 \u043f\u043e\u0434\u0430\u0446\u0438", 
- "Customer Name": "\u0418\u043c\u0435 \u043a\u043b\u0438\u0458\u0435\u043d\u0442\u0430", 
- "Project": "\u041f\u0440\u043e\u0458\u0435\u043a\u0430\u0442", 
- "Projects": "\u041f\u0440\u043e\u0458\u0435\u043a\u0442\u0438", 
- "Task Id": "\u0417\u0430\u0434\u0430\u0442\u0430\u043a \u0418\u0434", 
- "Task Name": "\u041d\u0430\u0437\u0438\u0432 \u0437\u0430\u0434\u0430\u0442\u043a\u0430", 
- "Timesheet Detail": "\u0422\u0438\u043c\u0435\u0441\u0445\u0435\u0435\u0442 \u0414\u0435\u0442\u0430\u0459", 
- "Total Hours (Actual)": "\u0423\u043a\u0443\u043f\u043d\u043e \u0432\u0440\u0435\u043c\u0435 (\u0421\u0443\u043d\u0446\u0435)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/ta-doc.json b/projects/doctype/timesheet_detail/locale/ta-doc.json
deleted file mode 100644
index d6abb7f..0000000
--- a/projects/doctype/timesheet_detail/locale/ta-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "\u0ba8\u0b9f\u0bb5\u0b9f\u0bbf\u0b95\u0bcd\u0b95\u0bc8 \u0bb5\u0b95\u0bc8", 
- "Actual End Time": "\u0b89\u0ba3\u0bcd\u0bae\u0bc8\u0baf\u0bbe\u0ba9 \u0bae\u0bc1\u0b9f\u0bbf\u0bb5\u0bc1 \u0ba8\u0bc7\u0bb0\u0bae\u0bcd", 
- "Actual Start Time": "\u0b89\u0ba3\u0bcd\u0bae\u0bc8\u0baf\u0bbe\u0ba9 \u0ba4\u0bc6\u0bbe\u0b9f\u0b95\u0bcd\u0b95 \u0ba8\u0bc7\u0bb0\u0bae\u0bcd", 
- "Additional Info": "\u0b95\u0bc2\u0b9f\u0bc1\u0ba4\u0bb2\u0bcd \u0ba4\u0b95\u0bb5\u0bb2\u0bcd", 
- "Customer Name": "\u0bb5\u0bbe\u0b9f\u0bbf\u0b95\u0bcd\u0b95\u0bc8\u0baf\u0bbe\u0bb3\u0bb0\u0bcd \u0baa\u0bc6\u0baf\u0bb0\u0bcd", 
- "Project": "\u0ba4\u0bbf\u0b9f\u0bcd\u0b9f\u0bae\u0bcd", 
- "Projects": "\u0ba4\u0bbf\u0b9f\u0bcd\u0b9f\u0b99\u0bcd\u0b95\u0bb3\u0bcd", 
- "Task Id": "\u0baa\u0ba3\u0bbf \u0b85\u0b9f\u0bc8\u0baf\u0bbe\u0bb3\u0bae\u0bcd", 
- "Task Name": "\u0baa\u0ba3\u0bbf \u0baa\u0bc6\u0baf\u0bb0\u0bcd", 
- "Timesheet Detail": "Timesheet \u0bb5\u0bbf\u0bb0\u0bbf\u0bb5\u0bbe\u0b95", 
- "Total Hours (Actual)": "\u0bae\u0bc6\u0bbe\u0ba4\u0bcd\u0ba4 \u0ba8\u0bc7\u0bb0\u0bae\u0bcd (\u0b85\u0b9a\u0bb2\u0bcd)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/locale/th-doc.json b/projects/doctype/timesheet_detail/locale/th-doc.json
deleted file mode 100644
index 197e90f..0000000
--- a/projects/doctype/timesheet_detail/locale/th-doc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Activity Type": "\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21", 
- "Actual End Time": "\u0e40\u0e27\u0e25\u0e32\u0e2a\u0e34\u0e49\u0e19\u0e2a\u0e38\u0e14\u0e08\u0e23\u0e34\u0e07", 
- "Actual Start Time": "\u0e40\u0e27\u0e25\u0e32\u0e40\u0e23\u0e34\u0e48\u0e21\u0e15\u0e49\u0e19\u0e08\u0e23\u0e34\u0e07", 
- "Additional Info": "\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21", 
- "Customer Name": "\u0e0a\u0e37\u0e48\u0e2d\u0e25\u0e39\u0e01\u0e04\u0e49\u0e32", 
- "Project": "\u0e42\u0e04\u0e23\u0e07\u0e01\u0e32\u0e23", 
- "Projects": "\u0e42\u0e04\u0e23\u0e07\u0e01\u0e32\u0e23", 
- "Task Id": "\u0e23\u0e2b\u0e31\u0e2a\u0e07\u0e32\u0e19", 
- "Task Name": "\u0e0a\u0e37\u0e48\u0e2d\u0e07\u0e32\u0e19", 
- "Timesheet Detail": "\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14 Timesheet", 
- "Total Hours (Actual)": "\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07\u0e23\u0e27\u0e21 (\u0e08\u0e23\u0e34\u0e07)"
-}
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/timesheet_detail.py b/projects/doctype/timesheet_detail/timesheet_detail.py
deleted file mode 100644
index 7f48feb..0000000
--- a/projects/doctype/timesheet_detail/timesheet_detail.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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
-
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/projects/doctype/timesheet_detail/timesheet_detail.txt b/projects/doctype/timesheet_detail/timesheet_detail.txt
deleted file mode 100644
index b99425b..0000000
--- a/projects/doctype/timesheet_detail/timesheet_detail.txt
+++ /dev/null
@@ -1,132 +0,0 @@
-[
- {
-  "creation": "2013-01-10 16:34:18", 
-  "docstatus": 0, 
-  "modified": "2013-01-22 14:50:09", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "autoname": "TSD.#####", 
-  "doctype": "DocType", 
-  "istable": 1, 
-  "module": "Projects", 
-  "name": "__common__"
- }, 
- {
-  "doctype": "DocField", 
-  "name": "__common__", 
-  "parent": "Timesheet Detail", 
-  "parentfield": "fields", 
-  "parenttype": "DocType", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocType", 
-  "name": "Timesheet Detail"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "act_start_time", 
-  "fieldtype": "Time", 
-  "label": "Actual Start Time", 
-  "oldfieldname": "act_start_time", 
-  "oldfieldtype": "Time", 
-  "print_width": "160px", 
-  "reqd": 1, 
-  "width": "160px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "act_end_time", 
-  "fieldtype": "Time", 
-  "label": "Actual End Time", 
-  "oldfieldname": "act_end_time", 
-  "oldfieldtype": "Time", 
-  "print_width": "160px", 
-  "reqd": 1, 
-  "width": "160px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "activity_type", 
-  "fieldtype": "Link", 
-  "label": "Activity Type", 
-  "options": "Activity Type", 
-  "print_width": "200px", 
-  "reqd": 1, 
-  "search_index": 0, 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "other_details", 
-  "fieldtype": "Text", 
-  "label": "Additional Info", 
-  "oldfieldname": "other_details", 
-  "oldfieldtype": "Text", 
-  "print_width": "200px", 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "act_total_hrs", 
-  "fieldtype": "Data", 
-  "label": "Total Hours (Actual)", 
-  "oldfieldname": "act_total_hrs", 
-  "oldfieldtype": "Data", 
-  "print_width": "100px", 
-  "read_only": 1, 
-  "width": "100px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "customer_name", 
-  "fieldtype": "Link", 
-  "label": "Customer Name", 
-  "oldfieldname": "customer_name", 
-  "oldfieldtype": "Data", 
-  "options": "Customer", 
-  "print_width": "150px", 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "project_name", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Project", 
-  "oldfieldname": "project_name", 
-  "oldfieldtype": "Link", 
-  "options": "Project", 
-  "print_width": "150px", 
-  "reqd": 0, 
-  "search_index": 1, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "task_id", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Task Id", 
-  "oldfieldname": "task_id", 
-  "oldfieldtype": "Link", 
-  "options": "Task", 
-  "print_width": "150px", 
-  "search_index": 1, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "task_name", 
-  "fieldtype": "Data", 
-  "label": "Task Name", 
-  "oldfieldname": "task_name", 
-  "oldfieldtype": "Link", 
-  "print_width": "250px", 
-  "reqd": 0, 
-  "search_index": 0, 
-  "width": "250px"
- }
-]
\ No newline at end of file
diff --git a/public/css/splash.css b/public/css/splash.css
new file mode 100644
index 0000000..d4f0493
--- /dev/null
+++ b/public/css/splash.css
@@ -0,0 +1,52 @@
+@-webkit-keyframes pulse {
+  from {
+    opacity: 0.7;
+  }
+
+  to {
+    opacity: 1;
+  }
+}
+
+@keyframes pulse {
+  from {
+    opacity: 0.7;
+  }
+
+  to {
+    opacity: 1;
+  }
+}
+
+
+.splash {
+	margin: auto;
+	position: absolute;
+	top: 0px;
+	left: 0px;
+	right: 0px;
+	bottom: 30px;
+	width: 160px;
+	height: 160px;
+	text-align: center;
+	color: #888;
+	
+	animation-duration: 1s;
+	animation-name: pulse;
+	animation-iteration-count: infinite;
+	animation-direction: alternate;
+
+	-webkit-animation-duration: 1s;
+	-webkit-animation-name: pulse;
+	-webkit-animation-iteration-count: infinite;
+	-webkit-animation-direction: alternate;
+}
+
+.splash:after {
+	content: "erpnext";
+	font-size: 30px;
+	font-weight: 700;
+	font-family: Helvetica, Arial, sans-serif;
+	position: relative;
+	top: -30px;
+}
diff --git a/public/images/favicon.ico b/public/images/favicon.ico
index 045b1bd..4fbf3f2 100644
--- a/public/images/favicon.ico
+++ b/public/images/favicon.ico
Binary files differ
diff --git a/public/images/splash.svg b/public/images/splash.svg
new file mode 100644
index 0000000..3f9fa88
--- /dev/null
+++ b/public/images/splash.svg
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.48.2 r9819"
+   sodipodi:docname="splash-mono.svg"
+   inkscape:export-filename="/Users/anandpdoshi/Dropbox/erpnext/logo 2013/erpnext-logo-2013 other colors 3.png"
+   inkscape:export-xdpi="167.56363"
+   inkscape:export-ydpi="167.56363"
+   viewBox="0 0 680 820"
+   preserveAspectRatio="xMidyMid meet"
+   width="100%"
+   height="100%">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.53740115"
+     inkscape:cx="417.75453"
+     inkscape:cy="501.17067"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer4"
+     showgrid="false"
+     inkscape:snap-bbox="false"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:snap-global="true"
+     inkscape:bbox-paths="false"
+     inkscape:bbox-nodes="false"
+     inkscape:snap-page="false"
+     inkscape:snap-grids="true"
+     inkscape:window-width="721"
+     inkscape:window-height="690"
+     inkscape:window-x="293"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid3836" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     style="display:inline">
+    <rect
+       style="opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:1"
+       id="rect3800"
+       width="150"
+       height="150"
+       x="60.000008"
+       y="-472.36218"
+       rx="20"
+       ry="20"
+       transform="scale(1,-1)" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="Layer 2">
+    <path
+       transform="scale(1,-1)"
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:1"
+       d="m 180,-372.36218 110,0 20,0 0,20 0,110 c 0,11.08 -8.92,20 -20,20 l -110,0 c -11.08,0 -20,-8.92 -20,-20 l 0,-110 c 0,-11.08 8.92,-20 20,-20 z"
+       id="rect3051"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="scccssssss" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer3"
+     inkscape:label="Layer 3">
+    <rect
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:0.94117647"
+       id="rect3840"
+       width="150"
+       height="150"
+       x="260"
+       y="-272.36218"
+       rx="20"
+       ry="20"
+       transform="scale(1,-1)" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer4"
+     inkscape:label="Layer 4">
+    <path
+       sodipodi:nodetypes="scccssssss"
+       inkscape:connector-curvature="0"
+       id="path3054"
+       d="m 490,372.36218 -110,0 -20,0 0,-20 0,-110 c 0,-11.08 8.92,-20 20,-20 l 110,0 c 11.08,0 20,8.92 20,20 l 0,110 c 0,11.08 -8.92,20 -20,20 z"
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:1" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer5"
+     inkscape:label="Layer 5">
+    <rect
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:0.94117647"
+       id="rect3844"
+       width="150"
+       height="150"
+       x="460"
+       y="-472.36218"
+       rx="20"
+       ry="20"
+       transform="scale(1,-1)" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer6"
+     inkscape:label="Layer 6">
+    <path
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:0.94117647"
+       d="m 490,422.36218 -110,0 -20,0 0,20 0,110 c 0,11.08 8.92,20 20,20 l 110,0 c 11.08,0 20,-8.92 20,-20 l 0,-110 c 0,-11.08 -8.92,-20 -20,-20 z"
+       id="path3058"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="scccssssss" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer7"
+     inkscape:label="Layer 7">
+    <rect
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:1"
+       id="rect3848"
+       width="150"
+       height="150"
+       x="260"
+       y="-672.36218"
+       rx="20"
+       ry="20"
+       transform="scale(1,-1)" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer8"
+     inkscape:label="Layer 8">
+    <path
+       sodipodi:nodetypes="scccssssss"
+       inkscape:connector-curvature="0"
+       id="path3056"
+       d="m 180,422.36218 110,0 20,0 0,20 0,110 c 0,11.08 -8.92,20 -20,20 l -110,0 c -11.08,0 -20,-8.92 -20,-20 l 0,-110 c 0,-11.08 8.92,-20 20,-20 z"
+       style="display:inline;opacity:0.90000000000000002;fill:#bdc3c7;fill-opacity:1" />
+  </g>
+</svg>
diff --git a/public/js/conf.js b/public/js/conf.js
index 522de0a..71f1fa6 100644
--- a/public/js/conf.js
+++ b/public/js/conf.js
@@ -15,8 +15,8 @@
 
 // add toolbar icon
 $(document).bind('toolbar_setup', function() {
-	$('.brand').html((wn.boot.website_settings.brand_html || 'erpnext') +
-	' <i class="icon-home icon-white navbar-icon-home" ></i>')
+	$('.navbar-brand').html('<object data="app/images/splash.svg" \
+		class="toolbar-splash" type="image/svg+xml"></object>erpnext')
 	.css('max-width', '200px').css('overflow', 'hidden')
 	.hover(function() {
 		$(this).find('.icon-home').addClass('navbar-icon-home-hover');
diff --git a/public/js/kb_common.js b/public/js/kb_common.js
deleted file mode 100644
index 6dca3f8..0000000
--- a/public/js/kb_common.js
+++ /dev/null
@@ -1,158 +0,0 @@
-// 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/>.
-
-// question toolbar
-// contains - voting widget / tag list and user info / timestamp
-// By XXXXXX on YYYYY
-
-KBItemToolbar = function(args, kb) {
-	$.extend(this, args);
-	var me = this;
-	this.make = function() {
-		this.wrapper = $a(this.parent, 'div', '', {});
-		this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'});
-		this.make_timestamp();
-		this.make_answers();
-		if(this.with_tags)
-			this.make_tags();
-		this.setup_del();
-	}
-	
-	this.make_timestamp = function() {
-		this.line1.innerHTML = repl('By %(name)s | %(when)s', {
-			name: wn.user_info(this.det.owner).fullname,
-			when: wn.datetime.comment_when(this.det.modified)
-		});
-		
-		// allow system manager to delete questions / answers
-		if(has_common(user_roles, ['Administrator', 'System Manager'])) {
-			this.line1.innerHTML += ' | <a style="cursor:pointer;"\
-				class="del-link">delete</a>';
-		}
-	}
-
-	this.make_answers = function() {
-		if(this.doctype=='Question') {
-			if(this.det.answers==0) {
-				this.line1.innerHTML += ' | no answers';
-			} else if(this.det.answers==1) {
-				this.line1.innerHTML += ' | 1 answer';
-			} else {
-				this.line1.innerHTML += ' | '+this.det.answers+' answers';
-			}
-		}
-	}
-	
-	this.make_tags = function() {
-		this.line1.innerHTML += ' | '
-		this.tags_area = $a(this.line1, 'span', 'kb-tags')
-		this.tags = new TagList(this.tags_area, 
-			this.det._user_tags && (this.det._user_tags.split(',')), 
-			this.doctype, this.det.name, 0, kb.set_tag_filter)		
-	}
-
-	this.setup_del = function() {
-		$(this.line1).find('.del-link').click(function() {
-			this.innerHTML = 'deleting...'; 
-			this.disabled = 1;
-			$c_page('utilities', 'questions', 'delete', {
-				dt: me.doctype, dn: me.det.name}, function(r,rt) {
-				// reload the list
-				kb.list.run()
-			});
-		});		
-	}
-
-	this.make();
-}
-
-
-// displays an editable text,
-// needs parent, text, disp_class, inp_class
-// dt, dn
-
-EditableText = function(args) {
-	$.extend(this, args);
-	var me = this;
-	
-	me.$w = $(repl('<div class="ed-text">\
-		<div class="ed-text-display %(disp_class)s"></div>\
-		<a class="ed-text-edit" style="cursor: pointer; float: right; margin-top: -16px;">[edit]</a>\
-		<textarea class="ed-text-input %(inp_class)s hide"></textarea>\
-		<div class="help hide"><br>Formatted as <a href="#markdown-reference"\
-		 	target="_blank">markdown</a></div>\
-		<button class="btn btn-info hide ed-text-save">Save</button>\
-		<a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\
-	</div>', args)).appendTo(me.parent);
-	
-	this.set_display = function(txt) {
-		var display_wrapper = me.$w.find('.ed-text-display');
-		display_wrapper.html(wn.markdown(txt));
-		display_wrapper.find("a").attr("target", "blank");
-		me.text = txt;
-	}
-	
-	this.set_display(me.text);
-	
-	if(me.height) me.$w.find('.ed-text-input').css('height', me.height);
-	if(me.width) me.$w.find('.ed-text-input').css('width', me.width);
-	
-	// edit
-	me.$w.find('.ed-text-edit').click(function() {
-		me.$w.find('.ed-text-input').val(me.text);
-		me.show_as_input();
-	})
-	
-	// save button - save the new text
-	me.$w.find('.ed-text-save').click(
-		function() {
-			var v = me.$w.find('.ed-text-input').val();
-			// check if text is written
-			if(!v) {
-				msgprint('Please write something!');
-				return;
-			}
-			var btn = this;
-			$(btn).set_working();
-			$c_page('utilities', 'question_view', 'update_item', {
-					dt: me.dt, dn: me.dn, fn: me.fieldname, text: v
-				}, 
-				function(r) {
-					$(btn).done_working();
-					if(r.exc) {msgprint(r.exc); return; }
-					me.set_display(v);
-					me.show_as_text();
-				});
-		}
-	)
-	
-
-	// cancel button
-	me.$w.find('.ed-text-cancel').click(function() {
-		me.show_as_text();		
-	})
-
-	this.show_as_text = function() {
-		me.$w.find('.ed-text-display, .ed-text-edit').toggle(true);
-		me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(false);
-	}
-
-	this.show_as_input = function() {
-		me.$w.find('.ed-text-display, .ed-text-edit').toggle(false);
-		me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(true);
-	}
-
-}
diff --git a/public/js/startup.css b/public/js/startup.css
index 88ebedd..1cc808d 100644
--- a/public/js/startup.css
+++ b/public/js/startup.css
@@ -4,7 +4,6 @@
 
 body {
 	font-family: Arial, Helvetica, sans-serif;
-	font-size: 13px;
 }
 
 span, div, td, input, textarea, button, select {
@@ -60,4 +59,11 @@
 .show-all-reports {
 	margin-top: 5px;
 	font-size: 11px;
+}
+
+/* toolbar */
+.toolbar-splash {
+	width: 32px; 
+	height: 32px; 
+	margin: -11px auto;
 }
\ No newline at end of file
diff --git a/public/js/startup.js b/public/js/startup.js
index 76f2c26..5e651c5 100644
--- a/public/js/startup.js
+++ b/public/js/startup.js
@@ -38,12 +38,6 @@
 		// set interval for updates
 		erpnext.startup.set_periodic_updates();
 
-		// border to the body
-		// ------------------
-		$('footer').html('<div class="web-footer erpnext-footer">\
-			<a href="#attributions">Attributions and License</a> | \
-			<a href="#latest-updates"><b>Latest Updates</b></a></div>');
-
 		// complete registration
 		if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete=='No')) { 
 			wn.require("app/js/complete_setup.js");
diff --git a/public/js/toolbar.js b/public/js/toolbar.js
index 03d7d0a..1d3d1e7 100644
--- a/public/js/toolbar.js
+++ b/public/js/toolbar.js
@@ -18,75 +18,26 @@
 wn.provide('erpnext.toolbar');
 
 erpnext.toolbar.setup = function() {
-	// modules 
-	erpnext.toolbar.add_modules();
-	
 	// profile
-	$('#toolbar-user').append('<li><a href="#Form/Profile/'+user+'">'
+	var $user = $('#toolbar-user');
+	$user.append('<li><a href="#Form/Profile/'+user+'">'
 		+wn._("My Settings")+'...</a></li>');
+	$user.append('<li class="divider"></li>');
+	$user.append('<li><a href="https://erpnext.com/manual" target="_blank">'
+		+wn._('Documentation')+'</a></li>')
+	$user.append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">'
+		+wn._('Forum')+'</a></li>')
+	$user.append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
+		'+wn._('Live Chat')+'</a></li>')
+	
 
 	$('.navbar .pull-right').append('\
 		<li><a href="#!messages" title="'+wn._('Unread Messages')
 			+'"><span class="navbar-new-comments"></span></a></li>');
 
-	// help
-	$('.navbar .pull-right').prepend('<li class="dropdown">\
-		<a class="dropdown-toggle" data-toggle="dropdown" href="#" \
-			onclick="return false;">'+wn._('Help')+'<b class="caret"></b></a>\
-		<ul class="dropdown-menu" id="toolbar-help">\
-		</ul></li>')
-
-	$('#toolbar-help').append('<li><a href="https://erpnext.com/manual" target="_blank">'
-		+wn._('Documentation')+'</a></li>')
-
-	$('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">'
-		+wn._('Forum')+'</a></li>')
-
-	$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
-		'+wn._('Live Chat')+'</a></li>')
-
 	erpnext.toolbar.set_new_comments();
 }
 
-erpnext.toolbar.add_modules = function() {
-	$('<li class="dropdown">\
-		<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
-			title="'+wn._("Modules")+'"\
-			onclick="return false;"><i class="icon-th"></i></a>\
-		<ul class="dropdown-menu modules">\
-		</ul>\
-		</li>').prependTo('.navbar .nav:first');
-	
-	var modules_list = wn.user.get_desktop_items().sort();
-	
-	var _get_list_item = function(m) {
-		args = {
-			module: m,
-			module_page: wn.modules[m].link,
-			module_label: wn._(wn.modules[m].label || m),
-			icon: wn.modules[m].icon
-		}
-		
-		return repl('<li><a href="#!%(module_page)s" \
-			data-module="%(module)s"><i class="%(icon)s" style="display: inline-block; \
-				width: 21px; margin-top: -2px; margin-left: -7px;"></i>\
-			%(module_label)s</a></li>', args);
-	}
-
-	// add to dropdown
-	$.each(modules_list,function(i, m) {
-		if(m!='Setup') {
-			$('.navbar .modules').append(_get_list_item(m));			
-		}
-	})
-	
-	// setup for system manager
-	if(user_roles.indexOf("System Manager")!=-1) {
-		$('.navbar .modules').append('<li class="divider">' + _get_list_item("Setup"));
-	}
-	
-}
-
 erpnext.toolbar.set_new_comments = function(new_comments) {
 	var navbar_nc = $('.navbar-new-comments');
 	if(cint(new_comments)) {
diff --git a/public/js/transaction.js b/public/js/transaction.js
new file mode 100644
index 0000000..b7df5b6
--- /dev/null
+++ b/public/js/transaction.js
@@ -0,0 +1,524 @@
+// 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/>.
+
+wn.provide("erpnext");
+
+erpnext.TransactionController = wn.ui.form.Controller.extend({
+	onload: function() {
+		if(this.frm.doc.__islocal) {
+			var me = this,
+				today = get_today(),
+				currency = wn.defaults.get_default("currency");
+			
+			$.each({
+				posting_date: today,
+				due_date: today,
+				transaction_date: today,
+				currency: currency,
+				price_list_currency: currency,
+				status: "Draft",
+				company: wn.defaults.get_default("company"),
+				fiscal_year: wn.defaults.get_default("fiscal_year"),
+				is_subcontracted: "No",
+				conversion_rate: 1.0,
+				plc_conversion_rate: 1.0
+			}, function(fieldname, value) {
+				if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname])
+					me.frm.set_value(fieldname, value);
+			});
+		}
+	},
+	
+	refresh: function() {
+		this.frm.clear_custom_buttons();
+		erpnext.hide_naming_series();
+		this.show_item_wise_taxes();
+		this.frm.fields_dict.currency ? this.currency() : this.set_dynamic_labels();
+	},
+	
+	onload_post_render: function() {
+		if(this.frm.doc.__islocal && this.frm.doc.company) {
+			var me = this;
+			this.frm.call({
+				doc: this.frm.doc,
+				method: "onload_post_render",
+				freeze: true,
+				callback: function(r) {
+					// remove this call when using client side mapper
+					me.set_default_values();
+					me.frm.refresh();
+				}
+			});
+		}
+	},
+	
+	validate: function() {
+		this.calculate_taxes_and_totals();
+	},
+	
+	company: function() {
+		if(this.frm.doc.company) {
+			var me = this;
+			var company_currency = this.get_company_currency();
+			$.each(["currency", "price_list_currency"], function(i, fieldname) {
+				if(!me.doc[fieldname]) {
+					me.frm.set_value(fieldname, company_currency);
+				}
+			});
+			this.price_list_currency();
+		}
+	},
+	
+	get_company_currency: function() {
+		return erpnext.get_currency(this.frm.doc.company);
+	},
+	
+	currency: function() {
+		this.price_list_currency();
+	},
+	
+	price_list_name: function(use_for) {
+		var me = this;
+		if(this.frm.doc.price_list_name) {
+			this.frm.call({
+				method: "setup.utils.get_price_list_currency",
+				args: {args: {
+					price_list_name: this.frm.doc.price_list_name,
+					use_for: use_for
+				}},
+				callback: function(r) {
+					if(!r.exc) {
+						me.price_list_currency();
+					}
+				}
+			});
+		}
+	},
+	
+	price_list_currency: function() {
+		// What TODO? should we make price list system non-mandatory?
+		this.frm.toggle_reqd("plc_conversion_rate",
+			!!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency));
+		
+		if(this.frm.doc.price_list_currency === this.get_company_currency()) {
+			this.frm.set_value("plc_conversion_rate", 1.0);
+		} else if(this.frm.doc.price_list_currency === this.frm.doc.currency) {
+			this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate);
+		}
+		this.set_dynamic_labels();
+	},
+	
+	plc_conversion_rate: function() {
+		this.price_list_currency();
+	},
+	
+	conversion_rate: function() {
+		this.price_list_currency();
+		this.calculate_taxes_and_totals();
+	},
+	
+	qty: function(doc, cdt, cdn) {
+		this.calculate_taxes_and_totals();
+	},
+	
+	tax_rate: function(doc, cdt, cdn) {
+		this.calculate_taxes_and_totals();
+	},
+	
+	row_id: function(doc, cdt, cdn) {
+		var tax = wn.model.get_doc(cdt, cdn);
+		try {
+			this.validate_on_previous_row(tax);
+			this.calculate_taxes_and_totals();
+		} catch(e) {
+			tax.row_id = null;
+			refresh_field("row_id", tax.name, tax.parentfield);
+			throw e;
+		}
+	},
+	
+	recalculate: function() {
+		this.calculate_taxes_and_totals();
+	},
+	
+	recalculate_values: function() {
+		this.calculate_taxes_and_totals();
+	},
+	
+	calculate_charges: function() {
+		this.calculate_taxes_and_totals();
+	},
+	
+	included_in_print_rate: function(doc, cdt, cdn) {
+		var tax = wn.model.get_doc(cdt, cdn);
+		try {
+			this.validate_on_previous_row(tax);
+			this.validate_inclusive_tax(tax);
+			this.calculate_taxes_and_totals();
+		} catch(e) {
+			tax.included_in_print_rate = 0;
+			refresh_field("included_in_print_rate", tax.name, tax.parentfield);
+			throw e;
+		}
+	},
+	
+	validate_on_previous_row: function(tax) {
+		// validate if a valid row id is mentioned in case of
+		// On Previous Row Amount and On Previous Row Total
+		if((["On Previous Row Amount", "On Previous Row Total"].indexOf(tax.charge_type) != -1) &&
+			(!tax.row_id || cint(tax.row_id) >= tax.idx)) {
+				var msg = repl(wn._("Row") + " # %(idx)s [%(doctype)s]: " +
+					wn._("Please specify a valid") + " %(row_id_label)s", {
+						idx: tax.idx,
+						doctype: tax.doctype,
+						row_id_label: wn.meta.get_label(tax.doctype, "row_id", tax.name)
+					});
+				msgprint(msg);
+				throw msg;
+			}
+	},
+	
+	validate_inclusive_tax: function(tax) {
+		if(!this.frm.tax_doclist) this.frm.tax_doclist = this.get_tax_doclist();
+		
+		var actual_type_error = function() {
+			var msg = repl(wn._("For row") + " # %(idx)s [%(doctype)s]: " + 
+				"%(charge_type_label)s = \"%(charge_type)s\" " +
+				wn._("cannot be included in Item's rate"), {
+					idx: tax.idx,
+					doctype: tax.doctype,
+					charge_type_label: wn.meta.get_label(tax.doctype, "charge_type", tax.name),
+					charge_type: tax.charge_type
+				});
+			msgprint(msg);
+			throw msg;
+		};
+		
+		var on_previous_row_error = function(row_range) {
+			var msg = repl(wn._("For row") + " # %(idx)s [%(doctype)s]: " + 
+				wn._("to be included in Item's rate, it is required that: ") + 
+				" [" + wn._("Row") + " # %(row_range)s] " + wn._("also be included in Item's rate"), {
+					idx: tax.idx,
+					doctype: tax.doctype,
+					charge_type_label: wn.meta.get_label(tax.doctype, "charge_type", tax.name),
+					charge_type: tax.charge_type,
+					inclusive_label: wn.meta.get_label(tax.doctype, "included_in_print_rate", tax.name),
+					row_range: row_range,
+				});
+			
+			msgprint(msg);
+			throw msg;
+		};
+		
+		if(cint(tax.included_in_print_rate)) {
+			if(tax.charge_type == "Actual") {
+				// inclusive tax cannot be of type Actual
+				actual_type_error();
+			} else if(tax.charge_type == "On Previous Row Amount" &&
+				!cint(this.frm.tax_doclist[tax.row_id - 1].included_in_print_rate)) {
+					// referred row should also be an inclusive tax
+					on_previous_row_error(tax.row_id);
+			} else if(tax.charge_type == "On Previous Row Total") {
+				var taxes_not_included = $.map(this.frm.tax_doclist.slice(0, tax.row_id), 
+					function(t) { return cint(t.included_in_print_rate) ? null : t; });
+				if(taxes_not_included.length > 0) {
+					// all rows above this tax should be inclusive
+					on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id);
+				}
+			}
+		}
+	},
+	
+	_load_item_tax_rate: function(item_tax_rate) {
+		return item_tax_rate ? JSON.parse(item_tax_rate) : {};
+	},
+	
+	_get_tax_rate: function(tax, item_tax_map) {
+		return (keys(item_tax_map).indexOf(tax.account_head) != -1) ?
+			flt(item_tax_map[tax.account_head], precision("rate", tax)) :
+			tax.rate;
+	},
+	
+	get_item_wise_taxes_html: function() {
+		var item_tax = {};
+		var tax_accounts = [];
+		var company_currency = this.get_company_currency();
+		
+		$.each(this.get_tax_doclist(), function(i, tax) {
+			var tax_amount_precision = precision("tax_amount", tax);
+			var tax_rate_precision = precision("rate", tax);
+			$.each(JSON.parse(tax.item_wise_tax_detail || '{}'), 
+				function(item_code, tax_data) {
+					if(!item_tax[item_code]) item_tax[item_code] = {};
+					if($.isArray(tax_data)) {
+						var tax_rate = tax_data[0] == null ? "" : (flt(tax_data[0], tax_rate_precision) + "%"),
+							tax_amount = format_currency(flt(tax_data[1], tax_amount_precision), company_currency);
+						
+						item_tax[item_code][tax.account_head] = [tax_rate, tax_amount];
+					} else {
+						item_tax[item_code][tax.account_head] = [flt(tax_data, tax_rate_precision) + "%", ""];
+					}
+				});
+			tax_accounts.push(tax.account_head);
+		});
+		
+		var headings = $.map([wn._("Item Name")].concat(tax_accounts), 
+			function(head) { return '<th style="min-width: 100px;">' + (head || "") + "</th>" }).join("\n");
+		
+		var rows = $.map(this.get_item_doclist(), function(item) {
+			var item_tax_record = item_tax[item.item_code || item.item_name];
+			if(!item_tax_record) { return null; }
+			return repl("<tr><td>%(item_name)s</td>%(taxes)s</tr>", {
+				item_name: item.item_name,
+				taxes: $.map(tax_accounts, function(head) {
+					return "<td>(" + item_tax_record[head][0] + ") " + item_tax_record[head][1] + "</td>"
+				}).join("\n")
+			});
+		}).join("\n");
+		
+		if(!rows) return "";
+		return '<div style="overflow-x: scroll;"><table class="table table-bordered table-hover">\
+			<thead><tr>' + headings + '</tr></thead> \
+			<tbody>' + rows + '</tbody> \
+		</table></div>';
+	},
+	
+	set_default_values: function() {
+		$.each(wn.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) {
+			var updated = wn.model.set_default_values(doc);
+			if(doc.parentfield) {
+				refresh_field(doc.parentfield);
+			} else {
+				refresh_field(updated);
+			}
+		});
+	},
+	
+	_validate_before_fetch: function(fieldname) {
+		var me = this;
+		if(!me.frm.doc[fieldname]) {
+			return (wn._("Please specify") + ": " + 
+				wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) + 
+				". " + wn._("It is needed to fetch Item Details."));
+		}
+		return null;
+	},
+	
+	validate_company_and_party: function(party_field) {
+		var me = this;
+		var valid = true;
+		var msg = "";
+		$.each(["company", party_field], function(i, fieldname) {
+			var msg_for_fieldname = me._validate_before_fetch(fieldname);
+			if(msg_for_fieldname) {
+				msgprint(msg_for_fieldname);
+				valid = false;
+			}
+		});
+		return valid;
+	},
+	
+	get_item_doclist: function() {
+		return wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name,
+			{parentfield: this.fname});
+	},
+	
+	get_tax_doclist: function() {
+		return wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name,
+			{parentfield: this.other_fname});
+	},
+	
+	validate_conversion_rate: function() {
+		this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate"));
+		var conversion_rate_label = wn.meta.get_label(this.frm.doc.doctype, "conversion_rate", 
+			this.frm.doc.name);
+		
+		if(this.frm.doc.conversion_rate == 0) {
+			wn.throw(wn._(conversion_rate_label) + " " + wn._("cannot be 0"));
+		}
+		
+		var company_currency = this.get_company_currency();
+		var valid_conversion_rate = this.frm.doc.conversion_rate ?
+			((this.frm.doc.currency == company_currency && this.frm.doc.conversion_rate == 1.0) ||
+			(this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) :
+			false;
+		
+		if(!valid_conversion_rate) {
+			wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + 
+				" 1 " + this.frm.doc.currency + " = [?] " + company_currency);
+		}
+	},
+	
+	calculate_taxes_and_totals: function() {
+		this.validate_conversion_rate();
+		this.frm.item_doclist = this.get_item_doclist();
+		this.frm.tax_doclist = this.get_tax_doclist();
+		
+		this.calculate_item_values();
+		this.initialize_taxes();
+		this.determine_exclusive_rate && this.determine_exclusive_rate();
+		this.calculate_net_total();
+		this.calculate_taxes();
+		this.calculate_totals();
+		this._cleanup();
+		
+		this.show_item_wise_taxes();
+	},
+	
+	initialize_taxes: function() {
+		var me = this;
+		$.each(this.frm.tax_doclist, function(i, tax) {
+			tax.item_wise_tax_detail = {};
+			$.each(["tax_amount", "total",
+				"tax_amount_for_current_item", "grand_total_for_current_item",
+				"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"],
+				function(i, fieldname) { tax[fieldname] = 0.0 });
+			
+			me.validate_on_previous_row(tax);
+			me.validate_inclusive_tax(tax);
+			wn.model.round_floats_in(tax);
+		});
+	},
+	
+	calculate_taxes: function() {
+		var me = this;
+		
+		$.each(this.frm.item_doclist, function(n, item) {
+			var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
+			
+			$.each(me.frm.tax_doclist, function(i, tax) {
+				// tax_amount represents the amount of tax for the current step
+				var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map);
+
+				me.set_item_tax_amount && me.set_item_tax_amount(item, tax, current_tax_amount);
+				
+				// case when net total is 0 but there is an actual type charge
+				// in this case add the actual amount to tax.tax_amount
+				// and tax.grand_total_for_current_item for the first such iteration
+				if(tax.charge_type == "Actual" && 
+					!(current_tax_amount || me.frm.doc.net_total || tax.tax_amount)) {
+						var zero_net_total_adjustment = flt(tax.rate, precision("tax_amount", tax));
+						current_tax_amount += zero_net_total_adjustment;
+					}
+				
+				// store tax_amount for current item as it will be used for
+				// charge type = 'On Previous Row Amount'
+				tax.tax_amount_for_current_item = current_tax_amount;
+				
+				// accumulate tax amount into tax.tax_amount
+				tax.tax_amount += current_tax_amount;
+				
+				// for buying
+				if(tax.category) {
+					// if just for valuation, do not add the tax amount in total
+					// hence, setting it as 0 for further steps
+					current_tax_amount = (tax.category == "Valuation") ? 0.0 : current_tax_amount;
+					
+					current_tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0;
+				}
+				
+				// Calculate tax.total viz. grand total till that step
+				// note: grand_total_for_current_item contains the contribution of 
+				// item's amount, previously applied tax and the current tax on that item
+				if(i==0) {
+					tax.grand_total_for_current_item = flt(item.amount + current_tax_amount,
+						precision("total", tax));
+				} else {
+					tax.grand_total_for_current_item = 
+						flt(me.frm.tax_doclist[i-1].grand_total_for_current_item + current_tax_amount,
+							precision("total", tax));
+				}
+				
+				// in tax.total, accumulate grand total for each item
+				tax.total += tax.grand_total_for_current_item;
+			});
+		});
+	},
+	
+	get_current_tax_amount: function(item, tax, item_tax_map) {
+		var tax_rate = this._get_tax_rate(tax, item_tax_map);
+		var current_tax_amount = 0.0;
+		
+		if(tax.charge_type == "Actual") {
+			// distribute the tax amount proportionally to each item row
+			var actual = flt(tax.rate, precision("tax_amount", tax));
+			current_tax_amount = this.frm.doc.net_total ?
+				((item.amount / this.frm.doc.net_total) * actual) :
+				0.0;
+			
+		} else if(tax.charge_type == "On Net Total") {
+			current_tax_amount = (tax_rate / 100.0) * item.amount;
+			
+		} else if(tax.charge_type == "On Previous Row Amount") {
+			current_tax_amount = (tax_rate / 100.0) *
+				this.frm.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item;
+			
+		} else if(tax.charge_type == "On Previous Row Total") {
+			current_tax_amount = (tax_rate / 100.0) *
+				this.frm.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item;
+			
+		}
+		
+		current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
+		
+		// store tax breakup for each item
+		tax.item_wise_tax_detail[item.item_code || item.item_name] = [tax_rate, current_tax_amount];
+		
+		return current_tax_amount;
+	},
+	
+	_cleanup: function() {
+		$.each(this.frm.tax_doclist, function(i, tax) {
+			$.each(["tax_amount_for_current_item", "grand_total_for_current_item",
+				"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"], 
+				function(i, fieldname) { delete tax[fieldname]; });
+			
+			tax.item_wise_tax_detail = JSON.stringify(tax.item_wise_tax_detail);
+		});
+	},
+
+	calculate_total_advance: function(parenttype, advance_parentfield) {
+		if(this.frm.doc.doctype == parenttype && this.frm.doc.docstatus < 2) {
+			var advance_doclist = wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, 
+				{parentfield: advance_parentfield});
+			this.frm.doc.total_advance = flt(wn.utils.sum(
+				$.map(advance_doclist, function(adv) { return adv.allocated_amount })
+			), precision("total_advance"));
+			
+			this.calculate_outstanding_amount();
+		}
+	},
+	
+	_set_in_company_currency: function(item, print_field, base_field) {
+		// set values in base currency
+		item[base_field] = flt(item[print_field] * this.frm.doc.conversion_rate,
+			precision(base_field, item));
+	},
+	
+	get_terms: function() {
+		var me = this;
+		if(this.frm.doc.tc_name) {
+			this.frm.call({
+				method: "webnotes.client.get_value",
+				args: {
+					doctype: "Terms and Conditions",
+					fieldname: "terms",
+					filters: { name: this.frm.doc.tc_name },
+				},
+			});
+		}
+	},
+});
\ No newline at end of file
diff --git a/public/js/utils.js b/public/js/utils.js
index 4df9555..0284670 100644
--- a/public/js/utils.js
+++ b/public/js/utils.js
@@ -13,8 +13,7 @@
 // 
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-wn.provide('erpnext.utils');
+wn.provide("erpnext.utils");
 
 erpnext.get_currency = function(company) {
 	if(!company && cur_frm)
@@ -23,4 +22,4 @@
 		return wn.model.get(":Company", company).default_currency || wn.boot.sysdefaults.currency;
 	else
 		return wn.boot.sysdefaults.currency;
-}
\ No newline at end of file
+}
diff --git a/selling/Print Format/Quotation Classic/Quotation Classic.txt b/selling/Print Format/Quotation Classic/Quotation Classic.txt
index 03a056b..0a63309 100644
--- a/selling/Print Format/Quotation Classic/Quotation Classic.txt
+++ b/selling/Print Format/Quotation Classic/Quotation Classic.txt
@@ -1,15 +1,15 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-04-02 18:14:21", 
+  "modified": "2013-05-28 17:17:05", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Quotation", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td>\n\t\t\t\t\t<script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script>\n\t\t\t</td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td>\n\t\t\t\t\t<script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script>\n\t\t\t</td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
   "print_format_type": "Client", 
diff --git a/selling/Print Format/Quotation Modern/Quotation Modern.txt b/selling/Print Format/Quotation Modern/Quotation Modern.txt
index b7a29bf..0f841aa 100644
--- a/selling/Print Format/Quotation Modern/Quotation Modern.txt
+++ b/selling/Print Format/Quotation Modern/Quotation Modern.txt
@@ -1,15 +1,15 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-04-02 18:14:05", 
+  "modified": "2013-05-28 17:18:02", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Quotation", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Quotation No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Quotation No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
   "print_format_type": "Client", 
diff --git a/selling/Print Format/Quotation Spartan/Quotation Spartan.txt b/selling/Print Format/Quotation Spartan/Quotation Spartan.txt
index 3fbf629..d2bfcd0 100644
--- a/selling/Print Format/Quotation Spartan/Quotation Spartan.txt
+++ b/selling/Print Format/Quotation Spartan/Quotation Spartan.txt
@@ -1,15 +1,15 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-04-02 18:13:47", 
+  "modified": "2013-05-28 17:18:38", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Quotation", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Quotation',\n\t\t\t\tdoc.name,\n\t\t\t\t'quotation_details',\n\t\t\t\t'Quotation Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'export_rate', 'export_amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Quotation') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Quotation Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
   "print_format_type": "Client", 
diff --git a/selling/Print Format/Sales Order Classic/Sales Order Classic.txt b/selling/Print Format/Sales Order Classic/Sales Order Classic.txt
index 9415035..28e3af0 100644
--- a/selling/Print Format/Sales Order Classic/Sales Order Classic.txt
+++ b/selling/Print Format/Sales Order Classic/Sales Order Classic.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:18:37", 
+  "modified": "2013-05-28 17:20:59", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Order", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/selling/Print Format/Sales Order Modern/Sales Order Modern.txt b/selling/Print Format/Sales Order Modern/Sales Order Modern.txt
index f222d5b..5237068 100644
--- a/selling/Print Format/Sales Order Modern/Sales Order Modern.txt
+++ b/selling/Print Format/Sales Order Modern/Sales Order Modern.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:18:20", 
+  "modified": "2013-05-28 17:21:05", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Order", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt b/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt
index 3db5f05..f1f5d92 100644
--- a/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt
+++ b/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:19:08", 
+  "modified": "2013-05-28 17:20:50", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Sales Order", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Sales Order',\n\t\t\t\tdoc.name,\n\t\t\t\t'sales_order_details',\n\t\t\t\t'Sales Order Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '20%', '37%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Sales Order') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Sales Order Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Delivery Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.delivery_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Selling", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py
index ea20d51..9b7344b 100644
--- a/selling/doctype/installation_note/installation_note.py
+++ b/selling/doctype/installation_note/installation_note.py
@@ -21,10 +21,7 @@
 from webnotes.model.bean import getlist
 from webnotes.model.code import get_obj
 from webnotes import msgprint
-from stock.utils import get_valid_serial_nos
-
-sql = webnotes.conn.sql
-	
+from stock.utils import get_valid_serial_nos	
 
 from utilities.transaction_base import TransactionBase
 
@@ -34,6 +31,19 @@
 		self.doclist = doclist
 		self.tname = 'Installation Note Item'
 		self.fname = 'installed_item_details'
+		self.status_updater = [{
+			'source_dt': 'Installation Note Item',
+			'target_dt': 'Delivery Note Item',
+			'target_field': 'installed_qty',
+			'target_ref_field': 'qty',
+			'join_field': 'prevdoc_detail_docname',
+			'target_parent_dt': 'Delivery Note',
+			'target_parent_field': 'per_installed',
+			'source_field': 'qty',
+			'percent_join_field': 'prevdoc_docname',
+			'status_field': 'installation_status',
+			'keyword': 'Installed'
+		}]
 
 	def validate(self):
 		self.validate_fiscal_year()
@@ -45,153 +55,114 @@
 		self.validate_mandatory()
 		self.validate_reference_value()
  
-	
-	#fetch delivery note details
-	#====================================
 	def pull_delivery_note_details(self):
 		self.validate_prev_docname()
-		self.doclist = get_obj('DocType Mapper', 'Delivery Note-Installation Note').dt_map('Delivery Note', 'Installation Note', self.doc.delivery_note_no, self.doc, self.doclist, "[['Delivery Note', 'Installation Note'],['Delivery Note Item', 'Installation Note Item']]")
+		self.doclist = get_obj('DocType Mapper', 'Delivery Note-Installation Note').dt_map(
+			'Delivery Note', 'Installation Note', self.doc.delivery_note_no, 
+			self.doc, self.doclist, "[['Delivery Note', 'Installation Note'], \
+			['Delivery Note Item', 'Installation Note Item']]")
 	
-	# Validates that Delivery Note is not pulled twice 
-	#============================================
 	def validate_prev_docname(self):
 		for d in getlist(self.doclist, 'installed_item_details'): 
 			if self.doc.delivery_note_no == d.prevdoc_docname:
-				msgprint(cstr(self.doc.delivery_note_no) + " delivery note details have already been pulled. ")
-				raise Exception, "Validation Error. "
-	
-	#Fiscal Year Validation
-	#================================
+				msgprint(cstr(self.doc.delivery_note_no) + 
+					" delivery note details have already been pulled", raise_exception=1)
+
 	def validate_fiscal_year(self):
-		get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.inst_date,'Installation Date')
-	
-	#	Validate Mandatory 
-	#===============================
+		get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year, self.doc.inst_date, 
+			'Installation Date')
+
 	def validate_mandatory(self):
-		# Amendment Date
 		if self.doc.amended_from and not self.doc.amendment_date:
 			msgprint("Please Enter Amendment Date")
 			raise Exception, "Validation Error. "
-	
-	# Validate values with reference document
-	#----------------------------------------
+
 	def validate_reference_value(self):
-		get_obj('DocType Mapper', 'Delivery Note-Installation Note', with_children = 1).validate_reference_value(self, self.doc.name)
+		mapper = get_obj('DocType Mapper', 'Delivery Note-Installation Note', with_children = 1)
+		mapper.validate_reference_value(self, self.doc.name)
 	
-	#check if serial no added
-	#-----------------------------
-	def is_serial_no_added(self,item_code,serial_no):
-		ar_required = sql("select has_serial_no from tabItem where name = '%s'" % item_code)
-		ar_required = ar_required and ar_required[0][0] or ''
+	def is_serial_no_added(self, item_code, serial_no):
+		ar_required = webnotes.conn.get_value("Item", item_code, "has_serial_no")
 		if ar_required == 'Yes' and not serial_no:
-			msgprint("Serial No is mandatory for item: "+ item_code)
-			raise Exception
+			msgprint("Serial No is mandatory for item: " + item_code, raise_exception=1)
 		elif ar_required != 'Yes' and cstr(serial_no).strip():
-			msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :"+item_code)
-			raise Exception
+			msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + 
+				item_code, raise_exception=1)
 	
-	#check if serial no exist in system
-	#-------------------------------------
 	def is_serial_no_exist(self, item_code, serial_no):
 		for x in serial_no:
-			chk = sql("select name from `tabSerial No` where name =%s", x)
-			if not chk:
-				msgprint("Serial No "+x+" does not exist in the system")
-				raise Exception
+			if not webnotes.conn.exists("Serial No", x):
+				msgprint("Serial No " + x + " does not exist in the system", raise_exception=1)
 	
-	#check if serial no already installed
-	#------------------------------------------
 	def is_serial_no_installed(self,cur_s_no,item_code):
 		for x in cur_s_no:
-			status = sql("select status from `tabSerial No` where name = %s", x)
+			status = webnotes.conn.sql("select status from `tabSerial No` where name = %s", x)
 			status = status and status[0][0] or ''
 			
 			if status == 'Installed':
-				msgprint("Item "+item_code+" with serial no. "+x+" already installed")
-				raise Exception, "Validation Error."
+				msgprint("Item "+item_code+" with serial no. " + x + " already installed", 
+					raise_exception=1)
 	
-	#get list of serial no from previous_doc
-	#----------------------------------------------
-	def get_prevdoc_serial_no(self, prevdoc_detail_docname, prevdoc_docname):
-		res = sql("select serial_no from `tabDelivery Note Item` where name = '%s' and parent ='%s'" % (prevdoc_detail_docname, prevdoc_docname))
-		return get_valid_serial_nos(res[0][0])
+	def get_prevdoc_serial_no(self, prevdoc_detail_docname):
+		serial_nos = webnotes.conn.get_value("Delivery Note Item", 
+			prevdoc_detail_docname, "serial_no")
+		return get_valid_serial_nos(serial_nos)
 		
-	#check if all serial nos from current record exist in resp delivery note
-	#---------------------------------------------------------------------------------
 	def is_serial_no_match(self, cur_s_no, prevdoc_s_no, prevdoc_docname):
-		for x in cur_s_no:
-			if not(x in prevdoc_s_no):
-				msgprint("Serial No. "+x+" not present in the Delivery Note "+prevdoc_docname, raise_exception = 1)
-				raise Exception, "Validation Error."
-	
-	#validate serial number
-	#----------------------------------------
+		for sr in cur_s_no:
+			if sr not in prevdoc_s_no:
+				msgprint("Serial No. " + sr + " is not matching with the Delivery Note " + 
+					prevdoc_docname, raise_exception = 1)
+
 	def validate_serial_no(self):
 		cur_s_no, prevdoc_s_no, sr_list = [], [], []
 		for d in getlist(self.doclist, 'installed_item_details'):
 			self.is_serial_no_added(d.item_code, d.serial_no)
-			
 			if d.serial_no:
-
 				sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code)
 				self.is_serial_no_exist(d.item_code, sr_list)
 				
-				prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname, d.prevdoc_docname)
+				prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname)
 				if prevdoc_s_no:
 					self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname)
 				
 				self.is_serial_no_installed(sr_list, d.item_code)
 		return sr_list
-	
-	#validate installation date
-	#-------------------------------
+
 	def validate_installation_date(self):
 		for d in getlist(self.doclist, 'installed_item_details'):
 			if d.prevdoc_docname:
-				d_date = sql("select posting_date from `tabDelivery Note` where name=%s", d.prevdoc_docname)
-				d_date = d_date and d_date[0][0] or ''
-				
+				d_date = webnotes.conn.get_value("Delivery Note", d.prevdoc_docname, "posting_date")				
 				if d_date > getdate(self.doc.inst_date):
-					msgprint("Installation Date can not be before Delivery Date "+cstr(d_date)+" for item "+d.item_code)
-					raise Exception
+					msgprint("Installation Date can not be before Delivery Date " + cstr(d_date) + 
+						" for item "+d.item_code, raise_exception=1)
 	
 	def check_item_table(self):
 		if not(getlist(self.doclist, 'installed_item_details')):
-			msgprint("Please fetch items from Delivery Note selected")
-			raise Exception
+			msgprint("Please fetch items from Delivery Note selected", raise_exception=1)
 	
 	def on_update(self):
+		get_obj("Stock Ledger").scrub_serial_nos(self, 'installed_item_details')
 		webnotes.conn.set(self.doc, 'status', 'Draft')
 	
 	def on_submit(self):
 		valid_lst = []
 		valid_lst = self.validate_serial_no()
 		
-		get_obj("Sales Common").update_prevdoc_detail(1,self)
-		
 		for x in valid_lst:
-			wp = sql("select warranty_period from `tabSerial No` where name = '%s'"% x)
-			wp = wp and wp[0][0] or 0
-			if wp:
-				sql("update `tabSerial No` set maintenance_status = 'Under Warranty' where name = '%s'" % x)
-			
-			sql("update `tabSerial No` set status = 'Installed' where name = '%s'" % x)
-		
-		webnotes.conn.set(self.doc, 'status', 'Submitted')
+			if webnotes.conn.get_value("Serial No", x, "warranty_period"):
+				webnotes.conn.set_value("Serial No", x, "maintenance_status", "Under Warranty")
+			webnotes.conn.set_value("Serial No", x, "status", "Installed")
 
+		self.update_prevdoc_status()
+		webnotes.conn.set(self.doc, 'status', 'Submitted')
 	
 	def on_cancel(self):
-		cur_s_no = []
-		sales_com_obj = get_obj(dt = 'Sales Common')
-		sales_com_obj.update_prevdoc_detail(0,self)
-		
 		for d in getlist(self.doclist, 'installed_item_details'):
 			if d.serial_no:
-				#get current list of serial no
-				cur_serial_no = d.serial_no.replace(' ', '')
-				cur_s_no = cur_serial_no.split(',')
-		
-		for x in cur_s_no:
-			sql("update `tabSerial No` set status = 'Delivered' where name = '%s'" % x)
-			
+				d.serial_no = d.serial_no.replace(",", "\n")
+				for sr_no in d.serial_no.split("\n"):
+					webnotes.conn.set_value("Serial No", sr_no, "status", "Delivered")
+
+		self.update_prevdoc_status()
 		webnotes.conn.set(self.doc, 'status', 'Cancelled')
diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js
index 118b4c7..c94aafa 100644
--- a/selling/doctype/lead/lead.js
+++ b/selling/doctype/lead/lead.js
@@ -50,7 +50,7 @@
 	}
 
 	if(in_list(user_roles,'System Manager')) {
-		cur_frm.page_layout.footer.help_area.innerHTML = '<hr>\
+		cur_frm.footer.help_area.innerHTML = '<hr>\
 			<p><a href="#Form/Sales Email Settings">Sales Email Settings</a><br>\
 			<span class="help">Automatically extract Leads from a mail box e.g. "sales@example.com"</span></p>';
 	}
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index 078baf1..4276193 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -21,109 +21,52 @@
 cur_frm.cscript.sales_team_fname = "sales_team";
 
 // =====================================================================================
-wn.require('app/selling/doctype/sales_common/sales_common.js');
 wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/selling/doctype/sales_common/sales_common.js');
 
-// ONLOAD
-// ===================================================================================
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-	cur_frm.cscript.manage_rounded_total();
-	if(!doc.quotation_to) 
-		hide_field(['customer','customer_address','contact_person','customer_name','lead', 
-	 		'address_display', 'contact_display', 'contact_mobile', 'contact_email', 
-			'territory', 'customer_group']);
-	if(!doc.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
-	if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
-	if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
-	if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1.00'});
-	if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
-	if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
-
-	if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
-	if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
-	
-	if(doc.quotation_to) {
-		if(doc.quotation_to == 'Customer') {
-			hide_field('lead');
+erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
+	refresh: function(doc, dt, dn) {
+		this._super();
+		
+		if(doc.docstatus == 1 && doc.status!='Order Lost') {
+			cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
+			cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
+			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
 		}
-		else if (doc.quotation_to == 'Lead') {
-			hide_field(['customer', 'customer_address', 'contact_person', 'customer_group']);
+
+		if (!doc.__islocal) {
+			cur_frm.communication_view = new wn.views.CommunicationList({
+				list: wn.model.get("Communication", {"quotation": doc.name}),
+				parent: cur_frm.fields_dict.communication_html.wrapper,
+				doc: doc,
+				recipients: doc.contact_email
+			});		
 		}
-	}
-}
-
-cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	var callback = function(doc, dt, dn) {
-		// defined in sales_common.js
-		cur_frm.cscript.update_item_details(doc, dt, dn);
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
-}
-
-// hide - unhide fields based on lead or customer..
-// =======================================================================================================================
-cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
-	hide_field(['lead', 'customer','customer_address','contact_person',
-		'customer_name','address_display','contact_display','contact_mobile','contact_email',
-		'territory','customer_group']);
-	if(doc.quotation_to == 'Lead') unhide_field(['lead']);
-	else if(doc.quotation_to == 'Customer') unhide_field(['customer']);
+		
+		this.quotation_to();
+	},
 	
-	doc.lead = doc.customer = doc.customer_name = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
-}
-
-
-
-//================ hide - unhide fields on basis of quotation to either lead or customer ===============================
-cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
-	cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
-}
-
-
-// REFRESH
-// ===================================================================================
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-	cur_frm.clear_custom_buttons();
-
-	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
-
-
-	if(doc.docstatus == 1 && doc.status!='Order Lost') {
-		cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
-		cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
-		cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
-	}
-
-	erpnext.hide_naming_series();
-	cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
+	quotation_to: function() {
+		this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
+		this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
+	},
 	
-	if (!doc.__islocal) {
-		cur_frm.communication_view = new wn.views.CommunicationList({
-			list: wn.model.get("Communication", {"quotation": doc.name}),
-			parent: cur_frm.fields_dict.communication_html.wrapper,
-			doc: doc,
-			recipients: doc.contact_email
-		});		
-	}
-}
+	validate_company_and_party: function(party_field) {
+		if(this.frm.doc.quotation_to == "Lead") {
+			return true;
+		} else if(!this.frm.doc.quotation_to) {
+			msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
+				"quotation_to", this.frm.doc.name)));
+			return false;
+		} else {
+			return this._super(party_field);
+		}
+	},
+});
 
-
-//customer
-cur_frm.cscript.customer = function(doc,dt,dn) {
-	var pl = doc.price_list_name;
-	var callback = function(r,rt) {
-		var doc = locals[cur_frm.doctype][cur_frm.docname];
-		cur_frm.refresh();		
-		if (pl != doc.price_list_name) cur_frm.cscript.price_list_name(doc, dt, dn); 
-	}
-
-	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 
-		'get_default_customer_address', '', callback);
-	if(doc.customer) unhide_field(['customer_address','contact_person','territory', 'customer_group']);
-	cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
-		console.log(doc.customer_group);
-}
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, new erpnext.selling.QuotationController({frm: cur_frm}));
 
 cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
 	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({
@@ -136,8 +79,6 @@
 cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
 
 cur_frm.cscript.lead = function(doc, cdt, cdn) {
-	cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
-	
 	if(doc.lead) {
 		get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
 		unhide_field('territory');
@@ -248,31 +189,6 @@
 	qtn_lost_dialog.show();
 }
 
-//===================== Quotation to validation - either customer or lead mandatory ====================
-cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
-
-	if(doc.quotation_to == 'Lead'){
-
-		if(!doc.lead){
-			alert("Lead is mandatory.");
-			validated = false;
-		}
-	}
-	else if(doc.quotation_to == 'Customer'){
-		if(!doc.customer){
-			alert("Customer is mandatory.");
-			validated = false;
-		}
-	}
-}
-
-//===================validation function =================================
-
-cur_frm.cscript.validate = function(doc,cdt,cdn){
-	cur_frm.cscript.recalculate_values(doc, cdt, cdn);
-	cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
-}
-
 //================ Last Quoted Price and Last Sold Price suggestion ======================
 cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
 	var d = locals[cdt][cdn];
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index c154a6a..1151e63 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -95,23 +95,6 @@
 	def get_rate(self,arg):
 		return get_obj('Sales Common').get_rate(arg)
 
-	# Load Default Charges
-	# ----------------------------------------------------------
-	def load_default_taxes(self):
-		self.doclist = get_obj('Sales Common').load_default_taxes(self)
-
-	# Pull details from other charges master (Get Sales Taxes and Charges Master)
-	# ----------------------------------------------------------
-	def get_other_charges(self):
-		self.doclist = get_obj('Sales Common').get_other_charges(self)	
-	
-		 
-# GET TERMS AND CONDITIONS
-# ====================================================================================
-	def get_tc_details(self):
-		return get_obj('Sales Common').get_tc_details(self)
-
-		
 # VALIDATE
 # ==============================================================================================
 	
@@ -142,6 +125,8 @@
 	#do not allow sales item in maintenance quotation and service item in sales quotation
 	#-----------------------------------------------------------------------------------------------
 	def validate_order_type(self):
+		super(DocType, self).validate_order_type()
+		
 		if self.doc.order_type in ['Maintenance', 'Service']:
 			for d in getlist(self.doclist, 'quotation_details'):
 				is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index 4115be8..1017221 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-05-22 12:10:46", 
+  "creation": "2013-05-24 19:29:08", 
   "docstatus": 0, 
-  "modified": "2013-05-22 16:54:07", 
+  "modified": "2013-06-05 19:07:51", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -78,6 +78,7 @@
   "reqd": 1
  }, 
  {
+  "depends_on": "eval:doc.quotation_to == \"Customer\"", 
   "doctype": "DocField", 
   "fieldname": "customer", 
   "fieldtype": "Link", 
@@ -92,6 +93,7 @@
   "search_index": 1
  }, 
  {
+  "depends_on": "eval:doc.quotation_to == \"Lead\"", 
   "doctype": "DocField", 
   "fieldname": "lead", 
   "fieldtype": "Link", 
@@ -105,19 +107,21 @@
   "read_only": 0
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "customer_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Customer Name", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_filter": 0, 
   "label": "Address", 
   "oldfieldname": "customer_address", 
@@ -128,29 +132,32 @@
   "search_index": 0
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_filter": 0, 
   "label": "Contact", 
   "print_hide": 0, 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "print_hide": 0, 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -164,6 +171,34 @@
   "width": "50%"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "amended_from", 
+  "fieldtype": "Data", 
+  "label": "Amended From", 
+  "no_copy": 1, 
+  "oldfieldname": "amended_from", 
+  "oldfieldtype": "Data", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "width": "150px"
+ }, 
+ {
+  "description": "Select the relevant company name if you have multiple companies.", 
+  "doctype": "DocField", 
+  "fieldname": "company", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Company", 
+  "oldfieldname": "company", 
+  "oldfieldtype": "Link", 
+  "options": "Company", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 0, 
+  "width": "150px"
+ }, 
+ {
   "default": "Today", 
   "description": "The date at which current entry is made in system.", 
   "doctype": "DocField", 
@@ -196,107 +231,49 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "items", 
-  "fieldtype": "Section Break", 
-  "label": "Items", 
-  "oldfieldtype": "Section Break", 
-  "print_hide": 0, 
-  "read_only": 0, 
-  "search_index": 0
- }, 
- {
-  "allow_on_submit": 1, 
-  "doctype": "DocField", 
-  "fieldname": "quotation_details", 
-  "fieldtype": "Table", 
-  "label": "Quotation Items", 
-  "oldfieldname": "quotation_details", 
-  "oldfieldtype": "Table", 
-  "options": "Quotation Item", 
-  "read_only": 0, 
-  "width": "40px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "sec_break23", 
-  "fieldtype": "Section Break", 
-  "options": "Simple", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break34", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "net_total", 
-  "fieldtype": "Currency", 
-  "label": "Net Total*", 
-  "no_copy": 0, 
-  "oldfieldname": "net_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "100px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "recalculate_values", 
-  "fieldtype": "Button", 
-  "label": "Re-Calculate Values", 
-  "oldfieldtype": "Button", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break35", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "description": "To create Quotation against Opportunity, Select Opportunity No. and click on 'Pull Opportunity Details' ", 
-  "doctype": "DocField", 
-  "fieldname": "enq_no", 
-  "fieldtype": "Link", 
-  "hidden": 0, 
-  "in_filter": 1, 
-  "label": "Opportunity No", 
-  "no_copy": 0, 
-  "oldfieldname": "enq_no", 
-  "oldfieldtype": "Link", 
-  "options": "Opportunity", 
-  "print_hide": 0, 
-  "read_only": 0, 
-  "report_hide": 0, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "pull_enquiry_detail", 
-  "fieldtype": "Button", 
-  "hidden": 0, 
-  "label": "Pull Opportunity Detail", 
-  "no_copy": 0, 
-  "oldfieldtype": "Button", 
-  "print_hide": 0, 
-  "read_only": 0, 
-  "report_hide": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "section_break0", 
   "fieldtype": "Section Break", 
   "label": "Price List and Currency", 
   "read_only": 0
  }, 
  {
+  "description": "Customer's currency - If you want to select a currency that is not the default currency, then you must also specify the Currency Conversion Rate.", 
+  "doctype": "DocField", 
+  "fieldname": "currency", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Currency", 
+  "oldfieldname": "currency", 
+  "oldfieldtype": "Select", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 0, 
+  "width": "100px"
+ }, 
+ {
+  "default": "1.00", 
+  "description": "Rate at which customer's currency is converted to company's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Conversion Rate", 
+  "oldfieldname": "conversion_rate", 
+  "oldfieldtype": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "width": "100px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break2", 
+  "fieldtype": "Column Break", 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
   "description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.", 
   "doctype": "DocField", 
   "fieldname": "price_list_name", 
@@ -335,40 +312,100 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break2", 
+  "fieldname": "items", 
+  "fieldtype": "Section Break", 
+  "label": "Items", 
+  "oldfieldtype": "Section Break", 
+  "print_hide": 0, 
+  "read_only": 0, 
+  "search_index": 0
+ }, 
+ {
+  "allow_on_submit": 1, 
+  "doctype": "DocField", 
+  "fieldname": "quotation_details", 
+  "fieldtype": "Table", 
+  "label": "Quotation Items", 
+  "oldfieldname": "quotation_details", 
+  "oldfieldtype": "Table", 
+  "options": "Quotation Item", 
+  "read_only": 0, 
+  "reqd": 1, 
+  "width": "40px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "sec_break23", 
+  "fieldtype": "Section Break", 
+  "options": "Simple", 
+  "read_only": 0
+ }, 
+ {
+  "description": "To create Quotation against Opportunity, Select Opportunity No. and click on 'Pull Opportunity Details' ", 
+  "doctype": "DocField", 
+  "fieldname": "enq_no", 
+  "fieldtype": "Link", 
+  "hidden": 0, 
+  "in_filter": 1, 
+  "label": "Opportunity No", 
+  "no_copy": 0, 
+  "oldfieldname": "enq_no", 
+  "oldfieldtype": "Link", 
+  "options": "Opportunity", 
+  "print_hide": 0, 
+  "read_only": 0, 
+  "report_hide": 0, 
+  "search_index": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "pull_enquiry_detail", 
+  "fieldtype": "Button", 
+  "hidden": 0, 
+  "label": "Pull Opportunity Detail", 
+  "no_copy": 0, 
+  "oldfieldtype": "Button", 
+  "print_hide": 0, 
+  "read_only": 0, 
+  "report_hide": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "col_break34", 
   "fieldtype": "Column Break", 
   "read_only": 0, 
   "width": "50%"
  }, 
  {
-  "description": "Customer's currency - If you want to select a currency that is not the default currency, then you must also specify the Currency Conversion Rate.", 
   "doctype": "DocField", 
-  "fieldname": "currency", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Currency", 
-  "oldfieldname": "currency", 
-  "oldfieldtype": "Select", 
-  "options": "Currency", 
+  "fieldname": "net_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Net Total (Export)", 
+  "options": "currency", 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "net_total", 
+  "fieldtype": "Currency", 
+  "label": "Net Total*", 
+  "no_copy": 0, 
+  "oldfieldname": "net_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
   "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 0, 
+  "read_only": 1, 
+  "reqd": 0, 
   "width": "100px"
  }, 
  {
-  "default": "1.00", 
-  "description": "Rate at which customer's currency is converted to company's base currency", 
   "doctype": "DocField", 
-  "fieldname": "conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Conversion Rate", 
-  "oldfieldname": "conversion_rate", 
-  "oldfieldtype": "Currency", 
+  "fieldname": "recalculate_values", 
+  "fieldtype": "Button", 
+  "label": "Re-Calculate Values", 
+  "oldfieldtype": "Button", 
   "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1, 
-  "width": "100px"
+  "read_only": 0
  }, 
  {
   "doctype": "DocField", 
@@ -392,6 +429,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_34", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_charges", 
   "fieldtype": "Button", 
   "hidden": 0, 
@@ -402,6 +444,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_36", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges", 
   "fieldtype": "Table", 
   "label": "Sales Taxes and Charges", 
@@ -412,18 +459,32 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "calculate_charges", 
-  "fieldtype": "Button", 
-  "label": "Calculate Taxes and Charges", 
-  "oldfieldtype": "Button", 
+  "fieldname": "other_charges_calculation", 
+  "fieldtype": "HTML", 
+  "label": "Taxes and Charges Calculation", 
+  "oldfieldtype": "HTML", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_39", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "other_charges_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Taxes and Charges Total (Export)", 
+  "options": "currency", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges_total", 
   "fieldtype": "Currency", 
-  "label": "Taxes and Charges Total*", 
+  "label": "Taxes and Charges Total", 
   "oldfieldname": "other_charges_total", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
@@ -432,10 +493,15 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "other_charges_calculation", 
-  "fieldtype": "HTML", 
-  "label": "Taxes and Charges Calculation", 
-  "oldfieldtype": "HTML", 
+  "fieldname": "column_break_42", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "calculate_charges", 
+  "fieldtype": "Button", 
+  "label": "Calculate Taxes and Charges", 
+  "oldfieldtype": "Button", 
   "print_hide": 1, 
   "read_only": 0
  }, 
@@ -450,55 +516,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "grand_total", 
-  "fieldtype": "Currency", 
-  "label": "Grand Total*", 
-  "no_copy": 0, 
-  "oldfieldname": "grand_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "rounded_total", 
-  "fieldtype": "Currency", 
-  "label": "Rounded Total", 
-  "no_copy": 0, 
-  "oldfieldname": "rounded_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "width": "200px"
- }, 
- {
-  "description": "In Words will be visible once you save the Quotation.", 
-  "doctype": "DocField", 
-  "fieldname": "in_words", 
-  "fieldtype": "Data", 
-  "label": "In Words", 
-  "no_copy": 0, 
-  "oldfieldname": "in_words", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "column_break3", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "grand_total_export", 
   "fieldtype": "Currency", 
   "in_list_view": 1, 
@@ -539,6 +556,55 @@
   "width": "200px"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "column_break3", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "grand_total", 
+  "fieldtype": "Currency", 
+  "label": "Grand Total*", 
+  "no_copy": 0, 
+  "oldfieldname": "grand_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "reqd": 0, 
+  "width": "200px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rounded_total", 
+  "fieldtype": "Currency", 
+  "label": "Rounded Total", 
+  "no_copy": 0, 
+  "oldfieldname": "rounded_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "width": "200px"
+ }, 
+ {
+  "description": "In Words will be visible once you save the Quotation.", 
+  "doctype": "DocField", 
+  "fieldname": "in_words", 
+  "fieldtype": "Data", 
+  "label": "In Words", 
+  "no_copy": 0, 
+  "oldfieldname": "in_words", 
+  "oldfieldtype": "Data", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "width": "200px"
+ }, 
+ {
   "description": "Add Terms and Conditions for the Quotation like Payment Terms, Validity of Offer etc. You can also prepare a Terms and Conditions Master and use the Template", 
   "doctype": "DocField", 
   "fieldname": "terms_section_break", 
@@ -562,22 +628,21 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_54", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
   "oldfieldtype": "Button", 
-  "options": "get_tc_details", 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1, 
-  "read_only": 0
+  "fieldname": "section_break_56", 
+  "fieldtype": "Section Break"
  }, 
  {
   "doctype": "DocField", 
@@ -596,6 +661,36 @@
   "read_only": 0
  }, 
  {
+  "description": "Will be fetched from Customer", 
+  "doctype": "DocField", 
+  "fieldname": "territory", 
+  "fieldtype": "Link", 
+  "hidden": 0, 
+  "in_filter": 1, 
+  "label": "Territory", 
+  "options": "Territory", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 0
+ }, 
+ {
+  "depends_on": "customer", 
+  "doctype": "DocField", 
+  "fieldname": "customer_group", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Customer Group", 
+  "oldfieldname": "customer_group", 
+  "oldfieldtype": "Link", 
+  "options": "Customer Group", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 0, 
+  "search_index": 0
+ }, 
+ {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "col_break98", 
   "fieldtype": "Column Break", 
@@ -628,41 +723,6 @@
   "reqd": 0
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "col_break99", 
-  "fieldtype": "Column Break", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "description": "Will be fetched from Customer", 
-  "doctype": "DocField", 
-  "fieldname": "territory", 
-  "fieldtype": "Link", 
-  "hidden": 0, 
-  "in_filter": 1, 
-  "label": "Territory", 
-  "options": "Territory", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "customer_group", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Customer Group", 
-  "oldfieldname": "customer_group", 
-  "oldfieldtype": "Link", 
-  "options": "Customer Group", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 0, 
-  "search_index": 0
- }, 
- {
   "description": "Filling in additional information about the Quotation will help you analyze your data better.", 
   "doctype": "DocField", 
   "fieldname": "more_info", 
@@ -673,32 +733,18 @@
   "read_only": 0
  }, 
  {
-  "allow_on_submit": 1, 
   "doctype": "DocField", 
-  "fieldname": "letter_head", 
-  "fieldtype": "Select", 
-  "label": "Letter Head", 
-  "oldfieldname": "letter_head", 
-  "oldfieldtype": "Select", 
-  "options": "link:Letter Head", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "description": "Select the relevant company name if you have multiple companies.", 
-  "doctype": "DocField", 
-  "fieldname": "company", 
+  "fieldname": "campaign", 
   "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Company", 
-  "oldfieldname": "company", 
+  "hidden": 0, 
+  "label": "Campaign", 
+  "no_copy": 0, 
+  "oldfieldname": "campaign", 
   "oldfieldtype": "Link", 
-  "options": "Company", 
+  "options": "Campaign", 
   "print_hide": 1, 
   "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 0, 
-  "width": "150px"
+  "report_hide": 0
  }, 
  {
   "doctype": "DocField", 
@@ -715,6 +761,70 @@
   "report_hide": 0
  }, 
  {
+  "allow_on_submit": 0, 
+  "default": "Draft", 
+  "doctype": "DocField", 
+  "fieldname": "status", 
+  "fieldtype": "Select", 
+  "in_filter": 1, 
+  "label": "Status", 
+  "no_copy": 1, 
+  "oldfieldname": "status", 
+  "oldfieldtype": "Select", 
+  "options": "\nDraft\nSubmitted\nOrder Confirmed\nOrder Lost\nCancelled", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "reqd": 1, 
+  "search_index": 0
+ }, 
+ {
+  "allow_on_submit": 1, 
+  "doctype": "DocField", 
+  "fieldname": "order_lost_reason", 
+  "fieldtype": "Small Text", 
+  "label": "Quotation Lost Reason", 
+  "no_copy": 1, 
+  "oldfieldname": "order_lost_reason", 
+  "oldfieldtype": "Small Text", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break4", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
+  "allow_on_submit": 1, 
+  "doctype": "DocField", 
+  "fieldname": "letter_head", 
+  "fieldtype": "Select", 
+  "label": "Letter Head", 
+  "oldfieldname": "letter_head", 
+  "oldfieldtype": "Select", 
+  "options": "link:Letter Head", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "allow_on_submit": 1, 
+  "doctype": "DocField", 
+  "fieldname": "select_print_heading", 
+  "fieldtype": "Link", 
+  "label": "Select Print Heading", 
+  "no_copy": 1, 
+  "oldfieldname": "select_print_heading", 
+  "oldfieldtype": "Link", 
+  "options": "Print Heading", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "report_hide": 1
+ }, 
+ {
   "doctype": "DocField", 
   "fieldname": "fiscal_year", 
   "fieldtype": "Select", 
@@ -743,97 +853,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break4", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "allow_on_submit": 0, 
-  "default": "Draft", 
-  "doctype": "DocField", 
-  "fieldname": "status", 
-  "fieldtype": "Select", 
-  "in_filter": 1, 
-  "label": "Status", 
-  "no_copy": 1, 
-  "oldfieldname": "status", 
-  "oldfieldtype": "Select", 
-  "options": "\nDraft\nSubmitted\nOrder Confirmed\nOrder Lost\nCancelled", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "reqd": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "campaign", 
-  "fieldtype": "Link", 
-  "hidden": 0, 
-  "label": "Campaign", 
-  "no_copy": 0, 
-  "oldfieldname": "campaign", 
-  "oldfieldtype": "Link", 
-  "options": "Campaign", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "report_hide": 0
- }, 
- {
-  "allow_on_submit": 1, 
-  "doctype": "DocField", 
-  "fieldname": "order_lost_reason", 
-  "fieldtype": "Small Text", 
-  "label": "Quotation Lost Reason", 
-  "no_copy": 1, 
-  "oldfieldname": "order_lost_reason", 
-  "oldfieldtype": "Small Text", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "allow_on_submit": 1, 
-  "doctype": "DocField", 
-  "fieldname": "select_print_heading", 
-  "fieldtype": "Link", 
-  "label": "Select Print Heading", 
-  "no_copy": 1, 
-  "oldfieldname": "select_print_heading", 
-  "oldfieldtype": "Link", 
-  "options": "Print Heading", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "report_hide": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "amended_from", 
-  "fieldtype": "Data", 
-  "label": "Amended From", 
-  "no_copy": 1, 
-  "oldfieldname": "amended_from", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "width": "150px"
- }, 
- {
-  "description": "The date at which current entry is corrected in the system.", 
-  "doctype": "DocField", 
-  "fieldname": "amendment_date", 
-  "fieldtype": "Date", 
-  "label": "Amendment Date", 
-  "no_copy": 1, 
-  "oldfieldname": "amendment_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "width": "100px"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "communication_history", 
   "fieldtype": "Section Break", 
   "oldfieldtype": "Section Break", 
@@ -854,14 +873,13 @@
   "width": "40px"
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "file_list", 
-  "fieldtype": "Small Text", 
-  "hidden": 1, 
-  "label": "File List", 
-  "no_copy": 1, 
-  "print_hide": 1, 
-  "read_only": 0
+  "amend": 1, 
+  "cancel": 1, 
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "role": "Sales Manager", 
+  "submit": 1, 
+  "write": 1
  }, 
  {
   "amend": 1, 
@@ -873,17 +891,13 @@
   "write": 1
  }, 
  {
+  "amend": 0, 
+  "cancel": 0, 
+  "create": 0, 
   "doctype": "DocPerm", 
-  "role": "Customer"
- }, 
- {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "role": "Sales Manager", 
-  "submit": 1, 
-  "write": 1
+  "role": "Customer", 
+  "submit": 0, 
+  "write": 0
  }, 
  {
   "amend": 1, 
diff --git a/selling/doctype/quotation_item/quotation_item.txt b/selling/doctype/quotation_item/quotation_item.txt
index bcb9281..11ac1ba 100644
--- a/selling/doctype/quotation_item/quotation_item.txt
+++ b/selling/doctype/quotation_item/quotation_item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 11:42:57", 
   "docstatus": 0, 
-  "modified": "2013-05-22 12:08:32", 
+  "modified": "2013-05-22 12:10:32", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -119,7 +119,7 @@
   "options": "currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "100px"
  }, 
@@ -195,7 +195,7 @@
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "search_index": 0, 
   "width": "100px"
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 8a8d8d0..dc3f60d 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -21,118 +21,474 @@
 // cur_frm.cscript.other_fname - wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); fieldname
 // cur_frm.cscript.sales_team_fname - Sales Team fieldname
 
-// ============== Load Default Taxes ===================
-cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
-	// run if this is not executed from dt_map...
-	doc = locals[doc.doctype][doc.name];
-	if(doc.customer || getchildren('Sales Taxes and Charges', doc.name, 'other_charges', doc.doctype).length) {
-		if(callback) {
-			callback(doc, cdt, cdn);
+wn.provide("erpnext.selling");
+wn.require("app/js/transaction.js");
+
+erpnext.selling.SellingController = erpnext.TransactionController.extend({
+	setup: function() {
+		this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate");
+	},
+	
+	onload: function() {
+		this._super();
+		this.toggle_rounded_total();
+	},
+	
+	customer: function() {
+		var me = this;
+		if(this.frm.doc.customer || this.frm.doc.debit_to) {
+			if(!this.frm.doc.company) {
+				this.frm.set_value("customer", null);
+				msgprint(wn._("Please specify Company"));
+			} else {
+				var price_list_name = this.frm.doc.price_list_name;
+				this.frm.call({
+					doc: this.frm.doc,
+					method: "set_customer_defaults",
+					freeze: true,
+					callback: function(r) {
+						if(!r.exc) {
+							me.frm.refresh_fields();
+							(me.frm.doc.price_list_name !== price_list_name) ? 
+								me.price_list_name() :
+								me.price_list_currency();
+						}
+					}
+				});
+			}
 		}
-	} else if(doc.charge) {
-		cur_frm.cscript.get_charges(doc, cdt, cdn, callback);
-	} else {
-		$c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
-			refresh_field('other_charges');
-			if(callback) callback(doc, cdt, cdn);
+	},
+	
+	barcode: function(doc, cdt, cdn) {
+		this.item_code(doc, cdt, cdn);
+	},
+	
+	item_code: function(doc, cdt, cdn) {
+		var me = this;
+		var item = wn.model.get_doc(cdt, cdn);
+		if(item.item_code || item.barcode) {
+			if(!this.validate_company_and_party("customer")) {
+				item.item_code = null;
+				refresh_field("item_code", item.name, item.parentfield);
+			} else {
+				this.frm.call({
+					method: "selling.utils.get_item_details",
+					child: item,
+					args: {
+						args: {
+							item_code: item.item_code,
+							barcode: item.barcode,
+							warehouse: item.warehouse,
+							doctype: me.frm.doc.doctype,
+							customer: me.frm.doc.customer,
+							currency: me.frm.doc.currency,
+							conversion_rate: me.frm.doc.conversion_rate,
+							price_list_name: me.frm.doc.price_list_name,
+							price_list_currency: me.frm.doc.price_list_currency,
+							plc_conversion_rate: me.frm.doc.plc_conversion_rate,
+							company: me.frm.doc.company,
+							order_type: me.frm.doc.order_type,
+							is_pos: cint(me.frm.doc.is_pos),
+						}
+					},
+					callback: function(r) {
+						if(!r.exc) {
+							me.ref_rate(me.frm.doc, cdt, cdn);
+						}
+					}
+				});
+			}
+		}
+	},
+	
+	price_list_name: function() {
+		this._super("selling");
+	},
+	
+	ref_rate: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["ref_rate", "adj_rate"]);
+		
+		item.export_rate = flt(item.ref_rate * (1 - item.adj_rate / 100.0),
+			precision("export_rate", item));
+		
+		this.calculate_taxes_and_totals();
+	},
+	
+	adj_rate: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		if(!item.ref_rate) {
+			item.adj_rate = 0.0;
+		} else {
+			this.ref_rate(doc, cdt, cdn);
+		}
+	},
+	
+	export_rate: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["export_rate", "ref_rate"]);
+		
+		if(item.ref_rate) {
+			item.adj_rate = flt((1 - item.export_rate / item.ref_rate) * 100.0,
+				precision("adj_rate", item));
+		} else {
+			item.adj_rate = 0.0;
+		}
+		
+		this.calculate_taxes_and_totals();
+	},
+	
+	commission_rate: function() {
+		this.calculate_commission();
+		refresh_field("total_commission");
+	},
+	
+	total_commission: function() {
+		if(this.frm.doc.net_total) {
+			wn.model.round_floats_in(this.frm.doc, ["net_total", "total_commission"]);
+			
+			if(this.frm.doc.net_total < this.frm.doc.total_commission) {
+				var msg = (wn._("[Error]") + " " + 
+					wn._(wn.meta.get_label(this.frm.doc.doctype, "total_commission", 
+						this.frm.doc.name)) + " > " + 
+					wn._(wn.meta.get_label(this.frm.doc.doctype, "net_total", this.frm.doc.name)));
+				msgprint(msg);
+				throw msg;
+			}
+		
+			this.frm.set_value("commission_rate", 
+				flt(this.frm.doc.total_commission * 100.0 / this.frm.doc.net_total));
+		}
+	},
+	
+	allocated_percentage: function(doc, cdt, cdn) {
+		var sales_person = wn.model.get_doc(cdt, cdn);
+		
+		if(sales_person.allocated_percentage) {
+			sales_person.allocated_percentage = flt(sales_person.allocated_percentage,
+				precision("allocated_percentage", sales_person));
+			sales_person.allocated_amount = flt(this.frm.doc.net_total *
+				sales_person.allocated_percentage / 100.0, 
+				precision("allocated_amount", sales_person));
+
+			refresh_field(["allocated_percentage", "allocated_amount"], sales_person.name,
+				sales_person.parentfield);
+		}
+	},
+	
+	warehouse: function(doc, cdt, cdn) {
+		var item = webnotes.get_doc(cdt, cdn);
+		if(item.item_code && (item.warehouse || item.reserved_warehouse)) {
+			this.frm.call({
+				method: "selling.utils.get_available_qty",
+				child: item,
+				args: {
+					item_code: item.item_code,
+					warehouse: item.warehouse || item.reserved_warehouse,
+				},
+			});
+		}
+	},
+	
+	toggle_rounded_total: function() {
+		var me = this;
+		if(cint(wn.defaults.get_global_default("disable_rounded_total"))) {
+			$.each(["rounded_total", "rounded_total_export"], function(i, fieldname) {
+				me.frm.set_df_property(fieldname, "print_hide", 1);
+				me.frm.toggle_display(fieldname, false);
+			});
+		}
+	},
+	
+	calculate_taxes_and_totals: function() {
+		this._super();
+		this.calculate_total_advance("Sales Invoice", "advance_adjustment_details");
+		this.calculate_commission();
+		this.calculate_contribution();
+
+		// TODO check for custom_recalc in custom scripts of server
+		
+		this.frm.refresh_fields();
+	},
+	
+	calculate_item_values: function() {
+		var me = this;
+		$.each(this.frm.item_doclist, function(i, item) {
+			wn.model.round_floats_in(item);
+			item.export_amount = flt(item.export_rate * item.qty, precision("export_amount", item));
+			
+			me._set_in_company_currency(item, "ref_rate", "base_ref_rate");
+			me._set_in_company_currency(item, "export_rate", "basic_rate");
+			me._set_in_company_currency(item, "export_amount", "amount");
 		});
-	}
-}
-
-
-// Gets called after existing item details are update to fill in
-// remaining default values
-cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
-	if(!cur_frm.doc.__islocal) { return; }
-
-	doc = locals[doc.doctype][doc.name];
-	var fields_to_refresh = wn.model.set_default_values(doc);
-	if(fields_to_refresh) { refresh_many(fields_to_refresh); }
-
-	fields_to_refresh = null;
-	var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
-	if(!children) { return; }
-	for(var i=0; i<children.length; i++) {
-		wn.model.set_default_values(children[i]);
-	}
-	refresh_field(cur_frm.cscript.fname);
-	cur_frm.cscript.load_taxes(doc, dt, dn, callback);
-}
-
-
-// Update existing item details
-cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
-	doc = locals[doc.doctype][doc.name];
-	if(!cur_frm.doc.__islocal) return;
-	var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
-	if(children.length) {
-		$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
-		function(r, rt) {
-			if(!r.exc) {
-				refresh_field(cur_frm.cscript.fname);
-				doc = locals[doc.doctype][doc.name];
-				cur_frm.cscript.load_defaults(doc, dt, dn, callback);
+		
+	},
+	
+	determine_exclusive_rate: function() {
+		var me = this;
+		$.each(me.frm.item_doclist, function(n, item) {
+			var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
+			var cumulated_tax_fraction = 0.0;
+			
+			$.each(me.frm.tax_doclist, function(i, tax) {
+				tax.tax_fraction_for_current_item = me.get_current_tax_fraction(tax, item_tax_map);
+				
+				if(i==0) {
+					tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item;
+				} else {
+					tax.grand_total_fraction_for_current_item = 
+						me.frm.tax_doclist[i-1].grand_total_fraction_for_current_item +
+						tax.tax_fraction_for_current_item;
+				}
+				
+				cumulated_tax_fraction += tax.tax_fraction_for_current_item;
+			});
+			
+			if(cumulated_tax_fraction) {
+				item.basic_rate = flt(
+					(item.export_rate * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction),
+					precision("basic_rate", item));
+				
+				item.amount = flt(item.basic_rate * item.qty, precision("amount", item));
+				
+				if(item.adj_rate == 100) {
+					item.base_ref_rate = item.basic_rate;
+					item.basic_rate = 0.0;
+				} else {
+					item.base_ref_rate = flt(item.basic_rate / (1 - item.adj_rate / 100.0),
+						precision("base_ref_rate", item));
+				}
 			}
 		});
-	} else {
-		cur_frm.cscript.load_taxes(doc, dt, dn, callback);
-	}
-}
-
-
-var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
-	//parent flds
-	par_cols_base = {'net_total': 'Net Total', 'other_charges_total': 'Taxes and Charges Total', 
-		'grand_total':	'Grand Total', 'rounded_total': 'Rounded Total', 'in_words': 'In Words'}
-	par_cols_export = {'grand_total_export': 'Grand Total', 'rounded_total_export':	'Rounded Total', 'in_words_export':	'In Words'};
-
-	for (d in par_cols_base) cur_frm.fields_dict[d].label_span.innerHTML = par_cols_base[d]+' (' + base_curr + ')';
-	for (d in par_cols_export) cur_frm.fields_dict[d].label_span.innerHTML = par_cols_export[d]+' (' + doc.currency + ')';
-	cur_frm.fields_dict['conversion_rate'].label_span.innerHTML = "Conversion Rate (" + doc.currency +' -> '+ base_curr + ')';
-	cur_frm.fields_dict['plc_conversion_rate'].label_span.innerHTML = 'Price List Currency Conversion Rate (' + doc.price_list_currency +' -> '+ base_curr + ')';
-
-	if (doc.doctype == 'Sales Invoice') {
-		si_cols = {'total_advance': 'Total Advance', 'outstanding_amount': 'Outstanding Amount', 'paid_amount': 'Paid Amount', 'write_off_amount': 'Write Off Amount'}
-		for (d in si_cols) cur_frm.fields_dict[d].label_span.innerHTML = si_cols[d] + ' (' + base_curr + ')';
-	}
-}
-
-
-var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
-	// item table flds
-	item_cols_base = {'basic_rate': 'Basic Rate', 'base_ref_rate': 'Price List Rate', 'amount': 'Amount'};
-	item_cols_export = {'export_rate': 'Basic Rate', 'ref_rate': 'Price List Rate', 'export_amount': 'Amount'};
+	},
+	
+	get_current_tax_fraction: function(tax, item_tax_map) {
+		// Get tax fraction for calculating tax exclusive amount
+		// from tax inclusive amount
+		var current_tax_fraction = 0.0;
 		
-	for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
-	for (d in item_cols_export) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_export[d]+' ('+doc.currency+')');	
-
-	var hide = (doc.currency == sys_defaults['currency']) ? false : true;
-	for (f in item_cols_base) {
-		cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
-	}
-
-	//tax table flds
-	tax_cols = {'tax_amount': 'Amount', 'total': 'Total'};
-	for (d in tax_cols) $('[data-grid-fieldname="Sales Taxes and Charges-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');
+		if(cint(tax.included_in_print_rate)) {
+			var tax_rate = this._get_tax_rate(tax, item_tax_map);
+			
+			if(tax.charge_type == "On Net Total") {
+				current_tax_fraction = (tax_rate / 100.0);
+				
+			} else if(tax.charge_type == "On Previous Row Amount") {
+				current_tax_fraction = (tax_rate / 100.0) *
+					this.frm.tax_doclist[cint(tax.row_id) - 1].tax_fraction_for_current_item;
+				
+			} else if(tax.charge_type == "On Previous Row Total") {
+				current_tax_fraction = (tax_rate / 100.0) *
+					this.frm.tax_doclist[cint(tax.row_id) - 1].grand_total_fraction_for_current_item;
+			}
+		}
 		
-	if (doc.doctype == 'Sales Invoice') {
-		// advance table flds
-		adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount'}
-		for (d in adv_cols) $('[data-grid-fieldname="Sales Invoice Advance-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');	
-	}
-}
+		return current_tax_fraction;
+	},
+	
+	calculate_net_total: function() {
+		var me = this;
 
-// Change label dynamically based on currency
-//------------------------------------------------------------------
+		this.frm.doc.net_total = this.frm.doc.net_total_export = 0.0;
+		$.each(this.frm.item_doclist, function(i, item) {
+			me.frm.doc.net_total += item.amount;
+			me.frm.doc.net_total_export += item.export_amount;
+		});
+		
+		wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_export"]);
+	},
+	
+	calculate_totals: function() {
+		var tax_count = this.frm.tax_doclist.length;
+		this.frm.doc.grand_total = flt(
+			tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
+			precision("grand_total"));
+		this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate,
+			precision("grand_total_export"));
+			
+		this.frm.doc.other_charges_total = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
+			precision("other_charges_total"));
+		this.frm.doc.other_charges_total_export = flt(
+			this.frm.doc.grand_total_export - this.frm.doc.net_total_export,
+			precision("other_charges_total_export"));
+			
+		this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
+		this.frm.doc.rounded_total_export = Math.round(this.frm.doc.grand_total_export);
+	},
+	
+	calculate_outstanding_amount: function() {
+		// NOTE: 
+		// write_off_amount is only for POS Invoice
+		// total_advance is only for non POS Invoice
+		if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.docstatus < 2) {
+			wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount",
+				"paid_amount"]);
+			var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount;
+			this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.total_advance - 
+				this.frm.doc.paid_amount, precision("outstanding_amount"));
+		}
+	},
+	
+	calculate_commission: function() {
+		if(this.frm.fields_dict.commission_rate) {
+			if(this.frm.doc.commission_rate > 100) {
+				var msg = wn._(wn.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name)) +
+					" " + wn._("cannot be greater than 100");
+				msgprint(msg);
+				throw msg;
+			}
+		
+			this.frm.doc.total_commission = flt(this.frm.doc.net_total * this.frm.doc.commission_rate / 100.0,
+				precision("total_commission"));
+		}
+	},
+	
+	calculate_contribution: function() {
+		var me = this;
+		$.each(wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, 
+			{parentfield: "sales_team"}), function(i, sales_person) {
+				wn.model.round_floats_in(sales_person);
+				if(sales_person.allocated_percentage) {
+					sales_person.allocated_amount = flt(
+						me.frm.doc.net_total * sales_person.allocated_percentage / 100.0,
+						precision("allocated_amount", sales_person));
+				}
+			});
+	},
+	
+	_cleanup: function() {
+		this._super();
+		this.frm.doc.in_words = this.frm.doc.in_words_export = "";
+	},
 
-cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, base_curr, callback) {
-	cur_frm.cscript.base_currency = base_curr;
-	set_dynamic_label_par(doc, cdt, cdn, base_curr);
-	set_dynamic_label_child(doc, cdt, cdn, base_curr);
-	set_sales_bom_help(doc);
+	show_item_wise_taxes: function() {
+		if(this.frm.fields_dict.other_charges_calculation) {
+			$(this.get_item_wise_taxes_html())
+				.appendTo($(this.frm.fields_dict.other_charges_calculation.wrapper).empty());
+		}
+	},
+	
+	get_charges: function() {
+		var me = this;
+		if(this.frm.doc.charge) {
+			this.frm.call({
+				doc: this.frm.doc,
+				method: "get_other_charges",
+				callback: function(r) {
+					if(!r.exc) {
+						me.calculate_taxes_and_totals();
+					}
+				}
+			});
+		}
+	},
+	
+	set_dynamic_labels: function() {
+		var company_currency = this.get_company_currency();
+		
+		this.change_form_labels(company_currency);
+		this.change_grid_labels(company_currency);
+		set_sales_bom_help(this.frm.doc);
+	},
+	
+	change_form_labels: function(company_currency) {
+		var me = this;
+		var field_label_map = {};
+		
+		var setup_field_label_map = function(fields_list, currency) {
+			$.each(fields_list, function(i, fname) {
+				var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
+				if(docfield) {
+					var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
+					field_label_map[fname] = label.trim() + " (" + currency + ")";
+				}
+			});
+		};
+		
+		setup_field_label_map(["net_total", "other_charges_total", "grand_total", 
+			"rounded_total", "in_words",
+			"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
+			company_currency);
+		
+		setup_field_label_map(["net_total_export", "other_charges_total_export", "grand_total_export", 
+			"rounded_total_export", "in_words_export"], this.frm.doc.currency);
+		
+		setup_field_label_map(["conversion_rate"], 	"1 " + this.frm.doc.currency 
+			+ " = [?] " + company_currency);
+		
+		if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
+			setup_field_label_map(["plc_conversion_rate"], 	"1 " + this.frm.doc.price_list_currency 
+				+ " = [?] " + company_currency);
+		}
+		
+		// toggle fields
+		this.frm.toggle_display(["conversion_rate", "net_total", "other_charges_total", 
+			"grand_total", "rounded_total", "in_words"],
+			this.frm.doc.currency != company_currency);
+			
+		this.frm.toggle_display(["plc_conversion_rate"], 
+			this.frm.doc.price_list_currency != company_currency);
+		
+		// set labels
+		$.each(field_label_map, function(fname, label) {
+			me.frm.fields_dict[fname].set_label(label);
+		});
+	},
+	
+	change_grid_labels: function(company_currency) {
+		var me = this;
+		var field_label_map = {};
+		
+		var setup_field_label_map = function(fields_list, currency, parentfield) {
+			var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
+			$.each(fields_list, function(i, fname) {
+				var docfield = wn.meta.get_docfield(grid_doctype, fname);
+				if(docfield) {
+					var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
+					field_label_map[grid_doctype + "-" + fname] = 
+						label.trim() + " (" + currency + ")";
+				}
+			});
+		}
+		
+		setup_field_label_map(["basic_rate", "base_ref_rate", "amount"],
+			company_currency, this.fname);
+		
+		setup_field_label_map(["export_rate", "ref_rate", "export_amount"],
+			this.frm.doc.currency, this.fname);
+		
+		setup_field_label_map(["tax_amount", "total"], company_currency, "other_charges");
+		
+		if(this.frm.fields_dict["advance_allocation_details"]) {
+			setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
+				"advance_allocation_details");
+		}
+		
+		// toggle columns
+		var item_grid = this.frm.fields_dict[this.fname].grid;
+		var show = this.frm.doc.currency != company_currency;
+		$.each(["basic_rate", "base_ref_rate", "amount"], function(i, fname) {
+			if(wn.meta.get_docfield(item_grid.doctype, fname))
+				item_grid.set_column_disp(fname, show);
+		});
+		
+		// set labels
+		var $wrapper = $(this.frm.wrapper);
+		$.each(field_label_map, function(fname, label) {
+			$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
+		});
+	},
+	
+});
 
-	if (callback) callback(doc, cdt, cdn);
-}
+// to save previous state of cur_frm.cscript
+var prev_cscript = {};
+$.extend(prev_cscript, cur_frm.cscript);
+
+cur_frm.cscript = new erpnext.selling.SellingController({frm: cur_frm});
+
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, prev_cscript);
 
 // Help for Sales BOM items
 var set_sales_bom_help = function(doc) {
@@ -158,113 +514,8 @@
 	refresh_field('sales_bom_help');
 }
 
-
-// hide / unhide price list currency based on availability of price list in customer's currency
-//---------------------------------------------------------------------------------------------------
-
-cur_frm.cscript.hide_price_list_currency = function(doc, cdt, cdn, callback1) {
-	if (doc.price_list_name && doc.currency) {
-		wn.call({
-			method: 'selling.doctype.sales_common.sales_common.get_price_list_currency',
-			args: {'price_list':doc.price_list_name, 'company': doc.company},
-			callback: function(r, rt) {
-				pl_currency = r.message[0]?r.message[0]:[];
-				unhide_field(['price_list_currency', 'plc_conversion_rate']);
-				
-				if (pl_currency.length==1) {
-					if (doc.price_list_currency != pl_currency[0]) 
-						set_multiple(cdt, cdn, {price_list_currency:pl_currency[0]});
-					if (pl_currency[0] == doc.currency) {
-						if(doc.plc_conversion_rate != doc.conversion_rate) 
-							set_multiple(cdt, cdn, {plc_conversion_rate:doc.conversion_rate});
-						hide_field(['price_list_currency', 'plc_conversion_rate']);
-					} else if (pl_currency[0] == r.message[1]) {
-						if (doc.plc_conversion_rate != 1) 
-							set_multiple(cdt, cdn, {plc_conversion_rate:1})
-						hide_field(['price_list_currency', 'plc_conversion_rate']);
-					}
-				}
-
-				if (r.message[1] == doc.currency) {
-					if (doc.conversion_rate != 1) 
-						set_multiple(cdt, cdn, {conversion_rate:1});
-					hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
-				} else {
-					unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export']);
-					if(!cint(sys_defaults.disable_rounded_total))
-						unhide_field("rounded_total_export");
-				}
-				if (r.message[1] == doc.price_list_currency) {
-					if (doc.plc_conversion_rate != 1) 
-						set_multiple(cdt, cdn, {plc_conversion_rate:1});
-					hide_field('plc_conversion_rate');
-				} else unhide_field('plc_conversion_rate');
-				cur_frm.cscript.dynamic_label(doc, cdt, cdn, r.message[1], callback1);	
-			}
-		})
-	}
-}
-
-cur_frm.cscript.manage_rounded_total = function() {
-	if(cint(sys_defaults.disable_rounded_total)) {
-		cur_frm.set_df_property("rounded_total", "print_hide", 1);
-		cur_frm.set_df_property("rounded_total_export", "print_hide", 1);
-		hide_field(["rounded_total", "rounded_total_export"]);
-	}
-}
-
-// TRIGGERS FOR CALCULATIONS
-// =====================================================================================================
-
-// ********************* CURRENCY ******************************
-cur_frm.cscript.currency = function(doc, cdt, cdn) {
-	cur_frm.cscript.price_list_name(doc, cdt, cdn); 
-}
-
-cur_frm.cscript.price_list_currency = cur_frm.cscript.currency;
-cur_frm.cscript.conversion_rate = cur_frm.cscript.currency;
-cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
-
-cur_frm.cscript.company = function(doc, cdt, cdn) {
-	wn.call({
-		method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
-		args: {company:doc.company},
-		callback: function(r, rt) {
-			var doc = locals[cdt][cdn];
-			set_multiple(doc.doctype, doc.name, {
-				currency:r.message, 
-				price_list_currency:r.message
-			});
-			cur_frm.cscript.currency(doc, cdt, cdn);
-		}
-	});
-}
-
-
-
-// ******************** PRICE LIST ******************************
-cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
-	var callback = function() {
-		var fname = cur_frm.cscript.fname;
-		var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
-		if(doc.price_list_name && doc.currency && doc.price_list_currency && doc.conversion_rate && doc.plc_conversion_rate) {
-			$c_obj(make_doclist(doc.doctype, doc.name), 'get_adj_percent', '',
-				function(r, rt) {
-					refresh_field(fname);
-					var doc = locals[cdt][cdn];
-					cur_frm.cscript.recalc(doc,3);		//this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE
-				}
-			);
-		}
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
-}
-
-
-
-// ******************** ITEM CODE ******************************** 
 cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
-	if (inList(['Maintenance', 'Service'], doc.order_type)) {
+	if (doc.order_type == "Maintenance") {
 	 	return erpnext.queries.item({
 			'ifnull(tabItem.is_service_item, "No")': 'Yes'
 		});
@@ -275,47 +526,6 @@
 	}
 }
 
-
-cur_frm.cscript.item_code = function(doc, cdt, cdn) {
-	var fname = cur_frm.cscript.fname;
-	var d = locals[cdt][cdn];
-	if (d.item_code) {
-		if (!doc.company) {
-			msgprint("Please select company to proceed");
-			d.item_code = '';
-			refresh_field('item_code', d.name, fname);
-		} else {
-			var callback = function(r, rt){
-				cur_frm.cscript.recalc(doc, 1);
-			}
-			var args = {
-				'item_code':d.item_code, 
-				'income_account':d.income_account, 
-				'cost_center': d.cost_center, 
-				'warehouse': d.warehouse
-			};
-			get_server_fields('get_item_details',JSON.stringify(args), 
-				fname,doc,cdt,cdn,1,callback);
-		}
-	}
-	if(cur_frm.cscript.custom_item_code){
-		cur_frm.cscript.custom_item_code(doc, cdt, cdn);
-	}
-}
-
-//Barcode
-//
-cur_frm.cscript.barcode = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	var callback = function(r, rt) {
-		cur_frm.cscript.item_code(doc, cdt, cdn);
-	}
-	if(d.barcode) {
-		get_server_fields('get_barcode_details', d.barcode, cur_frm.cscript.fname, 
-		doc, cdt, cdn, 1, callback);
-	}
-}
-
 cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field('batch_no').get_query = 
 	function(doc, cdt, cdn) {
 		var d = locals[cdt][cdn];
@@ -360,66 +570,6 @@
 		'" AND docstatus != 2 AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
 }
 
-// *********************** QUANTITY ***************************
-cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
-	
-// ************************ DISCOUNT (%) ***********************
-cur_frm.cscript.adj_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
-
-// ************************ REF RATE ****************************
-cur_frm.cscript.ref_rate = function(doc, cdt, cdn){
-	var d = locals[cdt][cdn];
-	var consider_incl_rate = cur_frm.cscript.consider_incl_rate(doc, cur_frm.cscript.other_fname);
-	if(!consider_incl_rate) {
-		set_multiple(cur_frm.cscript.tname, d.name, {'export_rate': flt(d.ref_rate) * (100 - flt(d.adj_rate)) / 100}, cur_frm.cscript.fname);
-	}
-	cur_frm.cscript.recalc(doc, 1);
-}
-
-// *********************** BASIC RATE **************************
-cur_frm.cscript.basic_rate = function(doc, cdt, cdn) { 
-	var fname = cur_frm.cscript.fname;
-	var d = locals[cdt][cdn];
-	if(!d.qty) {
-		d.qty = 1;
-		refresh_field('qty', d.name, fname);
-	}
-	var consider_incl_rate = cur_frm.cscript.consider_incl_rate(doc, cur_frm.cscript.other_fname);
-	if(!consider_incl_rate) {
-		cur_frm.cscript.recalc(doc, 2);
-	} else {
-		var basic_rate = cur_frm.cscript.back_calc_basic_rate(
-			doc, cur_frm.cscript.tname, fname, d, cur_frm.cscript.other_fname
-		);
-		// TODO: remove roundNumber for basic_rate comparison
-		if (d.basic_rate != roundNumber(basic_rate, 2)) { 
-			d.basic_rate = basic_rate;
-			refresh_field('basic_rate', d.name, fname); 
-			msgprint("You cannot change Basic Rate* (Base Currency) when \
-				considering rates inclusive of taxes.<br /> \
-				Please either <br /> \
-				* Specify Basic Rate (i.e. Rate which will be displayed in print) <br /> \
-				-- or -- <br />\
-				* Uncheck 'Is this Tax included in Basic Rate?' in the tax entries of Taxes section.");
-		}
-	}
-}
-
-// ************************ EXPORT RATE *************************
-cur_frm.cscript.export_rate = function(doc,cdt,cdn) {
-	var cur_rec = locals[cdt][cdn];
-	var fname = cur_frm.cscript.fname;
-	var tname = cur_frm.cscript.tname;
-	if(flt(cur_rec.ref_rate)>0 && flt(cur_rec.export_rate)>0) {
-		var adj_rate = 100 * (1 - (flt(cur_rec.export_rate) / flt(cur_rec.ref_rate)));
-		set_multiple(tname, cur_rec.name, { 'adj_rate': adj_rate }, fname);
-	}
-	doc = locals[doc.doctype][doc.name];
-	cur_frm.cscript.recalc(doc, 1);
-}
-
-
-
 // ************* GET OTHER CHARGES BASED ON COMPANY *************
 cur_frm.fields_dict.charge.get_query = function(doc) {
 	return 'SELECT DISTINCT `tabSales Taxes and Charges Master`.name FROM \
@@ -430,492 +580,4 @@
 		ORDER BY `tabSales Taxes and Charges Master`.name LIMIT 50';
 }
 
-// ********************* Get Charges ****************************
-cur_frm.cscript.get_charges = function(doc, cdt, cdn, callback) {
-	$c_obj(make_doclist(doc.doctype,doc.name),
-		'get_other_charges',
-		'', 
-		function(r, rt) {
-			cur_frm.cscript.calculate_charges(doc, cdt, cdn);
-			if(callback) callback(doc, cdt, cdn);
-		}, null,null,cur_frm.fields_dict.get_charges.input);
-}
-
-
-// CALCULATION OF TOTAL AMOUNTS
-// ======================================================================================================== 
-cur_frm.cscript.recalc = function(doc, n) {
-	if(!n)n=0;
-	doc = locals[doc.doctype][doc.name];
-	var tname = cur_frm.cscript.tname;
-	var fname = cur_frm.cscript.fname;
-	var sales_team = cur_frm.cscript.sales_team_fname;
-	var other_fname	= cur_frm.cscript.other_fname;
-	
-	if(!flt(doc.conversion_rate)) { 
-		doc.conversion_rate = 1; 
-		refresh_field('conversion_rate'); 
-	}
-	if(!flt(doc.plc_conversion_rate)) { 
-		doc.plc_conversion_rate = 1; 
-		refresh_field('plc_conversion_rate'); 
-	}
-
-	if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n, other_fname); // updates all values in table (i.e. amount, export amount, net total etc.)
-	
-	if(flt(doc.net_total) > 0) {
-		var cl = getchildren('Sales Taxes and Charges', doc.name, other_fname,doc.doctype);
-		for(var i = 0; i<cl.length; i++){
-			cl[i].total_tax_amount = 0;
-			cl[i].total_amount = 0;
-			cl[i].tax_amount = 0;										// this is done to calculate other charges
-			cl[i].total = 0;
-			cl[i].item_wise_tax_detail = "";
-			if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
-				alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
-				validated = false;
-			}
-		}
-		cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
-	}
-	cur_frm.cscript.calc_doc_values(doc, null, null, tname, fname, other_fname); // calculates total amounts
-
-	// ******************* calculate allocated amount of sales person ************************
-	cl = getchildren('Sales Team', doc.name, sales_team);
-	for(var i=0;i<cl.length;i++) {
-		if (cl[i].allocated_percentage) {
-			cl[i].allocated_amount = flt(flt(doc.net_total)*flt(cl[i].allocated_percentage)/100);
-			refresh_field('allocated_amount', cl[i].name, sales_team);
-		}
-	}
-	doc.in_words = '';
-	doc.in_words_export = '';
-	refresh_many(['total_discount_rate','total_discount','net_total','total_commission','grand_total','rounded_total','grand_total_export','rounded_total_export','in_words','in_words_export','other_charges','other_charges_total']);
-	if(cur_frm.cscript.custom_recalc)cur_frm.cscript.custom_recalc(doc);
-}
-
-// ******* Calculation of total amounts of document (item amount + other charges)****************
-cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fname) {
-	doc = locals[doc.doctype][doc.name];
-	var net_total = 0; var other_charges_total = 0;
-	var net_total_incl = 0
-	var cl = getchildren(tname, doc.name, fname);
-	for(var i = 0; i<cl.length; i++){
-		//net_total += flt(cl[i].basic_rate) * flt(cl[i].qty);
-		net_total += flt(cl[i].amount);
-		net_total_incl += flt(cl[i].export_amount);
-	}
-
-	var inclusive_rate = 0
-	var d = getchildren('Sales Taxes and Charges', doc.name, other_fname,doc.doctype);
-	for(var j = 0; j<d.length; j++){
-		other_charges_total += flt(d[j].tax_amount);
-		if(d[j].included_in_print_rate) {
-			inclusive_rate = 1;
-		}
-	}
-
-	if(flt(doc.conversion_rate)>1) {
-		net_total_incl *= flt(doc.conversion_rate);
-	}
-
-	doc.net_total = inclusive_rate ? flt(net_total_incl) : flt(net_total);
-	doc.other_charges_total = roundNumber(flt(other_charges_total), 2);
-	doc.grand_total = roundNumber((flt(net_total) + flt(other_charges_total)), 2);
-	doc.rounded_total = Math.round(doc.grand_total);
-	doc.grand_total_export = roundNumber((flt(doc.grand_total) / flt(doc.conversion_rate)), 2);
-	doc.rounded_total_export = Math.round(doc.grand_total_export);
-	doc.total_commission = flt(flt(net_total) * flt(doc.commission_rate) / 100);
-}
-
-// ******************************* OTHER CHARGES *************************************
-cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
-	doc = locals[doc.doctype][doc.name];
-
-	// Make Display Area
-	cur_frm.fields_dict['other_charges_calculation'].disp_area.innerHTML =
-		'<b style="padding: 8px 0px;">Calculation Details for Taxes and Charges:</b>';
-
-	var cl = getchildren(tname, doc.name, fname);
-	var tax = getchildren('Sales Taxes and Charges', doc.name, other_fname,doc.doctype);
-	
-	// Make display table
-	var otc = make_table(cur_frm.fields_dict['other_charges_calculation'].disp_area,
-		cl.length + 1, tax.length + 1, '90%', [], { border:'1px solid #AAA', padding:'2px' });
-	$y(otc,{marginTop:'8px'});
-
-	var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
-	
-	for(var i=0;i<cl.length;i++) {
-		net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
-		var prev_total = flt(cl[i].amount);
-		if(cl[i].item_tax_rate) {
-			try {
-				var check_tax = JSON.parse(cl[i].item_tax_rate);				//to get in dictionary
-			} catch(exception) {
-				var check_tax = eval('var a='+cl[i].item_tax_rate+';a');        //to get in dictionary
-			}
-		}
-		
-		// Add Item Code in new Row
-		$td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description;
-		
-		//var tax = getchildren('Sales Taxes and Charges', doc.name, other_fname,doc.doctype);
-		var total = net_total;
-		
-		
-		for(var t=0;t<tax.length;t++){
-			var account = tax[t].account_head;
-			$td(otc,0,t+1).innerHTML = account?account:'';
-			//Check For Rate
-			if(cl[i].item_tax_rate && check_tax[account]!=null) {
-				var rate = flt(check_tax[account]);
-			} else {
-				// if particular item doesn't have particular rate it will take other charges rate
-				var rate = flt(tax[t].rate);
-			}
-
-			//Check For Rate and get tax amount
-			var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
-			
-			//enter item_wise_tax_detail i.e. tax rate on each item
-			var item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail(doc, rate, cl, i, tax, t);
-			if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
-			tax[t].total_amount = flt(tax_amount);		 //stores actual tax amount in virtual field
-			tax[t].total_tax_amount = flt(prev_total);			//stores total amount in virtual field
-			tax[t].tax_amount += flt(tax_amount);			 
-			var total_amount = flt(tax[t].tax_amount);
-			total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
-			set_multiple('Sales Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':roundNumber(flt(total_amount), 2), 'total':roundNumber(flt(total)+flt(tax[t].tax_amount), 2)}, other_fname);
-			prev_total += flt(tax[t].total_amount);	 // for previous row total
-			total += flt(tax[t].tax_amount);		 // for adding total to previous amount
-
-			if(tax[t].charge_type == 'Actual')
-				$td(otc,i+1,t+1).innerHTML = format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-			else
-				$td(otc,i+1,t+1).innerHTML = '('+format_number(rate) + '%) ' +format_currency(tax[t].total_amount, erpnext.get_currency(doc.company));
-
-		}
-	}
-	
-	for(var t=0;t<tax.length;t++){
-		tax[t].tax_amount = roundNumber(tax[t].tax_amount, 2);
-	}
-}
-cur_frm.cscript.check_charge_type_and_get_tax_amount = function( doc, tax, t, cl, rate, print_amt) {
-	doc = locals[doc.doctype][doc.name];
-	if (! print_amt) print_amt = 0;
-	var tax_amount = 0;
-	if(tax[t].charge_type == 'Actual') {
-		var value = flt(tax[t].rate) / flt(doc.net_total);	 // this give the ratio in which all items are divided					 
-		return tax_amount = flt(value) * flt(cl.amount);
-	 }	 
-	else if(tax[t].charge_type == 'On Net Total') {
-		if (flt(print_amt) == 1) {
-			doc.excise_rate = flt(rate);
-			doc.total_excise_rate += flt(rate);
-			refresh_field('excise_rate');
-			refresh_field('total_excise_rate');
-			return
-		}
-	return tax_amount = (flt(rate) * flt(cl.amount) / 100);
-	}
-	else if(tax[t].charge_type == 'On Previous Row Amount'){
-		if(flt(print_amt) == 1) {
-			doc.total_excise_rate += flt(flt(doc.excise_rate) * 0.01 * flt(rate));
-			refresh_field('total_excise_rate');
-			return
-		}
-		var row_no = (tax[t].row_id).toString();
-		var row = (row_no).split("+");			// splits the values and stores in an array
-		for(var r = 0;r<row.length;r++){
-			var id = cint(row[r].replace(/^\s+|\s+$/g,""));
-			tax_amount += (flt(rate) * flt(tax[id-1].total_amount) / 100);
-		}
-		var row_id = row_no.indexOf("/");
-		if(row_id != -1) {
-			rate = '';
-			var row = (row_no).split("/");			// splits the values and stores in an array
-			if(row.length>2) alert("You cannot enter more than 2 nos. for division");
-			var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
-			var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
-			tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
-		}
-		return tax_amount
-	}
-	else if(tax[t].charge_type == 'On Previous Row Total') {
-		if(flt(print_amt) == 1) {
-			doc.sales_tax_rate += flt(rate);
-			refresh_field('sales_tax_rate');
-			return
-		}
-		var row = cint(tax[t].row_id);
-		return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
-	}
-}
-
-// ********************** Functions for inclusive value calc ******************************
-cur_frm.cscript.consider_incl_rate = function(doc, other_fname) {
-	var tax_list = getchildren('Sales Taxes and Charges', doc.name, other_fname, doc.doctype);
-	for(var i=0; i<tax_list.length; i++) {
-		if(tax_list[i].included_in_print_rate) {
-			return true;
-		}
-	}
-	return false;
-}
-
-cur_frm.cscript.back_calc_basic_rate = function(doc, tname, fname, child, other_fname) {	
-	var get_item_tax_rate = function(item, tax) {
-		if(item.item_tax_rate) {
-			try {
-				var item_tax = JSON.parse(item.item_tax_rate);
-			} catch(exception) {
-				var item_tax = eval('var a='+item.item_tax_rate+';a');
-			}
-			if(item_tax[tax.account_head]!=null) {
-				return flt(item_tax[tax.account_head]);
-			}
-		}
-	};
-
-	var tax_list = getchildren('Sales Taxes and Charges', doc.name, other_fname, doc.doctype);
-	var total = 1;
-	var temp_tax_list = [];
-	var amt = 0;
-	var item_tax_rate = 0;
-	var rate = 0;
-	for(var i=0; i<tax_list.length; i++) {
-		amt = 0;
-		item_tax_rate = get_item_tax_rate(child, tax_list[i]);
-		rate = item_tax_rate ? item_tax_rate : flt(tax_list[i].rate);
-		if(tax_list[i].included_in_print_rate) {
-			if(tax_list[i].charge_type=='On Net Total') {
-				amt = flt(rate / 100);
-			} else if(tax_list[i].charge_type=='On Previous Row Total') {
-				amt = flt((rate * temp_tax_list[tax_list[i].row_id-1]['total']) / 100);
-			} else if(tax_list[i].charge_type=='On Previous Row Amount') {
-				amt = flt((rate * temp_tax_list[tax_list[i].row_id-1]['amt']) / 100);
-			}
-		}
-		total += flt(amt);
-		temp_tax_list[i] = {
-			amt: amt,
-			total: total
-		};
-	}
-	var basic_rate = (child.export_rate * flt(doc.conversion_rate)) / total;
-	//console.log(temp_tax_list);
-	//console.log('in basic rate back calc');
-	//console.log(basic_rate);
-	return basic_rate;
-}
-
-cur_frm.cscript.included_in_print_rate = function(doc, cdt, cdn) {
-	var tax = locals[cdt][cdn];
-	if(tax.included_in_print_rate==1) { 
-		if(!inList(['On Net Total', 'On Previous Row Total', 'On Previous Row Amount'], tax.charge_type)) {
-			msgprint("'Is this Tax included in Basic Rate?' (i.e. Inclusive Price) is only valid for charges of type: <br /> \
-				* On Net Total <br /> \
-				* On Previous Row Amount <br /> \
-				* On Previous Row Total");
-			tax.included_in_print_rate = 0;
-			refresh_field('included_in_print_rate', tax.name, cur_frm.cscript.other_fname);
-		} 
-		var tax_list = getchildren('Sales Taxes and Charges', doc.name, cur_frm.cscript.other_fname, doc.doctype);
-		cur_frm.cscript.validate_print_rate_option(doc, tax_list, tax.idx-1);
-	}
-}
-
-// ********************** Update values in table ******************************
-cur_frm.cscript.update_fname_table = function(doc , tname , fname , n, other_fname) {
-	doc = locals[doc.doctype][doc.name] 
-	var net_total = 0
-	var cl = getchildren(tname, doc.name, fname);
-	var consider_incl_rate = cur_frm.cscript.consider_incl_rate(doc, other_fname);
-	for(var i=0;i<cl.length;i++) {
-		if(n == 1){
-			if(!consider_incl_rate) {
-				if(flt(cl[i].ref_rate) > 0) {
-					set_multiple(tname, cl[i].name, {
-						'export_rate': flt(flt(cl[i].ref_rate) * (100 - flt(cl[i].adj_rate)) / 100)
-					}, fname);
-				}
-				set_multiple(tname, cl[i].name, {
-					'export_amount': flt(flt(cl[i].qty) * flt(cl[i].export_rate)),
-					'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate)),
-					'amount': roundNumber(flt((flt(cl[i].export_rate) * flt(doc.conversion_rate)) * flt(cl[i].qty)), 2)
-				}, fname);
-				//var base_ref_rate = flt(cl[i].basic_rate) + flt(flt(cl[i].basic_rate) * flt(cl[i].adj_rate) / 100);
-				//set_multiple(tname, cl[i].name, {
-				//	'base_ref_rate': flt(base_ref_rate)
-				//}, fname);
-
-		} else if(consider_incl_rate) {
-			if(flt(cl[i].export_rate) > 0) {
-				// calculate basic rate based on taxes
-				// then calculate and set basic_rate, base_ref_rate, ref_rate, amount, export_amount
-				var ref_rate = flt(cl[i].adj_rate)!=flt(100) ?
-					flt((100 * flt(cl[i].export_rate))/flt(100 - flt(cl[i].adj_rate))) :
-					flt(0)
-				set_multiple(tname, cl[i].name, { 'ref_rate': ref_rate }, fname);
-			} else if((flt(cl[i].ref_rate) > 0) && (flt(cl[i].adj_rate) > 0)) {
-				var export_rate = flt(cl[i].ref_rate) * flt(1 - flt(cl[i].adj_rate / 100));
-				set_multiple(tname, cl[i].name, { 'export_rate': flt(export_rate) }, fname);
-			}
-			//console.log("export_rate: " + cl[i].export_rate);
-
-			var basic_rate = cur_frm.cscript.back_calc_basic_rate(doc, tname, fname, cl[i], other_fname);
-			var base_ref_rate = basic_rate + flt(basic_rate * flt(cl[i].adj_rate) / 100);
-			set_multiple(tname, cl[i].name, {
-				'basic_rate': flt(basic_rate),
-				'amount': roundNumber(flt(basic_rate * flt(cl[i].qty)), 2),
-				'export_amount': flt(flt(cl[i].qty) * flt(cl[i].export_rate)),
-				'base_ref_rate': flt(base_ref_rate)
-			}, fname);
-		}
-		}
-		else if(n == 2){
-			if(flt(cl[i].ref_rate) > 0)
-				set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].basic_rate)	* 100 / (flt(cl[i].ref_rate) * flt(doc.conversion_rate)))}, fname);
-			set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i].basic_rate)), 'export_rate': flt(flt(cl[i].basic_rate) / flt(doc.conversion_rate)), 'export_amount': flt((flt(cl[i].basic_rate) / flt(doc.conversion_rate)) * flt(cl[i].qty)) }, fname);
-		}
-		/*else if(n == 3){
-			set_multiple(tname, cl[i].name, {'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate))}, fname);
-			set_multiple(tname, cl[i].name, {'amount' : flt(flt(cl[i].basic_rate) * flt(cl[i].qty)), 'export_amount': flt(flt(cl[i].export_rate) * flt(cl[i].qty))}, fname);
-			if(cl[i].ref_rate > 0)
-		set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].export_rate) * 100 / flt(cl[i].ref_rate)), 'base_ref_rate': flt(flt(cl[i].ref_rate) * flt(doc.conversion_rate)) }, fname);
-		}*/
-		net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
-	}
-	doc.net_total = net_total;
-	refresh_field('net_total');
-}
-
-cur_frm.cscript.get_item_wise_tax_detail = function( doc, rate, cl, i, tax, t) {
-	doc = locals[doc.doctype][doc.name];
-	var detail = '';
-	detail = cl[i].item_code + " : " + cstr(rate) + NEWLINE;
-	return detail;
-}
-
-// **************** RE-CALCULATE VALUES ***************************
-
-cur_frm.cscript.recalculate_values = function(doc, cdt, cdn) {	
-	cur_frm.cscript.calculate_charges(doc,cdt,cdn);
-}
-
-cur_frm.cscript.validate_print_rate_option = function(doc, taxes, i) {
-	if(in_list(['On Previous Row Amount','On Previous Row Total'], taxes[i].charge_type)) { 
-		if(!taxes[i].row_id){
-			alert("Please Enter Row on which amount needs to be calculated for row : "+taxes[i].idx);
-			validated = false;
-		} else if(taxes[i].included_in_print_rate && taxes[taxes[i].row_id-1].charge_type=='Actual') {
-			msgprint("Row of type 'Actual' cannot be depended on for type '" + taxes[i].charge_type + "'\
-				when using tax inclusive prices.<br />\
-				This will lead to incorrect values.<br /><br /> \
-				<b>Please specify correct value in 'Enter Row' column of <span style='color:red'>Row: "	
-				+ taxes[i].idx + "</span> in Taxes table</b>");
-			validated = false;
-			taxes[i].included_in_print_rate = 0;
-			refresh_field('included_in_print_rate', taxes[i].name, other_fname);
-		} else if ((taxes[i].included_in_print_rate && !taxes[taxes[i].row_id-1].included_in_print_rate) || 
-			(!taxes[i].included_in_print_rate && taxes[taxes[i].row_id-1].included_in_print_rate)) {
-			msgprint("If any row in the tax table depends on 'Previous Row Amount/Total', <br />\
-				'Is this Tax included in Basic Rate?' column should be same for both row <br />\
-				i.e for that row and the previous row. <br /><br />\
-				The same is violated for row #"+(i+1)+" and row #"+taxes[i].row_id
-			);
-			validated = false;
-		}		
-	}
-}
-
-cur_frm.cscript.calculate_charges = function(doc, cdt, cdn) {
-	var other_fname	= cur_frm.cscript.other_fname;
-
-	var cl = getchildren('Sales Taxes and Charges', doc.name, other_fname, doc.doctype);
-	for(var i = 0; i<cl.length; i++){
-		cl[i].total_tax_amount = 0;
-		cl[i].total_amount = 0;
-		cl[i].tax_amount = 0;										// this is done to calculate other charges
-		cl[i].total = 0;
-		cur_frm.cscript.validate_print_rate_option(doc, cl, i);
-	}
-	cur_frm.cscript.recalc(doc, 1);
-}
-
-// Get Sales Partner Commission
-// =================================================================================
-cur_frm.cscript.sales_partner = function(doc, cdt, cdn){
-	if(doc.sales_partner){
-
-		get_server_fields('get_comm_rate', doc.sales_partner, '', doc, cdt, cdn, 1);
-	}
-}
-
-// *******Commission Rate Trigger (calculates total commission amount)*********
-cur_frm.cscript.commission_rate = function(doc, cdt, cdn) {
-	if(doc.commission_rate > 100){
-		alert("Commision rate cannot be greater than 100.");
-		doc.total_commission = 0;
-		doc.commission_rate = 0;
-	} else {
-		doc.total_commission = doc.net_total * doc.commission_rate / 100;
-	}
-	refresh_many(['total_commission','commission_rate']);
-
-}
-
-// *******Total Commission Trigger (calculates commission rate)*********
-cur_frm.cscript.total_commission = function(doc, cdt, cdn) {
-	if(doc.net_total){
-		if(doc.net_total < doc.total_commission){
-			alert("Total commission cannot be greater than net total.");
-			doc.total_commission = 0;
-			doc.commission_rate = 0;
-		} else {
-			doc.commission_rate = doc.total_commission * 100 / doc.net_total;
-		}
-		refresh_many(['total_commission','commission_rate']);
-	}
-}
-// Sales Person Allocated % trigger 
-// ==============================================================================
-cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) {
-	var fname = cur_frm.cscript.sales_team_fname;
-	var d = locals[cdt][cdn];
-	if (d.allocated_percentage) {
-		d.allocated_amount = flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);
-		refresh_field('allocated_amount', d.name, fname);
-	}
-}
-
-// Client Side Validation
-// =================================================================================
-cur_frm.cscript.validate = function(doc, cdt, cdn) {
-	cur_frm.cscript.validate_items(doc);
-	var cl = getchildren('Sales Taxes and Charges Master', doc.name, 'other_charges');
-	for(var i =0;i<cl.length;i++) {
-		if(!cl[i].amount) {
-			alert("Please Enter Amount in Row no. "+cl[i].idx+" in Taxes and Charges table");
-			validated = false;
-		}
-	}
-	cur_frm.cscript.calculate_charges (doc, cdt, cdn);
-
-	if (doc.docstatus == 0 && cur_frm.cscript.calc_adjustment_amount)
-	 	cur_frm.cscript.calc_adjustment_amount(doc);
-}
-
-
-// ************** Atleast one item in document ****************
-cur_frm.cscript.validate_items = function(doc) {
-	var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
-	if(!cl.length){
-		alert("Please enter Items for " + doc.doctype);
-		validated = false;
-	}
-}
-
 cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
\ No newline at end of file
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index 549128f..5068ad3 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -28,23 +28,6 @@
 
 from utilities.transaction_base import TransactionBase
 
-
-@webnotes.whitelist()
-def get_comp_base_currency(arg=None):
-	""" get default currency of company"""
-	res = webnotes.conn.sql("""select default_currency from `tabCompany`
-			where name = %s""", webnotes.form_dict.get('company'))
-	return res and res[0][0] or None
-
-@webnotes.whitelist()
-def get_price_list_currency(arg=None):
-	""" Get all currency in which price list is maintained"""
-	plc = webnotes.conn.sql("select distinct ref_currency from `tabItem Price` where price_list_name = %s", webnotes.form_dict['price_list'])
-	plc = [d[0] for d in plc]
-	base_currency = get_comp_base_currency(webnotes.form_dict['company'])
-	return plc, base_currency
-
-
 class DocType(TransactionBase):
 	def __init__(self,d,dl):
 		self.doc, self.doclist = d,dl
@@ -65,26 +48,6 @@
 
 		self.msg = []
 
-
-	# Get Sales Person Details
-	# ==========================
-	
-	# TODO: To be deprecated if not in use
-	def get_sales_person_details(self, obj):
-		if obj.doc.doctype != 'Quotation':
-			obj.doclist = obj.doc.clear_table(obj.doclist,'sales_team')
-			idx = 0
-			for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
-				ch = addchild(obj.doc, 'sales_team', 'Sales Team', obj.doclist)
-				ch.sales_person = d and cstr(d[0]) or ''
-				ch.allocated_percentage = d and flt(d[1]) or 0
-				ch.allocated_amount = d and flt(d[2]) or 0
-				ch.incentives = d and flt(d[3]) or 0
-				ch.idx = idx
-				idx += 1
-		return obj.doclist
-
-
 	# Get customer's contact person details
 	# ==============================================================
 	def get_contact_details(self, obj = '', primary = 0):
@@ -117,189 +80,7 @@
 		if obj.doc.company:
 			acc_head = webnotes.conn.sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + webnotes.conn.get_value('Company', obj.doc.company, 'abbr')))
 			obj.doc.debit_to = acc_head and acc_head[0][0] or ''
-
-	
-	
-	# Get Item Details
-	# ===============================================================
-	def get_item_details(self, args, obj):
-		import json
-		if not obj.doc.price_list_name:
-			msgprint("Please Select Price List before selecting Items", raise_exception=True)
-		item = webnotes.conn.sql("""select description, item_name, brand, item_group, stock_uom, 
-			default_warehouse, default_income_account, default_sales_cost_center, 
-			purchase_account, description_html, barcode from `tabItem` 
-			where name = %s and (ifnull(end_of_life,'')='' or end_of_life >	now() 
-			or end_of_life = '0000-00-00') and (is_sales_item = 'Yes' 
-			or is_service_item = 'Yes')""", args['item_code'], as_dict=1)
-		
-		tax = webnotes.conn.sql("""select tax_type, tax_rate from `tabItem Tax` 
-			where parent = %s""", args['item_code'])
-		t = {}
-		for x in tax: t[x[0]] = flt(x[1])
-		ret = {
-			'description': item and item[0]['description_html'] or \
-				item[0]['description'],
-			'barcode': item and item[0]['barcode'] or '',
-			'item_group': item and item[0]['item_group'] or '',
-			'item_name': item and item[0]['item_name'] or '',
-			'brand': item and item[0]['brand'] or '',
-			'stock_uom': item and item[0]['stock_uom'] or '',
-			'reserved_warehouse': item and item[0]['default_warehouse'] or '',
-			'warehouse': item and item[0]['default_warehouse'] or \
-				args.get('warehouse'),
-			'income_account': item and item[0]['default_income_account'] or \
-				args.get('income_account'),
-			'expense_account': item and item[0]['purchase_account'] or \
-			 	args.get('expense_account'),
-			'cost_center': item and item[0]['default_sales_cost_center'] or \
-				args.get('cost_center'),
-			# this is done coz if item once fetched is fetched again than its qty shld be reset to 1
-			'qty': 1.00, 
-			'adj_rate': 0,
-			'amount': 0,
-			'export_amount': 0,
-			'item_tax_rate': json.dumps(t),
-			'batch_no': ''
-		}
-		if(obj.doc.price_list_name and item):	#this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST
-			base_ref_rate =	self.get_ref_rate(args['item_code'], obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
-			ret['ref_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-			ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-			ret['base_ref_rate'] = flt(base_ref_rate)
-			ret['basic_rate'] = flt(base_ref_rate)
-		
-		if ret['warehouse'] or ret['reserved_warehouse']:
 			
-			av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
-			ret.update(av_qty)
-			
-		# get customer code for given item from Item Customer Detail
-		customer_item_code_row = webnotes.conn.sql("""\
-			select ref_code from `tabItem Customer Detail`
-			where parent = %s and customer_name = %s""",
-			(args['item_code'], obj.doc.customer))
-		if customer_item_code_row and customer_item_code_row[0][0]:
-			ret['customer_item_code'] = customer_item_code_row[0][0]
-
-		return ret
-
-
-	def get_item_defaults(self, args):
-		item = webnotes.conn.sql("""select default_warehouse, default_income_account, 
-			default_sales_cost_center, purchase_account from `tabItem` where name = %s 
-			and (ifnull(end_of_life,'') = '' or end_of_life > now() or end_of_life = '0000-00-00') 
-			and (is_sales_item = 'Yes' or is_service_item = 'Yes') """, 
-			(args['item_code']), as_dict=1)
-		ret = {
-			'reserved_warehouse': item and item[0]['default_warehouse'] or '',
-			'warehouse': item and item[0]['default_warehouse'] or args.get('warehouse'),
-			'income_account': item and item[0]['default_income_account'] or \
-				args.get('income_account'),
-			'expense_account': item and item[0]['purchase_account'] or args.get('expense_account'),
-			'cost_center': item and item[0]['default_sales_cost_center'] or args.get('cost_center'),
-		}
-
-		return ret
-
-	def get_available_qty(self,args):
-		tot_avail_qty = webnotes.conn.sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
-		ret = {
-			 'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
-			 'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
-		}
-		return ret
-
-	
-	# ***************** Get Ref rate as entered in Item Master ********************
-	def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
-		ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s and selling=1", 
-		(item_code, price_list_name, price_list_currency))
-		base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
-		return base_ref_rate
-
-	def get_barcode_details(self, barcode):
-		item = webnotes.conn.sql("select name, end_of_life, is_sales_item, is_service_item \
-			from `tabItem` where barcode = %s", barcode, as_dict=1)
-		ret = {}
-		if not item:
-			msgprint("""No item found for this barcode: %s. 
-				May be barcode not updated in item master. Please check""" % barcode)
-		elif item[0]['end_of_life'] and getdate(cstr(item[0]['end_of_life'])) < nowdate():
-			msgprint("Item: %s has been expired. Please check 'End of Life' field in item master" % item[0]['name'])
-		elif item[0]['is_sales_item'] == 'No' and item[0]['is_service_item'] == 'No':
-			msgprint("Item: %s is not a sales or service item" % item[0]['name'])
-		elif len(item) > 1:
-			msgprint("There are multiple item for this barcode. \nPlease select item code manually")
-		else:
-			ret = {'item_code': item and item[0]['name'] or ''}
-			
-		return ret
-
-		
-	# ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
-	def get_adj_percent(self, obj): 
-		for d in getlist(obj.doclist, obj.fname):
-			base_ref_rate = self.get_ref_rate(d.item_code, obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
-			d.adj_rate = 0
-			d.ref_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-			d.basic_rate = flt(base_ref_rate)
-			d.base_ref_rate = flt(base_ref_rate)
-			d.export_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-			d.amount = flt(d.qty)*flt(base_ref_rate)
-			d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-
-
-	# Load Default Taxes
-	# ====================
-	def load_default_taxes(self, obj):
-		if cstr(obj.doc.charge):
-			return self.get_other_charges(obj)
-		else:
-			return self.get_other_charges(obj, 1)
-
-		
-	# Get other charges from Master
-	# =================================================================================
-	def get_other_charges(self,obj, default=0):
-		obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
-		if not getlist(obj.doclist, 'other_charges'):
-			if default: add_cond = 'ifnull(t2.is_default,0) = 1'
-			else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
-			idx = 0
-			other_charge = webnotes.conn.sql("""\
-				select t1.*
-				from
-					`tabSales Taxes and Charges` t1,
-					`tabSales Taxes and Charges Master` t2
-				where
-					t1.parent = t2.name and
-					t2.company = '%s' and
-					%s
-				order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
-			from webnotes.model import default_fields
-			for other in other_charge:
-				# remove default fields like parent, parenttype etc.
-				# from query results
-				for field in default_fields:
-					if field in other: del other[field]
-
-				d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
-					obj.doclist)
-				d.fields.update(other)
-				d.rate = flt(d.rate)
-				d.tax_amount = flt(d.tax_rate)
-				d.included_in_print_rate = cint(d.included_in_print_rate)
-				d.idx = idx
-				idx += 1
-		return obj.doclist
-			
-	# Get TERMS AND CONDITIONS
-	# =======================================================================================
-	def get_tc_details(self,obj):
-		r = webnotes.conn.sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name)
-		if r: obj.doc.terms = r[0][0]
-
 #---------------------------------------- Get Tax Details -------------------------------#
 	def get_tax_details(self, item_code, obj):
 		import json
@@ -329,23 +110,6 @@
 		}
 		return ret
 		
-	# Get Commission rate
-	# =======================================================================
-	def get_comm_rate(self, sales_partner, obj):
-
-		comm_rate = webnotes.conn.sql("select commission_rate from `tabSales Partner` where name = '%s' and docstatus != 2" %(sales_partner), as_dict=1)
-		if comm_rate:
-			total_comm = flt(comm_rate[0]['commission_rate']) * flt(obj.doc.net_total) / 100
-			ret = {
-				'commission_rate'		 :	comm_rate and flt(comm_rate[0]['commission_rate']) or 0,
-				'total_commission'		:	flt(total_comm)
-			}
-			return ret
-		else:
-			msgprint("Business Associate : %s does not exist in the system." % (sales_partner))
-			raise Exception
-
-	
 	# To verify whether rate entered in details table does not exceed max discount %
 	# =======================================================================================
 	def validate_max_discount(self,obj, detail_table):
@@ -354,16 +118,6 @@
 			if discount and discount[0]['max_discount'] and (flt(d.adj_rate)>flt(discount[0]['max_discount'])):
 				msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
 				raise Exception
-
-
-	# Get sum of allocated % of sales person (it should be 100%)
-	# ========================================================================
-	# it indicates % contribution of sales person in sales
-	def get_allocated_sum(self,obj):
-		sales_team_list = obj.doclist.get({"parentfield": "sales_team"})
-		total_allocation = sum([flt(d.allocated_percentage) for d in sales_team_list])
-		if sales_team_list and total_allocation != 100.0:
-			msgprint("Total Allocated % of Sales Persons should be 100%", raise_exception=True)
 			
 	# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
 	# ===========================================================================
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index b792754..ded9c44 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -26,105 +26,54 @@
 wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
 
-
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-	cur_frm.cscript.manage_rounded_total();
-	
-	if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
-	if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
-	if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
-	// load default charges
-	
-	if(doc.__islocal && !doc.customer){
-		hide_field(['customer_address','contact_person', 'customer_name', 
-			'address_display', 'contact_display', 'contact_mobile', 
-			'contact_email', 'territory',  'customer_group']);
-	}
-}
-
-cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
-	var callback = function(doc, cdt, cdn) {
-		if(doc.__islocal) {
-			// defined in sales_common.js
-			cur_frm.cscript.update_item_details(doc, cdt, cdn);
-		}
-	}
-	
-	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); 
-
-}
-
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-	cur_frm.clear_custom_buttons();
-	erpnext.hide_naming_series();
-
-	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
-	
-	cur_frm.toggle_display("contact_info", doc.customer);
-	
-	if(doc.docstatus==1) {
-		if(doc.status != 'Stopped') {
-			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
-			// delivery note
-			if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
-				cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
+erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
+	refresh: function(doc, dt, dn) {
+		this._super();
+		
+		if(doc.docstatus==1) {
+			if(doc.status != 'Stopped') {
+				cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
+				// delivery note
+				if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
+					cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
 			
-			// maintenance
-			if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
-				cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
-				cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
+				// maintenance
+				if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
+					cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
+					cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
+				}
+
+				// indent
+				if(!doc.order_type || (doc.order_type == 'Sales'))
+					cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
+			
+				// sales invoice
+				if(flt(doc.per_billed, 2) < 100)
+					cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
+			
+				// stop
+				if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
+					cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
+			} else {	
+				// un-stop
+				cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
 			}
-
-			// indent
-			if(!doc.order_type || (doc.order_type == 'Sales'))
-				cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
-			
-			// sales invoice
-			if(flt(doc.per_billed, 2) < 100)
-				cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
-			
-			// stop
-			if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
-				cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
-		} else {	
-			// un-stop
-			cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
 		}
-	}
 	
-	cur_frm.cscript.order_type(doc);
-}
-
-cur_frm.cscript.order_type = function(doc) {
-	if(doc.order_type == "Sales") {
-		cur_frm.toggle_reqd("delivery_date", 1);
-	} else {
-		cur_frm.toggle_reqd("delivery_date", 0);
-	}
-}
-
-//customer
-cur_frm.cscript.customer = function(doc,dt,dn) {
-	cur_frm.toggle_display("contact_info", doc.customer);
+		this.order_type(doc);
+	},
 	
-	var pl = doc.price_list_name;
-	var callback = function(r,rt) {
-		var callback2  = function(r, rt) {
-			if(doc.customer) 
-				unhide_field(['customer_address', 'contact_person', 'territory','customer_group']);
-			cur_frm.refresh();
-			
-			if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn);
+	order_type: function() {
+		this.frm.toggle_reqd("delivery_date", this.frm.doc.order_type == "Sales");
+	},
+	
+	reserved_warehouse: function(doc, cdt, cdn) {
+		this.warehouse(doc, cdt, cdn);
+	},
+});
 
-		}
-		var doc = locals[cur_frm.doctype][cur_frm.docname];
-		get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0, callback2);
-			
-	}	 
-	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 
-		'get_default_customer_address', '', callback);
-}
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
 
 cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
 	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -180,15 +129,6 @@
 			ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
 }
 
-
-cur_frm.cscript.reserved_warehouse = function(doc, cdt , cdn) {
-	var d = locals[cdt][cdn];
-	if (d.reserved_warehouse) {
-		arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.reserved_warehouse +"'}";
-		get_server_fields('get_available_qty',arg,'sales_order_details',doc,cdt,cdn,1);
-	}
-}
-
 //----------- make maintenance schedule----------
 cur_frm.cscript['Make Maintenance Schedule'] = function() {
 	var doc = cur_frm.doc;
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index c8db1f9..70d209b 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -58,22 +58,6 @@
 	def get_comm_rate(self, sales_partner):
 		return get_obj('Sales Common').get_comm_rate(sales_partner, self)
 
-	def get_item_details(self, args=None):
-		import json
-		args = args and json.loads(args) or {}
-		if args.get('item_code'):
-			return get_obj('Sales Common').get_item_details(args, self)
-		else:
-			obj = get_obj('Sales Common')
-			for doc in self.doclist:
-				if doc.fields.get('item_code'):
-					arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 
-						'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
-					ret = obj.get_item_defaults(arg)
-					for r in ret:
-						if not doc.fields.get(r):
-							doc.fields[r] = ret[r]					
-
 	def get_adj_percent(self, arg=''):
 		get_obj('Sales Common').get_adj_percent(self)
 
@@ -83,15 +67,6 @@
 	def get_rate(self,arg):
 		return get_obj('Sales Common').get_rate(arg)
 
-	def load_default_taxes(self):
-		self.doclist = get_obj('Sales Common').load_default_taxes(self)
-
-	def get_other_charges(self):
-		self.doclist = get_obj('Sales Common').get_other_charges(self)
- 
-	def get_tc_details(self):
-		return get_obj('Sales Common').get_tc_details(self)
-
 	def check_maintenance_schedule(self):
 		nm = sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", self.doc.name)
 		nm = nm and nm[0][0] or ''
@@ -194,6 +169,8 @@
 						and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
 
 	def validate_order_type(self):
+		super(DocType, self).validate_order_type()
+		
 		#validate delivery date
 		if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
 			msgprint("Please enter 'Expected Delivery Date'")
@@ -226,7 +203,6 @@
 		sales_com_obj.check_conversion_rate(self)
 
 		sales_com_obj.validate_max_discount(self,'sales_order_details')
-		sales_com_obj.get_allocated_sum(self)
 		self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
 		
 		if not self.doc.status:
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index ba0b1de..02ffae7 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-07 14:48:34", 
+  "creation": "2013-05-24 19:29:08", 
   "docstatus": 0, 
-  "modified": "2013-01-29 17:14:58", 
+  "modified": "2013-06-05 18:59:41", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -32,6 +32,7 @@
   "parent": "Sales Order", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
+  "permlevel": 0, 
   "read": 1
  }, 
  {
@@ -76,42 +77,47 @@
   "search_index": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "customer_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Name", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -137,6 +143,34 @@
   "width": "50%"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "amended_from", 
+  "fieldtype": "Data", 
+  "hidden": 1, 
+  "label": "Amended From", 
+  "no_copy": 1, 
+  "oldfieldname": "amended_from", 
+  "oldfieldtype": "Data", 
+  "print_hide": 1, 
+  "read_only": 1, 
+  "width": "150px"
+ }, 
+ {
+  "description": "Select the relevant company name if you have multiple companies.", 
+  "doctype": "DocField", 
+  "fieldname": "company", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Company", 
+  "oldfieldname": "company", 
+  "oldfieldtype": "Link", 
+  "options": "Company", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "search_index": 1, 
+  "width": "150px"
+ }, 
+ {
   "default": "Today", 
   "description": "The date at which current entry is made in system.", 
   "doctype": "DocField", 
@@ -216,6 +250,76 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "sec_break45", 
+  "fieldtype": "Section Break", 
+  "label": "Price List and Currency"
+ }, 
+ {
+  "description": "Customer's currency", 
+  "doctype": "DocField", 
+  "fieldname": "currency", 
+  "fieldtype": "Link", 
+  "label": "Currency", 
+  "oldfieldname": "currency", 
+  "oldfieldtype": "Select", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "width": "100px"
+ }, 
+ {
+  "default": "1.00", 
+  "description": "Rate at which customer's currency is converted to company's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Conversion Rate", 
+  "oldfieldname": "conversion_rate", 
+  "oldfieldtype": "Currency", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "width": "100px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break2", 
+  "fieldtype": "Column Break", 
+  "width": "50%"
+ }, 
+ {
+  "description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.", 
+  "doctype": "DocField", 
+  "fieldname": "price_list_name", 
+  "fieldtype": "Select", 
+  "label": "Price List", 
+  "oldfieldname": "price_list_name", 
+  "oldfieldtype": "Select", 
+  "options": "link:Price List", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "width": "100px"
+ }, 
+ {
+  "description": "Select the currency in which price list is maintained", 
+  "doctype": "DocField", 
+  "fieldname": "price_list_currency", 
+  "fieldtype": "Link", 
+  "label": "Price List Currency", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "reqd": 1
+ }, 
+ {
+  "description": "Rate at which Price list currency is converted to company's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "plc_conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Price List Currency Conversion Rate", 
+  "print_hide": 1, 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "items", 
   "fieldtype": "Section Break", 
   "label": "Items", 
@@ -230,7 +334,29 @@
   "oldfieldname": "sales_order_details", 
   "oldfieldtype": "Table", 
   "options": "Sales Order Item", 
-  "print_hide": 0
+  "print_hide": 0, 
+  "reqd": 1
+ }, 
+ {
+  "description": "Display all the individual items delivered with the main items", 
+  "doctype": "DocField", 
+  "fieldname": "packing_list", 
+  "fieldtype": "Section Break", 
+  "hidden": 0, 
+  "label": "Packing List", 
+  "oldfieldtype": "Section Break", 
+  "print_hide": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "packing_details", 
+  "fieldtype": "Table", 
+  "label": "Packing Details", 
+  "oldfieldname": "packing_details", 
+  "oldfieldtype": "Table", 
+  "options": "Delivery Note Packing Item", 
+  "print_hide": 1, 
+  "read_only": 1
  }, 
  {
   "doctype": "DocField", 
@@ -238,40 +364,6 @@
   "fieldtype": "Section Break"
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "col_break20", 
-  "fieldtype": "Column Break", 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "net_total", 
-  "fieldtype": "Currency", 
-  "label": "Net Total*", 
-  "oldfieldname": "net_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "recalculate_values", 
-  "fieldtype": "Button", 
-  "label": "Re-Calculate Values", 
-  "oldfieldtype": "Button", 
-  "print_hide": 1, 
-  "search_index": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break_21", 
-  "fieldtype": "Column Break", 
-  "width": "50%"
- }, 
- {
   "description": "Quotation no against which this Sales Order is made ", 
   "doctype": "DocField", 
   "fieldname": "quotation_no", 
@@ -312,73 +404,39 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "sec_break45", 
-  "fieldtype": "Section Break", 
-  "label": "Price List and Currency"
- }, 
- {
-  "description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.", 
-  "doctype": "DocField", 
-  "fieldname": "price_list_name", 
-  "fieldtype": "Select", 
-  "label": "Price List", 
-  "oldfieldname": "price_list_name", 
-  "oldfieldtype": "Select", 
-  "options": "link:Price List", 
-  "print_hide": 1, 
-  "reqd": 1, 
-  "width": "100px"
- }, 
- {
-  "description": "Select the currency in which price list is maintained", 
-  "doctype": "DocField", 
-  "fieldname": "price_list_currency", 
-  "fieldtype": "Link", 
-  "label": "Price List Currency", 
-  "options": "Currency", 
-  "print_hide": 1, 
-  "reqd": 1
- }, 
- {
-  "description": "Rate at which Price list currency is converted to company's base currency", 
-  "doctype": "DocField", 
-  "fieldname": "plc_conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Price List Currency Conversion Rate", 
-  "print_hide": 1, 
-  "reqd": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "column_break2", 
+  "fieldname": "col_break20", 
   "fieldtype": "Column Break", 
   "width": "50%"
  }, 
  {
-  "description": "Customer's currency", 
   "doctype": "DocField", 
-  "fieldname": "currency", 
-  "fieldtype": "Link", 
-  "label": "Currency", 
-  "oldfieldname": "currency", 
-  "oldfieldtype": "Select", 
-  "options": "Currency", 
-  "print_hide": 1, 
-  "reqd": 1, 
-  "width": "100px"
+  "fieldname": "net_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Net Total (Export)", 
+  "options": "currency", 
+  "read_only": 1
  }, 
  {
-  "default": "1.00", 
-  "description": "Rate at which customer's currency is converted to company's base currency", 
   "doctype": "DocField", 
-  "fieldname": "conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Conversion Rate", 
-  "oldfieldname": "conversion_rate", 
+  "fieldname": "net_total", 
+  "fieldtype": "Currency", 
+  "label": "Net Total*", 
+  "oldfieldname": "net_total", 
   "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
   "print_hide": 1, 
-  "reqd": 1, 
-  "width": "100px"
+  "read_only": 1, 
+  "reqd": 0, 
+  "width": "150px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "recalculate_values", 
+  "fieldtype": "Button", 
+  "label": "Re-Calculate Values", 
+  "oldfieldtype": "Button", 
+  "print_hide": 1, 
+  "search_index": 0
  }, 
  {
   "doctype": "DocField", 
@@ -400,6 +458,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_38", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_charges", 
   "fieldtype": "Button", 
   "label": "Get Taxes and Charges", 
@@ -407,6 +470,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_40", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges", 
   "fieldtype": "Table", 
   "label": "Sales Taxes and Charges", 
@@ -416,17 +484,31 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "calculate_charges", 
-  "fieldtype": "Button", 
-  "label": "Calculate Taxes and Charges", 
-  "oldfieldtype": "Button", 
+  "fieldname": "other_charges_calculation", 
+  "fieldtype": "HTML", 
+  "label": "Taxes and Charges Calculation", 
+  "oldfieldtype": "HTML", 
   "print_hide": 0
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_43", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "other_charges_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Taxes and Charges Total (Export)", 
+  "options": "currency", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges_total", 
   "fieldtype": "Currency", 
-  "label": "Taxes and Charges Total*", 
+  "label": "Taxes and Charges Total", 
   "oldfieldname": "other_charges_total", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
@@ -436,10 +518,15 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "other_charges_calculation", 
-  "fieldtype": "HTML", 
-  "label": "Taxes and Charges Calculation", 
-  "oldfieldtype": "HTML", 
+  "fieldname": "column_break_46", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "calculate_charges", 
+  "fieldtype": "Button", 
+  "label": "Calculate Taxes and Charges", 
+  "oldfieldtype": "Button", 
   "print_hide": 0
  }, 
  {
@@ -452,6 +539,50 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "grand_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Grand Total (Export)", 
+  "oldfieldname": "grand_total_export", 
+  "oldfieldtype": "Currency", 
+  "options": "currency", 
+  "print_hide": 0, 
+  "read_only": 1, 
+  "reqd": 0, 
+  "width": "150px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rounded_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Rounded Total (Export)", 
+  "oldfieldname": "rounded_total_export", 
+  "oldfieldtype": "Currency", 
+  "options": "currency", 
+  "print_hide": 0, 
+  "read_only": 1, 
+  "width": "150px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "in_words_export", 
+  "fieldtype": "Data", 
+  "label": "In Words (Export)", 
+  "oldfieldname": "in_words_export", 
+  "oldfieldtype": "Data", 
+  "print_hide": 0, 
+  "read_only": 1, 
+  "width": "200px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break3", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
+  "print_hide": 1, 
+  "width": "50%"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "grand_total", 
   "fieldtype": "Currency", 
   "label": "Grand Total*", 
@@ -489,50 +620,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break3", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "print_hide": 1, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "grand_total_export", 
-  "fieldtype": "Currency", 
-  "label": "Grand Total (Export)", 
-  "oldfieldname": "grand_total_export", 
-  "oldfieldtype": "Currency", 
-  "options": "currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "rounded_total_export", 
-  "fieldtype": "Currency", 
-  "label": "Rounded Total (Export)", 
-  "oldfieldname": "rounded_total_export", 
-  "oldfieldtype": "Currency", 
-  "options": "currency", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "in_words_export", 
-  "fieldtype": "Data", 
-  "label": "In Words (Export)", 
-  "oldfieldname": "in_words_export", 
-  "oldfieldtype": "Data", 
-  "print_hide": 0, 
-  "read_only": 1, 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "terms_section_break", 
   "fieldtype": "Section Break", 
   "label": "Terms and Conditions", 
@@ -552,21 +639,21 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_58", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
   "oldfieldtype": "Button", 
-  "options": "get_tc_details", 
   "print_hide": 1
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1
+  "fieldname": "section_break_60", 
+  "fieldtype": "Section Break"
  }, 
  {
   "doctype": "DocField", 
@@ -578,6 +665,7 @@
   "print_hide": 0
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_info", 
   "fieldtype": "Section Break", 
@@ -591,6 +679,35 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "territory", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Territory", 
+  "options": "Territory", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "search_index": 1
+ }, 
+ {
+  "description": "Category of customer as entered in Customer master", 
+  "doctype": "DocField", 
+  "fieldname": "customer_group", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Customer Group", 
+  "options": "Customer Group", 
+  "print_hide": 1, 
+  "reqd": 1, 
+  "search_index": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "col_break46", 
+  "fieldtype": "Column Break", 
+  "width": "50%"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "customer_address", 
   "fieldtype": "Link", 
   "hidden": 0, 
@@ -609,35 +726,6 @@
   "print_hide": 1
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "territory", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Territory", 
-  "options": "Territory", 
-  "print_hide": 1, 
-  "reqd": 1, 
-  "search_index": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break46", 
-  "fieldtype": "Column Break", 
-  "width": "50%"
- }, 
- {
-  "description": "Category of customer as entered in Customer master", 
-  "doctype": "DocField", 
-  "fieldname": "customer_group", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Customer Group", 
-  "options": "Customer Group", 
-  "print_hide": 1, 
-  "reqd": 1, 
-  "search_index": 1
- }, 
- {
   "description": "Filling in additional information about the Sales Order will help you analyze your data better.", 
   "doctype": "DocField", 
   "fieldname": "more_info", 
@@ -647,6 +735,39 @@
   "print_hide": 1
  }, 
  {
+  "description": "Track this Sales Order against any Project", 
+  "doctype": "DocField", 
+  "fieldname": "project_name", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Project Name", 
+  "oldfieldname": "project_name", 
+  "oldfieldtype": "Link", 
+  "options": "Project", 
+  "search_index": 1
+ }, 
+ {
+  "depends_on": "eval:doc.source == 'Campaign'", 
+  "doctype": "DocField", 
+  "fieldname": "campaign", 
+  "fieldtype": "Link", 
+  "label": "Campaign", 
+  "oldfieldname": "campaign", 
+  "oldfieldtype": "Link", 
+  "options": "Campaign", 
+  "print_hide": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "source", 
+  "fieldtype": "Select", 
+  "label": "Source", 
+  "oldfieldname": "source", 
+  "oldfieldtype": "Select", 
+  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
+  "print_hide": 1
+ }, 
+ {
   "doctype": "DocField", 
   "fieldname": "column_break4", 
   "fieldtype": "Column Break", 
@@ -679,58 +800,6 @@
   "report_hide": 1
  }, 
  {
-  "depends_on": "eval:doc.source == 'Campaign'", 
-  "doctype": "DocField", 
-  "fieldname": "campaign", 
-  "fieldtype": "Link", 
-  "label": "Campaign", 
-  "oldfieldname": "campaign", 
-  "oldfieldtype": "Link", 
-  "options": "Campaign", 
-  "print_hide": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "amended_from", 
-  "fieldtype": "Data", 
-  "hidden": 1, 
-  "label": "Amended From", 
-  "no_copy": 1, 
-  "oldfieldname": "amended_from", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1, 
-  "width": "150px"
- }, 
- {
-  "description": "The date at which current entry is corrected in the system.", 
-  "doctype": "DocField", 
-  "fieldname": "amendment_date", 
-  "fieldtype": "Date", 
-  "hidden": 1, 
-  "label": "Amendment Date", 
-  "no_copy": 1, 
-  "oldfieldname": "amendment_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "width": "100px"
- }, 
- {
-  "description": "Select the relevant company name if you have multiple companies.", 
-  "doctype": "DocField", 
-  "fieldname": "company", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Company", 
-  "oldfieldname": "company", 
-  "oldfieldtype": "Link", 
-  "options": "Company", 
-  "print_hide": 1, 
-  "reqd": 1, 
-  "search_index": 1, 
-  "width": "150px"
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "fiscal_year", 
   "fieldtype": "Select", 
@@ -745,48 +814,14 @@
   "width": "150px"
  }, 
  {
-  "depends_on": "eval:!doc.__islocal", 
   "doctype": "DocField", 
-  "fieldname": "cancel_reason", 
-  "fieldtype": "Data", 
-  "label": "Cancel Reason", 
-  "no_copy": 1, 
-  "oldfieldname": "cancel_reason", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "column_break5", 
-  "fieldtype": "Column Break", 
+  "fieldname": "section_break_78", 
+  "fieldtype": "Section Break", 
   "oldfieldtype": "Column Break", 
   "print_hide": 1, 
   "width": "50%"
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "source", 
-  "fieldtype": "Select", 
-  "label": "Source", 
-  "oldfieldname": "source", 
-  "oldfieldtype": "Select", 
-  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
-  "print_hide": 1
- }, 
- {
-  "description": "Track this Sales Order against any Project", 
-  "doctype": "DocField", 
-  "fieldname": "project_name", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Project Name", 
-  "oldfieldname": "project_name", 
-  "oldfieldtype": "Link", 
-  "options": "Project", 
-  "search_index": 1
- }, 
- {
   "default": "Draft", 
   "doctype": "DocField", 
   "fieldname": "status", 
@@ -805,6 +840,16 @@
   "width": "100px"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "delivery_status", 
+  "fieldtype": "Select", 
+  "hidden": 1, 
+  "label": "Delivery Status", 
+  "no_copy": 1, 
+  "options": "Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable", 
+  "print_hide": 1
+ }, 
+ {
   "depends_on": "eval:!doc.__islocal", 
   "description": "% of materials delivered against this Sales Order", 
   "doctype": "DocField", 
@@ -821,6 +866,11 @@
   "width": "100px"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "column_break_81", 
+  "fieldtype": "Column Break"
+ }, 
+ {
   "depends_on": "eval:!doc.__islocal", 
   "description": "% of materials billed against this Sales Order", 
   "doctype": "DocField", 
@@ -838,16 +888,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "delivery_status", 
-  "fieldtype": "Select", 
-  "hidden": 1, 
-  "label": "Delivery Status", 
-  "no_copy": 1, 
-  "options": "Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable", 
-  "print_hide": 1
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "billing_status", 
   "fieldtype": "Select", 
   "hidden": 1, 
@@ -857,27 +897,6 @@
   "print_hide": 1
  }, 
  {
-  "description": "Display all the individual items delivered with the main items", 
-  "doctype": "DocField", 
-  "fieldname": "packing_list", 
-  "fieldtype": "Section Break", 
-  "hidden": 0, 
-  "label": "Packing List", 
-  "oldfieldtype": "Section Break", 
-  "print_hide": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "packing_details", 
-  "fieldtype": "Table", 
-  "label": "Packing Details", 
-  "oldfieldname": "packing_details", 
-  "oldfieldtype": "Table", 
-  "options": "Delivery Note Packing Item", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "sales_team_section_break", 
   "fieldtype": "Section Break", 
@@ -886,13 +905,6 @@
   "print_hide": 1
  }, 
  {
-  "doctype": "DocField", 
-  "fieldname": "column_break6", 
-  "fieldtype": "Column Break", 
-  "print_hide": 1, 
-  "width": "50%"
- }, 
- {
   "description": "Name as entered in Sales Partner master", 
   "doctype": "DocField", 
   "fieldname": "sales_partner", 
@@ -951,23 +963,10 @@
   "print_hide": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Sales Manager", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
   "report": 1, 
   "role": "Sales Manager", 
   "submit": 1, 
@@ -978,76 +977,38 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 0, 
   "report": 1, 
   "role": "Sales User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Sales User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
   "report": 1, 
   "role": "Maintenance Manager", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "role": "Maintenance Manager", 
-  "submit": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
   "report": 1, 
   "role": "Maintenance User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "role": "Maintenance User", 
-  "submit": 0
- }, 
- {
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
   "role": "Accounts User"
  }, 
  {
   "doctype": "DocPerm", 
   "match": "customer", 
-  "permlevel": 0, 
   "role": "Customer"
  }
 ]
\ No newline at end of file
diff --git a/selling/doctype/sales_order_item/sales_order_item.txt b/selling/doctype/sales_order_item/sales_order_item.txt
index c65ac0d..7276fc3 100644
--- a/selling/doctype/sales_order_item/sales_order_item.txt
+++ b/selling/doctype/sales_order_item/sales_order_item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 11:42:58", 
   "docstatus": 0, 
-  "modified": "2013-05-22 12:09:03", 
+  "modified": "2013-05-22 12:10:03", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -113,7 +113,7 @@
   "options": "currency", 
   "print_hide": 1, 
   "print_width": "70px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "70px"
  }, 
@@ -183,7 +183,7 @@
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "100px"
  }, 
diff --git a/selling/doctype/sales_team/sales_team.txt b/selling/doctype/sales_team/sales_team.txt
index add466c..29a951e 100644
--- a/selling/doctype/sales_team/sales_team.txt
+++ b/selling/doctype/sales_team/sales_team.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-02-22 01:27:53", 
+  "creation": "2013-04-19 13:30:51", 
   "docstatus": 0, 
-  "modified": "2013-03-07 07:03:31", 
+  "modified": "2013-05-21 17:04:45", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -42,6 +42,7 @@
   "doctype": "DocField", 
   "fieldname": "sales_designation", 
   "fieldtype": "Data", 
+  "hidden": 0, 
   "label": "Designation", 
   "oldfieldname": "sales_designation", 
   "oldfieldtype": "Data", 
@@ -63,7 +64,7 @@
   "doctype": "DocField", 
   "fieldname": "allocated_percentage", 
   "fieldtype": "Float", 
-  "label": "Allocated (%)", 
+  "label": "Contribution (%)", 
   "oldfieldname": "allocated_percentage", 
   "oldfieldtype": "Currency", 
   "print_width": "100px", 
@@ -74,11 +75,12 @@
   "doctype": "DocField", 
   "fieldname": "allocated_amount", 
   "fieldtype": "Currency", 
-  "label": "Allocated Amount", 
+  "label": "Contribution to Net Total", 
   "oldfieldname": "allocated_amount", 
   "oldfieldtype": "Currency", 
   "options": "Company:company:default_currency", 
   "print_width": "120px", 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "120px"
  }, 
diff --git a/selling/page/sales_analytics/sales_analytics.js b/selling/page/sales_analytics/sales_analytics.js
index 0b35af5..7fdc3ac 100644
--- a/selling/page/sales_analytics/sales_analytics.js
+++ b/selling/page/sales_analytics/sales_analytics.js
@@ -23,7 +23,7 @@
 	new erpnext.SalesAnalytics(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Selling")
+	wrapper.appframe.add_module_icon("Selling")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/selling/page/sales_browser/sales_browser.html b/selling/page/sales_browser/sales_browser.html
deleted file mode 100644
index 4683a07..0000000
--- a/selling/page/sales_browser/sales_browser.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
-	<div class="appframe-area"></div>
-	<div class="layout-main-section">
-		<div class="tree-area"></div>
-	</div>
-	<div class="layout-side-section">
-		<div class="help">To add child nodes, explore tree and click on the node under which you want to add more nodes.
-		</div>
-	</div>
-	<div class="clear"></div>
-</div>
\ No newline at end of file
diff --git a/selling/page/sales_browser/sales_browser.js b/selling/page/sales_browser/sales_browser.js
index 4622f24..ed13f9d 100644
--- a/selling/page/sales_browser/sales_browser.js
+++ b/selling/page/sales_browser/sales_browser.js
@@ -15,14 +15,22 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 pscript['onload_Sales Browser'] = function(wrapper){
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
-	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Selling")
+	wn.ui.make_app_page({
+		parent: wrapper,
+	})
+	
+	wrapper.appframe.add_module_icon("Selling")
 	
 	wrapper.appframe.add_button('Refresh', function() {  
 			wrapper.make_tree();
 		}, 'icon-refresh');
 
+
+	$(wrapper)
+		.find(".layout-side-section")
+		.html('<div class="text-muted">Click on a link to get options to expand \
+		 	get options Add / Edit / Delete.</div>')
+
 	wrapper.make_tree = function() {
 		var ctype = wn.get_route()[1] || 'Territory';
 		wn.call({
@@ -30,7 +38,13 @@
 			args: {ctype: ctype},
 			callback: function(r) {
 				var root = r.message[0]["value"];
-				erpnext.sales_chart = new erpnext.SalesChart(ctype, root, wrapper);
+				erpnext.sales_chart = new erpnext.SalesChart(ctype, root, 
+					$(wrapper)
+						.find(".layout-main-section")
+						.css({
+							"min-height": "300px",
+							"padding-bottom": "25px"
+						}));
 			}
 		});
 	}
@@ -50,12 +64,12 @@
 };
 
 erpnext.SalesChart = Class.extend({
-	init: function(ctype, root, wrapper) {
-		$(wrapper).find('.tree-area').empty();
+	init: function(ctype, root, parent) {
+		$(parent).empty();
 		var me = this;
 		me.ctype = ctype;
 		this.tree = new wn.ui.Tree({
-			parent: $(wrapper).find('.tree-area'), 
+			parent: $(parent), 
 			label: root,
 			args: {ctype: ctype},
 			method: 'selling.page.sales_browser.sales_browser.get_children',
diff --git a/selling/utils.py b/selling/utils.py
index 21e94f7..6901028 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -16,6 +16,9 @@
 
 from __future__ import unicode_literals
 import webnotes
+from webnotes import msgprint, _
+from webnotes.utils import flt, cint, comma_and
+import json
 
 def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
 	if webnotes.conn.get_default("cust_master_name") == "Customer Name":
@@ -29,4 +32,149 @@
 		case when customer_name like %s then 0 else 1 end,
 		name, customer_name limit %s, %s""" % 
 		(", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"), 
-		("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
\ No newline at end of file
+		("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
+		
+@webnotes.whitelist()
+def get_item_details(args):
+	"""
+		args = {
+			"item_code": "",
+			"warehouse": None,
+			"customer": "",
+			"conversion_rate": 1.0,
+			"price_list_name": None,
+			"price_list_currency": None,
+			"plc_conversion_rate": 1.0
+		}
+	"""
+	if isinstance(args, basestring):
+		args = json.loads(args)
+	args = webnotes._dict(args)
+	
+	if args.barcode:
+		args.item_code = _get_item_code(args.barcode)
+	
+	item_bean = webnotes.bean("Item", args.item_code)
+	
+	_validate_item_details(args, item_bean.doc)
+	
+	out = _get_basic_details(args, item_bean)
+	
+	meta = webnotes.get_doctype(args.doctype)
+	if meta.get_field("currency"):
+		out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
+		
+		if args.price_list_name and args.price_list_currency:
+			out.update(_get_price_list_rate(args, item_bean, meta))
+	
+	if out.warehouse or out.reserved_warehouse:
+		out.update(get_available_qty(args.item_code, out.warehouse or out.reserved_warehouse))
+	
+	out.customer_item_code = _get_customer_item_code(args, item_bean)
+	
+	if cint(args.is_pos):
+		pos_settings = get_pos_settings(args.company)
+		out.update(apply_pos_settings(pos_settings, out))
+	
+	return out
+	
+def _get_item_code(barcode):
+	item_code = webnotes.conn.sql_list("""select name from `tabItem` where barcode=%s""", barcode)
+			
+	if not item_code:
+		msgprint(_("No Item found with Barcode") + ": %s" % barcode, raise_exception=True)
+	
+	elif len(item_code) > 1:
+		msgprint(_("Items") + " %s " % comma_and(item_code) + 
+			_("have the same Barcode") + " %s" % barcode, raise_exception=True)
+	
+	return item_code[0]
+	
+def _validate_item_details(args, item):
+	from utilities.transaction_base import validate_item_fetch
+	validate_item_fetch(args, item)
+	
+	# validate if sales item or service item
+	if args.order_type == "Maintenance":
+		if item.is_service_item != "Yes":
+			msgprint(_("Item") + (" %s: " % item.name) + 
+				_("not a service item.") +
+				_("Please select a service item or change the order type to Sales."), 
+				raise_exception=True)
+		
+	elif item.is_sales_item != "Yes":
+		msgprint(_("Item") + (" %s: " % item.name) + _("not a sales item"),
+			raise_exception=True)
+			
+def _get_basic_details(args, item_bean):
+	item = item_bean.doc
+	out = webnotes._dict({
+			"item_code": item.name,
+			"description": item.description_html or item.description,
+			"reserved_warehouse": item.default_warehouse,
+			"warehouse": item.default_warehouse or args.warehouse,
+			"income_account": item.default_income_account or args.income_account,
+			"expense_account": item.purchase_account or args.expense_account,
+			"cost_center": item.default_sales_cost_center or args.cost_center,
+			"qty": 1.0,
+			"adj_rate": 0.0,
+			"export_amount": 0.0,
+			"amount": 0.0,
+			"batch_no": None,
+			"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in 
+				item_bean.doclist.get({"parentfield": "item_tax"})))),
+		})
+	
+	for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"):
+		out[fieldname] = item.fields.get(fieldname)
+			
+	return out
+	
+def _get_price_list_rate(args, item_bean, meta):
+	base_ref_rate = item_bean.doclist.get({
+		"parentfield": "ref_rate_details",
+		"price_list_name": args.price_list_name, 
+		"price_list_currency": args.price_list_currency,
+		"selling": 1})
+	
+	if not base_ref_rate:
+		return {}
+	
+	# found price list rate - now we can validate
+	from utilities.transaction_base import validate_currency
+	validate_currency(args, item_bean.doc, meta)
+	
+	return {"ref_rate": flt(base_ref_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)}
+
+@webnotes.whitelist()
+def get_available_qty(item_code, warehouse):
+	return webnotes.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, 
+		["projected_qty", "actual_qty"], as_dict=True) or {}
+		
+def _get_customer_item_code(args, item_bean):
+	customer_item_code = item_bean.doclist.get({"parentfield": "item_customer_details",
+		"customer_name": args.customer})
+	
+	return customer_item_code and customer_item_code[0].ref_code or None
+	
+def get_pos_settings(company):
+	pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s 
+		and company = %s""", (webnotes.session['user'], company), as_dict=1)
+		
+	if not pos_settings:
+		pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting` 
+			where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
+
+	return pos_settings and pos_settings[0] or None
+	
+def apply_pos_settings(pos_settings, opts):
+	out = {}
+	
+	for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"):
+		if not opts.get(fieldname):
+			out[fieldname] = pos_settings.get(fieldname)
+			
+	if out.get("warehouse"):
+		out["actual_qty"] = get_available_qty(opts.item_code, out.get("warehouse")).get("actual_qty")
+	
+	return out
diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py
index dc7f6b4..2d28009 100644
--- a/setup/doctype/global_defaults/global_defaults.py
+++ b/setup/doctype/global_defaults/global_defaults.py
@@ -46,7 +46,6 @@
 	'maintain_same_rate' : 'maintain_same_rate',
 	'session_expiry': 'session_expiry',
 	'disable_rounded_total': 'disable_rounded_total',
-	"update_stock": "update_stock",
 	"auto_inventory_accounting": "auto_inventory_accounting",
 }
 
diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt
index 175ca94..16954a0 100644
--- a/setup/doctype/global_defaults/global_defaults.txt
+++ b/setup/doctype/global_defaults/global_defaults.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-02 17:53:24", 
   "docstatus": 0, 
-  "modified": "2013-05-22 15:57:26", 
+  "modified": "2013-05-30 12:23:34", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -27,8 +27,6 @@
   "permlevel": 0
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
   "create": 1, 
   "doctype": "DocPerm", 
   "name": "__common__", 
@@ -327,14 +325,6 @@
   "read_only": 0
  }, 
  {
-  "description": "If checked, then in POS Sales Invoice, Update Stock gets checked by default", 
-  "doctype": "DocField", 
-  "fieldname": "update_stock", 
-  "fieldtype": "Check", 
-  "label": "Update Stock when using POS Sales Invoice", 
-  "read_only": 0
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "account_info", 
   "fieldtype": "HTML", 
@@ -527,6 +517,11 @@
   "read_only": 0
  }, 
  {
+  "amend": 0, 
+  "cancel": 0, 
+  "doctype": "DocPerm"
+ }, 
+ {
   "doctype": "DocPerm"
  }
 ]
\ No newline at end of file
diff --git a/setup/utils.py b/setup/utils.py
index 1a86921..33fa3e2 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -46,4 +46,4 @@
 	if result and len(result)==1:
 		return {"price_list_currency": result[0][0]}
 	else:
-		return {}
\ No newline at end of file
+		return {}
diff --git a/startup/boot.py b/startup/boot.py
index 9ed20ff..b202d17 100644
--- a/startup/boot.py
+++ b/startup/boot.py
@@ -36,9 +36,8 @@
 		for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
 			if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
 
-		bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center,
-			cost_center as 'cost_center_other_charges' from `tabCompany`""", 
-			as_dict=1, update={"doctype":":Company"})
+		bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
+            from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
 			
 def get_letter_heads():
 	"""load letter heads with startup"""
diff --git a/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt b/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
index c5beb65..4f6272d 100644
--- a/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
+++ b/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:31:11", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:19:46", 
+  "modified": "2013-05-28 17:20:31", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Delivery Note", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Georgia\", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Georgia\", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Stock", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt b/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt
index 6993bfd..82d2376 100644
--- a/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt
+++ b/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:31:11", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:20:58", 
+  "modified": "2013-05-28 17:20:21", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Delivery Note", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Delivery Note No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Helvetica\", \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style=\"height:15px\"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class='imp-details'>\n\t\t\t\t\t\t<td><b>Delivery Note No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold' class='imp-details'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Stock", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt b/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt
index 69eb9ff..81ecbd2 100644
--- a/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt
+++ b/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt
@@ -1,17 +1,18 @@
 [
  {
-  "creation": "2012-04-17 11:29:12", 
+  "creation": "2013-04-19 13:31:11", 
   "docstatus": 0, 
-  "modified": "2013-01-25 17:19:30", 
+  "modified": "2013-05-28 17:20:39", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
   "doc_type": "Delivery Note", 
   "doctype": "Print Format", 
-  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
+  "html": "<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: \"Arial\", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: \"Arial\", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t'Delivery Note',\n\t\t\t\tdoc.name,\n\t\t\t\t'delivery_note_details',\n\t\t\t\t'Delivery Note Item',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t'SR', 'item_code', 'item_name', 'description', 'qty', 'stock_uom',\n\t\t\t\t\t'basic_rate', 'amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t'Sr', 'Item Code', 'Item Name', 'Description', 'Qty',\n\t\t\t\t\t'UoM', 'Basic Rate', 'Amount'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t'3%', '10%', '15%', '32%', '5%',\n\t\t\t\t\t'5%', '15%', '15%'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t'description' : function(data_row) {\n\t\t\t\t\t\tvar to_append = ''\n\t\t\t\t\t\tif(data_row.adj_rate){\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Discount: ' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + '% on ' + doc.currency + ' ' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(data_row.serial_no) {\n\t\t\t\t\t\t\tto_append = '<div style=\"padding-left: 15px;\"><i>Serial No.:' + \n\t\t\t\t\t\t\t\t((data_row.serial_no.indexOf('\\n')>-1)?'<br />':'&nbsp;') + \n\t\t\t\t\t\t\t\tdata_row.serial_no + '</i></div>';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\tdata_row.description = data_row.description + to_append;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = '';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t'<div style = \"page-break-after: always;\" \\\n\t\t\t\t\t\tclass = \"page_break\"></div>\\\n\t\t\t\t\t\t<div class=\"page-settings\"></div>';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');\n\t\t\tvar rows = '<table width=100%>\\n';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t'<tr>\\n' +\n\t\t\t\t\t\t\t'\\t<td>' + oc[i].description + '</td>\\n' +\n\t\t\t\t\t\t\t'\\t<td></td>\\n' +\n\t\t\t\t\t\t\t'\\t<td width=38%>' + fmt_money(oc[i].tax_amount/doc.conversion_rate) + '</td>\\n' +\n\t\t\t\t\t\t'</tr>\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + '</table>\\n';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class='common page-header'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class='header-table' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>'<h1>' + (doc.select_print_heading || 'Delivery Note') + '</h1>'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=22%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=63%><b>Delivery Note Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.transaction_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<script>doc.sales_order_no</script><br />\n\t\t\t\t\t\t\t<i>(<script>date.str_to_user(doc.posting_date)</script>)</i>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class='common page-body'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class='common page-footer'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class='footer-table' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style='padding-right: 10px;'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style='font-weight: bold'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n", 
   "module": "Stock", 
   "name": "__common__", 
+  "print_format_type": "Client", 
   "standard": "Yes"
  }, 
  {
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 0a31dfe..e1b23f0 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -20,84 +20,36 @@
 cur_frm.cscript.other_fname = "other_charges";
 cur_frm.cscript.sales_team_fname = "sales_team";
 
-wn.require('app/selling/doctype/sales_common/sales_common.js');
 wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/selling/doctype/sales_common/sales_common.js');
 
-// ONLOAD
-// ================================================================================================
-cur_frm.cscript.onload = function(doc, dt, dn) {
-	cur_frm.cscript.manage_rounded_total();
-	if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
-	if(!doc.transaction_date) set_multiple(dt,dn,{transaction_date:get_today()});
-	if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
-	if(doc.__islocal && doc.customer) cur_frm.cscript.customer(doc,dt,dn,onload=true);
-	if(!doc.price_list_currency) {
-		set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate:1});
-	}
+wn.provide("erpnext.stock");
+erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({
+	refresh: function(doc, dt, dn) {
+		this._super();
 		
-	if(doc.__islocal){
-		hide_field(['customer_address', 'contact_person', 'customer_name', 
-			'address_display', 'contact_display', 'contact_mobile', 
-			'contact_email', 'territory', 'customer_group']);
-	}	
-}
+		if(flt(doc.per_billed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
+	
+		if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
 
-cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	// defined in sales_common.js
-	var callback = function(doc, dt, dn) {
-		if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn);
+		if (doc.docstatus==1) cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
+
+		if(doc.docstatus==0 && !doc.__islocal) {
+			cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
+		}
+	
+		set_print_hide(doc, dt, dn);
+	
+		// unhide expense_account and cost_center is auto_inventory_accounting enabled
+		var aii_enabled = cint(sys_defaults.auto_inventory_accounting)
+		cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled);
+		cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled);
 	}
+});
 
-	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
-} 
-
-// REFRESH
-// ================================================================================================
-cur_frm.cscript.refresh = function(doc, cdt, cdn) { 
-	cur_frm.clear_custom_buttons();
-	erpnext.hide_naming_series();
-	
-	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
-
- 
-	if(flt(doc.per_billed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
-	
-	if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
-
-	if (doc.docstatus==1) cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
-
-	if(doc.docstatus==0 && !doc.__islocal) {
-		cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
-	}
-	
-	cur_frm.toggle_display("contact_info", doc.customer);
-	
-	set_print_hide(doc, cdt, cdn);
-	
-	// unhide expense_account and cost_center is auto_inventory_accounting enabled
-	var aii_enabled = cint(sys_defaults.auto_inventory_accounting)
-	cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled);
-	cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled);
-}
-
-
-//customer
-cur_frm.cscript.customer = function(doc,dt,dn,onload) {	
-	cur_frm.toggle_display("contact_info", doc.customer);
-	
-	var pl = doc.price_list_name;
-	var callback = function(r,rt) {
-			var doc = locals[cur_frm.doctype][cur_frm.docname];
-			if(doc.customer)
-			 	unhide_field(['customer_address','contact_person','territory','customer_group']);
-			cur_frm.refresh();
-			if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn); 
-	} 
-	var args = onload ? 'onload':''
-	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
-	 	'get_default_customer_shipping_address', args, callback);
-}
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm}));
 
 cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
 	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -157,11 +109,6 @@
 	return repl('SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "%(company)s" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_delivered,0) < 99.99 and %(cond)s `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50', {company:doc.company,cond:cond})
 }
 
-
-cur_frm.cscript.delivery_type = function(doc, cdt, cdn) {
-	if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn);
-}
-
 cur_frm.cscript.serial_no = function(doc, cdt, cdn) {
 	var d = locals[cdt][cdn];
 	if (d.serial_no) {
@@ -169,17 +116,6 @@
 	}
 }
 
-
-cur_frm.cscript.warehouse = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	if (! d.item_code) {alert("please enter item code first"); return};
-	if (d.warehouse) {
-		arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
-		get_server_fields('get_actual_qty',arg,'delivery_note_details',doc,cdt,cdn,1);
-	}
-}
-
-
 cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
 	return 'SELECT DISTINCT `tabSupplier`.`name` FROM `tabSupplier` WHERE `tabSupplier`.supplier_type = "transporter" AND `tabSupplier`.docstatus != 2 AND `tabSupplier`.%(key)s LIKE "%s" ORDER BY `tabSupplier`.`name` LIMIT 50';
 }
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 6ffd960..fa83571 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -17,7 +17,7 @@
 from __future__ import unicode_literals
 import webnotes
 
-from webnotes.utils import cstr, flt, getdate, cint
+from webnotes.utils import cstr, flt, cint
 from webnotes.model.bean import getlist
 from webnotes.model.code import get_obj
 from webnotes import msgprint, _
@@ -34,6 +34,22 @@
 		self.doclist = doclist
 		self.tname = 'Delivery Note Item'
 		self.fname = 'delivery_note_details'
+		self.status_updater = [{
+			'source_dt': 'Delivery Note Item',
+			'target_dt': 'Sales Order Item',
+			'join_field': 'prevdoc_detail_docname',
+			'target_field': 'delivered_qty',
+			'target_parent_dt': 'Sales Order',
+			'target_parent_field': 'per_delivered',
+			'target_ref_field': 'qty',
+			'source_field': 'qty',
+			'percent_join_field': 'prevdoc_docname',
+			'status_field': 'delivery_status',
+			'keyword': 'Delivered'
+		}]
+		
+	def set_customer_defaults(self):
+		self.get_default_customer_shipping_address()
 
 	def validate_fiscal_year(self):
 		get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
@@ -75,28 +91,6 @@
 				d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0
 
 
-	def get_tc_details(self):
-		return get_obj('Sales Common').get_tc_details(self)
-
-	def get_item_details(self, args=None):
-		import json
-		args = args and json.loads(args) or {}
-		if args.get('item_code'):
-			return get_obj('Sales Common').get_item_details(args, self)
-		else:
-			obj = get_obj('Sales Common')
-			for doc in self.doclist:
-				if doc.fields.get('item_code'):
-					arg = {
-						'item_code':doc.fields.get('item_code'),
-						'expense_account':doc.fields.get('expense_account'), 
-						'cost_center': doc.fields.get('cost_center'), 
-						'warehouse': doc.fields.get('warehouse')};
-					ret = obj.get_item_defaults(arg)
-					for r in ret:
-						if not doc.fields.get(r):
-							doc.fields[r] = ret[r]					
-
 	def get_barcode_details(self, barcode):
 		return get_obj('Sales Common').get_barcode_details(barcode)
 
@@ -105,25 +99,9 @@
 		"""Re-calculates Basic Rate & amount based on Price List Selected"""
 		get_obj('Sales Common').get_adj_percent(self)
 
-
-	def get_actual_qty(self,args):
-		"""Get Actual Qty of item in warehouse selected"""
-		return get_obj('Sales Common').get_available_qty(eval(args))
-
-
 	def get_rate(self,arg):
 		return get_obj('Sales Common').get_rate(arg)
 
-
-	def load_default_taxes(self):
-		self.doclist = get_obj('Sales Common').load_default_taxes(self)
-
-
-	def get_other_charges(self):
-		"""Pull details from Sales Taxes and Charges Master"""
-		self.doclist = get_obj('Sales Common').get_other_charges(self)
-
-
 	def so_required(self):
 		"""check in manage account if sales order required or not"""
 		if webnotes.conn.get_value('Global Defaults', 'Global Defaults', 'so_required') == 'Yes':
@@ -152,7 +130,6 @@
 		self.validate_warehouse()
 		
 		sales_com_obj.validate_max_discount(self, 'delivery_note_details')
-		sales_com_obj.get_allocated_sum(self)
 		sales_com_obj.check_conversion_rate(self)
 
 		# Set actual qty for each item in selected warehouse
@@ -261,8 +238,8 @@
 		sl_obj.update_serial_record(self, 'delivery_note_details', is_submit = 1, is_incoming = 0)
 		sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
 		
-		# update delivered qty in sales order
-		get_obj("Sales Common").update_prevdoc_detail(1,self)
+		# update delivered qty in sales order	
+		self.update_prevdoc_status()
 		
 		# create stock ledger entry
 		self.update_stock_ledger(update_stock = 1)
@@ -309,7 +286,8 @@
 		sl.update_serial_record(self, 'delivery_note_details', is_submit = 0, is_incoming = 0)
 		sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
 		
-		sales_com_obj.update_prevdoc_detail(0,self)
+		self.update_prevdoc_status()
+		
 		self.update_stock_ledger(update_stock = -1)
 		webnotes.conn.set(self.doc, 'status', 'Cancelled')
 		self.cancel_packing_slips()
@@ -419,4 +397,4 @@
 				
 		if gl_entries:
 			from accounts.general_ledger import make_gl_entries
-			make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))
\ No newline at end of file
+			make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index 36c2789..74a21b3 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-04-02 10:50:50", 
+  "creation": "2013-05-24 19:29:09", 
   "docstatus": 0, 
-  "modified": "2013-02-02 19:18:38", 
+  "modified": "2013-06-05 19:22:52", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -11,6 +11,7 @@
   "autoname": "naming_series:", 
   "doctype": "DocType", 
   "document_type": "Transaction", 
+  "hide_toolbar": 0, 
   "in_create": 0, 
   "is_submittable": 1, 
   "module": "Stock", 
@@ -32,7 +33,9 @@
   "parent": "Delivery Note", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -76,10 +79,11 @@
   "search_index": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "customer_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Customer Name", 
   "read_only": 1
@@ -96,34 +100,38 @@
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Shipping Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -136,6 +144,37 @@
   "read_only": 0
  }, 
  {
+  "allow_on_submit": 0, 
+  "doctype": "DocField", 
+  "fieldname": "amended_from", 
+  "fieldtype": "Data", 
+  "label": "Amended From", 
+  "no_copy": 1, 
+  "oldfieldname": "amended_from", 
+  "oldfieldtype": "Data", 
+  "print_hide": 1, 
+  "print_width": "150px", 
+  "read_only": 1, 
+  "width": "150px"
+ }, 
+ {
+  "description": "Select the relevant company name if you have multiple companies", 
+  "doctype": "DocField", 
+  "fieldname": "company", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Company", 
+  "oldfieldname": "company", 
+  "oldfieldtype": "Link", 
+  "options": "Company", 
+  "print_hide": 1, 
+  "print_width": "150px", 
+  "read_only": 0, 
+  "reqd": 1, 
+  "search_index": 1, 
+  "width": "150px"
+ }, 
+ {
   "default": "Today", 
   "description": "The date at which current entry will get or has actually executed.", 
   "doctype": "DocField", 
@@ -206,108 +245,39 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "items", 
-  "fieldtype": "Section Break", 
-  "label": "Items", 
-  "oldfieldtype": "Section Break", 
-  "read_only": 0
- }, 
- {
-  "allow_on_submit": 1, 
-  "doctype": "DocField", 
-  "fieldname": "delivery_note_details", 
-  "fieldtype": "Table", 
-  "label": "Delivery Note Items", 
-  "no_copy": 0, 
-  "oldfieldname": "delivery_note_details", 
-  "oldfieldtype": "Table", 
-  "options": "Delivery Note Item", 
-  "print_hide": 0, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "sales_bom_help", 
-  "fieldtype": "HTML", 
-  "label": "Sales BOM Help", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "section_break0", 
-  "fieldtype": "Section Break", 
-  "options": "Simple", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break24", 
-  "fieldtype": "Column Break", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "net_total", 
-  "fieldtype": "Currency", 
-  "label": "Net Total*", 
-  "no_copy": 0, 
-  "oldfieldname": "net_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 0, 
-  "print_width": "150px", 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "recalculate_values", 
-  "fieldtype": "Button", 
-  "label": "Re-Calculate Values", 
-  "oldfieldtype": "Button", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break28", 
-  "fieldtype": "Column Break", 
-  "read_only": 0
- }, 
- {
-  "description": "You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.", 
-  "doctype": "DocField", 
-  "fieldname": "sales_order_no", 
-  "fieldtype": "Link", 
-  "in_list_view": 1, 
-  "label": "Sales Order No", 
-  "no_copy": 0, 
-  "oldfieldname": "sales_order_no", 
-  "oldfieldtype": "Link", 
-  "options": "Sales Order", 
-  "print_hide": 0, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "get_items", 
-  "fieldtype": "Button", 
-  "hidden": 0, 
-  "label": "Get Items", 
-  "oldfieldtype": "Button", 
-  "options": "pull_sales_order_details", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "sec_break25", 
   "fieldtype": "Section Break", 
   "label": "Price List and Currency", 
   "read_only": 0
  }, 
  {
+  "description": "Customer's Currency", 
+  "doctype": "DocField", 
+  "fieldname": "currency", 
+  "fieldtype": "Link", 
+  "label": "Currency", 
+  "oldfieldname": "currency", 
+  "oldfieldtype": "Select", 
+  "options": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
+  "default": "1.00", 
+  "description": "Rate at which customer's currency is converted to company's base currency", 
+  "doctype": "DocField", 
+  "fieldname": "conversion_rate", 
+  "fieldtype": "Float", 
+  "label": "Conversion Rate", 
+  "no_copy": 0, 
+  "oldfieldname": "conversion_rate", 
+  "oldfieldtype": "Currency", 
+  "print_hide": 1, 
+  "read_only": 0, 
+  "reqd": 1
+ }, 
+ {
   "doctype": "DocField", 
   "fieldname": "col_break23", 
   "fieldtype": "Column Break", 
@@ -349,41 +319,125 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break2", 
-  "fieldtype": "Column Break", 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
+  "fieldname": "items", 
+  "fieldtype": "Section Break", 
+  "label": "Items", 
+  "oldfieldtype": "Section Break", 
+  "read_only": 0
  }, 
  {
-  "description": "Customer's Currency", 
+  "allow_on_submit": 1, 
   "doctype": "DocField", 
-  "fieldname": "currency", 
-  "fieldtype": "Link", 
-  "label": "Currency", 
-  "oldfieldname": "currency", 
-  "oldfieldtype": "Select", 
-  "options": "Currency", 
-  "print_hide": 1, 
-  "read_only": 0, 
-  "reqd": 1
- }, 
- {
-  "default": "1.00", 
-  "description": "Rate at which customer's currency is converted to company's base currency", 
-  "doctype": "DocField", 
-  "fieldname": "conversion_rate", 
-  "fieldtype": "Float", 
-  "label": "Conversion Rate", 
+  "fieldname": "delivery_note_details", 
+  "fieldtype": "Table", 
+  "label": "Delivery Note Items", 
   "no_copy": 0, 
-  "oldfieldname": "conversion_rate", 
-  "oldfieldtype": "Currency", 
-  "print_hide": 1, 
+  "oldfieldname": "delivery_note_details", 
+  "oldfieldtype": "Table", 
+  "options": "Delivery Note Item", 
+  "print_hide": 0, 
   "read_only": 0, 
   "reqd": 1
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "packing_list", 
+  "fieldtype": "Section Break", 
+  "label": "Packing List", 
+  "oldfieldtype": "Section Break", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "packing_details", 
+  "fieldtype": "Table", 
+  "label": "Packing Details", 
+  "oldfieldname": "packing_details", 
+  "oldfieldtype": "Table", 
+  "options": "Delivery Note Packing Item", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "sales_bom_help", 
+  "fieldtype": "HTML", 
+  "label": "Sales BOM Help", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "section_break0", 
+  "fieldtype": "Section Break", 
+  "options": "Simple", 
+  "read_only": 0
+ }, 
+ {
+  "description": "You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.", 
+  "doctype": "DocField", 
+  "fieldname": "sales_order_no", 
+  "fieldtype": "Link", 
+  "in_list_view": 1, 
+  "label": "Sales Order No", 
+  "no_copy": 0, 
+  "oldfieldname": "sales_order_no", 
+  "oldfieldtype": "Link", 
+  "options": "Sales Order", 
+  "print_hide": 0, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "get_items", 
+  "fieldtype": "Button", 
+  "hidden": 0, 
+  "label": "Get Items", 
+  "oldfieldtype": "Button", 
+  "options": "pull_sales_order_details", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "col_break24", 
+  "fieldtype": "Column Break", 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "net_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Net Total (Export)", 
+  "options": "currency", 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "net_total", 
+  "fieldtype": "Currency", 
+  "label": "Net Total*", 
+  "no_copy": 0, 
+  "oldfieldname": "net_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "print_width": "150px", 
+  "read_only": 1, 
+  "reqd": 0, 
+  "width": "150px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "recalculate_values", 
+  "fieldtype": "Button", 
+  "label": "Re-Calculate Values", 
+  "oldfieldtype": "Button", 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "taxes", 
   "fieldtype": "Section Break", 
   "label": "Taxes", 
@@ -404,6 +458,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_39", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_charges", 
   "fieldtype": "Button", 
   "label": "Get Taxes and Charges", 
@@ -413,6 +472,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "section_break_41", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges", 
   "fieldtype": "Table", 
   "label": "Sales Taxes and Charges", 
@@ -424,6 +488,28 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "other_charges_calculation", 
+  "fieldtype": "HTML", 
+  "label": "Taxes and Charges Calculation", 
+  "oldfieldtype": "HTML", 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "section_break_44", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "other_charges_total_export", 
+  "fieldtype": "Currency", 
+  "label": "Taxes and Charges Total (Export)", 
+  "options": "company", 
+  "print_hide": 1, 
+  "read_only": 1
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "other_charges_total", 
   "fieldtype": "Currency", 
   "label": "Taxes and Charges Total", 
@@ -437,6 +523,11 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_47", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "calculate_charges", 
   "fieldtype": "Button", 
   "label": "Calculate Charges", 
@@ -446,14 +537,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "other_charges_calculation", 
-  "fieldtype": "HTML", 
-  "label": "Taxes and Charges Calculation", 
-  "oldfieldtype": "HTML", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "totals", 
   "fieldtype": "Section Break", 
   "label": "Totals", 
@@ -463,56 +546,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "grand_total", 
-  "fieldtype": "Currency", 
-  "label": "Grand Total", 
-  "no_copy": 0, 
-  "oldfieldname": "grand_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "print_width": "150px", 
-  "read_only": 1, 
-  "reqd": 0, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "rounded_total", 
-  "fieldtype": "Currency", 
-  "label": "Rounded Total", 
-  "no_copy": 0, 
-  "oldfieldname": "rounded_total", 
-  "oldfieldtype": "Currency", 
-  "options": "Company:company:default_currency", 
-  "print_hide": 1, 
-  "print_width": "150px", 
-  "read_only": 1, 
-  "width": "150px"
- }, 
- {
-  "description": "In Words will be visible once you save the Delivery Note.", 
-  "doctype": "DocField", 
-  "fieldname": "in_words", 
-  "fieldtype": "Data", 
-  "label": "In Words", 
-  "no_copy": 0, 
-  "oldfieldname": "in_words", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "print_width": "200px", 
-  "read_only": 1, 
-  "width": "200px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "column_break3", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "grand_total_export", 
   "fieldtype": "Currency", 
   "label": "Grand Total (Export)", 
@@ -556,6 +589,56 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break3", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "grand_total", 
+  "fieldtype": "Currency", 
+  "label": "Grand Total", 
+  "no_copy": 0, 
+  "oldfieldname": "grand_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "print_width": "150px", 
+  "read_only": 1, 
+  "reqd": 0, 
+  "width": "150px"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rounded_total", 
+  "fieldtype": "Currency", 
+  "label": "Rounded Total", 
+  "no_copy": 0, 
+  "oldfieldname": "rounded_total", 
+  "oldfieldtype": "Currency", 
+  "options": "Company:company:default_currency", 
+  "print_hide": 1, 
+  "print_width": "150px", 
+  "read_only": 1, 
+  "width": "150px"
+ }, 
+ {
+  "description": "In Words will be visible once you save the Delivery Note.", 
+  "doctype": "DocField", 
+  "fieldname": "in_words", 
+  "fieldtype": "Data", 
+  "label": "In Words", 
+  "no_copy": 0, 
+  "oldfieldname": "in_words", 
+  "oldfieldtype": "Data", 
+  "print_hide": 1, 
+  "print_width": "200px", 
+  "read_only": 1, 
+  "width": "200px"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "terms_section_break", 
   "fieldtype": "Section Break", 
   "label": "Terms and Conditions", 
@@ -575,23 +658,22 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "column_break_59", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
   "oldfieldtype": "Button", 
-  "options": "get_tc_details", 
   "print_hide": 1, 
   "read_only": 0
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1, 
-  "read_only": 0
+  "fieldname": "section_break_61", 
+  "fieldtype": "Section Break"
  }, 
  {
   "doctype": "DocField", 
@@ -612,15 +694,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break4", 
-  "fieldtype": "Column Break", 
-  "print_hide": 1, 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "transporter_name", 
   "fieldtype": "Data", 
   "label": "Transporter Name", 
@@ -672,6 +745,7 @@
   "width": "100px"
  }, 
  {
+  "depends_on": "customer", 
   "doctype": "DocField", 
   "fieldname": "contact_info", 
   "fieldtype": "Section Break", 
@@ -680,32 +754,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "col_break20", 
-  "fieldtype": "Column Break", 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "contact_person", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Contact Person", 
-  "options": "Contact", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "col_break21", 
-  "fieldtype": "Column Break", 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "territory", 
   "fieldtype": "Link", 
   "hidden": 0, 
@@ -729,6 +777,24 @@
   "search_index": 1
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "col_break21", 
+  "fieldtype": "Column Break", 
+  "print_width": "50%", 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "contact_person", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Contact Person", 
+  "options": "Contact", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
   "description": "Filling in Additional Information about the Delivery Note will help you analyze your data better.", 
   "doctype": "DocField", 
   "fieldname": "more_info", 
@@ -739,6 +805,52 @@
   "read_only": 0
  }, 
  {
+  "description": "Track this Delivery Note against any Project", 
+  "doctype": "DocField", 
+  "fieldname": "project_name", 
+  "fieldtype": "Link", 
+  "in_filter": 1, 
+  "label": "Project Name", 
+  "oldfieldname": "project_name", 
+  "oldfieldtype": "Link", 
+  "options": "Project", 
+  "read_only": 0, 
+  "search_index": 1
+ }, 
+ {
+  "depends_on": "eval:doc.source == 'Campaign'", 
+  "doctype": "DocField", 
+  "fieldname": "campaign", 
+  "fieldtype": "Link", 
+  "label": "Campaign", 
+  "oldfieldname": "campaign", 
+  "oldfieldtype": "Link", 
+  "options": "Campaign", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "source", 
+  "fieldtype": "Select", 
+  "label": "Source", 
+  "oldfieldname": "source", 
+  "oldfieldtype": "Select", 
+  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
+  "print_hide": 1, 
+  "read_only": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break5", 
+  "fieldtype": "Column Break", 
+  "oldfieldtype": "Column Break", 
+  "print_hide": 1, 
+  "print_width": "50%", 
+  "read_only": 0, 
+  "width": "50%"
+ }, 
+ {
   "description": "Time at which items were delivered from warehouse", 
   "doctype": "DocField", 
   "fieldname": "posting_time", 
@@ -755,19 +867,17 @@
   "width": "100px"
  }, 
  {
-  "default": "Draft", 
   "doctype": "DocField", 
-  "fieldname": "status", 
+  "fieldname": "fiscal_year", 
   "fieldtype": "Select", 
   "in_filter": 1, 
-  "label": "Status", 
-  "no_copy": 1, 
-  "oldfieldname": "status", 
+  "label": "Fiscal Year", 
+  "oldfieldname": "fiscal_year", 
   "oldfieldtype": "Select", 
-  "options": "\nDraft\nSubmitted\nCancelled", 
+  "options": "link:Fiscal Year", 
   "print_hide": 1, 
   "print_width": "150px", 
-  "read_only": 1, 
+  "read_only": 0, 
   "reqd": 1, 
   "search_index": 1, 
   "width": "150px"
@@ -799,42 +909,6 @@
   "report_hide": 1
  }, 
  {
-  "description": "Track this Delivery Note against any Project", 
-  "doctype": "DocField", 
-  "fieldname": "project_name", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Project Name", 
-  "oldfieldname": "project_name", 
-  "oldfieldtype": "Link", 
-  "options": "Project", 
-  "read_only": 0, 
-  "search_index": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "source", 
-  "fieldtype": "Select", 
-  "label": "Source", 
-  "oldfieldname": "source", 
-  "oldfieldtype": "Select", 
-  "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "depends_on": "eval:doc.source == 'Campaign'", 
-  "doctype": "DocField", 
-  "fieldname": "campaign", 
-  "fieldtype": "Link", 
-  "label": "Campaign", 
-  "oldfieldname": "campaign", 
-  "oldfieldtype": "Link", 
-  "options": "Campaign", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
   "allow_on_submit": 1, 
   "doctype": "DocField", 
   "fieldname": "print_without_amount", 
@@ -847,13 +921,26 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break5", 
-  "fieldtype": "Column Break", 
-  "oldfieldtype": "Column Break", 
+  "fieldname": "section_break_83", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "default": "Draft", 
+  "doctype": "DocField", 
+  "fieldname": "status", 
+  "fieldtype": "Select", 
+  "in_filter": 1, 
+  "label": "Status", 
+  "no_copy": 1, 
+  "oldfieldname": "status", 
+  "oldfieldtype": "Select", 
+  "options": "\nDraft\nSubmitted\nCancelled", 
   "print_hide": 1, 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
+  "print_width": "150px", 
+  "read_only": 1, 
+  "reqd": 1, 
+  "search_index": 1, 
+  "width": "150px"
  }, 
  {
   "depends_on": "eval:!doc.__islocal", 
@@ -908,32 +995,9 @@
   "read_only": 0
  }, 
  {
-  "allow_on_submit": 0, 
   "doctype": "DocField", 
-  "fieldname": "amended_from", 
-  "fieldtype": "Data", 
-  "label": "Amended From", 
-  "no_copy": 1, 
-  "oldfieldname": "amended_from", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "print_width": "150px", 
-  "read_only": 1, 
-  "width": "150px"
- }, 
- {
-  "description": "The date at which current entry is corrected in the system.", 
-  "doctype": "DocField", 
-  "fieldname": "amendment_date", 
-  "fieldtype": "Date", 
-  "label": "Amendment Date", 
-  "no_copy": 1, 
-  "oldfieldname": "amendment_date", 
-  "oldfieldtype": "Date", 
-  "print_hide": 1, 
-  "print_width": "100px", 
-  "read_only": 0, 
-  "width": "100px"
+  "fieldname": "column_break_89", 
+  "fieldtype": "Column Break"
  }, 
  {
   "description": "Required only for sample item.", 
@@ -970,72 +1034,6 @@
   "read_only": 0
  }, 
  {
-  "description": "Select the relevant company name if you have multiple companies", 
-  "doctype": "DocField", 
-  "fieldname": "company", 
-  "fieldtype": "Link", 
-  "in_filter": 1, 
-  "label": "Company", 
-  "oldfieldname": "company", 
-  "oldfieldtype": "Link", 
-  "options": "Company", 
-  "print_hide": 1, 
-  "print_width": "150px", 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 1, 
-  "width": "150px"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "fiscal_year", 
-  "fieldtype": "Select", 
-  "in_filter": 1, 
-  "label": "Fiscal Year", 
-  "oldfieldname": "fiscal_year", 
-  "oldfieldtype": "Select", 
-  "options": "link:Fiscal Year", 
-  "print_hide": 1, 
-  "print_width": "150px", 
-  "read_only": 0, 
-  "reqd": 1, 
-  "search_index": 1, 
-  "width": "150px"
- }, 
- {
-  "depends_on": "eval:!doc.__islocal", 
-  "doctype": "DocField", 
-  "fieldname": "cancel_reason", 
-  "fieldtype": "Data", 
-  "hidden": 0, 
-  "label": "Cancel Reason", 
-  "no_copy": 1, 
-  "oldfieldname": "cancel_reason", 
-  "oldfieldtype": "Data", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "packing_list", 
-  "fieldtype": "Section Break", 
-  "label": "Packing List", 
-  "oldfieldtype": "Section Break", 
-  "print_hide": 1, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "packing_details", 
-  "fieldtype": "Table", 
-  "label": "Packing Details", 
-  "oldfieldname": "packing_details", 
-  "oldfieldtype": "Table", 
-  "options": "Delivery Note Packing Item", 
-  "print_hide": 1, 
-  "read_only": 1
- }, 
- {
   "doctype": "DocField", 
   "fieldname": "sales_team_section_break", 
   "fieldtype": "Section Break", 
@@ -1046,15 +1044,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "column_break6", 
-  "fieldtype": "Column Break", 
-  "print_hide": 1, 
-  "print_width": "50%", 
-  "read_only": 0, 
-  "width": "50%"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "sales_partner", 
   "fieldtype": "Link", 
   "label": "Sales Partner", 
@@ -1125,96 +1114,39 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material Manager", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material Manager", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Sales User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Sales User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Accounts User", 
   "submit": 0, 
   "write": 0
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "role": "Accounts User", 
-  "submit": 0
- }, 
- {
   "doctype": "DocPerm", 
   "match": "customer_name", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Customer"
  }
 ]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_item/delivery_note_item.txt b/stock/doctype/delivery_note_item/delivery_note_item.txt
index f90ba69..a8eda20 100644
--- a/stock/doctype/delivery_note_item/delivery_note_item.txt
+++ b/stock/doctype/delivery_note_item/delivery_note_item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-04-22 13:15:44", 
   "docstatus": 0, 
-  "modified": "2013-05-22 12:05:32", 
+  "modified": "2013-05-22 12:15:32", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -120,7 +120,7 @@
   "options": "currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "100px"
  }, 
@@ -189,7 +189,7 @@
   "options": "Company:company:default_currency", 
   "print_hide": 1, 
   "print_width": "150px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "reqd": 0, 
   "width": "150px"
  }, 
diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt
index 9e0a2fb..611ae5e 100644
--- a/stock/doctype/item/item.txt
+++ b/stock/doctype/item/item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-03 10:45:46", 
   "docstatus": 0, 
-  "modified": "2013-05-22 15:48:27", 
+  "modified": "2013-05-22 15:49:27", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
diff --git a/stock/doctype/material_request/material_request.js b/stock/doctype/material_request/material_request.js
index 21bc141..6c7b2a7 100644
--- a/stock/doctype/material_request/material_request.js
+++ b/stock/doctype/material_request/material_request.js
@@ -17,8 +17,8 @@
 cur_frm.cscript.tname = "Material Request Item";
 cur_frm.cscript.fname = "indent_details";
 
-wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 
 erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({
 	refresh: function(doc) {
@@ -48,43 +48,20 @@
 			cur_frm.toggle_display("sales_order_no", false);
 			cur_frm.fields_dict.indent_details.grid.set_column_disp("sales_order_no", false);
 		}
+	},
+	
+	validate_company_and_party: function(party_field) {
+		return true;
+	},
+	
+	calculate_taxes_and_totals: function() {
+		return;
 	}
 });
 
-var new_cscript = new erpnext.buying.MaterialRequestController({frm: cur_frm});
-
 // for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
+$.extend(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm}));
 	
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-	if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
-	if (!doc.status) doc.status = 'Draft';
-
-	// defined in purchase_common.js
-	//cur_frm.cscript.update_item_details(doc, cdt, cdn);
-};
-
-cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
-	// second call
-	if(doc.__islocal){ 
-		cur_frm.cscript.get_item_defaults(doc);
-	}	
-};
-
-cur_frm.cscript.get_item_defaults = function(doc) {
-		var ch = getchildren( 'Material Request Item', doc.name, 'indent_details');
-		if (flt(ch.length) > 0){
-			$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_defaults', '', function(r, rt) {refresh_field('indent_details'); });
-		}
-};
-
-cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
-	if(doc.__islocal){ 
-		cur_frm.cscript.get_default_schedule_date(doc);
-	}
-};
-
 cur_frm.cscript.qty = function(doc, cdt, cdn) {
 	var d = locals[cdt][cdn];
 	if (flt(d.qty) < flt(d.min_order_qty))
diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py
index 8a899b3..dfed6c4 100644
--- a/stock/doctype/material_request/material_request.py
+++ b/stock/doctype/material_request/material_request.py
@@ -17,9 +17,6 @@
 		self.tname = 'Material Request Item'
 		self.fname = 'indent_details'
 
-	def get_default_schedule_date(self):
-		get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
-	
 	# get available qty at warehouse
 	def get_bin_details(self, arg = ''):
 		return get_obj(dt='Purchase Common').get_bin_details(arg)
@@ -30,22 +27,12 @@
 		self.check_if_already_pulled()
 		if self.doc.sales_order_no:
 			get_obj('DocType Mapper', 'Sales Order-Material Request', with_children=1).dt_map('Sales Order', 'Material Request', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Material Request'],['Sales Order Item', 'Material Request Item']]")
-			self.get_item_defaults()
 		else:
 			msgprint("Please select Sales Order whose details need to pull")
 
 	def check_if_already_pulled(self):
 		pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]
 
-
-	# Get item's other details
-	#- ------------------------
-	def get_item_defaults(self):
-		self.get_default_schedule_date()
-		for d in getlist(self.doclist, 'indent_details'):
-			det = webnotes.conn.sql("select min_order_qty from tabItem where name = '%s'" % d.item_code)
-			d.min_order_qty = det and flt(det[0][0]) or 0
-
 	# Validate so items
 	# ----------------------------
 	def validate_qty_against_so(self):
@@ -77,11 +64,6 @@
 	def validate_fiscal_year(self):
 		get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Material Request Date')
 
-	# GET TERMS & CONDITIONS
-	#-----------------------------
-	def get_tc_details(self):
-		return get_obj('Purchase Common').get_tc_details(self)
-		
 	# Validate Schedule Date
 	#--------------------------------
 	def validate_schedule_date(self):
diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt
index eb788e4..f8c5226 100644
--- a/stock/doctype/material_request/material_request.txt
+++ b/stock/doctype/material_request/material_request.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 14:48:38", 
   "docstatus": 0, 
-  "modified": "2013-02-25 15:38:02", 
+  "modified": "2013-06-05 14:46:10", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -26,12 +26,19 @@
   "permlevel": 0
  }, 
  {
+  "amend": 1, 
+  "cancel": 1, 
+  "create": 1, 
   "doctype": "DocPerm", 
   "name": "__common__", 
   "parent": "Material Request", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1, 
+  "submit": 1, 
+  "write": 1
  }, 
  {
   "doctype": "DocType", 
@@ -72,7 +79,7 @@
   "oldfieldtype": "Section Break"
  }, 
  {
-  "allow_on_submit": 1, 
+  "allow_on_submit": 0, 
   "doctype": "DocField", 
   "fieldname": "indent_details", 
   "fieldtype": "Table", 
@@ -311,8 +318,7 @@
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
-  "oldfieldtype": "Button", 
-  "options": "get_tc_details"
+  "oldfieldtype": "Button"
  }, 
  {
   "doctype": "DocField", 
@@ -332,89 +338,19 @@
   "print_hide": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Purchase Manager", 
-  "submit": 0, 
-  "write": 0
+  "role": "Purchase Manager"
  }, 
  {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Purchase Manager", 
-  "submit": 1, 
-  "write": 1
+  "role": "Material Manager"
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
   "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material Manager", 
-  "submit": 0, 
-  "write": 0
+  "role": "Material User"
  }, 
  {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Material Manager", 
-  "submit": 1, 
-  "write": 1
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Material User", 
-  "submit": 1, 
-  "write": 1
- }, 
- {
-  "amend": 1, 
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
-  "role": "Purchase User", 
-  "submit": 1, 
-  "write": 1
- }, 
- {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "permlevel": 1, 
-  "role": "Purchase User", 
-  "submit": 0
+  "role": "Purchase User"
  }
 ]
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js
index 82e494c..f405a55 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -19,10 +19,11 @@
 cur_frm.cscript.other_fname = "purchase_tax_details";
 
 wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
-wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/buying/doctype/purchase_common/purchase_common.js');
 
-erpnext.buying.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
+wn.provide("erpnext.stock");
+erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
 	refresh: function() {
 		this._super();
 		
@@ -37,43 +38,49 @@
 		if(wn.boot.control_panel.country == 'India') {
 			unhide_field(['challan_no', 'challan_date']);
 		}
-	}, 
-	onload_post_render: function(doc, dt, dn) {	
-		var me = this;
-		var callback = function(doc, dt, dn) {
-			me.update_item_details(doc, dt, dn, function(r,rt) { });
+	},
+	
+	received_qty: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["qty", "received_qty"]);
+
+		item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
+		this.qty(doc, cdt, cdn);
+	},
+	
+	qty: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["qty", "received_qty"]);
+		
+		if(item.qty > item.received_qty) {
+			msgprint(wn._("Error") + ": " + wn._(wn.meta.get_label(item.doctype, "qty", item.name))
+				+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
+			item.qty = item.rejected_qty = 0.0;
+		} else {
+			item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
 		}
 		
-		// TODO: improve this
-		if(this.frm.doc.__islocal) {
-			if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) 
-				this.price_list_name(callback);
-			else
-				callback(doc, dt, dn);
+		this._super();
+	},
+	
+	rejected_qty: function(doc, cdt, cdn) {
+		var item = wn.model.get_doc(cdt, cdn);
+		wn.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
+		
+		if(item.rejected_qty > item.received_qty) {
+			msgprint(wn._("Error") + ": " + wn._(wn.meta.get_label(item.doctype, "rejected_qty", item.name))
+				+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
+			item.qty = item.rejected_qty = 0.0;
+		} else {
+			item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
 		}
-	}
+		
+		this.qty(doc, cdt, cdn);
+	},
 });
 
-var new_cscript = new erpnext.buying.PurchaseReceiptController({frm: cur_frm});
-
 // for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-	if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);}
-	if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
-	if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
-	if (!doc.status) doc.status = 'Draft';
-}
-
-cur_frm.cscript.supplier = function(doc,dt,dn) {
-	if (doc.supplier) {
-		get_server_fields('get_default_supplier_address',
-			JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
-				cur_frm.refresh();
-			});
-	}
-}
+$.extend(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm}));
 
 cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
 	if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -151,81 +158,6 @@
 	return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
 }
 
-//========================= Received Qty =============================================================
-
-cur_frm.cscript.received_qty = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	ret = {
-			'qty' : (flt(d.qty) && flt(d.qty) < flt(d.received_qty)) 
-			 	? flt(d.qty) : flt(d.received_qty),
-			'stock_qty': 0,
-			'rejected_qty' : 0,
-		}
-	set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
-	cur_frm.cscript.calc_amount(doc, 2);
-}
-
-//======================== Qty (Accepted Qty) =========================================================
-
-cur_frm.cscript.qty = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	// Step 1 :=> Check If Qty > Received Qty
-	if (flt(d.qty) > flt(d.received_qty)) {
-		alert("Accepted Qty cannot be greater than Received Qty")
-		ret = {
-			'qty' : 0,
-			'stock_qty': 0,
-			'rejected_qty' : 0
-		}
-		// => Set Qty = 0 and rejected_qty = 0
-		set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
-		cur_frm.cscript.calc_amount(doc, 2);
-		// => Return
-		return
-	}
-	// Step 2 :=> Check IF Qty <= REceived Qty
-	else {
-		ret = {
-			'rejected_qty':flt(d.received_qty) - flt(d.qty)
-		}
-		// => Set Rejected Qty = Received Qty - Qty
-		set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
-		// => Calculate Amount
-		cur_frm.cscript.calc_amount(doc, 2);
-		cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
-	}	
-}
-
-//======================== Rejected Qty =========================================================
-cur_frm.cscript.rejected_qty = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	// Step 1 :=> Check If Rejected Qty > Received Qty
-	if (flt(d.rejected_qty) > flt(d.received_qty)) {
-		alert("Rejected Qty cannot be greater than Received Qty") 
-		ret = {
-			'qty' : 0,
-			'stock_qty': 0,
-			'rejected_qty' : 0
-		}
-		// => Set Qty = 0 and rejected_qty = 0
-		set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
-		cur_frm.cscript.calc_amount(doc, 2);
-		// => Return
-		return
-	}
-	// Step 2 :=> Check IF Rejected Qty <= REceived Qty
-	else {
-		ret = {
-			'qty':flt(d.received_qty) - flt(d.rejected_qty)
-		}
-		// => Set Qty = Received Qty - Rejected Qty
-		set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
-		// Calculate Amount
-		cur_frm.cscript.calc_amount(doc, 2);
-		cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
-	}
-}
-
 //================================= Purchase Order No Get Query ====================================
 cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) {
 	if (doc.supplier)
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 8e81fa5..83322c1 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -33,16 +33,21 @@
 		self.tname = 'Purchase Receipt Item'
 		self.fname = 'purchase_receipt_details'
 		self.count = 0
+		self.status_updater = [{
+			'source_dt': 'Purchase Receipt Item',
+			'target_dt': 'Purchase Order Item',
+			'join_field': 'prevdoc_detail_docname',
+			'target_field': 'received_qty',
+			'target_parent_dt': 'Purchase Order',
+			'target_parent_field': 'per_received',
+			'target_ref_field': 'qty',
+			'source_field': 'qty',
+			'percent_join_field': 'prevdoc_docname',
+		}]
 
 	def validate_fiscal_year(self):
 		get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Transaction Date')
 
-	# GET TERMS & CONDITIONS
-	# =====================================================================================
-	def get_tc_details(self):
-		return get_obj('Purchase Common').get_tc_details(self)
-
-
 	# get available qty at warehouse
 	def get_bin_details(self, arg = ''):
 		return get_obj(dt='Purchase Common').get_bin_details(arg)
@@ -243,8 +248,7 @@
 		# Set status as Submitted
 		webnotes.conn.set(self.doc,'status', 'Submitted')
 
-		# Update Previous Doc i.e. update pending_qty and Status accordingly
-		purchase_controller.update_prevdoc_detail(self, is_submit = 1)
+		self.update_prevdoc_status()
 
 		# Update Serial Record
 		get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 1, is_incoming = 1)
@@ -285,8 +289,7 @@
 		# 4.Update Bin
 		self.update_stock(is_submit = 0)
 
-		# 5.Update Material Requests Pending Qty and accordingly it's Status
-		pc_obj.update_prevdoc_detail(self, is_submit = 0)
+		self.update_prevdoc_status()
 
 		# 6. Update last purchase rate
 		pc_obj.update_last_purchase_rate(self, 0)
@@ -310,12 +313,6 @@
 	def get_rate(self,arg):
 		return get_obj('Purchase Common').get_rate(arg,self)
 	
-	def load_default_taxes(self):
-		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
-	
-	def get_purchase_tax_details(self):
-		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
-		
 	def make_gl_entries(self):
 		if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
 			return
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt
index 350777d..96b4141 100755
--- a/stock/doctype/purchase_receipt/purchase_receipt.txt
+++ b/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-25 16:01:29", 
+  "creation": "2013-05-21 16:16:39", 
   "docstatus": 0, 
-  "modified": "2013-02-02 19:09:37", 
+  "modified": "2013-06-05 14:45:10", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -31,7 +31,9 @@
   "parent": "Purchase Receipt", 
   "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "read": 1
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -75,43 +77,48 @@
   "width": "150px"
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "supplier_name", 
   "fieldtype": "Data", 
-  "hidden": 1, 
+  "hidden": 0, 
   "in_list_view": 1, 
   "label": "Supplier Name", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "address_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Address", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_display", 
   "fieldtype": "Small Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_mobile", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Mobile No", 
   "read_only": 1
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_email", 
   "fieldtype": "Text", 
-  "hidden": 1, 
+  "hidden": 0, 
   "label": "Contact Email", 
   "print_hide": 1, 
   "read_only": 1
@@ -548,17 +555,7 @@
   "fieldname": "get_terms", 
   "fieldtype": "Button", 
   "label": "Get Terms and Conditions", 
-  "oldfieldtype": "Button", 
-  "options": "get_tc_details"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "terms_html", 
-  "fieldtype": "HTML", 
-  "label": "Terms and Conditions HTML", 
-  "oldfieldtype": "HTML", 
-  "options": "You can add Terms and Notes that will be printed in the Transaction", 
-  "print_hide": 1
+  "oldfieldtype": "Button"
  }, 
  {
   "doctype": "DocField", 
@@ -569,6 +566,7 @@
   "oldfieldtype": "Text Editor"
  }, 
  {
+  "depends_on": "supplier", 
   "doctype": "DocField", 
   "fieldname": "contact_section", 
   "fieldtype": "Section Break", 
@@ -884,47 +882,19 @@
   "read_only": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material Manager", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material Manager", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "report": 0, 
-  "role": "Material User", 
-  "submit": 0, 
-  "write": 0
- }, 
- {
   "amend": 1, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Material User", 
   "submit": 1, 
   "write": 1
@@ -934,28 +904,13 @@
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Purchase User", 
   "submit": 1, 
   "write": 1
  }, 
  {
-  "amend": 0, 
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
-  "match": "", 
-  "permlevel": 1, 
-  "role": "Purchase User", 
-  "submit": 0
- }, 
- {
   "doctype": "DocPerm", 
   "match": "supplier", 
-  "permlevel": 0, 
-  "report": 1, 
   "role": "Supplier"
  }
 ]
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt/purchase_receipt_list.js b/stock/doctype/purchase_receipt/purchase_receipt_list.js
index d20c352..c80f6ae 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt_list.js
+++ b/stock/doctype/purchase_receipt/purchase_receipt_list.js
@@ -6,7 +6,7 @@
 	group_by: "`tabPurchase Receipt`.name",
 	prepare_data: function(data) {
 		if(data.purchase_order_no) {
-			data.purchase_order_no = data.purchase_order_no.split(",");
+			data.purchase_order_no = $.unique(data.purchase_order_no.split(","));
 			var po_list = [];
 			$.each(data.purchase_order_no, function(i, v){
 				if(po_list.indexOf(v)==-1) po_list.push(
diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
index 8cef6a3..6a35c47 100755
--- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
+++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-07 11:42:59", 
+  "creation": "2013-05-24 19:29:10", 
   "docstatus": 0, 
-  "modified": "2013-05-22 12:01:08", 
+  "modified": "2013-05-31 14:26:41", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -357,7 +357,7 @@
   "oldfieldtype": "Currency", 
   "print_hide": 1, 
   "print_width": "100px", 
-  "read_only": 0, 
+  "read_only": 1, 
   "width": "100px"
  }, 
  {
@@ -370,7 +370,7 @@
   "oldfieldname": "prevdoc_doctype", 
   "oldfieldtype": "Data", 
   "print_hide": 1, 
-  "read_only": 0
+  "read_only": 1
  }, 
  {
   "doctype": "DocField", 
@@ -453,18 +453,14 @@
   "width": "150px"
  }, 
  {
-  "default": "0.00", 
   "doctype": "DocField", 
-  "fieldname": "billed_qty", 
-  "fieldtype": "Float", 
-  "label": "Billed Quantity", 
+  "fieldname": "billed_amt", 
+  "fieldtype": "Currency", 
+  "label": "Billed Amt", 
   "no_copy": 1, 
-  "oldfieldname": "billed_qty", 
-  "oldfieldtype": "Currency", 
+  "options": "currency", 
   "print_hide": 1, 
-  "print_width": "100px", 
-  "read_only": 1, 
-  "width": "100px"
+  "read_only": 1
  }, 
  {
   "doctype": "DocField", 
diff --git a/stock/doctype/serial_no/test_serial_no.py b/stock/doctype/serial_no/test_serial_no.py
index fb27aa9..8ffaabc 100644
--- a/stock/doctype/serial_no/test_serial_no.py
+++ b/stock/doctype/serial_no/test_serial_no.py
@@ -81,8 +81,8 @@
 		self.assertFalse(gl_entries)
 		
 		webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
-	
-	
+
+test_dependencies = ["Item"]
 test_records = [
 	[
 		{
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 522a14a..d2f25f0 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -285,11 +285,10 @@
 					+ _("Status should be Submitted"), raise_exception=webnotes.InvalidStatusError)
 			
 			# update stock check
-			if ref.doclist[0].doctype == "Sales Invoice" and (cint(ref.doclist[0].is_pos) != 1 \
-				or cint(ref.doclist[0].update_stock) != 1):
-					webnotes.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": ' 
-						+ _("Is POS and Update Stock should be checked."), 
-						raise_exception=NotUpdateStockError)
+			if ref.doclist[0].doctype == "Sales Invoice" and cint(ref.doclist[0].update_stock) != 1:
+				webnotes.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": ' 
+					+ _("Update Stock should be checked."), 
+					raise_exception=NotUpdateStockError)
 			
 			# posting date check
 			ref_posting_datetime = "%s %s" % (cstr(ref.doclist[0].posting_date), 
@@ -680,7 +679,7 @@
 def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
 	conditions = ""
 	if doctype == "Sales Invoice":
-		conditions = "and is_pos=1 and update_stock=1"
+		conditions = "and update_stock=1"
 	
 	return webnotes.conn.sql("""select name, customer, customer_name
 		from `tab%s` where docstatus = 1
diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py
index c3ce2d7..a9281cd 100644
--- a/stock/doctype/stock_entry/test_stock_entry.py
+++ b/stock/doctype/stock_entry/test_stock_entry.py
@@ -450,6 +450,7 @@
 		for d in pi.doclist.get({"parentfield": "entries"}):
 			d.expense_head = "_Test Account Cost for Goods Sold - _TC"
 			d.cost_center = "_Test Cost Center - _TC"
+			
 		for d in pi.doclist.get({"parentfield": "purchase_tax_details"}):
 			d.cost_center = "_Test Cost Center - _TC"
 		
diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js
index 456f5f1..b9b4c80 100644
--- a/stock/page/stock_ageing/stock_ageing.js
+++ b/stock/page/stock_ageing/stock_ageing.js
@@ -25,7 +25,7 @@
 	new erpnext.StockAgeing(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Stock")
+	wrapper.appframe.add_module_icon("Stock")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/stock/page/stock_analytics/stock_analytics.js b/stock/page/stock_analytics/stock_analytics.js
index a003963..a52cb7d 100644
--- a/stock/page/stock_analytics/stock_analytics.js
+++ b/stock/page/stock_analytics/stock_analytics.js
@@ -25,7 +25,7 @@
 	new erpnext.StockAnalytics(wrapper);
 
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Stock")
+	wrapper.appframe.add_module_icon("Stock")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js
index 163b74f..4467b98 100644
--- a/stock/page/stock_balance/stock_balance.js
+++ b/stock/page/stock_balance/stock_balance.js
@@ -26,7 +26,7 @@
 	new erpnext.StockBalance(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Stock")
+	wrapper.appframe.add_module_icon("Stock")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js
index d8c63aa..511ddd7 100644
--- a/stock/page/stock_home/stock_home.js
+++ b/stock/page/stock_home/stock_home.js
@@ -8,17 +8,17 @@
 		items: [
 			{
 				label: wn._("Material Request"),
-				description: wn._("Request Material for Transfer or Purchase."),
+				description: wn._("Requests for items."),
 				doctype:"Material Request"
 			},
 			{
 				label: wn._("Stock Entry"),
-				description: wn._("Transfer stock from one warehouse to another."),
+				description: wn._("Record item movement."),
 				doctype:"Stock Entry"
 			},
 			{
 				label: wn._("Delivery Note"),
-				description: wn._("Delivery (shipment) to customers."),
+				description: wn._("Shipments to customers."),
 				doctype:"Delivery Note"
 			},
 			{
@@ -164,7 +164,7 @@
 		items: [
 			{
 				"label":wn._("Stock Ledger"),
-				route: "Report2/Stock Ledger Entry/Stock Ledger",
+				route: "Report/Stock Ledger Entry/Stock Ledger",
 				doctype: "Stock Ledger Entry"
 			},
 			{
@@ -179,17 +179,17 @@
 			},
 			{
 				"label":wn._("Serial No Service Contract Expiry"),
-				route: "Report2/Serial No/Serial No Service Contract Expiry",
+				route: "Report/Serial No/Serial No Service Contract Expiry",
 				doctype: "Serial No"
 			},
 			{
 				"label":wn._("Serial No Status"),
-				route: "Report2/Serial No/Serial No Status",
+				route: "Report/Serial No/Serial No Status",
 				doctype: "Serial No"
 			},
 			{
 				"label":wn._("Serial No Warranty Expiry"),
-				route: "Report2/Serial No/Serial No Warranty Expiry",
+				route: "Report/Serial No/Serial No Warranty Expiry",
 				doctype: "Serial No"
 			},
 			{
diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js
index a37ea1c..438f132 100644
--- a/stock/page/stock_ledger/stock_ledger.js
+++ b/stock/page/stock_ledger/stock_ledger.js
@@ -24,7 +24,7 @@
 	new erpnext.StockLedger(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Stock")
+	wrapper.appframe.add_module_icon("Stock")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/stock/page/stock_level/stock_level.js b/stock/page/stock_level/stock_level.js
index 75819a5..5f129c3 100644
--- a/stock/page/stock_level/stock_level.js
+++ b/stock/page/stock_level/stock_level.js
@@ -24,7 +24,7 @@
 	new erpnext.StockLevel(wrapper);
 
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Stock")
+	wrapper.appframe.add_module_icon("Stock")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart");
 }
 
diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js
index 4ee4c1d..4226b47 100644
--- a/support/doctype/support_ticket/support_ticket.js
+++ b/support/doctype/support_ticket/support_ticket.js
@@ -19,8 +19,7 @@
 $.extend(cur_frm.cscript, {
 	onload: function(doc, dt, dn) {
 		if(in_list(user_roles,'System Manager')) {
-			cur_frm.page_layout.footer.help_area.innerHTML = '<hr>\
-				<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\
+			cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\
 				<span class="help">Integrate incoming support emails to Support Ticket</span></p>';
 		}
 	},
diff --git a/support/page/support_analytics/support_analytics.js b/support/page/support_analytics/support_analytics.js
index 60384bb..9b46e6d 100644
--- a/support/page/support_analytics/support_analytics.js
+++ b/support/page/support_analytics/support_analytics.js
@@ -8,7 +8,7 @@
 	new erpnext.SupportAnalytics(wrapper);
 	
 	wrapper.appframe.add_home_breadcrumb()
-	wrapper.appframe.add_module_breadcrumb("Support")
+	wrapper.appframe.add_module_icon("Support")
 	wrapper.appframe.add_breadcrumb("icon-bar-chart")
 }
 
diff --git a/support/page/support_home/support_home.js b/support/page/support_home/support_home.js
index bde5e5c..65ea4b8 100644
--- a/support/page/support_home/support_home.js
+++ b/support/page/support_home/support_home.js
@@ -8,17 +8,17 @@
 		items: [
 			{
 				label: wn._("Support Ticket"),
-				description: wn._("Support queries from customers via email or website."),
+				description: wn._("Support queries from customers."),
 				doctype:"Support Ticket"
 			},
 			{
 				label: wn._("Customer Issue"),
-				description: wn._("Customer Issue against a Serial No (warranty)."),
+				description: wn._("Customer Issue against Serial No."),
 				doctype:"Customer Issue"
 			},
 			{
 				label: wn._("Maintenance Schedule"),
-				description: wn._("Plan for scheduled maintenance contracts."),
+				description: wn._("Plan for maintenance visits."),
 				doctype:"Maintenance Schedule"
 			},
 			{
@@ -28,7 +28,7 @@
 			},
 			{
 				label: wn._("Newsletter"),
-				description: wn._("Send Newsletters to your contacts, leads."),
+				description: wn._("Newsletters to contacts, leads."),
 				doctype:"Newsletter"
 			},
 			{
diff --git a/utilities/doctype/answer/__init__.py b/utilities/doctype/answer/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/utilities/doctype/answer/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/doctype/answer/answer.py b/utilities/doctype/answer/answer.py
deleted file mode 100644
index 7f48feb..0000000
--- a/utilities/doctype/answer/answer.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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
-
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/utilities/doctype/answer/answer.txt b/utilities/doctype/answer/answer.txt
deleted file mode 100644
index 58f0ba3..0000000
--- a/utilities/doctype/answer/answer.txt
+++ /dev/null
@@ -1,80 +0,0 @@
-[
- {
-  "creation": "2012-03-27 14:36:01", 
-  "docstatus": 0, 
-  "modified": "2012-03-27 14:36:01", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "allow_attach": 0, 
-  "allow_trash": 1, 
-  "autoname": "_ANS.#######", 
-  "doctype": "DocType", 
-  "in_create": 1, 
-  "module": "Utilities", 
-  "name": "__common__", 
-  "read_only": 1, 
-  "section_style": "Simple", 
-  "show_in_menu": 0, 
-  "version": 3
- }, 
- {
-  "doctype": "DocField", 
-  "name": "__common__", 
-  "parent": "Answer", 
-  "parentfield": "fields", 
-  "parenttype": "DocType", 
-  "permlevel": 0
- }, 
- {
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "name": "__common__", 
-  "parent": "Answer", 
-  "parentfield": "permissions", 
-  "parenttype": "DocType", 
-  "permlevel": 0, 
-  "read": 1, 
-  "report": 1, 
-  "role": "All", 
-  "write": 1
- }, 
- {
-  "doctype": "DocType", 
-  "name": "Answer"
- }, 
- {
-  "doctype": "DocPerm"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "question", 
-  "fieldtype": "Link", 
-  "label": "Question", 
-  "options": "Question"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "answer", 
-  "fieldtype": "Text", 
-  "label": "Answer", 
-  "oldfieldname": "question", 
-  "oldfieldtype": "Text"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "points", 
-  "fieldtype": "Int", 
-  "label": "Points"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "_users_voted", 
-  "fieldtype": "Text", 
-  "hidden": 1, 
-  "label": "Users Voted", 
-  "print_hide": 1
- }
-]
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/_messages_doc.json b/utilities/doctype/answer/locale/_messages_doc.json
deleted file mode 100644
index 252553e4..0000000
--- a/utilities/doctype/answer/locale/_messages_doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- "Question", 
- "Utilities", 
- "Answer", 
- "Points", 
- "Users Voted"
-]
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/ar-doc.json b/utilities/doctype/answer/locale/ar-doc.json
deleted file mode 100644
index 4950916..0000000
--- a/utilities/doctype/answer/locale/ar-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "\u0625\u062c\u0627\u0628\u0629", 
- "Points": "\u0646\u0642\u0627\u0637", 
- "Question": "\u0633\u0624\u0627\u0644", 
- "Users Voted": "\u0635\u0648\u062a \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645\u064a\u0646", 
- "Utilities": "\u062e\u062f\u0645\u0627\u062a"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/de-doc.json b/utilities/doctype/answer/locale/de-doc.json
deleted file mode 100644
index 13b8911..0000000
--- a/utilities/doctype/answer/locale/de-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Beantworten", 
- "Points": "Punkte", 
- "Question": "Frage", 
- "Users Voted": "Nutzer", 
- "Utilities": "Dienstprogramme"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/es-doc.json b/utilities/doctype/answer/locale/es-doc.json
deleted file mode 100644
index ac4cb59..0000000
--- a/utilities/doctype/answer/locale/es-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Responder", 
- "Points": "Puntos", 
- "Question": "Cuesti\u00f3n", 
- "Users Voted": "Los usuarios Votado", 
- "Utilities": "Utilidades"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/fr-doc.json b/utilities/doctype/answer/locale/fr-doc.json
deleted file mode 100644
index e3c0b30..0000000
--- a/utilities/doctype/answer/locale/fr-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "R\u00e9pondre", 
- "Points": "Points", 
- "Question": "Question", 
- "Users Voted": "Des internautes Yahoo!", 
- "Utilities": "Utilitaires"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/hi-doc.json b/utilities/doctype/answer/locale/hi-doc.json
deleted file mode 100644
index 1c44b86..0000000
--- a/utilities/doctype/answer/locale/hi-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "\u091c\u0935\u093e\u092c", 
- "Points": "\u00bb", 
- "Question": "\u0938\u0935\u093e\u0932", 
- "Users Voted": "\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e \u0935\u094b\u091f \u0926\u093f\u092f\u093e", 
- "Utilities": "\u0909\u092a\u092f\u094b\u0917\u093f\u0924\u093e\u090f\u0901"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/hr-doc.json b/utilities/doctype/answer/locale/hr-doc.json
deleted file mode 100644
index b712783..0000000
--- a/utilities/doctype/answer/locale/hr-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Odgovoriti", 
- "Points": "Bodovi", 
- "Question": "Pitanje", 
- "Users Voted": "Korisnici Glasao", 
- "Utilities": "Komunalne usluge"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/nl-doc.json b/utilities/doctype/answer/locale/nl-doc.json
deleted file mode 100644
index dc7d232..0000000
--- a/utilities/doctype/answer/locale/nl-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Beantwoorden", 
- "Points": "Punten", 
- "Question": "Vraag", 
- "Users Voted": "Gebruikers Verkozen", 
- "Utilities": "Utilities"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/pt-BR-doc.json b/utilities/doctype/answer/locale/pt-BR-doc.json
deleted file mode 100644
index b8b74d7..0000000
--- a/utilities/doctype/answer/locale/pt-BR-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Resposta", 
- "Points": "Pontos", 
- "Question": "Pergunta", 
- "Users Voted": "Votos de usu\u00e1rios", 
- "Utilities": "Utilit\u00e1rios"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/pt-doc.json b/utilities/doctype/answer/locale/pt-doc.json
deleted file mode 100644
index 987cbf2..0000000
--- a/utilities/doctype/answer/locale/pt-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "Responder", 
- "Points": "Pontos", 
- "Question": "Pergunta", 
- "Users Voted": "Votado usu\u00e1rios", 
- "Utilities": "Utilit\u00e1rios"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/sr-doc.json b/utilities/doctype/answer/locale/sr-doc.json
deleted file mode 100644
index 711187f..0000000
--- a/utilities/doctype/answer/locale/sr-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "\u041e\u0434\u0433\u043e\u0432\u043e\u0440", 
- "Points": "\u0422\u0430\u0447\u043a\u0435", 
- "Question": "\u041f\u0438\u0442\u0430\u045a\u0435", 
- "Users Voted": "\u041a\u043e\u0440\u0438\u0441\u043d\u0438\u0446\u0438 \u0413\u043b\u0430\u0441\u0430\u043e", 
- "Utilities": "\u041a\u043e\u043c\u0443\u043d\u0430\u043b\u043d\u0435 \u0443\u0441\u043b\u0443\u0433\u0435"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/ta-doc.json b/utilities/doctype/answer/locale/ta-doc.json
deleted file mode 100644
index 2fa783a..0000000
--- a/utilities/doctype/answer/locale/ta-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "\u0baa\u0ba4\u0bbf\u0bb2\u0bcd", 
- "Points": "\u0baa\u0bc1\u0bb3\u0bcd\u0bb3\u0bbf\u0b95\u0bb3\u0bcd", 
- "Question": "\u0bb5\u0bbf\u0ba9\u0bbe", 
- "Users Voted": "\u0baa\u0baf\u0ba9\u0bb0\u0bcd \u0ba4\u0bb3\u0bae\u0bcd", 
- "Utilities": "\u0baa\u0baf\u0ba9\u0bcd\u0baa\u0bbe\u0b9f\u0bc1\u0b95\u0bb3\u0bcd"
-}
\ No newline at end of file
diff --git a/utilities/doctype/answer/locale/th-doc.json b/utilities/doctype/answer/locale/th-doc.json
deleted file mode 100644
index eb8c623..0000000
--- a/utilities/doctype/answer/locale/th-doc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "Answer": "\u0e15\u0e2d\u0e1a", 
- "Points": "\u0e08\u0e38\u0e14", 
- "Question": "\u0e04\u0e33\u0e16\u0e32\u0e21", 
- "Users Voted": "\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49\u0e42\u0e2b\u0e27\u0e15", 
- "Utilities": "\u0e22\u0e39\u0e17\u0e34\u0e25\u0e34\u0e15\u0e35\u0e49"
-}
\ No newline at end of file
diff --git a/utilities/doctype/note/__init__.py b/utilities/doctype/note/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utilities/doctype/note/__init__.py
diff --git a/utilities/doctype/note/note.py b/utilities/doctype/note/note.py
new file mode 100644
index 0000000..02862de
--- /dev/null
+++ b/utilities/doctype/note/note.py
@@ -0,0 +1,25 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+		
+	def autoname(self):
+		# replace forbidden characters
+		import re
+		self.doc.name = re.sub("[%'\"#*?`]", "", self.doc.title.strip())
+		
+	def onload(self):
+		if not self.doc.public and webnotes.session.user != self.doc.owner:
+			if webnotes.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]:
+				webnotes.msgprint("You are not authorized to read this record.", raise_exception=True)
+	
+	def validate(self):
+		if not self.doc.fields.get("__islocal"):
+			if webnotes.session.user != self.doc.owner:
+				if webnotes.session.user not in webnotes.conn.sql_list("""select user from `tabNote User` 
+					where parent=%s and permission='Edit'""", self.doc.name):
+					webnotes.msgprint("You are not authorized to edit this record.", raise_exception=True)
diff --git a/utilities/doctype/note/note.txt b/utilities/doctype/note/note.txt
new file mode 100644
index 0000000..a6cdf2b
--- /dev/null
+++ b/utilities/doctype/note/note.txt
@@ -0,0 +1,84 @@
+[
+ {
+  "creation": "2013-05-24 13:41:00", 
+  "docstatus": 0, 
+  "modified": "2013-05-27 12:16:46", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "allow_print": 0, 
+  "allow_rename": 1, 
+  "description": "Note is a free page where users can share documents / notes", 
+  "doctype": "DocType", 
+  "document_type": "Transaction", 
+  "module": "Utilities", 
+  "name": "__common__", 
+  "read_only_onload": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "name": "__common__", 
+  "parent": "Note", 
+  "parentfield": "fields", 
+  "parenttype": "DocType", 
+  "permlevel": 0
+ }, 
+ {
+  "cancel": 1, 
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "name": "__common__", 
+  "parent": "Note", 
+  "parentfield": "permissions", 
+  "parenttype": "DocType", 
+  "permlevel": 0, 
+  "read": 1, 
+  "role": "All", 
+  "write": 1
+ }, 
+ {
+  "doctype": "DocType", 
+  "name": "Note"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "title", 
+  "fieldtype": "Data", 
+  "label": "Title", 
+  "print_hide": 1
+ }, 
+ {
+  "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", 
+  "doctype": "DocField", 
+  "fieldname": "content", 
+  "fieldtype": "Text Editor", 
+  "in_list_view": 0, 
+  "label": "Content"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "share", 
+  "fieldtype": "Section Break", 
+  "label": "Share"
+ }, 
+ {
+  "description": "Everyone can read", 
+  "doctype": "DocField", 
+  "fieldname": "public", 
+  "fieldtype": "Check", 
+  "label": "Public", 
+  "print_hide": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "share_with", 
+  "fieldtype": "Table", 
+  "label": "Share With", 
+  "options": "Note User", 
+  "print_hide": 1
+ }, 
+ {
+  "doctype": "DocPerm"
+ }
+]
\ No newline at end of file
diff --git a/utilities/doctype/note_user/__init__.py b/utilities/doctype/note_user/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utilities/doctype/note_user/__init__.py
diff --git a/utilities/doctype/note_user/note_user.py b/utilities/doctype/note_user/note_user.py
new file mode 100644
index 0000000..928aa9f
--- /dev/null
+++ b/utilities/doctype/note_user/note_user.py
@@ -0,0 +1,8 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/utilities/doctype/note_user/note_user.txt b/utilities/doctype/note_user/note_user.txt
new file mode 100644
index 0000000..2d82bb0
--- /dev/null
+++ b/utilities/doctype/note_user/note_user.txt
@@ -0,0 +1,45 @@
+[
+ {
+  "creation": "2013-05-24 14:24:48", 
+  "docstatus": 0, 
+  "modified": "2013-05-24 14:24:48", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "description": "List of users who can edit a particular Note", 
+  "doctype": "DocType", 
+  "document_type": "Other", 
+  "istable": 1, 
+  "module": "Utilities", 
+  "name": "__common__"
+ }, 
+ {
+  "doctype": "DocField", 
+  "name": "__common__", 
+  "parent": "Note User", 
+  "parentfield": "fields", 
+  "parenttype": "DocType", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocType", 
+  "name": "Note User"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "user", 
+  "fieldtype": "Link", 
+  "label": "User", 
+  "options": "Profile", 
+  "reqd": 1
+ }, 
+ {
+  "default": "Edit", 
+  "doctype": "DocField", 
+  "fieldname": "permission", 
+  "fieldtype": "Select", 
+  "label": "Permission", 
+  "options": "Edit\nRead"
+ }
+]
\ No newline at end of file
diff --git a/utilities/doctype/question/__init__.py b/utilities/doctype/question/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/utilities/doctype/question/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/doctype/question/locale/_messages_doc.json b/utilities/doctype/question/locale/_messages_doc.json
deleted file mode 100644
index 4d4aa11..0000000
--- a/utilities/doctype/question/locale/_messages_doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-[
- "User Tags", 
- "Question", 
- "Utilities", 
- "Answer", 
- "Points", 
- "File List", 
- "Users Voted"
-]
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/ar-doc.json b/utilities/doctype/question/locale/ar-doc.json
deleted file mode 100644
index bafb808..0000000
--- a/utilities/doctype/question/locale/ar-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "\u0625\u062c\u0627\u0628\u0629", 
- "File List": "\u0645\u0644\u0641 \u0642\u0627\u0626\u0645\u0629", 
- "Points": "\u0646\u0642\u0627\u0637", 
- "Question": "\u0633\u0624\u0627\u0644", 
- "User Tags": "\u0627\u0644\u0643\u0644\u0645\u0627\u062a \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645", 
- "Users Voted": "\u0635\u0648\u062a \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645\u064a\u0646", 
- "Utilities": "\u062e\u062f\u0645\u0627\u062a"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/de-doc.json b/utilities/doctype/question/locale/de-doc.json
deleted file mode 100644
index cf7569c..0000000
--- a/utilities/doctype/question/locale/de-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Beantworten", 
- "File List": "Dateiliste", 
- "Points": "Punkte", 
- "Question": "Frage", 
- "User Tags": "Nutzertags", 
- "Users Voted": "Nutzer", 
- "Utilities": "Dienstprogramme"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/es-doc.json b/utilities/doctype/question/locale/es-doc.json
deleted file mode 100644
index 683fc0c..0000000
--- a/utilities/doctype/question/locale/es-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Responder", 
- "File List": "Lista de archivos", 
- "Points": "Puntos", 
- "Question": "Cuesti\u00f3n", 
- "User Tags": "Nube de etiquetas", 
- "Users Voted": "Los usuarios Votado", 
- "Utilities": "Utilidades"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/fr-doc.json b/utilities/doctype/question/locale/fr-doc.json
deleted file mode 100644
index 8722801..0000000
--- a/utilities/doctype/question/locale/fr-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "R\u00e9pondre", 
- "File List": "Liste des fichiers", 
- "Points": "Points", 
- "Question": "Question", 
- "User Tags": "Nuage de Tags", 
- "Users Voted": "Des internautes Yahoo!", 
- "Utilities": "Utilitaires"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/hi-doc.json b/utilities/doctype/question/locale/hi-doc.json
deleted file mode 100644
index c7b9ebc..0000000
--- a/utilities/doctype/question/locale/hi-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "\u091c\u0935\u093e\u092c", 
- "File List": "\u092b\u093c\u093e\u0907\u0932 \u0938\u0942\u091a\u0940", 
- "Points": "\u00bb", 
- "Question": "\u0938\u0935\u093e\u0932", 
- "User Tags": "\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e \u0915\u0947 \u091f\u0948\u0917", 
- "Users Voted": "\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e \u0935\u094b\u091f \u0926\u093f\u092f\u093e", 
- "Utilities": "\u0909\u092a\u092f\u094b\u0917\u093f\u0924\u093e\u090f\u0901"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/hr-doc.json b/utilities/doctype/question/locale/hr-doc.json
deleted file mode 100644
index 94127c2..0000000
--- a/utilities/doctype/question/locale/hr-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Odgovoriti", 
- "File List": "Popis datoteka", 
- "Points": "Bodovi", 
- "Question": "Pitanje", 
- "User Tags": "Upute Tags", 
- "Users Voted": "Korisnici Glasao", 
- "Utilities": "Komunalne usluge"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/nl-doc.json b/utilities/doctype/question/locale/nl-doc.json
deleted file mode 100644
index b9f30e2..0000000
--- a/utilities/doctype/question/locale/nl-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Beantwoorden", 
- "File List": "File List", 
- "Points": "Punten", 
- "Question": "Vraag", 
- "User Tags": "Gebruiker-tags", 
- "Users Voted": "Gebruikers Verkozen", 
- "Utilities": "Utilities"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/pt-BR-doc.json b/utilities/doctype/question/locale/pt-BR-doc.json
deleted file mode 100644
index 36a2804..0000000
--- a/utilities/doctype/question/locale/pt-BR-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Resposta", 
- "File List": "Lista de Arquivos", 
- "Points": "Pontos", 
- "Question": "Pergunta", 
- "User Tags": "Etiquetas de Usu\u00e1rios", 
- "Users Voted": "Votos de usu\u00e1rios", 
- "Utilities": "Utilit\u00e1rios"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/pt-doc.json b/utilities/doctype/question/locale/pt-doc.json
deleted file mode 100644
index 415ce2b..0000000
--- a/utilities/doctype/question/locale/pt-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "Responder", 
- "File List": "Lista de Arquivos", 
- "Points": "Pontos", 
- "Question": "Pergunta", 
- "User Tags": "Etiquetas de usu\u00e1rios", 
- "Users Voted": "Votado usu\u00e1rios", 
- "Utilities": "Utilit\u00e1rios"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/sr-doc.json b/utilities/doctype/question/locale/sr-doc.json
deleted file mode 100644
index 07f56ce..0000000
--- a/utilities/doctype/question/locale/sr-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "\u041e\u0434\u0433\u043e\u0432\u043e\u0440", 
- "File List": "\u0424\u0438\u043b\u0435 \u041b\u0438\u0441\u0442", 
- "Points": "\u0422\u0430\u0447\u043a\u0435", 
- "Question": "\u041f\u0438\u0442\u0430\u045a\u0435", 
- "User Tags": "\u041a\u043e\u0440\u0438\u0441\u043d\u0438\u043a \u0422\u0430\u0433\u0441:", 
- "Users Voted": "\u041a\u043e\u0440\u0438\u0441\u043d\u0438\u0446\u0438 \u0413\u043b\u0430\u0441\u0430\u043e", 
- "Utilities": "\u041a\u043e\u043c\u0443\u043d\u0430\u043b\u043d\u0435 \u0443\u0441\u043b\u0443\u0433\u0435"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/ta-doc.json b/utilities/doctype/question/locale/ta-doc.json
deleted file mode 100644
index 8efcefc..0000000
--- a/utilities/doctype/question/locale/ta-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "\u0baa\u0ba4\u0bbf\u0bb2\u0bcd", 
- "File List": "\u0b95\u0bc7\u0bbe\u0baa\u0bcd\u0baa\u0bc1 \u0baa\u0b9f\u0bcd\u0b9f\u0bbf\u0baf\u0bb2\u0bcd", 
- "Points": "\u0baa\u0bc1\u0bb3\u0bcd\u0bb3\u0bbf\u0b95\u0bb3\u0bcd", 
- "Question": "\u0bb5\u0bbf\u0ba9\u0bbe", 
- "User Tags": "\u0baa\u0baf\u0ba9\u0bb0\u0bcd \u0b95\u0bc1\u0bb1\u0bbf\u0b9a\u0bcd\u0b9a\u0bc6\u0bbe\u0bb1\u0bcd\u0b95\u0bb3\u0bcd", 
- "Users Voted": "\u0baa\u0baf\u0ba9\u0bb0\u0bcd \u0ba4\u0bb3\u0bae\u0bcd", 
- "Utilities": "\u0baa\u0baf\u0ba9\u0bcd\u0baa\u0bbe\u0b9f\u0bc1\u0b95\u0bb3\u0bcd"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/locale/th-doc.json b/utilities/doctype/question/locale/th-doc.json
deleted file mode 100644
index cafd736..0000000
--- a/utilities/doctype/question/locale/th-doc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Answer": "\u0e15\u0e2d\u0e1a", 
- "File List": "\u0e23\u0e32\u0e22\u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e1f\u0e25\u0e4c", 
- "Points": "\u0e08\u0e38\u0e14", 
- "Question": "\u0e04\u0e33\u0e16\u0e32\u0e21", 
- "User Tags": "\u0e41\u0e17\u0e47\u0e01\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49", 
- "Users Voted": "\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49\u0e42\u0e2b\u0e27\u0e15", 
- "Utilities": "\u0e22\u0e39\u0e17\u0e34\u0e25\u0e34\u0e15\u0e35\u0e49"
-}
\ No newline at end of file
diff --git a/utilities/doctype/question/question.txt b/utilities/doctype/question/question.txt
deleted file mode 100644
index fbd7b75..0000000
--- a/utilities/doctype/question/question.txt
+++ /dev/null
@@ -1,84 +0,0 @@
-[
- {
-  "creation": "2013-01-02 17:08:46", 
-  "docstatus": 0, 
-  "modified": "2013-01-01 18:58:55", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "allow_attach": 0, 
-  "autoname": "QUES.#######", 
-  "doctype": "DocType", 
-  "in_create": 1, 
-  "module": "Utilities", 
-  "name": "__common__", 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "name": "__common__", 
-  "parent": "Question", 
-  "parentfield": "fields", 
-  "parenttype": "DocType", 
-  "permlevel": 0
- }, 
- {
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "name": "__common__", 
-  "parent": "Question", 
-  "parentfield": "permissions", 
-  "parenttype": "DocType", 
-  "permlevel": 0, 
-  "read": 1, 
-  "report": 1, 
-  "role": "All", 
-  "submit": 0, 
-  "write": 1
- }, 
- {
-  "doctype": "DocType", 
-  "name": "Question"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "question", 
-  "fieldtype": "Text", 
-  "label": "Question", 
-  "oldfieldname": "question", 
-  "oldfieldtype": "Text"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "points", 
-  "fieldtype": "Int", 
-  "hidden": 1, 
-  "label": "Points"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "answer", 
-  "fieldtype": "Text Editor", 
-  "label": "Answer", 
-  "oldfieldname": "answer", 
-  "oldfieldtype": "Text Editor"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "_user_tags", 
-  "fieldtype": "Data", 
-  "hidden": 1, 
-  "label": "User Tags"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "_users_voted", 
-  "fieldtype": "Text", 
-  "label": "Users Voted"
- }, 
- {
-  "doctype": "DocPerm"
- }
-]
\ No newline at end of file
diff --git a/utilities/page/markdown_reference/markdown_reference.html b/utilities/page/markdown_reference/markdown_reference.html
index cdf646c..767ac36 100644
--- a/utilities/page/markdown_reference/markdown_reference.html
+++ b/utilities/page/markdown_reference/markdown_reference.html
@@ -1,4 +1,4 @@
-<div class="layout-wrapper layout-wrapper-background">
+<div class="appframe col col-lg-12">
 	<div class="layout-appframe">
 		<div class="appframe-titlebar">
 			<span class="appframe-title">Markdown Reference</span>
diff --git a/utilities/page/question_view/__init__.py b/utilities/page/question_view/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/utilities/page/question_view/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/page/question_view/question_view.css b/utilities/page/question_view/question_view.css
deleted file mode 100644
index 4472da7..0000000
--- a/utilities/page/question_view/question_view.css
+++ /dev/null
@@ -1,44 +0,0 @@
-.qv-body {
-	padding: 13px;
-}
-
-
-.qv-input {
-	font-size: 14px;
-	height: 2.5em;
-	width: 100%;
-}
-
-.qv-text {
-	font-size: 20px;
-	font-weight: bold;
-}
-
-.qv-ans-input {
-	height: 5em;
-}
-
-.qv-ans-text {
-	color: #444;
-	line-height: 1.7em;
-}
-
-.qv-question-wrapper {
-}
-
-.qv-add-answer {
-	width: 50%;
-	margin: 7px 0px;
-	padding: 7px;
-	background-color: #E2E2EE;
-	display: none;
-}
-
-.qv-add-answer textarea {
-	height: 17em;
-	font-size: 12px;
-}
-
-.qv-answer {
-
-}
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.html b/utilities/page/question_view/question_view.html
deleted file mode 100644
index b091d95..0000000
--- a/utilities/page/question_view/question_view.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<div class="layout-wrapper layout-wrapper-appframe">
-	<div class="layout-appframe"></div>
-	<div class="layout-main" style="min-height: 400px">
-		<div class="qv-question-wrapper">
-		</div>
-		<hr>
-		<div class="qv-answer-wrapper">
-		</div>
-		<div class="add-answer-area"></div>
-	</div>
-</div>
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.js b/utilities/page/question_view/question_view.js
deleted file mode 100644
index e479e13..0000000
--- a/utilities/page/question_view/question_view.js
+++ /dev/null
@@ -1,193 +0,0 @@
-// 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/>.
-
-pscript['onload_question-view'] = function(wrapper) {
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
-	wrapper.appframe.title('Question');
-	wrapper.appframe.add_home_breadcrumb();
-	wrapper.appframe.add_module_breadcrumb("Knowledge Base");
-	wrapper.appframe.add_breadcrumb("icon-file");
-
-	wrapper.add_answer_area = $('.add-answer-area').get(0);
-}
-
-pscript['refresh_question-view'] = function(wrapper) {
-	// href
-	var qid = window.location.hash.split('/')[1];
-	if(qid) {
-		pscript.question_view(qid);
-	}
-}
-
-pscript.question_view = function(qid, qtext) {
-	var w = wn.pages['question-view'];
-	new KBQuestionView(w, qid, qtext);
-}
-
-KBQuestionView = function(w, qid, qtext) {
-	var me = this;
-		
-	this.make_question = function() {
-		$(w).find('.qv-question-wrapper').empty();
-		$(w.add_answer_area).empty();
-		new EditableText({
-			parent: $(w).find('.qv-question-wrapper').get(0),
-			dt: 'Question',
-			dn: qid,
-			fieldname: 'question',
-			text: qtext,
-			inp_class: 'qv-input',
-			disp_class: 'qv-text'
-		});
-
-		// show tags
-	}
-	
-	// answer list
-	this.make_answer_list = function() {
-		$(w).find('.qv-answer-wrapper').empty();
-		this.ans_list = new KBAnswerList({
-			parent: $(w).find('.qv-answer-wrapper').get(0),
-			qid: qid
-		})
-	}
-	
-	// check if users has answered 
-	// (if no) then add a box to add a new answer
-	this.make_add_answer = function() {
-		$c_page('utilities', 'question_view', 'has_answered', qid, function(r, rt) {
-			if(r.message=='No') {
-				me.make_answer_box_link();
-			}
-		});
-	}
-	
-	// add a link to open add answer
-	this.make_answer_box_link = function() {
-		wn.pages['question-view'].appframe.add_button('Add your answer', function() {
-			$(this).toggle(false);
-			me.make_answer_box();
-		}, 'icon-plus');
-	}
-	
-	// answer box
-	// text area + add button
-	this.make_answer_box = function() {
-		$ds(w.add_answer_area);
-		$(w.add_answer_area, '<h3>Add your Answer</h3>\
-			<div class="help">In markdown format</div>');
-		this.input = $a(w.add_answer_area, 'textarea');
-		$(this.input).css({width: "90%", height: "200px"});
-		//wn.tinymce.add_simple(this.input);
-		
-		this.btn = $btn($a(w.add_answer_area, 'div'), 'Post', function() {
-			var v = $(me.input).val();
-			if(!v) { msgprint('Write something!'); return; }
-			me.btn.set_working();
-			$c_page('utilities', 'question_view', 'add_answer', 
-				JSON.stringify({qid: qid, "answer":v}), 
-				function(r, rt) {
-					me.btn.done_working();
-					me.ans_list.list.run();
-					$dh(w.add_answer_area);
-				}
-			);
-		});
-	}
-	
-	this.setup = function() {
-		if(qtext) {
-			this.make();
-		}
-		else {
-			$c_page('utilities', 'question_view', 'get_question', qid, function(r, rt) {
-				qtext = r.message;
-				me.make();
-			});
-		}
-	}
-	
-	this.make = function() {
-		set_title(qtext);
-		this.make_question();
-		this.make_answer_list();
-		this.make_add_answer();		
-	}
-	
-	this.setup();
-}
-
-
-// kb answer list
-KBAnswerList = function(args) {
-	var me = this;
-	$.extend(this, args);
-	
-	this.make_list = function() {
-		wn.pages['question-view'].appframe.clear_buttons();
-		this.list = new wn.ui.Listing({
-			parent: me.parent,
-			appframe: wn.pages['question-view'].appframe,
-			as_dict: 1,
-			no_result_message: 'No answers yet, be the first one to answer!',
-			render_row: function(body, data) {
-				new KBAnswer(body, data, me)
-			},
-			get_query: function() {
-				return repl("SELECT t1.name, t1.owner, t1.answer, t1._users_voted, t2.first_name, "
-					+"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 "
-					+"where question='%(qid)s' and t1.owner = t2.name "
-					+"order by t1.modified desc", {qid: me.qid})
-			}
-		});
-		
-		this.list.run();
-		
-	}
-	
-	this.make_list();
-	
-}
-
-// kb answer
-// answer
-// by xxx | on xxx
-KBAnswer = function(body, data, ans_list) {
-	body.className = 'qv-answer';
-	var edtxt = new EditableText({
-		parent: body,
-		dt: 'Answer',
-		dn: data.name,
-		fieldname: 'answer',
-		text: data.answer,
-		inp_class: 'qv-ans-input',
-		disp_class: 'qv-ans-text',
-		height: '300px',
-		width: '90%'
-	});	
-	
-	$(edtxt.wrapper).addClass('well');
-	
-	var div = $a(body, 'div', '', {})
-	new KBItemToolbar({
-		parent: div,
-		det: data,
-		with_tags: 0,
-		doctype: 'Answer'
-	}, ans_list)
-}
-
-wn.require('app/js/kb_common.js');
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.py b/utilities/page/question_view/question_view.py
deleted file mode 100644
index 175a8ed..0000000
--- a/utilities/page/question_view/question_view.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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 load_json, cstr, now
-
-@webnotes.whitelist()
-def update_item(arg):
-	args = load_json(arg)
-	
-	webnotes.conn.sql("update `tab%s` set `%s`=%s, modified=%s where name=%s" \
-		% (args['dt'], args['fn'], '%s', '%s', '%s'), (args['text'], now(), args['dn']))
-
-@webnotes.whitelist()
-def has_answered(arg):
-	return webnotes.conn.sql("select name from tabAnswer where owner=%s and question=%s", (webnotes.user.name, arg)) and 'Yes' or 'No'
-
-@webnotes.whitelist()
-def get_question(arg):
-	return cstr(webnotes.conn.sql("select question from tabQuestion where name=%s", arg)[0][0])
-
-@webnotes.whitelist()
-def add_answer(arg):
-	arg = load_json(arg)
-	
-	from webnotes.model.doc import Document
-	a = Document('Answer')
-	a.answer = arg['answer']
-	a.question = arg['qid']
-	a.points = 1
-	a.save(1)
-	
-	webnotes.conn.set_value('Question', arg['qid'], 'modified', now())
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.txt b/utilities/page/question_view/question_view.txt
deleted file mode 100644
index 87fd053..0000000
--- a/utilities/page/question_view/question_view.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
-  "creation": "2013-04-09 11:45:31", 
-  "docstatus": 0, 
-  "modified": "2013-04-09 11:47:24", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "doctype": "Page", 
-  "module": "Utilities", 
-  "name": "__common__", 
-  "page_name": "Question View", 
-  "standard": "Yes"
- }, 
- {
-  "doctype": "Page Role", 
-  "name": "__common__", 
-  "parent": "question-view", 
-  "parentfield": "roles", 
-  "parenttype": "Page", 
-  "role": "All"
- }, 
- {
-  "doctype": "Page", 
-  "name": "question-view"
- }, 
- {
-  "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/page/questions/__init__.py b/utilities/page/questions/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/utilities/page/questions/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/page/questions/questions.css b/utilities/page/questions/questions.css
deleted file mode 100644
index 779da55..0000000
--- a/utilities/page/questions/questions.css
+++ /dev/null
@@ -1,31 +0,0 @@
-div.kb-search-wrapper textarea {
-	height: 2.2em;
-	width: 80%;
-	font-size: 14px;
-	padding: 3px;
-	margin-bottom: 7px;
-}
-
-.kb-question-wrapper {
-	padding-bottom: 3px;
-	margin-bottom: 3px;
-}
-
-.kb-questions {
-}
-
-.un-answered {
-	color: #f33;
-}
-
-.kb-question-details {
-	margin: 11px 0px 11px 29px;
-}
-
-.kb-tag-filter-area {
-	padding: 7px;
-	background-color: #F2F2E8;
-	color: #222;
-	margin: 7px 0px;
-	display: none;
-}
\ No newline at end of file
diff --git a/utilities/page/questions/questions.html b/utilities/page/questions/questions.html
deleted file mode 100644
index bec483e..0000000
--- a/utilities/page/questions/questions.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
-	<div class="layout-appframe"></div>
-	<div class="layout-main-section">
-		<div class="kb-search-wrapper">
-			<textarea></textarea>
-			<div>
-				<button class="btn btn-small search" onclick="">
-					<i class="icon-search"></i> Search</button>
-				<button class="btn btn-small ask">
-					<i class="icon-question-sign"></i> Ask</button>
-			</div>
-		</div>
-	</div>
-	<div class="layout-side-section">
-		<div class="questions-tags"></div>
-		<p class="help">A wiki or Q&A for your organization</p>
-	</div>
-	<div style="clear: both;"></div>
-</div>
\ No newline at end of file
diff --git a/utilities/page/questions/questions.js b/utilities/page/questions/questions.js
deleted file mode 100644
index e7e99b5..0000000
--- a/utilities/page/questions/questions.js
+++ /dev/null
@@ -1,221 +0,0 @@
-// 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/>.
-
-pscript.onload_questions = function(wrapper) {
-	body = $(wrapper).find('.layout-main-section').get(0);
-	
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
-	wrapper.appframe.add_home_breadcrumb();
-	wrapper.appframe.add_breadcrumb(wn.modules["Knowledge Base"].icon);
-	wrapper.appframe.title('Knowledge Base');
-	
-	// kb
-	var kb = new KnowledgeBase(body);
-	
-	wn.model.with_doctype("Question", function() {
-		this.sidebar_stats = new wn.views.SidebarStats({
-			doctype: "Question",
-			stats: ["_user_tags"],
-			parent: $(wrapper).find('.questions-tags'),
-			set_filter: function(fieldname, label) {
-				kb.set_filter(fieldname, label);
-				//me.set_filter(fieldname, label);
-			}
-		});	
-	})
-}
-
-// knowledge base object
-// has a box for search or ask a question
-// and list of top rated search results
-//
-function KnowledgeBase(w) {
-	var me = this;
-	this.sort_by = 'modified';
-	this.tag_filter_dict = {};
-	
-	this.make_search_bar = function() {
-		this.search = $(w).find('.kb-search-wrapper textarea').get(0);
-		
-		$(w).find('.btn.search').click(function() {
-			me.run();
-		})
-		$(w).find('.btn.ask').click(function() {
-			me.ask();
-		})
-	}
-	
-	// ask a new question
-	this.ask = function() {
-		if(this.search.value==$(this.search).attr('default_text')) {
-			msgprint('Please enter some text'); return;
-		}
-		this.add_question([]);
-	}
-	
-	// suggest a few users who can answer
-	this.suggest = function() {
-		this.dialog = new wn.ui.Dialog({
-			title: 'Suggest a users',
-			width: 400,
-			fields: [
-				{fieldtype:'HTML', options:'Optional: Suggest a few users who can help you answer this question<br>'},
-				{fieldtype:'Link', fieldname:'profile1', label:'1st User',options:'Profile'},
-				{fieldtype:'Link', fieldname:'profile2', label:'2nd User',options:'Profile'},
-				{fieldtype:'Link', fieldname:'profile3', label:'3rd User',options:'Profile'},
-				{fieldtype:'Button', fieldname:'ask', label:'Add the Question'}
-			]
-		});
-		this.dialog.fields_dict.ask.input.onclick = function() {
-			me.dialog.hide();
-			me.add_question(values(me.dialog.get_values()));
-		}
-		this.dialog.show();
-	}
-	
-	// add a new question to the database
-	this.add_question = function(suggest_list) {
-		$c_page('utilities', 'questions', 'add_question', {
-			question: this.search.value,
-			suggest: suggest_list
-		}, function(r,rt) {
-			$(me.search).val('').blur();
-			me.run();
-		})
-	}
-	
-	// where tags that filter will be displayed
-	this.make_tag_filter_area = function() {
-		this.tag_filters = $a(w, 'div', 'kb-tag-filter-area');
-		$a(this.tag_filters,'span','',{marginRight:'4px',color:'#442'}, '<i>Showing for:</i>');
-		this.tag_area = $a(this.tag_filters, 'span');
-	}
-	
-	// make a list of questions
-	this.make_list = function() {
-		this.make_tag_filter_area();
-		this.list_area = $a(w, 'div', '', {marginRight:'13px'})
-		this.no_result = $a(w, 'div','help_box',{display:'none'},'No questions asked yet! Be the first one to ask')
-
-		this.list = new wn.ui.Listing({
-			parent: this.list_area,
-			no_results_message: 'No questions found. Ask a new question!',
-			appframe: wn.pages.questions.appframe,
-			as_dict: 1,
-			method: 'utilities.page.questions.questions.get_questions',
-			get_args: function() {
-				var args = {};
-				if(me.search.value) {
-					args.search_text = me.search.value;
-				}
-				if(me.tag_filter_dict) {
-					args.tag_filters = keys(me.tag_filter_dict);
-				}
-				return args
-			},
-			render_row: function(parent, data, listing) {
-				new KBQuestion(parent, data, me);
-			}
-		});
-		
-		this.list.run();
-
-	}
-
-	this.set_filter = function(fieldname, label) {
-		this.set_tag_filter({label:label});
-	}
-	// add a tag filter to the search in the
-	// main page
-	this.set_tag_filter = function(tag) {
-
-		// check if exists
-		if(in_list(keys(me.tag_filter_dict), tag.label)) return;
-
-		// create a tag in filters
-		var filter_tag = new SingleTag({
-			parent: me.tag_area,
-			label: tag.label,
-			dt: 'Question',
-			color: tag.color
-		});
-
-		// remove tag from filters
-		filter_tag.remove = function(tag_remove) {
-			$(tag_remove.body).fadeOut();
-			delete me.tag_filter_dict[tag_remove.label];
-
-			// hide everything?
-			if(!keys(me.tag_filter_dict).length) {
-				$(me.tag_filters).slideUp(); // hide
-			}
-
-			// run
-			me.run();
-		}
-
-		// add to dict
-		me.tag_filter_dict[tag.label] = filter_tag;
-		$ds(me.tag_filters);
-
-		// run
-		me.run();
-	}	
-	this.run = function() {
-		this.list.run();
-	}
-
-	this.make_search_bar();
-	this.make_list();
-	
-}
-
-// single kb question
-// "question
-//  points | tag list"
-
-KBQuestion = function(parent, det, kb) {
-	
-	this.make = function() {
-		this.wrapper = $a(parent, 'div', 'kb-question-wrapper');
-		this.q_area = $a($a(this.wrapper, 'div'), 'h3', 
-			'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question);
-		if(det.answers==0) {
-			$(this.q_area).addClass('un-answered')
-		}
-
-		this.q_area.onclick = function() {
-			var q = this;
-			window.location.href = '#!question-view/' + q.id;
-			//loadpage('question-view', function() { pscript.question_view(q.id, q.txt) })
-		}
-		
-		this.q_area.id = det.name; this.q_area.txt = det.question;
-
-		new KBItemToolbar({
-			parent: this.wrapper,
-			det: det,
-			with_tags: 1,
-			doctype: 'Question'
-		}, kb)
-		
-	}
-	
-
-	this.make()
-}
-
-wn.require('app/js/kb_common.js');
diff --git a/utilities/page/questions/questions.py b/utilities/page/questions/questions.py
deleted file mode 100644
index 442fb01..0000000
--- a/utilities/page/questions/questions.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# 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 load_json
-import json
-
-@webnotes.whitelist()
-def get_questions():
-	"""get list of questions"""
-	import json
-	conds = ''
-	
-	if 'search_text' in webnotes.form_dict:
-		conds = ' and t1.question like "%'+ webnotes.form_dict['search_text'] + '%"'
-		
-	if 'tag_filters' in webnotes.form_dict:
-		tag_filters = json.loads(webnotes.form_dict['tag_filters'])
-		for t in tag_filters:
-			conds += ' and t1._user_tags like "%'+ t +'%"'
-	
-	return webnotes.conn.sql("""select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags,
-			(select count(*) from tabAnswer where
-			tabAnswer.question = t1.name) as answers
-		from tabQuestion t1, tabProfile t2
-		where t1.docstatus!=2
-		and t1.owner = t2.name
-		%(conds)s
-		order by t1.modified desc""" % {"conds":conds}, as_dict=1)
-
-# add a new question
-@webnotes.whitelist()
-def add_question(arg):
-	args = load_json(arg)
-	
-	from webnotes.model.doc import Document
-	d = Document('Question')
-	d.question = args['question']
-	d.points = 1
-	d.save(1)
-	
-	if args['suggest']:
-		from core.page.messages import messages
-		for s in args['suggest']:
-			if s:
-				messages.post(json.dumps({
-					'contact': s,
-					'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
-					'notify': 1
-				}))
-
-@webnotes.whitelist()
-def delete(arg):
-	"""
-		delete a question or answer (called from kb toolbar)
-	"""
-	args = load_json(arg)
-	from webnotes.model import delete_doc
-	delete_doc(args['dt'], args['dn'])
diff --git a/utilities/page/questions/questions.txt b/utilities/page/questions/questions.txt
deleted file mode 100644
index e327ebf..0000000
--- a/utilities/page/questions/questions.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
-  "creation": "2013-04-09 11:50:08", 
-  "docstatus": 0, 
-  "modified": "2013-04-09 11:52:08", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "doctype": "Page", 
-  "module": "Utilities", 
-  "name": "__common__", 
-  "page_name": "Questions", 
-  "standard": "Yes"
- }, 
- {
-  "doctype": "Page Role", 
-  "name": "__common__", 
-  "parent": "questions", 
-  "parentfield": "roles", 
-  "parenttype": "Page", 
-  "role": "All"
- }, 
- {
-  "doctype": "Page", 
-  "name": "questions"
- }, 
- {
-  "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/page/trash/__init__.py b/utilities/page/trash/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/utilities/page/trash/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/page/trash/trash.html b/utilities/page/trash/trash.html
deleted file mode 100644
index b17e475..0000000
--- a/utilities/page/trash/trash.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<div class="layout_wrapper">
-<div id="trash_header"></div>
-<div id="trash_div" style="margin: 0px;"></div>
-</div>
\ No newline at end of file
diff --git a/utilities/page/trash/trash.js b/utilities/page/trash/trash.js
deleted file mode 100644
index b30626d..0000000
--- a/utilities/page/trash/trash.js
+++ /dev/null
@@ -1,144 +0,0 @@
-// 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/>.
-
-pscript['onload_Trash'] = function() {
-
-  // header and toolbar
-  var h = new PageHeader('trash_header','Trash Bin','Restore the documents that you have trashed')
-  
-  if(!pscript.trash_bin) pscript.trash_bin = new pscript.Trash();
-}
-
-pscript.Trash = function() {
-  // create UI elements
-  this.wrapper = $i('trash_div');
-  
-  this.head = $a(this.wrapper, 'div');
-  this.body = $a(this.wrapper, 'div');
-  $y(this.body, {margin:'8px'})
-
-  this.make_head();
-  this.load_masters();
-}
-
-// Make Button
-// ------------
-pscript.Trash.prototype.make_button = function(label, area){
-  var me = this;
-  var w = $a(area, 'div', '', {margin:'8px'});
-  var t = make_table(w,1,1,'400px',['50%','50%']);
-  var s = $a($td(t,0,0),'button');
-  s.innerHTML = label;
-  s.wrapper = w;
-  return s;
-}
-
-
-// Make Head
-// -------------
-pscript.Trash.prototype.make_head = function() {
-  var me = this;
-  
-  var make_select = function(label) {
-    var w = $a(me.head, 'div', '', {margin:'8px'});
-    var t = make_table(w,1,2,'400px',['50%','50%']);
-    $td(t,0,0).innerHTML = label;
-    var s = $a($td(t,0,1),'select','',{width:'140px'});
-    s.wrapper = w;
-    return s;
-  }
-  
-  // Select Master Name
-  this.master_select = make_select('Select Master');
-    
-  var me = this;
-  // Get Records
-  this.get_records_button = me.make_button('Get Records', me.head);
-  this.get_records_button.onclick = function() {
-    me.get_records();
-  }
-}
-
-
-// Load Masters
-// -------------
-pscript.Trash.prototype.load_masters = function(){
-  var me = this;
-  var callback = function(r, rt){
-    // Masters
-    empty_select(me.master_select);
-    add_sel_options(me.master_select,add_lists(['All'], r.message), 'All');
-  }
-  $c_obj('Trash Control','get_masters','',callback);
-}
-
-
-// Get Records
-// -----------
-pscript.Trash.prototype.get_records = function(){
-  var me = this;
-  me.body.innerHTML = '';
-  var callback = function(r, rt){
-    if(r.message) me.generate_trash_records(r.message);
-    else msgprint("No Records Found");
-  }
-  $c_obj('Trash Control','get_trash_records',sel_val(me.master_select),callback);
-}
-
-
-// Generate Trash Records
-// -----------------------
-pscript.Trash.prototype.generate_trash_records = function(rec_dict){
-  var me = this;
-  pscript.all_checkboxes = [];
-  mnames = keys(rec_dict).sort();
-  for(var i = 0; i < mnames.length; i ++){
-    var head = $a(me.body, 'h3'); head.innerHTML = mnames[i];
-    var rec_table = make_table(me.body,rec_dict[mnames[i]].length,2,'375px',['350px','25px'],{border:'1px solid #AAA',padding:'2px'});
-    for(var j = 0; j < rec_dict[mnames[i]].length; j++){
-      $a_input($td(rec_table,j,0), 'data');
-      $td(rec_table,j,0).innerHTML = rec_dict[mnames[i]][j];
-      var chk = $a_input($td(rec_table,j,1), 'checkbox');
-      chk.master = mnames[i];
-      chk.record = rec_dict[mnames[i]][j];
-      pscript.all_checkboxes.push(chk);
-    }
-  }
-  this.restore_button = me.make_button('Restore Selected', me.body);
-  this.restore_button.onclick = function() {
-    me.restore_records(0);
-  }
-  this.restore_all_button = me.make_button('Restore All', me.body);
-  this.restore_all_button.onclick = function() {
-    me.restore_records(1);
-  }
-}
-
-
-// Restore Records
-// ---------------
-pscript.Trash.prototype.restore_records = function(restore_all){
-  var me = this;
-  var out = {};
-  for(i in pscript.all_checkboxes) {
-    c = pscript.all_checkboxes[i];
-    if (restore_all || (!restore_all && c.checked)) {
-      if(!out[c.master]) out[c.master] = [c.record];
-      else {out[c.master].push(c.record);}
-    }
-  }
-  $c_obj('Trash Control','restore_records',JSON.stringify(out),function(r, rt){me.get_records();})
-}
\ No newline at end of file
diff --git a/utilities/page/trash/trash.txt b/utilities/page/trash/trash.txt
deleted file mode 100644
index a13e1b6..0000000
--- a/utilities/page/trash/trash.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2010-10-12 15:19:32", 
-  "modified_by": "Administrator", 
-  "modified": "2010-12-30 11:44:36"
- }, 
- {
-  "name": "__common__", 
-  "module": "Utilities", 
-  "page_name": "Trash", 
-  "doctype": "Page", 
-  "standard": "Yes"
- }, 
- {
-  "name": "__common__", 
-  "parent": "Trash", 
-  "doctype": "Page Role", 
-  "parenttype": "Page", 
-  "parentfield": "roles"
- }, 
- {
-  "name": "Trash", 
-  "doctype": "Page"
- }, 
- {
-  "role": "Administrator", 
-  "doctype": "Page Role"
- }, 
- {
-  "role": "Sales Master Manager", 
-  "doctype": "Page Role"
- }, 
- {
-  "role": "Material Master Manager", 
-  "doctype": "Page Role"
- }, 
- {
-  "role": "Purchase Master Manager", 
-  "doctype": "Page Role"
- }, 
- {
-  "role": "Accounts Manager", 
-  "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index f9af912..c17df6d 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -16,12 +16,13 @@
 
 from __future__ import unicode_literals
 import webnotes
+from webnotes import msgprint, _
 from webnotes.utils import load_json, cstr, flt, now_datetime
 from webnotes.model.doc import addchild
 
-from webnotes.model.controller import DocListController
+from controllers.status_updater import StatusUpdater
 
-class TransactionBase(DocListController):
+class TransactionBase(StatusUpdater):
 	def get_default_address_and_contact(self, party_type):
 		"""get a dict of default field values of address and contact for a given party type
 			party_type can be one of: customer, supplier"""
@@ -191,7 +192,8 @@
 	# Get Supplier Default Primary Address - first load
 	# -----------------------
 	def get_default_supplier_address(self, args):
-		args = load_json(args)
+		if isinstance(args, basestring):
+			args = load_json(args)
 		address_text, address_name = self.get_address_text(supplier=args['supplier'])
 		ret = {
 			'supplier_address' : address_name,
@@ -303,3 +305,57 @@
 				})
 			
 			webnotes.bean(event_doclist).insert()
+	
+def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
+	"""common validation for currency and price list currency"""
+	if conversion_rate == 0:
+		msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
+	
+	company_currency = webnotes.conn.get_value("Company", company, "default_currency")
+	
+	# parenthesis for 'OR' are necessary as we want it to evaluate as 
+	# mandatory valid condition and (1st optional valid condition 
+	# 	or 2nd optional valid condition)
+	valid_conversion_rate = (conversion_rate and 
+		((currency == company_currency and conversion_rate == 1.00)
+			or (currency != company_currency and conversion_rate != 1.00)))
+
+	if not valid_conversion_rate:
+		msgprint(_('Please enter valid ') + conversion_rate_label + (': ') 
+			+ ("1 %s = [?] %s" % (currency, company_currency)),
+			raise_exception=True)
+			
+def validate_item_fetch(args, item):
+	from stock.utils import validate_end_of_life
+	validate_end_of_life(item.name, item.end_of_life)
+	
+	# validate company
+	if not args.company:
+		msgprint(_("Please specify Company"), raise_exception=True)
+	
+def validate_currency(args, item, meta=None):
+	from webnotes.model.meta import get_field_precision
+	if not meta:
+		meta = webnotes.get_doctype(args.doctype)
+		
+	# validate conversion rate
+	if meta.get_field("currency"):
+		validate_conversion_rate(args.currency, args.conversion_rate, 
+			meta.get_label("conversion_rate"), args.company)
+		
+		# round it
+		args.conversion_rate = flt(args.conversion_rate, 
+			get_field_precision(meta.get_field("conversion_rate"), 
+				webnotes._dict({"fields": args})))
+	
+	# validate price list conversion rate
+	if meta.get_field("price_list_currency") and args.price_list_name and \
+		args.price_list_currency:
+		validate_conversion_rate(args.price_list_currency, args.plc_conversion_rate, 
+			meta.get_label("plc_conversion_rate"), args.company)
+		
+		# round it
+		args.plc_conversion_rate = flt(args.plc_conversion_rate, 
+			get_field_precision(meta.get_field("plc_conversion_rate"), 
+				webnotes._dict({"fields": args})))
+	
diff --git a/website/css/website.css b/website/css/website.css
index 25e2c91..36e306d 100644
--- a/website/css/website.css
+++ b/website/css/website.css
@@ -1,47 +1,15 @@
-div.outer {
-	padding: 30px;
-	margin: 30px -30px 10px -30px;
-	min-height: 400px;
+h1, h2, h3, h4, h5 {
+	font-weight: bold;
 }
 
-.outer .navbar {
-	margin: -30px -30px 20px -30px;
-}
-
-footer {
-	text-align: left;
-	margin: auto;
-	margin-bottom: 20px;
-}
-
-.navbar-inner {
-	border: 0px;
-	border-bottom: 1px solid #ddd;
-	border-radius: 0px;
-	padding-right: 30px;
-	padding-left: 30px;
-}
-
-p, li {
-	line-height: 1.5em;
-}
-
-.layout-wrapper {
-	box-shadow: none;
-	-webkit-box-shadow: none;
-	-moz-box-shadow: none;
-	border-radius: 0px 0px 5px 5px;
-}
-
-.layout-main {
-	min-height: 400px;
-	padding: 30px;
+.content {
+	padding-bottom: 30px;
 }
 
 .missing-image {
 	background-color: #eee;
 	padding: 40px;
-	width: 32px;
+	width: 112px;
 	font-size: 32px;
 	color: #888;
 }
@@ -129,3 +97,15 @@
 .avatar-x-large img {
 	width: 100px; 
 }
+
+.carousel-control .icon {
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  z-index: 5;
+  display: inline-block;
+  width: 20px;
+  height: 20px;
+  margin-top: -10px;
+  margin-left: -10px;
+}
diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css
index f055b78..996774e 100644
--- a/website/doctype/style_settings/custom_template.css
+++ b/website/doctype/style_settings/custom_template.css
@@ -66,8 +66,9 @@
 }
 
 /* Bootstrap Navbar */
-.navbar-inverse .navbar-inner {
+.navbar-inverse {
 	box-shadow: none;
+	border-radius: 0px;
     background-color: #{{ doc.top_bar_background or "444444"}};
     background-repeat: repeat-x;
 	background-image: none;
@@ -78,9 +79,9 @@
 	{%- endif %}
 }
 
-.navbar-inverse .brand,
-.navbar-inverse .brand:hover,
-.navbar-inverse .brand:focus,
+.navbar-inverse .navbar-brand,
+.navbar-inverse .navbar-brand:hover,
+.navbar-inverse .navbar-brand:focus,
 .navbar-inverse .nav > li > a {
   color: #{{ doc.top_bar_foreground or "fffffff"}};
   text-shadow: none;
@@ -117,8 +118,8 @@
   color: #{{ doc.top_bar_foreground or "fffffff"}};
 }
 
-.navbar-fixed-top .navbar-inner,
-.navbar-static-top .navbar-inner {
+.navbar-fixed-top,
+.navbar-static-top {
   -webkit-box-shadow: none;
      -moz-box-shadow: none;
           box-shadow: none;
@@ -190,14 +191,6 @@
   text-shadow: none;
 }
 
-.breadcrumb > li > .divider {
-  color: #{{ doc.page_text }};
-}
-
-.breadcrumb > .active {
-  color: #{{ doc.page_text }};
-}
-
 
 .table-striped tbody > tr:nth-child(odd) > td,
 .table-striped tbody > tr:nth-child(odd) > th {
diff --git a/website/doctype/website_script/website_script.py b/website/doctype/website_script/website_script.py
index 928aa9f..60403d4 100644
--- a/website/doctype/website_script/website_script.py
+++ b/website/doctype/website_script/website_script.py
@@ -5,4 +5,9 @@
 
 class DocType:
 	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+		self.doc, self.doclist = d, dl
+		
+	def on_update(self):
+		# make js and css
+		from website.helpers.make_web_include_files import make
+		make()
\ No newline at end of file
diff --git a/website/doctype/website_slideshow/website_slideshow.txt b/website/doctype/website_slideshow/website_slideshow.txt
index 2887d4b..e67e1f8 100644
--- a/website/doctype/website_slideshow/website_slideshow.txt
+++ b/website/doctype/website_slideshow/website_slideshow.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-03-07 14:48:40", 
+  "creation": "2013-03-07 15:53:15", 
   "docstatus": 0, 
-  "modified": "2012-12-25 16:56:34", 
+  "modified": "2013-05-28 16:57:32", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -53,6 +53,7 @@
  }, 
  {
   "depends_on": "eval:!doc.__islocal", 
+  "description": "Note: For best results, images must be of the same size and width must be greater than height.", 
   "doctype": "DocField", 
   "fieldname": "sb0", 
   "fieldtype": "Section Break", 
diff --git a/website/helpers/blog.py b/website/helpers/blog.py
index 386c4b7..2504067 100644
--- a/website/helpers/blog.py
+++ b/website/helpers/blog.py
@@ -63,18 +63,26 @@
 	"""
 	import webnotes
 	import webnotes.utils, markdown2
-	import webnotes.widgets.form.comments	
 	
 	if not args: args = webnotes.form_dict
 	args['comment'] = unicode(markdown2.markdown(args.get('comment') or ''))
+	args['doctype'] = "Comment"
 	
-	comment = webnotes.widgets.form.comments.add_comment(args)
+	page_name = args.get("page_name")
+	if "page_name" in args:
+		del args["page_name"]
+	if "cmd" in args:
+		del args["cmd"]
+		
+	comment = webnotes.bean(args)
+	comment.ignore_permissions = True
+	comment.insert()
 	
 	# since comments are embedded in the page, clear the web cache
-	webnotes.webutils.clear_cache(args.get('page_name'))
+	webnotes.webutils.clear_cache(page_name)
 	
-	comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
-	template_args = { 'comment_list': [comment], 'template': 'app/website/templates/html/comment.html' }
+	args['comment_date'] = webnotes.utils.global_date_format(comment.doc.creation)
+	template_args = { 'comment_list': [args], 'template': 'app/website/templates/html/comment.html' }
 	
 	# get html of comment row
 	comment_html = webnotes.webutils.build_html(template_args)
@@ -94,7 +102,7 @@
 		subject='New Comment on Blog: ' + blog['title'], 
 		message='%(comment)s<p>By %(comment_by_fullname)s</p>' % args)
 	
-	return comment_html
+	return comment_html.replace("\n", "")
 
 @webnotes.whitelist(allow_guest=True)
 def add_subscriber(name, email_id):
diff --git a/website/templates/css/blog_page.css b/website/templates/css/blog_page.css
index 8f56cd2..ffa45b4 100644
--- a/website/templates/css/blog_page.css
+++ b/website/templates/css/blog_page.css
@@ -1,4 +1,8 @@
 	<style>
+		[itemprop="articleBody"] {
+			font-size: 120%;
+		}
+	
 		.comment-title {
 			color:#777;
 		}
diff --git a/website/templates/html/blog_footer.html b/website/templates/html/blog_footer.html
index e439d14..8a84572 100644
--- a/website/templates/html/blog_footer.html
+++ b/website/templates/html/blog_footer.html
@@ -1,12 +1,12 @@
-<div class="span12">
+<div class="col col-lg-12">
 	<hr />
 	{% if categories %}
 	<h5>Explore posts by categories</h5>
 	<ul class="breadcrumb" style="background-color: transparent; padding-left: 0px;">
 	{% for category in categories %}
 		<li><a href="blog?category={{ category }}">{{ category }}</a> 
-		{% if not loop.last %}<span class="divider">/</span>{% endif %}</li>
 	{% endfor %}
+	</ul>
 	<br><br>
 	{% endif %}
 	<p>Show posts by <a href="blog">everyone</a>. Meet the <a href="writers">writers</a> of this blog</p>
diff --git a/website/templates/html/blog_page.html b/website/templates/html/blog_page.html
index cf1f00e..ddb61d0 100644
--- a/website/templates/html/blog_page.html
+++ b/website/templates/html/blog_page.html
@@ -9,7 +9,7 @@
 {% endblock %}
 
 {% block content %}
-<div class="span12" itemscope itemtype="http://schema.org/BlogPost">
+<div class="col col-lg-12" itemscope itemtype="http://schema.org/BlogPost">
 	<h2 itemprop="name headline">{{ title }}</h2>
 
 	<!-- begin blog content -->
@@ -37,7 +37,7 @@
 		
 		{% include 'app/website/templates/html/comment.html' %}
 	</div>
-	<div><button class="btn add-comment">{{ texts.add_comment }}</button></div>
+	<div><button class="btn btn-default add-comment">{{ texts.add_comment }}</button></div>
 	<div style="display: none; margin-top: 10px;" 
 		id="comment-form">
 		<div class="alert" style="display:none;"></div>
diff --git a/website/templates/html/blogger.html b/website/templates/html/blogger.html
index e18f86a..738fd1a 100644
--- a/website/templates/html/blogger.html
+++ b/website/templates/html/blogger.html
@@ -1,10 +1,10 @@
 <div class="row">
-	<div class="span2">
+	<div class="col col-lg-2">
 		<div class="avatar avatar-large">
 			<img itemprop="thumbnailUrl" src="{{ blogger_info.avatar }}" />
 		</div>
 	</div>
-	<div class="span10">
+	<div class="col col-lg-10">
 		<h4>{{ blogger_info.full_name }}</h4>
 		<p style="color: #999">{{ blogger_info.bio }}</p>
 		<p><a href="blog?by={{ blogger_info.name }}&by_name={{ blogger_info.full_name }}">
diff --git a/website/templates/html/footer.html b/website/templates/html/footer.html
index 2f1c7fe..3161987 100644
--- a/website/templates/html/footer.html
+++ b/website/templates/html/footer.html
@@ -1,71 +1,79 @@
-<footer class="container"><div class="web-footer">
-	{% if facebook_share or google_plus_one or twitter_share or linked_in_share %}
-	<div class="social-icons" style="">
-		<span style="font-size: 11px;">{{ share_text or "Share this page on: "}}</span>
-		{% if google_plus_one %}
-			<a href="https://plus.google.com/share?url={{ url }}"
-			 	target="_blank"><i class="icon-google-plus"></i></a>
+<footer class="container">
+	<div class="web-footer row">
+	<div class="col col-lg-12">
+		{% if facebook_share or google_plus_one or twitter_share or linked_in_share %}
+		<div class="social-icons" style="">
+			<span style="font-size: 11px;">{{ share_text or "Share this page on: "}}</span>
+			{% if google_plus_one %}
+				<a href="https://plus.google.com/share?url={{ url }}"
+				 	target="_blank"><i class="icon-google-plus"></i></a>
+			{% endif %}
+			{% if twitter_share %}
+				<a href="https://twitter.com/intent/tweet?url={{ url }}&text={{ encoded_title }}"
+					target="_blank" ><i class="icon-twitter"></i></a>
+			{% endif %}
+			{% if facebook_share %}
+				<a href="https://www.facebook.com/sharer.php?u={{ url }}&t={{ encoded_title }}&via={{ twitter_share_via }}"
+					target="_blank"><i class="icon-facebook"></i></a>
+			{% endif %}
+			{% if linked_in_share %}
+				<a href="http://www.linkedin.com/shareArticle?mini=true&url={{ url }}&title={{ encoded_title }}"
+					target="_blank"><i class="icon-linkedin"></i></a>
+			{% endif %}
+		</div>
 		{% endif %}
-		{% if twitter_share %}
-			<a href="https://twitter.com/intent/tweet?url={{ url }}&text={{ encoded_title }}"
-				target="_blank" ><i class="icon-twitter"></i></a>
+		<p style="float: right; clear: right;">
+			<a style="font-size: 90%; color: #888;" href="attributions">ERPNext Powered</a>
+		</p>
+		<div class="web-footer-menu">
+			<ul>
+				{% for item in footer_items %}
+				<li><a href="{{ item.url }}" {{ item.target }}
+					data-label="{{ item.label }}">{{ item.label }}</a></li>
+				{% endfor %}
+			</ul>
+		</div>
+		{% if copyright %}
+		<div class="web-footer-copyright">&copy; {{ copyright }}</div>
 		{% endif %}
-		{% if facebook_share %}
-			<a href="https://www.facebook.com/sharer.php?u={{ url }}&t={{ encoded_title }}&via={{ twitter_share_via }}"
-				target="_blank"><i class="icon-facebook"></i></a>
+		{% if address %}
+		{{ address }}
 		{% endif %}
-		{% if linked_in_share %}
-			<a href="http://www.linkedin.com/shareArticle?mini=true&url={{ url }}&title={{ encoded_title }}"
-				target="_blank"><i class="icon-linkedin"></i></a>
-		{% endif %}
-	</div>
-	{% endif %}
-	<p style="float: right; clear: right;">
-		<a style="font-size: 90%; color: #888;" href="attributions">ERPNext Powered</a>
-	</p>
-	<div class="web-footer-menu">
-	<ul>
-		{% for item in footer_items %}
-		<li><a href="{{ item.url }}" {{ item.target }}
-			data-label="{{ item.label }}">{{ item.label }}</a></li>
-		{% endfor %}
-	</ul>
-	</div>
-	{% if copyright %}
-	<div class="web-footer-copyright">&copy; {{ copyright }}</div>
-	{% endif %}
-	{% if address %}
-	{{ address }}
-	{% endif %}
-	<p><div class="input-append" style="text-align: center; margin:30px 0px;">
-	  <input class="span3" id="footer-subscribe-email" type="text" placeholder="Your email address...">
-	  <button class="btn" type="button" id="footer-subscribe-button">Stay Updated</button>
-	</div></p>
-	<script>
-		$("#footer-subscribe-button").click(function() {
+		<br>
+		<div class="input-group col col-lg-6 col-offset-3">
+			<input type="text" id="footer-subscribe-email" placeholder="Your email address...">
+			<span class="input-group-btn">
+				<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
+			</span>
+		</div>
+		<br>
+		<script>
+			$("#footer-subscribe-button").click(function() {
 
-			$("#footer-subscribe-email").attr('disabled', true);
-			$("#footer-subscribe-button").html("Sending...")
-				.attr("disabled", true);
+				$("#footer-subscribe-email").attr('disabled', true);
+				$("#footer-subscribe-button").html("Sending...")
+					.attr("disabled", true);
 
-			if($("#footer-subscribe-email").val()) {
-				erpnext.send_message({
-					subject:"Subscribe me",
-					sender: $("#footer-subscribe-email").val(),
-					message: "Subscribe to newsletter (via website footer).",
-					callback: function(r) {
-						if(!r.exc) {
-							$("#footer-subscribe-button").html("Thank You :)")
-								.addClass("btn-success").attr("disabled", true);
-						} else {
-							$("#footer-subscribe-button").html("Error :( Not a valid id?")
-								.addClass("btn-danger").attr("disabled", false);
-							$("#footer-subscribe-email").val("").attr('disabled', false);
+				if($("#footer-subscribe-email").val()) {
+					erpnext.send_message({
+						subject:"Subscribe me",
+						sender: $("#footer-subscribe-email").val(),
+						message: "Subscribe to newsletter (via website footer).",
+						callback: function(r) {
+							if(!r.exc) {
+								$("#footer-subscribe-button").html("Thank You :)")
+									.addClass("btn-success").attr("disabled", true);
+							} else {
+								$("#footer-subscribe-button").html("Error :( Not a valid id?")
+									.addClass("btn-danger").attr("disabled", false);
+								$("#footer-subscribe-email").val("").attr('disabled', false);
+							}
 						}
-					}
-				});
-			}
-		});
-	</script>
+					});
+				}
+			});
+		</script>
+		</div>
+	</div>
 	</div>
 </footer>
diff --git a/website/templates/html/navbar.html b/website/templates/html/navbar.html
index 55e8094..635cf34 100644
--- a/website/templates/html/navbar.html
+++ b/website/templates/html/navbar.html
@@ -1,37 +1,36 @@
 <div class="navbar navbar-inverse" style="">
-	<div class="navbar-inner">
-		{%- if brand_html %}<a class="brand" href="index">{{ brand_html }}</a>{% endif -%}
-		<div class="container">
-			<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
-				<span class="icon-bar"></span>
-				<span class="icon-bar"></span>
-				<span class="icon-bar"></span>
-			</button>
-			<div class="nav-collapse collapse">
-				<ul class="nav">
-					{%- for page in top_bar_items -%}
-					{% if not page.parent_label -%}
-					<li data-label="{{ page.label }}" {% if page.child_items %} class="dropdown"{% endif %}>
-						<a href="{{ page.url or '#' }}" {% if page.child_items %} class="dropdown-toggle" onclick="return false;" data-toggle="dropdown"{% endif %} {{ page.target or ''}}>
-						{{ page.label }}
-						{%- if page.child_items -%}
-							<b class="caret"></b>
-						</a>
-							<ul class="dropdown-menu">
-							{%- for child in page.child_items -%}
-								<li data-label="{{ child.label }}">
-									<a {% if child.indent %} style="padding-left: {{(int(child.indent)+1)*15 }}px"{% endif %} href="{{ child.url }}" {{ child.target or '' }}>{{ child.label }}</a>
-								</li>
-							{%- endfor -%}
-							</ul>
-						{%- else -%}
-						</a>
-						{%- endif -%}
-						</li>
+	{%- if brand_html %}<a class="navbar-brand" href="index">{{ brand_html }}</a>{% endif -%}
+	<div class="container">
+		<button type="button" class="navbar-toggle" data-toggle="collapse" 
+			data-target=".navbar-responsive-collapse">
+			<span class="icon-bar"></span>
+			<span class="icon-bar"></span>
+			<span class="icon-bar"></span>
+		</button>
+		<div class="nav-collapse collapse navbar-responsive-collapse">
+			<ul class="nav navbar-nav">
+				{%- for page in top_bar_items -%}
+				{% if not page.parent_label -%}
+				<li data-label="{{ page.label }}" {% if page.child_items %} class="dropdown"{% endif %}>
+					<a href="{{ page.url or '#' }}" {% if page.child_items %} class="dropdown-toggle" onclick="return false;" data-toggle="dropdown"{% endif %} {{ page.target or ''}}>
+					{{ page.label }}
+					{%- if page.child_items -%}
+						<b class="caret"></b>
+					</a>
+						<ul class="dropdown-menu">
+						{%- for child in page.child_items -%}
+							<li data-label="{{ child.label }}">
+								<a {% if child.indent %} style="padding-left: {{(int(child.indent)+1)*15 }}px"{% endif %} href="{{ child.url }}" {{ child.target or '' }}>{{ child.label }}</a>
+							</li>
+						{%- endfor -%}
+						</ul>
+					{%- else -%}
+					</a>
 					{%- endif -%}
-					{%- endfor %}
-				</ul>
-			</div>
+					</li>
+				{%- endif -%}
+				{%- endfor %}
+			</ul>
 		</div>
 	</div>
 </div>
diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html
index 570c769..ec71476 100644
--- a/website/templates/html/outer.html
+++ b/website/templates/html/outer.html
@@ -7,7 +7,7 @@
 		</div>
 		<div class="clearfix"></div>
 		{% if banner_html %}<div class="row" style="margin-top: 30px;">
-			<div class="span12">{{ banner_html }}</div>
+			<div class="col col-lg-12">{{ banner_html }}</div>
 		</div>{% endif %}
 		<div class="outer">
 			{% include "app/website/templates/html/navbar.html" %}
diff --git a/website/templates/html/product_breadcrumbs.html b/website/templates/html/product_breadcrumbs.html
index 0b026e7..3cd501e 100644
--- a/website/templates/html/product_breadcrumbs.html
+++ b/website/templates/html/product_breadcrumbs.html
@@ -1,9 +1,9 @@
 {% if obj.parent_groups and len(obj.parent_groups) > 1 %}
-<div class="span12">
+<div class="col col-lg-12">
 	<div class="clearfix">
 		<ul class="breadcrumb">
 			{% for ig in obj.parent_groups[:-1] %}
-			<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a> <span class="divider">/</span></li>
+			<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
 			{% endfor %}
 			<li class="active">{{ obj.parent_groups[-1].name }}</li>
 		</ul>
diff --git a/website/templates/html/product_group.html b/website/templates/html/product_group.html
index 0ad4048..54a55af 100644
--- a/website/templates/html/product_group.html
+++ b/website/templates/html/product_group.html
@@ -1,7 +1,9 @@
 {% extends "app/website/templates/html/page.html" %}
 
 {% block content %}
-<div class="span12">
+{% include 'app/website/templates/html/product_search_box.html' %}
+{% include 'app/website/templates/html/product_breadcrumbs.html' %}
+<div class="col col-lg-12">
 	{% if slideshow %}<!-- slideshow -->
 	{% include "app/website/templates/html/slideshow.html" %}
 	{% endif %}
@@ -11,14 +13,12 @@
 	<h3>{{ name }}</h3>
 	{% endif %}
 </div>
-{% include 'app/website/templates/html/product_search_box.html' %}
-{% include 'app/website/templates/html/product_breadcrumbs.html' %}
-<div class="span12">
+<div class="col col-lg-12">
 	{% if sub_groups %}
 	<hr />
 	<div class="row">
 	{% for d in sub_groups %}
-		<div class="span4">
+		<div class="col col-lg-4">
 			<a href="{{ d.page_name }}">{{ d.name }} ({{ d.count }})</a>
 		</div>
 	{% endfor %}
diff --git a/website/templates/html/product_in_list.html b/website/templates/html/product_in_list.html
index 5cd9eac..e9752b3 100644
--- a/website/templates/html/product_in_list.html
+++ b/website/templates/html/product_in_list.html
@@ -1,4 +1,4 @@
-<div class="span3">
+<div class="col col-lg-3">
 	<div style="height: 120px; overflow: hidden;">
 		<a href="{{ page_name }}">
 		{%- if website_image -%}
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html
index 3fda8cd..263159f 100644
--- a/website/templates/html/product_page.html
+++ b/website/templates/html/product_page.html
@@ -11,9 +11,9 @@
 {% block content %}
 	{% include 'app/website/templates/html/product_search_box.html' %}
 	{% include 'app/website/templates/html/product_breadcrumbs.html' %}
-	<div class="span12 product-page-content" itemscope itemtype="http://schema.org/Product">
+	<div class="col col-lg-12 product-page-content" itemscope itemtype="http://schema.org/Product">
 		<div class="row">
-			<div class="span6">
+			<div class="col col-lg-6">
 				{% if slideshow %}
 					{% include "app/website/templates/html/slideshow.html" %}
 				{% else %}
@@ -27,7 +27,7 @@
 					{% endif %}
 				{% endif %}
 			</div>
-			<div class="span6">
+			<div class="col col-lg-6">
 				<h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3>
 				<p class="help">Item Code: {{ name }}</p>
 				<h4>Product Description</h4>
@@ -41,7 +41,7 @@
 		</div>
 		{% if obj.doclist.get({"doctype":"Item Website Specification"}) -%}
 		<div class="row" style="margin-top: 20px">
-			<div class="span12">
+			<div class="col col-lg-12">
 				<h4>Specifications</h4>
 				<table class="table table-bordered" style="width: 100%">
 				{% for d in obj.doclist.get(
diff --git a/website/templates/html/product_search_box.html b/website/templates/html/product_search_box.html
index 3b3a95a..29564f3 100644
--- a/website/templates/html/product_search_box.html
+++ b/website/templates/html/product_search_box.html
@@ -1,11 +1,12 @@
-<div class="span12 clearfix">
-	<div class="pull-right" style="margin-top: 15px;">
+<div class="col col-lg-12 clearfix">
+	<div class="pull-right" style="margin-top: 15px; margin-bottom: 15px;">
 		<form class="form-search">
-			<div class="input-append">
-				<input type="text" class="span2 search-query" 
-					id="product-search" placeholder="Product Search..." />
-				<button class="btn" id="btn-product-search">
-					<i class="icon-search"></i></button>
+			<div class="input-group col col-lg-4 col-offset-8">
+				<input type="text" id="product-search" placeholder="Product Search...">
+				<span class="input-group-btn">
+					<button class="btn btn-default" type="button" id="btn-product-search">
+						<i class="icon-search"></i></button>
+				</span>
 			</div>
 		</form>
 	</div>
diff --git a/website/templates/html/slideshow.html b/website/templates/html/slideshow.html
index b26338c..b148cb1 100644
--- a/website/templates/html/slideshow.html
+++ b/website/templates/html/slideshow.html
@@ -1,6 +1,17 @@
 {% if slideshow %}
 {{ slideshow_header }}
-<div id="myCarousel" class="carousel slide">
+
+
+<div id="the-carousel" class="carousel slide">
+	<!-- Indicators -->
+	<ol class="carousel-indicators">
+		{% for slide in obj.slides %}
+			<li data-target="#the-carousel" data-slide-to="0" 
+				{%- if loop.index==0 %}class="active"{% endif %}></li>
+		{% endfor %}
+	</ol>
+	
+	<!-- Wrapper for slides -->
 	<div class="carousel-inner">
 		{% for slide in obj.slides %}
 		<div class="{% if slide.idx==1 %}active {% endif %}item">
@@ -14,10 +25,15 @@
 		</div>
 		{% endfor %}
 	</div>
-	<a class="carousel-control left" href="#myCarousel"
-		data-slide="prev">&lsaquo;</a>
-	<a class="carousel-control right" href="#myCarousel" 
-		data-slide="next">&rsaquo;</a>
-	</div>
-	<script>$(".carousel").carousel();</script>
+
+	<!-- Controls -->
+	<a class="left carousel-control" href="#the-carousel" data-slide="prev">
+		<span class="icon icon-chevron-left"></span>
+	</a>
+	<a class="right carousel-control" href="#the-carousel" data-slide="next">
+		<span class="icon icon-chevron-right"></span>
+	</a>
+</div>
+
+<script>$(".carousel").carousel();</script>
 {% endif %}
diff --git a/website/templates/html/web_page.html b/website/templates/html/web_page.html
index 6b8c914..4711e58 100644
--- a/website/templates/html/web_page.html
+++ b/website/templates/html/web_page.html
@@ -7,7 +7,7 @@
 {% endblock %}
 
 {% block content %}
-<div class="span12" style="margin-top: 15px;">
+<div class="col col-lg-12" style="margin-top: 15px;">
 	{% include "app/website/templates/html/slideshow.html" %}
 	{{ main_section }}
 </div>
diff --git a/website/templates/js/blog.js b/website/templates/js/blog.js
index fd5a156..2154d47 100644
--- a/website/templates/js/blog.js
+++ b/website/templates/js/blog.js
@@ -69,12 +69,12 @@
 			b.page_name = encodeURIComponent(b.page_name);
 			
 			$(repl('<div class="row">\
-					<div class="span1">\
+					<div class="col col-lg-1">\
 						<div class="avatar avatar-medium" style="margin-top: 6px;">\
 							<img src="%(avatar)s" />\
 						</div>\
 					</div>\
-					<div class="span11">\
+					<div class="col col-lg-11">\
 						<h4><a href="%(page_name)s">%(title)s</a></h4>\
 						<p>%(content)s</p>\
 						<p style="color: #aaa; font-size: 90%">\
@@ -87,7 +87,7 @@
 		if(!data.length || data.length < 20) {
 			if(blog.start) {
 				$("#next-page").toggle(false)
-					.parent().append("<div class='alert alert-info'>Nothing more to show.</div>");	
+					.parent().append("<div class='text-muted'>Nothing more to show.</div>");	
 			} else {
 				$("#next-page").toggle(false)
 					.parent().append("<div class='alert'>No blogs written yet.</div>");	
diff --git a/website/templates/js/product_list.js b/website/templates/js/product_list.js
index f8f21b3..6873973 100644
--- a/website/templates/js/product_list.js
+++ b/website/templates/js/product_list.js
@@ -40,7 +40,7 @@
 				.replaceWith("<div class='alert'>No products found.</div>");
 		} else {
 			$(".more-btn")
-				.replaceWith("<div class='alert'>Nothing more to show.</div>");
+				.replaceWith("<div class='text-muted'>Nothing more to show.</div>");
 		}
 	} else {
 		$(".more-btn").toggle(true)
diff --git a/website/templates/pages/about.html b/website/templates/pages/about.html
index 0cbd562..2f4f6e4 100644
--- a/website/templates/pages/about.html
+++ b/website/templates/pages/about.html
@@ -3,14 +3,14 @@
 {% set title="About Us" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
 	{{ obj.doc.company_introduction or "<h2>About Us</h2><p>Some Introduction about your company that you would like your website visitor to know. More people than you think will read your About page. People always like to know who the are doing business with. Be authentic and avoid using jargon like 'value added services' etc. Be sure to update your company history and list of key team members in Website > About Us Settings</p>" }}
 	{% if obj.doclist.get({"doctype":"Company History"}) %}
 	<h3>{{ obj.doc.company_history_heading or "Company History" }}</h3>
 	{% for d in obj.doclist.get({"doctype":"Company History"}) %}
 	<div class="row">
-		<span class="span2"><h4 style="margin:0px;">{{ d.year }}</h4></span>
-		<span class="span10"><p>{{ d.highlight }}</p></span>
+		<span class="col col-lg-2"><h4 style="margin:0px;">{{ d.year }}</h4></span>
+		<span class="col col-lg-10"><p>{{ d.highlight }}</p></span>
 	</div>
 	{% endfor %}
 	{% endif %}
@@ -18,12 +18,12 @@
 	<h3>{{ obj.doc.team_members_heading or "Team Members" }}</h3>
 	{% for d in obj.doclist.get({"doctype":"About Us Team Member"}) %}
 	<div class="row" itemscope itemtype="http://schema.org/Person">
-		<span class="span2">
+		<span class="col col-lg-2">
 			<div class="avatar avatar-large">
 				<img class="avatar" src="{{ d.image_link }}" style="" itemprop="image">
 			</div>
 		</span>
-		<span class="span10"><h4 itemprop="name">{{ d.full_name }}</h4>
+		<span class="col col-lg-10"><h4 itemprop="name">{{ d.full_name }}</h4>
 			<p itemprop="description">{{ d.bio }}</p>
 		</span>
 	</div>
diff --git a/website/templates/pages/account.html b/website/templates/pages/account.html
index fe2b858..f6992e1 100644
--- a/website/templates/pages/account.html
+++ b/website/templates/pages/account.html
@@ -3,7 +3,7 @@
 {% set title="My Account" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li class="active">My Account</li>
diff --git a/website/templates/pages/attributions.html b/website/templates/pages/attributions.html
index 05e8e88..0f534a4 100644
--- a/website/templates/pages/attributions.html
+++ b/website/templates/pages/attributions.html
@@ -11,7 +11,7 @@
 {% set title="ERPNext - Web Based, Open Source ERP" %}
 
 {% block content %}
-<div class="layout-attributions span12">
+<div class="layout-attributions col col-lg-12">
 	<h3>This website is made using these awesome Open Source projects <i class="icon-heart" style="color: red"></i></h3>
 	<hr>
 	<table class="table table-bordered table-striped">
diff --git a/website/templates/pages/blog.html b/website/templates/pages/blog.html
index 7483c7c..fcb542b 100644
--- a/website/templates/pages/blog.html
+++ b/website/templates/pages/blog.html
@@ -11,7 +11,7 @@
 {% set title="Blog" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
 	<h2 id="blog-title">{{ blog_title }}</h2>
 	{% if blog_introduction %}
 	<p>{{ blog_introduction }}</p>
@@ -25,7 +25,7 @@
 		<!-- blog list will be generated dynamically -->
 	</div>
 	<div style="text-align: center;">
-		<button id="next-page" class="btn" 
+		<button id="next-page" class="btn btn-default" 
 			style="display:none;">More...</button>
 	</div>
 </div>
diff --git a/website/templates/pages/contact.html b/website/templates/pages/contact.html
index b9b3cd7..113b627 100644
--- a/website/templates/pages/contact.html
+++ b/website/templates/pages/contact.html
@@ -7,28 +7,32 @@
 {% set title="Contact Us" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
 	<h3>{{ obj.doc.heading or "Contact Us"}}</h3>
 	<div class="row">
-		<div class="web-form span8">
-			<div class="row">
-			<div class="span6">
-				<p id="contact-alert" class="alert" 
-					style="display: none;">&nbsp;</p>
-			</div>
-			</div>
-			<div class="clearfix"></div>
-			<p><select class="span6" name="subject">
+		<div class="web-form col col-lg-8">
+			<p id="contact-alert" class="alert" 
+				style="display: none;">&nbsp;</p>
+			<p>
+				<select name="subject">
 				{% for option in obj.query_options %}
 					<option value="{{ option }}">{{ option }}</option>
 				{% endfor %}
-			</select></p>
-			<p><input class="span6" name="email" type="text" placeholder="Your Email Address" /></p>
-			<p><textarea class="span6" rows="10" name="message"></textarea></p>
-			<p><button class="btn btn-primary btn-send">Send</button></p>
+				</select>
+			</p>
+			<p>
+				<input name="email" type="text" 
+				placeholder="Your Email Address" />
+			</p>
+			<p>
+				<textarea rows="10" name="message"></textarea>
+			</p>
+			<p>
+				<button class="btn btn-primary btn-send">Send</button>
+			</p>
 		</div>
 		{% if obj.doc.address %}
-		<div class="span3 alert" style="margin-top: 20px;" itemscope itemtype="http://schema.org/PostalAddress">
+		<div class="col col-lg-3 col-offset-1 alert" style="margin-top: 20px;" itemscope itemtype="http://schema.org/PostalAddress">
 			<h4><i class="icon-map-marker"></i> {{ obj.address.address_title }}</h4>
 			{% if obj.address.address_line1 %}
 				<span itemprop="streetAddress">{{ obj.address.address_line1 }}</span><br>
diff --git a/website/templates/pages/order.html b/website/templates/pages/order.html
index 8e7bfe7..2588d39 100644
--- a/website/templates/pages/order.html
+++ b/website/templates/pages/order.html
@@ -3,7 +3,7 @@
 {% set title=doc.name %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li><a href="account">My Account</a> <span class="divider">/</span></li>
@@ -15,16 +15,16 @@
 	{%- if doc.status -%}
 	<div style="font-size: 13px;">
 	<div class="row">
-		<div class="span2">
+		<div class="col col-lg-2">
 			<div class="label">{{ doc.status }}</div>
 		</div>
-		<div class="span4">
+		<div class="col col-lg-4">
 			{{ utils.formatdate(doc.transaction_date) }}
 		</div>
 	</div>
 	<br>
 	<div class="row">
-		<div class="span12">
+		<div class="col col-lg-12">
 		<table class="table table-bordered">
 			<tbody>
 				<tr>
@@ -52,8 +52,8 @@
 		</div>
 	</div>
 	<div class="row">
-		<div class="span6"></div>
-		<div class="span6">
+		<div class="col col-lg-6"></div>
+		<div class="col col-lg-6">
 		<table cellspacing=0 width=100%>
 		<tbody>
 			<tr>
diff --git a/website/templates/pages/orders.html b/website/templates/pages/orders.html
index 0c93a68..b5b0dd9 100644
--- a/website/templates/pages/orders.html
+++ b/website/templates/pages/orders.html
@@ -8,7 +8,7 @@
 currency = "{{ currency }}";
 wn.currency_symbols = {{ currency_symbols }};
 </script>
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li><a href="account">My Account</a> <span class="divider">/</span></li>
@@ -44,8 +44,8 @@
 				
 				// parent
 				var $order = $(repl('<div class="row">\
-					<div class="span3"><a href="order?name=%(name)s">%(name)s</a></div>\
-					<div class="span9"></div>\
+					<div class="col col-lg-3"><a href="order?name=%(name)s">%(name)s</a></div>\
+					<div class="col col-lg-9"></div>\
 				</div>', order)).appendTo($list);
 				
 				// items
@@ -53,12 +53,12 @@
 					item.export_rate = format_currency(item.export_rate, order.currency);
 					item.export_amount = format_currency(item.export_amount, order.currency);
 					var $item = $(repl('<div class="row">\
-							<div class="span3">%(item_name)s</div>\
-							<div class="span2" style="text-align: right;">%(export_rate)s</div>\
-							<div class="span2" style="text-align: right;">%(qty)s %(stock_uom)s</div>\
-							<div class="span2" style="text-align: right;">%(export_amount)s</div>\
+							<div class="col col-lg-3">%(item_name)s</div>\
+							<div class="col col-lg-2" style="text-align: right;">%(export_rate)s</div>\
+							<div class="col col-lg-2" style="text-align: right;">%(qty)s %(stock_uom)s</div>\
+							<div class="col col-lg-2" style="text-align: right;">%(export_amount)s</div>\
 						</div>\
-					</div>', item)).appendTo($order.find(".span9"));
+					</div>', item)).appendTo($order.find(".col col-lg-9"));
 				});
 				
 				$("<hr>").appendTo($list);
diff --git a/website/templates/pages/product_search.html b/website/templates/pages/product_search.html
index 2dab6ff..4711408 100644
--- a/website/templates/pages/product_search.html
+++ b/website/templates/pages/product_search.html
@@ -18,7 +18,7 @@
 </script>
 
 {% include 'app/website/templates/html/product_search_box.html' %}
-<div class="span12">
+<div class="col col-lg-12">
 	<h3 class="search-results">Search Results</h3>
 	<div id="search-list" class="row">
 		
diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html
index d689cfb..40d6a19 100644
--- a/website/templates/pages/profile.html
+++ b/website/templates/pages/profile.html
@@ -3,7 +3,7 @@
 {% set title="My Profile" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li><a href="account">My Account</a> <span class="divider">/</span></li>
diff --git a/website/templates/pages/ticket.html b/website/templates/pages/ticket.html
index 858dd3b..5835246 100644
--- a/website/templates/pages/ticket.html
+++ b/website/templates/pages/ticket.html
@@ -3,7 +3,7 @@
 {% set title=doc.name %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li><a href="account">My Account</a> <span class="divider">/</span></li>
@@ -14,13 +14,13 @@
 	<hr>
 	{%- if doc.status -%}
 	<div class="row">
-		<div class="span2">
+		<div class="col col-lg-2">
 			<div class="label">{{ doc.status }}</div>
 		</div>
-		<div class="span7">
+		<div class="col col-lg-7">
 			{{ doc.subject }}
 		</div>
-		<div class="span3">
+		<div class="col col-lg-3">
 			{{ utils.formatdate(doc.transaction_date) }}
 		</div>
 	</div>
diff --git a/website/templates/pages/tickets.html b/website/templates/pages/tickets.html
index 843d10e..27881ef 100644
--- a/website/templates/pages/tickets.html
+++ b/website/templates/pages/tickets.html
@@ -3,7 +3,7 @@
 {% set title="My Tickets" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a> <span class="divider">/</span></li>
     	<li><a href="account">My Account</a> <span class="divider">/</span></li>
@@ -39,9 +39,9 @@
 				
 				// parent
 				var $ticket = $(repl('<div class="row">\
-					<div class="span2"><span class="label">%(status)s</span></div>\
-					<div class="span3"><a href="ticket?name=%(name)s">%(name)s</a></div>\
-					<div class="span7">%(subject)s</div>\
+					<div class="col col-lg-2"><span class="label">%(status)s</span></div>\
+					<div class="col col-lg-3"><a href="ticket?name=%(name)s">%(name)s</a></div>\
+					<div class="col col-lg-7">%(subject)s</div>\
 				</div>', ticket)).appendTo($list);
 				
 				$("<hr>").appendTo($list);
diff --git a/website/templates/pages/writers.html b/website/templates/pages/writers.html
index 67c0b7e..9d660b8 100644
--- a/website/templates/pages/writers.html
+++ b/website/templates/pages/writers.html
@@ -3,7 +3,7 @@
 {% set title="Blog Writers" %}
 
 {% block content %}
-<div class="span12">
+<div class="col col-lg-12">
 	<h2 id="blog-title">Blog Writers</h2>
 	{% if writers_introduction %}
 	<p>{{ writers_introduction }}</p>