Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
index 93e6bff..868e59a 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
@@ -17,6 +17,19 @@
 // Booking Entry Id
 // --------------------
 
+cur_frm.cscript.onload_post_render = function(doc) {
+	$(cur_frm.get_field("reconcile").input).addClass("btn-info");
+}
+
+cur_frm.cscript.refresh = function(doc) {
+	cur_frm.set_intro("");
+	if(!doc.voucher_no) {
+		cur_frm.set_intro("Select the Invoice against which you want to allocate payments.");
+	} else {
+		cur_frm.set_intro("Set allocated amount against each Payment Entry and click 'Allocate'.");
+	}
+}
+
 cur_frm.fields_dict.voucher_no.get_query = function(doc) {
 	if (!doc.account) msgprint("Please select Account first");
 	else {
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
index 81b94a2..e72d23e 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
@@ -107,7 +107,6 @@
 			ch.total_amt = flt(d.get('total_amt'))
 			ch.against_account = d.get('against_account')
 			ch.remarks = d.get('remark')
-			ch.amt_to_be_reconciled = flt(ch.amt_due)
 			ch.voucher_detail_no = d.get('voucher_detail_no')
 			
 	#--------------------------------------------------
@@ -128,7 +127,7 @@
 		
 		lst = []
 		for d in getlist(self.doclist, 'ir_payment_details'):
-			if d.selected and flt(d.amt_to_be_reconciled) > 0:
+			if flt(d.amt_to_be_reconciled) > 0:
 				args = {
 					'voucher_no' : d.voucher_no,
 					'voucher_detail_no' : d.voucher_detail_no, 
@@ -146,6 +145,6 @@
 
 		if lst:
 			get_obj('GL Control').reconcile_against_document(lst)
-			msgprint("Successfully reconciled.")
+			msgprint("Successfully allocated.")
 		else:
-			msgprint("No payment entries selected.", raise_exception=1)
+			msgprint("No amount allocated.", raise_exception=1)
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
index 4ae813a..91d2613 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
@@ -2,21 +2,17 @@
  {
   "owner": "Administrator", 
   "docstatus": 0, 
-  "creation": "2012-03-27 14:35:42", 
+  "creation": "2012-07-03 13:30:46", 
   "modified_by": "Administrator", 
-  "modified": "2012-03-27 14:35:42"
+  "modified": "2012-12-31 10:34:43"
  }, 
  {
-  "section_style": "Simple", 
-  "module": "Accounts", 
-  "doctype": "DocType", 
   "issingle": 1, 
-  "document_type": "Other", 
   "name": "__common__", 
-  "colour": "White:FFF", 
-  "_last_update": "1316509358", 
-  "show_in_menu": 1, 
-  "version": 37
+  "doctype": "DocType", 
+  "module": "Accounts", 
+  "document_type": "Other", 
+  "hide_toolbar": 1
  }, 
  {
   "name": "__common__", 
@@ -38,6 +34,148 @@
   "doctype": "DocType"
  }, 
  {
+  "doctype": "DocField", 
+  "label": "Account", 
+  "options": "Account", 
+  "fieldname": "account", 
+  "fieldtype": "Link", 
+  "reqd": 1, 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Voucher Type", 
+  "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", 
+  "fieldname": "voucher_type", 
+  "fieldtype": "Select", 
+  "reqd": 1, 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Voucher No", 
+  "options": "[Select]", 
+  "fieldname": "voucher_no", 
+  "fieldtype": "Link", 
+  "reqd": 1, 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Pull Payment Entries", 
+  "options": "get_payment_entries", 
+  "fieldname": "pull_payment_entries", 
+  "fieldtype": "Button", 
+  "permlevel": 0
+ }, 
+ {
+  "print_width": "50%", 
+  "doctype": "DocField", 
+  "width": "50%", 
+  "fieldname": "column_break1", 
+  "fieldtype": "Column Break", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Total Amount", 
+  "fieldname": "total_amount", 
+  "fieldtype": "Currency", 
+  "permlevel": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Outstanding Amount", 
+  "fieldname": "pending_amt_to_reconcile", 
+  "fieldtype": "Currency", 
+  "permlevel": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Payment Entries", 
+  "fieldname": "payment_entries", 
+  "fieldtype": "Section Break", 
+  "permlevel": 0
+ }, 
+ {
+  "description": "Update allocated amount in the above table and then click \"Allocate\" button", 
+  "doctype": "DocField", 
+  "label": "Payment Entries", 
+  "options": "Payment to Invoice Matching Tool Detail", 
+  "fieldname": "ir_payment_details", 
+  "fieldtype": "Table", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Allocate", 
+  "options": "reconcile", 
+  "fieldname": "reconcile", 
+  "fieldtype": "Button", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "options": "Simple", 
+  "fieldname": "section_break0", 
+  "fieldtype": "Section Break", 
+  "permlevel": 0
+ }, 
+ {
+  "print_width": "50%", 
+  "doctype": "DocField", 
+  "label": "Filter By Date", 
+  "width": "50%", 
+  "fieldname": "column_break2", 
+  "fieldtype": "Column Break", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "From Date", 
+  "fieldname": "from_date", 
+  "fieldtype": "Date", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "To Date", 
+  "fieldname": "to_date", 
+  "fieldtype": "Date", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Help HTML", 
+  "options": "Click \"Pull Payment Entries\" to refresh the table with filters.", 
+  "fieldname": "help_html", 
+  "fieldtype": "HTML", 
+  "permlevel": 0
+ }, 
+ {
+  "print_width": "50%", 
+  "doctype": "DocField", 
+  "label": "Filter By Amount", 
+  "width": "50%", 
+  "fieldname": "column_break3", 
+  "fieldtype": "Column Break", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Amount >=", 
+  "fieldname": "amt_greater_than", 
+  "fieldtype": "Data", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Amount <=", 
+  "fieldname": "amt_less_than", 
+  "fieldtype": "Data", 
+  "permlevel": 0
+ }, 
+ {
   "create": 1, 
   "doctype": "DocPerm", 
   "write": 1, 
@@ -59,159 +197,8 @@
   "permlevel": 0
  }, 
  {
+  "doctype": "DocPerm", 
   "role": "All", 
-  "permlevel": 1, 
-  "doctype": "DocPerm"
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "width": "50%", 
-  "fieldname": "column_break0", 
-  "fieldtype": "Column Break", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "options": "Account", 
-  "fieldname": "account", 
-  "fieldtype": "Link", 
-  "label": "Account", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", 
-  "fieldname": "voucher_type", 
-  "fieldtype": "Select", 
-  "label": "Voucher Type", 
-  "permlevel": 0
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "Voucher No", 
-  "trigger": "Client", 
-  "fieldname": "voucher_no", 
-  "fieldtype": "Link", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "width": "50%", 
-  "fieldname": "column_break1", 
-  "fieldtype": "Column Break", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "label": "Total Amount", 
-  "fieldname": "total_amount", 
-  "fieldtype": "Currency", 
   "permlevel": 1
- }, 
- {
-  "doctype": "DocField", 
-  "label": "Pending Amt To Reconcile", 
-  "fieldname": "pending_amt_to_reconcile", 
-  "fieldtype": "Currency", 
-  "permlevel": 1
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "Payment Entries", 
-  "fieldname": "payment_entries", 
-  "fieldtype": "Section Break", 
-  "permlevel": 0
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "<div class = 'field_description'>Filter payment entries based on date:</div>", 
-  "width": "50%", 
-  "fieldname": "column_break2", 
-  "fieldtype": "Column Break", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "label": "From Date", 
-  "fieldname": "from_date", 
-  "fieldtype": "Date", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "label": "To Date", 
-  "fieldname": "to_date", 
-  "fieldtype": "Date", 
-  "permlevel": 0
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "<div class = 'field_description'>Filter payment entries based on amount:</div>", 
-  "width": "50%", 
-  "fieldname": "column_break3", 
-  "fieldtype": "Column Break", 
-  "permlevel": 0
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "Amount >=", 
-  "fieldname": "amt_greater_than", 
-  "fieldtype": "Data", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "label": "Amount <=", 
-  "fieldname": "amt_less_than", 
-  "fieldtype": "Data", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "permlevel": 0, 
-  "fieldname": "section_break0", 
-  "fieldtype": "Section Break", 
-  "options": "Simple"
- }, 
- {
-  "doctype": "DocField", 
-  "options": "get_payment_entries", 
-  "fieldname": "pull_payment_entries", 
-  "fieldtype": "Button", 
-  "label": "Pull Payment Entries", 
-  "permlevel": 0
- }, 
- {
-  "doctype": "DocField", 
-  "options": "Payment to Invoice Matching Tool Detail", 
-  "fieldname": "ir_payment_details", 
-  "fieldtype": "Table", 
-  "label": "Payment Entries", 
-  "permlevel": 0
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "Reconcile HTML", 
-  "permlevel": 0, 
-  "fieldname": "reconcile_html", 
-  "fieldtype": "HTML", 
-  "options": "<div class='field_description'>Select Payment Voucher and Amount to Reconcile in the above table and then click Reconcile button</div>"
- }, 
- {
-  "colour": "White:FFF", 
-  "doctype": "DocField", 
-  "label": "Reconcile", 
-  "permlevel": 0, 
-  "trigger": "Client", 
-  "fieldname": "reconcile", 
-  "fieldtype": "Button", 
-  "options": "reconcile"
  }
 ]
\ No newline at end of file
diff --git a/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt b/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt
index ab7e6bb..81bc59e 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt
+++ b/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt
@@ -2,19 +2,15 @@
  {
   "owner": "Administrator", 
   "docstatus": 0, 
-  "creation": "2012-03-27 14:35:43", 
+  "creation": "2012-07-03 13:30:47", 
   "modified_by": "Administrator", 
-  "modified": "2012-03-27 14:35:43"
+  "modified": "2012-12-31 10:24:49"
  }, 
  {
-  "section_style": "Simple", 
   "istable": 1, 
   "name": "__common__", 
-  "colour": "White:FFF", 
-  "module": "Accounts", 
   "doctype": "DocType", 
-  "version": 14, 
-  "show_in_menu": 0
+  "module": "Accounts"
  }, 
  {
   "name": "__common__", 
@@ -28,15 +24,7 @@
   "doctype": "DocType"
  }, 
  {
-  "doctype": "DocField", 
-  "label": "Select", 
-  "width": "60px", 
-  "fieldname": "selected", 
-  "fieldtype": "Check", 
-  "reqd": 1, 
-  "permlevel": 0
- }, 
- {
+  "print_width": "140px", 
   "permlevel": 1, 
   "doctype": "DocField", 
   "label": "Voucher No", 
@@ -48,14 +36,14 @@
  }, 
  {
   "doctype": "DocField", 
-  "label": "Amt Due", 
+  "label": "Unmatched Amount", 
   "fieldname": "amt_due", 
   "fieldtype": "Currency", 
   "permlevel": 1
  }, 
  {
   "doctype": "DocField", 
-  "label": "Amt to be reconciled", 
+  "label": "Allocated Amount", 
   "fieldname": "amt_to_be_reconciled", 
   "fieldtype": "Currency", 
   "reqd": 1, 
@@ -70,7 +58,7 @@
  }, 
  {
   "doctype": "DocField", 
-  "label": "Total Amt", 
+  "label": "Total Amount", 
   "fieldname": "total_amt", 
   "fieldtype": "Currency", 
   "permlevel": 1
@@ -83,6 +71,7 @@
   "permlevel": 1
  }, 
  {
+  "print_width": "200px", 
   "doctype": "DocField", 
   "label": "Remarks", 
   "width": "200px", 
@@ -96,7 +85,6 @@
   "label": "Voucher Detail No", 
   "fieldname": "voucher_detail_no", 
   "fieldtype": "Data", 
-  "no_column": 0, 
   "reqd": 0, 
   "hidden": 1, 
   "permlevel": 1