update billed_amt, per billed and billing status based on amount
diff --git a/patches/patch.py b/patches/patch.py
index cd68b13..c4503f5 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,7 +1,7 @@
 # REMEMBER to update this
 # ========================
 
-last_patch = 337
+last_patch = 338
 
 #-------------------------------------------
 
@@ -1373,3 +1373,31 @@
 							sp_acx[i+1] = '"'.join(sp_quot)
 					html = "acx=".join(sp_acx)
 					webnotes.conn.sql("""UPDATE tabItem SET description_html=%s WHERE name=%s""", (html, item))
+	elif patch_no == 338:
+		# Patch for billing status based on amount
+		# reload so and dn
+		reload_doc('selling','doctype','sales_order')
+		reload_doc('stock','doctype','delivery_note')
+		
+		# delete billed_qty field
+		sql("delete from `tabDocField` where fieldname = 'billed_qty' and parent in ('Sales Order Detail', 'Delivery Note Detail')")
+		
+		# update billed amt in item table in so and dn
+		sql("""	update `tabSales Order Detail` so
+				set billed_amt = (select sum(amount) from `tabRV Detail` where `so_detail`= so.name and docstatus=1 and parent not like 'old%%'), modified = now()""")
+		
+		sql(""" update `tabDelivery Note Detail` dn
+				set billed_amt = (select sum(amount) from `tabRV Detail` where `dn_detail`= dn.name and docstatus=1 and parent not like 'old%%'), modified = now()""")
+		
+		# calculate % billed based on item table
+		sql("""	update `tabSales Order` so
+				set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabSales Order Detail` where parent = so.name), modified = now()""")
+		
+		sql("""	update `tabDelivery Note` dn
+				set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabDelivery Note Detail` where parent = dn.name), modified = now()""")
+
+		# update billing status based on % billed
+		sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
+				if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
+		sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
+				if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index 69773dd..98833d1 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -5,15 +5,14 @@
 	{
 		'creation': '2010-08-08 17:09:21',
 		'docstatus': 0,
-		'modified': '2011-06-27 16:05:56',
+		'modified': '2011-08-09 17:06:09',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1309170956',
-		'client_script': "cur_frm.add_fetch('customer','sales_person','sales_person');",
+		'_last_update': '1311621379',
 		'colour': 'White:FFF',
 		'doctype': 'DocType',
 		'document_type': 'Transaction',
@@ -28,7 +27,7 @@
 		'show_in_menu': 0,
 		'subject': 'From %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s | %(per_delivered)s% delivered | %(per_billed)s% billed',
 		'tag_fields': 'delivery_status,billing_status',
-		'version': 593
+		'version': 597
 	},
 
 	# These values are common for all DocField
@@ -58,28 +57,23 @@
 
 	# DocPerm
 	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
 		'doctype': 'DocPerm',
 		'idx': 1,
-		'permlevel': 1,
-		'role': 'Sales Manager',
-		'submit': 0,
-		'write': 0
+		'permlevel': 0,
+		'role': 'Production Manager'
 	},
 
 	# DocPerm
 	{
-		'amend': 1,
-		'cancel': 1,
-		'create': 1,
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
 		'doctype': 'DocPerm',
 		'idx': 2,
-		'permlevel': 0,
+		'permlevel': 1,
 		'role': 'Sales Manager',
-		'submit': 1,
-		'write': 1
+		'submit': 0,
+		'write': 0
 	},
 
 	# DocPerm
@@ -90,6 +84,19 @@
 		'doctype': 'DocPerm',
 		'idx': 3,
 		'permlevel': 0,
+		'role': 'Sales Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
 		'role': 'Sales User',
 		'submit': 1,
 		'write': 1
@@ -101,7 +108,7 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 4,
+		'idx': 5,
 		'permlevel': 1,
 		'role': 'Sales User',
 		'submit': 0,
@@ -111,7 +118,7 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 5,
+		'idx': 6,
 		'match': 'customer_name',
 		'permlevel': 0,
 		'role': 'Customer'
