Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/journal_voucher/journal_voucher.txt b/accounts/doctype/journal_voucher/journal_voucher.txt
new file mode 100644
index 0000000..104d3d1
--- /dev/null
+++ b/accounts/doctype/journal_voucher/journal_voucher.txt
@@ -0,0 +1,802 @@
+# DocType, Journal Voucher
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:06',
+		'docstatus': 0,
+		'modified': '2011-07-28 15:28:12',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1311251040',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'module': 'Accounts',
+		'name': '__common__',
+		'search_fields': 'voucher_type,posting_date, due_date, cheque_no',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': ' ',
+		'tag_fields': 'voucher_type',
+		'version': 309
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Journal Voucher',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Journal Voucher',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Journal Voucher
+	{
+		'doctype': 'DocType',
+		'name': 'Journal Voucher'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Accounts Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Accounts Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'Accounts User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'Accounts User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Basic Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 2,
+		'label': '1. Select Series and Dates',
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 3,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'voucher_type',
+		'fieldtype': 'Select',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Voucher Type',
+		'oldfieldname': 'voucher_type',
+		'oldfieldtype': 'Select',
+		'options': '\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nLoan Receipt',
+		'permlevel': 0,
+		'print_hide': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
+		'doctype': 'DocField',
+		'fieldname': 'write_off_amount',
+		'fieldtype': 'Currency',
+		'idx': 5,
+		'label': 'Write Off Amount <=',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Accounts Receivable',
+		'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
+		'doctype': 'DocField',
+		'fieldname': 'write_off_based_on',
+		'fieldtype': 'Select',
+		'idx': 6,
+		'label': 'Write Off Based On',
+		'options': 'Accounts Receivable\nAccounts Payable',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'idx': 7,
+		'label': 'Series',
+		'no_copy': 1,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'JV',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Today',
+		'doctype': 'DocField',
+		'fieldname': 'voucher_date',
+		'fieldtype': 'Date',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Voucher Date',
+		'no_copy': 1,
+		'oldfieldname': 'voucher_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry will get or has actually executed.',
+		'doctype': 'DocField',
+		'fieldname': 'posting_date',
+		'fieldtype': 'Date',
+		'idx': 9,
+		'in_filter': 1,
+		'label': 'Posting Date',
+		'no_copy': 1,
+		'oldfieldname': 'posting_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'due_date',
+		'fieldtype': 'Date',
+		'idx': 10,
+		'label': 'Due Date',
+		'oldfieldname': 'due_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is corrected in the system.',
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'idx': 11,
+		'label': 'Amendment Date',
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Link',
+		'idx': 12,
+		'label': 'Amended From',
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Link',
+		'options': 'Journal Voucher',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 13,
+		'label': 'Get Outstanding Invoices',
+		'options': 'get_outstanding_invoices',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Server'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 14,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cheque_no',
+		'fieldtype': 'Data',
+		'idx': 15,
+		'in_filter': 1,
+		'label': 'Cheque No',
+		'no_copy': 1,
+		'oldfieldname': 'cheque_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cheque_date',
+		'fieldtype': 'Date',
+		'idx': 16,
+		'label': 'Cheque Date',
+		'no_copy': 1,
+		'oldfieldname': 'cheque_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'clearance_date',
+		'fieldtype': 'Date',
+		'idx': 17,
+		'in_filter': 1,
+		'label': 'Clearance Date',
+		'no_copy': 1,
+		'oldfieldname': 'clearance_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'user_remark',
+		'fieldtype': 'Small Text',
+		'idx': 18,
+		'in_filter': 1,
+		'label': 'User Remark',
+		'no_copy': 1,
+		'oldfieldname': 'user_remark',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'description': 'User Remark will be added to Auto Remark',
+		'doctype': 'DocField',
+		'fieldname': 'remark',
+		'fieldtype': 'Small Text',
+		'idx': 19,
+		'label': 'Remark',
+		'no_copy': 1,
+		'oldfieldname': 'remark',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 20,
+		'label': '2. Add / Edit GL Entries',
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'entries',
+		'fieldtype': 'Table',
+		'idx': 21,
+		'label': 'Entries',
+		'oldfieldname': 'entries',
+		'oldfieldtype': 'Table',
+		'options': 'Journal Voucher Detail',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 22,
+		'label': 'Get Balance',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_debit',
+		'fieldtype': 'Currency',
+		'idx': 23,
+		'in_filter': 1,
+		'label': 'Total Debit',
+		'no_copy': 1,
+		'oldfieldname': 'total_debit',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_credit',
+		'fieldtype': 'Currency',
+		'idx': 24,
+		'in_filter': 1,
+		'label': 'Total Credit',
+		'no_copy': 1,
+		'oldfieldname': 'total_credit',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'difference',
+		'fieldtype': 'Currency',
+		'idx': 25,
+		'label': 'Difference',
+		'no_copy': 1,
+		'oldfieldname': 'difference',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 26,
+		'label': 'Addtional Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 27,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'bill_no',
+		'fieldtype': 'Data',
+		'idx': 28,
+		'label': 'Bill No',
+		'oldfieldname': 'bill_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'bill_date',
+		'fieldtype': 'Date',
+		'idx': 29,
+		'label': 'Bill Date',
+		'oldfieldname': 'bill_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'doctype': 'DocField',
+		'fieldname': 'is_opening',
+		'fieldtype': 'Select',
+		'idx': 30,
+		'in_filter': 1,
+		'label': 'Is Opening',
+		'oldfieldname': 'is_opening',
+		'oldfieldtype': 'Select',
+		'options': 'No\nYes',
+		'permlevel': 0,
+		'print_hide': 1,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'aging_date',
+		'fieldtype': 'Date',
+		'idx': 31,
+		'label': 'Aging Date',
+		'no_copy': 0,
+		'oldfieldname': 'aging_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'idx': 32,
+		'label': 'Cancel Reason',
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'pay_to_recd_from',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 33,
+		'label': 'Pay To / Recd From',
+		'no_copy': 1,
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_amount',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 34,
+		'label': 'Total Amount',
+		'no_copy': 1,
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_amount_in_words',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 35,
+		'label': 'Total Amount in Words',
+		'no_copy': 1,
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 36,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 37,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'idx': 38,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'idx': 39,
+		'label': 'Select Print Heading',
+		'no_copy': 1,
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 40,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 41,
+		'label': 'View Ledger Entry',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 42,
+		'label': 'TDS',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'default': 'No',
+		'doctype': 'DocField',
+		'fieldname': 'tds_applicable',
+		'fieldtype': 'Select',
+		'idx': 43,
+		'in_filter': 1,
+		'label': 'TDS Applicable',
+		'no_copy': 1,
+		'oldfieldname': 'tds_applicable',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'print_hide': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'tds_category',
+		'fieldtype': 'Select',
+		'hidden': 0,
+		'idx': 44,
+		'in_filter': 1,
+		'label': 'TDS Category',
+		'no_copy': 1,
+		'oldfieldname': 'tds_category',
+		'oldfieldtype': 'Select',
+		'options': 'link:TDS Category',
+		'permlevel': 0,
+		'print_hide': 1,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'supplier_account',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 45,
+		'label': 'Supplier Account',
+		'no_copy': 1,
+		'oldfieldname': 'supplier_account',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 46,
+		'label': 'Get TDS',
+		'no_copy': 0,
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Tax Code will be populated based on account head mentioned in TDS Category master',
+		'doctype': 'DocField',
+		'fieldname': 'tax_code',
+		'fieldtype': 'Link',
+		'idx': 47,
+		'label': 'TDS Account Head',
+		'no_copy': 1,
+		'oldfieldname': 'tax_code',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rate',
+		'fieldtype': 'Currency',
+		'idx': 48,
+		'label': 'Rate',
+		'no_copy': 1,
+		'oldfieldname': 'rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'ded_amount',
+		'fieldtype': 'Currency',
+		'idx': 49,
+		'label': 'Amount',
+		'no_copy': 1,
+		'oldfieldname': 'ded_amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	}
+]
\ No newline at end of file
diff --git a/accounts/doctype/lease_agreement/lease_agreement.js b/accounts/doctype/lease_agreement/lease_agreement.js
index 83e8500..8ffd522 100644
--- a/accounts/doctype/lease_agreement/lease_agreement.js
+++ b/accounts/doctype/lease_agreement/lease_agreement.js
@@ -1,5 +1,5 @@
 $.extend(cur_frm.cscript, {
-	Generate: function(doc, dt, dn) {msgprint(doc);
+	Generate: function(doc, dt, dn) {
 		if(doc.installment_amount==''){
 			msgprint('Set Installment Amount before generating schedule');
 			return;