Merge pull request #821 from akhileshdarjee/master

[fix] purchase receipt test cases
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 dc2bcc5..7522c23 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
@@ -19,7 +19,7 @@
 			webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
 		
 	def get_voucher_details(self):
-		total_amount = webnotes.conn.sql("""select %s from `tabGL Entry` 
+		total_amount = webnotes.conn.sql("""select sum(%s) from `tabGL Entry` 
 			where voucher_type = %s and voucher_no = %s 
 			and account = %s and ifnull(is_cancelled, 'No') = 'No'""" % 
 			(self.doc.account_type, '%s', '%s', '%s'), 
diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py
index a3ef197..b265356 100644
--- a/selling/doctype/opportunity/opportunity.py
+++ b/selling/doctype/opportunity/opportunity.py
@@ -160,6 +160,11 @@
 def make_quotation(source_name, target_doclist=None):
 	from webnotes.model.mapper import get_mapped_doclist
 	
+	def set_missing_values(source, target):
+		quotation = webnotes.bean(target)
+		quotation.run_method("onload_post_render")
+		quotation.run_method("calculate_taxes_and_totals")
+	
 	doclist = get_mapped_doclist("Opportunity", source_name, {
 		"Opportunity": {
 			"doctype": "Quotation", 
@@ -181,6 +186,6 @@
 			},
 			"add_if_empty": True
 		}
-	}, target_doclist)
+	}, target_doclist, set_missing_values)
 		
 	return [d.fields for d in doclist]
\ No newline at end of file