@@ -120,7 +127,7 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 6,
+		'idx': 7,
 		'permlevel': 2,
 		'role': 'Accounts User',
 		'write': 1
@@ -132,7 +139,7 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 7,
+		'idx': 8,
 		'permlevel': 0,
 		'role': 'Maintenance Manager',
 		'submit': 1,
@@ -142,7 +149,7 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 8,
+		'idx': 9,
 		'permlevel': 1,
 		'role': 'Maintenance Manager'
 	},
@@ -153,7 +160,7 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 9,
+		'idx': 10,
 		'permlevel': 0,
 		'role': 'Maintenance User',
 		'submit': 1,
@@ -163,7 +170,7 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 10,
+		'idx': 11,
 		'permlevel': 1,
 		'role': 'Maintenance User'
 	},
@@ -204,7 +211,7 @@
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
 		'oldfieldtype': 'Select',
-		'options': 'SO\nSO/10-11/',
+		'options': 'PI/2011/\nSO\nSO/10-11/\nSO1112',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1
@@ -504,7 +511,7 @@
 		'fieldtype': 'Currency',
 		'idx': 23,
 		'in_filter': 1,
-		'label': '% Qty Billed',
+		'label': '% Amount Billed',
 		'no_copy': 1,
 		'oldfieldname': 'per_billed',
 		'oldfieldtype': 'Currency',
@@ -607,12 +614,22 @@
 
 	# DocField
 	{
+		'doctype': 'DocField',
+		'fieldname': 'vehicle_detail',
+		'fieldtype': 'Small Text',
+		'idx': 30,
+		'label': 'Vehicle Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldname': 'quotation_date',
 		'fieldtype': 'Date',
 		'hidden': 1,
-		'idx': 30,
+		'idx': 31,
 		'label': 'Quotation Date',
 		'no_copy': 0,
 		'oldfieldname': 'quotation_date',
@@ -627,7 +644,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 31,
+		'idx': 32,
 		'label': 'Pull Quotation Details',
 		'oldfieldtype': 'Button',
 		'options': 'pull_quotation_details',
@@ -642,7 +659,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'price_list_name',
 		'fieldtype': 'Select',
-		'idx': 32,
+		'idx': 33,
 		'label': 'Price List',
 		'oldfieldname': 'price_list_name',
 		'oldfieldtype': 'Select',
@@ -658,7 +675,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 33,
+		'idx': 34,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -670,7 +687,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'currency',
 		'fieldtype': 'Select',
-		'idx': 34,
+		'idx': 35,
 		'label': 'Currency',
 		'oldfieldname': 'currency',
 		'oldfieldtype': 'Select',
@@ -689,7 +706,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'conversion_rate',
 		'fieldtype': 'Currency',
-		'idx': 35,
+		'idx': 36,
 		'label': 'Conversion Rate',
 		'oldfieldname': 'conversion_rate',
 		'oldfieldtype': 'Currency',
@@ -704,7 +721,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 36,
+		'idx': 37,
 		'permlevel': 0
 	},
 
@@ -715,7 +732,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_order_details',
 		'fieldtype': 'Table',
-		'idx': 37,
+		'idx': 38,
 		'label': 'Sales Order Details',
 		'oldfieldname': 'sales_order_details',
 		'oldfieldtype': 'Table',
@@ -729,7 +746,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 38,
+		'idx': 39,
 		'label': 'Clear Table',
 		'oldfieldtype': 'Button',
 		'options': 'clear_sales_order_details',
@@ -741,7 +758,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 39,
+		'idx': 40,
 		'label': 'Re-Calculate Values',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -755,7 +772,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'net_total',
 		'fieldtype': 'Currency',
-		'idx': 40,
+		'idx': 41,
 		'label': 'Net Total*',
 		'oldfieldname': 'net_total',
 		'oldfieldtype': 'Currency',
@@ -770,7 +787,7 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 41,
+		'idx': 42,
 		'label': 'Note1',
 		'oldfieldtype': 'HTML',
 		'options': '<b>NOTE :</b> * In Base Currency',
@@ -783,7 +800,7 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 42,
+		'idx': 43,
 		'label': 'Taxes',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -795,7 +812,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'charge',
 		'fieldtype': 'Link',
-		'idx': 43,
+		'idx': 44,
 		'label': 'Select Charges Master',
 		'oldfieldname': 'charge',
 		'oldfieldtype': 'Link',
@@ -808,7 +825,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 44,
+		'idx': 45,
 		'label': 'Get Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -820,7 +837,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges',
 		'fieldtype': 'Table',
-		'idx': 45,
+		'idx': 46,
 		'label': 'Other Charges',
 		'oldfieldname': 'other_charges',
 		'oldfieldtype': 'Table',
@@ -832,7 +849,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 46,
+		'idx': 47,
 		'label': 'Calculate Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -845,7 +862,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges_total',
 		'fieldtype': 'Currency',
-		'idx': 47,
+		'idx': 48,
 		'label': 'Charges Total*',
 		'oldfieldname': 'other_charges_total',
 		'oldfieldtype': 'Currency',
@@ -859,7 +876,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total',
 		'fieldtype': 'Currency',
-		'idx': 48,
+		'idx': 49,
 		'label': 'Grand Total*',
 		'oldfieldname': 'grand_total',
 		'oldfieldtype': 'Currency',
@@ -873,7 +890,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 49,
+		'idx': 50,
 		'label': 'OT Notes',
 		'oldfieldtype': 'HTML',
 		'options': '<b>NOTE :</b> * In Base Currency',
@@ -885,7 +902,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 50,
+		'idx': 51,
 		'label': 'Other Charges Calculation',
 		'oldfieldtype': 'HTML',
 		'permlevel': 0,
@@ -897,7 +914,7 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 51,
+		'idx': 52,
 		'label': 'Totals',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -909,7 +926,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total',
 		'fieldtype': 'Currency',
-		'idx': 52,
+		'idx': 53,
 		'label': 'Rounded Total',
 		'oldfieldname': 'rounded_total',
 		'oldfieldtype': 'Currency',
@@ -925,7 +942,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words',
 		'fieldtype': 'Data',
-		'idx': 53,
+		'idx': 54,
 		'label': 'In Words',
 		'oldfieldname': 'in_words',
 		'oldfieldtype': 'Data',
@@ -938,7 +955,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 54,
+		'idx': 55,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -950,7 +967,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total_export',
 		'fieldtype': 'Currency',
-		'idx': 55,
+		'idx': 56,
 		'label': 'Grand Total (Export)',
 		'oldfieldname': 'grand_total_export',
 		'oldfieldtype': 'Currency',
@@ -965,7 +982,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total_export',
 		'fieldtype': 'Currency',
-		'idx': 56,
+		'idx': 57,
 		'label': 'Rounded Total (Export)',
 		'oldfieldname': 'rounded_total_export',
 		'oldfieldtype': 'Currency',
@@ -981,7 +998,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words_export',
 		'fieldtype': 'Data',
-		'idx': 57,
+		'idx': 58,
 		'label': 'In Words (Export)',
 		'oldfieldname': 'in_words_export',
 		'oldfieldtype': 'Data',
@@ -995,7 +1012,7 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 58,
+		'idx': 59,
 		'label': 'Terms',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1007,7 +1024,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'tc_name',
 		'fieldtype': 'Link',
-		'idx': 59,
+		'idx': 60,
 		'label': 'Select Terms',
 		'oldfieldname': 'tc_name',
 		'oldfieldtype': 'Link',
@@ -1021,7 +1038,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 60,
+		'idx': 61,
 		'label': 'Get Terms',
 		'oldfieldtype': 'Button',
 		'options': 'get_tc_details',
@@ -1033,7 +1050,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 61,
+		'idx': 62,
 		'label': 'Terms HTML',
 		'oldfieldtype': 'HTML',
 		'options': 'You can add Terms and Notes that will be printed in the Transaction',
@@ -1046,7 +1063,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'terms',
 		'fieldtype': 'Text Editor',
-		'idx': 62,
+		'idx': 63,
 		'label': 'Term Details',
 		'oldfieldname': 'terms',
 		'oldfieldtype': 'Text Editor',
@@ -1060,7 +1077,7 @@
 		'description': 'Filling in additional information about the Sales Order will help you analyze your data better.',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 63,
+		'idx': 64,
 		'label': 'More Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1071,7 +1088,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 64,
+		'idx': 65,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1084,7 +1101,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'letter_head',
 		'fieldtype': 'Select',
-		'idx': 65,
+		'idx': 66,
 		'label': 'Letter Head',
 		'oldfieldname': 'letter_head',
 		'oldfieldtype': 'Select',
@@ -1100,7 +1117,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Link',
-		'idx': 66,
+		'idx': 67,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
@@ -1119,7 +1136,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 67,
+		'idx': 68,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'oldfieldname': 'fiscal_year',
@@ -1139,7 +1156,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'select_print_heading',
 		'fieldtype': 'Link',
-		'idx': 68,
+		'idx': 69,
 		'label': 'Select Print Heading',
 		'no_copy': 1,
 		'oldfieldname': 'select_print_heading',
@@ -1154,7 +1171,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 69,
+		'idx': 70,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1167,7 +1184,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'source',
 		'fieldtype': 'Select',
-		'idx': 70,
+		'idx': 71,
 		'label': 'Source',
 		'oldfieldname': 'source',
 		'oldfieldtype': 'Select',
@@ -1183,7 +1200,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'campaign',
 		'fieldtype': 'Link',
-		'idx': 71,
+		'idx': 72,
 		'label': 'Campaign',
 		'oldfieldname': 'campaign',
 		'oldfieldtype': 'Link',
@@ -1198,7 +1215,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'note',
 		'fieldtype': 'Text',
-		'idx': 72,
+		'idx': 73,
 		'label': 'Note',
 		'oldfieldname': 'note',
 		'oldfieldtype': 'Text',
@@ -1213,7 +1230,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'cancel_reason',
 		'fieldtype': 'Data',
-		'idx': 73,
+		'idx': 74,
 		'label': 'Cancel Reason',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1229,7 +1246,7 @@
 		'fieldname': 'delivery_status',
 		'fieldtype': 'Select',
 		'hidden': 1,
-		'idx': 74,
+		'idx': 75,
 		'label': 'Delivery Status',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1244,7 +1261,7 @@
 		'fieldname': 'billing_status',
 		'fieldtype': 'Select',
 		'hidden': 1,
-		'idx': 75,
+		'idx': 76,
 		'label': 'Billing Status',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1260,7 +1277,7 @@
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
 		'hidden': 0,
-		'idx': 76,
+		'idx': 77,
 		'label': 'Packing List',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1273,7 +1290,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'packing_details',
 		'fieldtype': 'Table',
-		'idx': 77,
+		'idx': 78,
 		'label': 'Packing Details',
 		'oldfieldname': 'packing_details',
 		'oldfieldtype': 'Table',
@@ -1286,7 +1303,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 78,
+		'idx': 79,
 		'label': 'Sales Team',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1300,7 +1317,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_partner',
 		'fieldtype': 'Link',
-		'idx': 79,
+		'idx': 80,
 		'in_filter': 1,
 		'label': 'Sales Partner',
 		'oldfieldname': 'sales_partner',
@@ -1318,7 +1335,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'commission_rate',
 		'fieldtype': 'Currency',
-		'idx': 80,
+		'idx': 81,
 		'label': 'Commission Rate',
 		'oldfieldname': 'commission_rate',
 		'oldfieldtype': 'Currency',
@@ -1333,7 +1350,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'total_commission',
 		'fieldtype': 'Currency',
-		'idx': 81,
+		'idx': 82,
 		'label': 'Total Commission',
 		'oldfieldname': 'total_commission',
 		'oldfieldtype': 'Currency',
@@ -1347,7 +1364,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_team',
 		'fieldtype': 'Table',
-		'idx': 82,
+		'idx': 83,
 		'label': 'Sales Team1',
 		'oldfieldname': 'sales_team',
 		'oldfieldtype': 'Table',
@@ -1361,7 +1378,7 @@
 		'allow_on_submit': 1,
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 83,
+		'idx': 84,
 		'label': 'Repair Sales Order',
 		'oldfieldtype': 'Button',
 		'options': 'repair_sales_order',
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index 97280e9..b77a6a5 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -3,16 +3,16 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2010-08-08 17:08:57',
+		'creation': '2011-04-18 15:58:20',
 		'docstatus': 0,
-		'modified': '2011-06-27 16:42:01',
+		'modified': '2011-08-09 17:10:45',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1309173122',
+		'_last_update': '1311621379',
 		'colour': 'White:FFF',
 		'doctype': 'DocType',
 		'document_type': 'Transaction',
@@ -27,7 +27,7 @@
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s on %(transaction_date)s | %(per_billed)s% billed',
 		'tag_fields': 'billing_status',
-		'version': 444
+		'version': 446
 	},
 
 	# These values are common for all DocField
@@ -70,15 +70,15 @@
 
 	# DocPerm
 	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
 		'doctype': 'DocPerm',
 		'idx': 2,
-		'permlevel': 1,
-		'role': 'Material User',
-		'submit': 0,
-		'write': 0
+		'permlevel': 0,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
 	},
 
 	# DocPerm
@@ -89,22 +89,22 @@
 		'doctype': 'DocPerm',
 		'idx': 3,
 		'permlevel': 0,
-		'role': 'Material Manager',
+		'role': 'Material Master Manager',
 		'submit': 1,
 		'write': 1
 	},
 
 	# DocPerm
 	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
 		'doctype': 'DocPerm',
 		'idx': 4,
-		'permlevel': 1,
+		'permlevel': 0,
 		'role': 'Material Manager',
-		'submit': 0,
-		'write': 0
+		'submit': 1,
+		'write': 1
 	},
 
 	# DocPerm
@@ -115,60 +115,25 @@
 		'doctype': 'DocPerm',
 		'idx': 5,
 		'permlevel': 0,
-		'role': 'Sales User',
+		'role': 'Sales Manager',
 		'submit': 1,
 		'write': 1
 	},
 
 	# DocPerm
 	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
 		'doctype': 'DocPerm',
 		'idx': 6,
 		'permlevel': 1,
-		'role': 'Sales User',
-		'submit': 0,
-		'write': 0
+		'role': 'All'
 	},
 
 	# DocPerm
 	{
-		'cancel': 0,
-		'create': 0,
 		'doctype': 'DocPerm',
 		'idx': 7,
-		'permlevel': 0,
-		'role': 'Accounts User',
-		'submit': 0,
-		'write': 0
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 8,
-		'permlevel': 1,
-		'role': 'Accounts User'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 9,
-		'match': 'customer_name',
-		'permlevel': 0,
-		'role': 'Customer'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 10,
 		'permlevel': 2,
-		'role': 'All',
-		'write': 1
+		'role': 'All'
 	},
 
 	# DocField
@@ -332,7 +297,7 @@
 		'permlevel': 0,
 		'print_hide': 0,
 		'reqd': 1,
-		'search_index': 0,
+		'search_index': 1,
 		'width': '100px'
 	},
 
@@ -352,7 +317,7 @@
 		'permlevel': 1,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0,
+		'search_index': 1,
 		'width': '150px'
 	},
 
@@ -366,13 +331,13 @@
 		'fieldtype': 'Currency',
 		'idx': 15,
 		'in_filter': 1,
-		'label': '% Qty Billed',
+		'label': '% Amount Billed',
 		'no_copy': 1,
 		'oldfieldname': 'per_billed',
 		'oldfieldtype': 'Currency',
 		'permlevel': 1,
 		'print_hide': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -391,7 +356,7 @@
 		'oldfieldtype': 'Currency',
 		'permlevel': 1,
 		'print_hide': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -439,7 +404,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -453,7 +418,7 @@
 		'options': 'Customer Group',
 		'permlevel': 0,
 		'print_hide': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -1014,7 +979,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0,
+		'search_index': 1,
 		'width': '150px'
 	},
 
@@ -1032,7 +997,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0,
+		'search_index': 1,
 		'width': '150px'
 	},