Merge pull request #6024 from rohitwaghchaure/get_account_of_payment_mode_issue

[Fix] Get account of the mode of payment on sales invoice and pos profile
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index b247e3e..930f25f 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -9,6 +9,7 @@
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Document", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 1, 
@@ -121,6 +122,33 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "description": "", 
+   "fieldname": "bill_no", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 1, 
+   "in_list_view": 0, 
+   "label": "Supplier Invoice No", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "bill_no", 
+   "oldfieldtype": "Data", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "is_paid", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -146,6 +174,32 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "0", 
+   "fieldname": "is_return", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Is Return", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "column_break1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -198,19 +252,18 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "description": "", 
-   "fieldname": "bill_no", 
-   "fieldtype": "Data", 
+   "fieldname": "bill_date", 
+   "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "label": "Supplier Invoice No", 
+   "label": "Supplier Invoice Date", 
    "length": 0, 
    "no_copy": 0, 
-   "oldfieldname": "bill_no", 
-   "oldfieldtype": "Data", 
+   "oldfieldname": "bill_date", 
+   "oldfieldtype": "Date", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -225,17 +278,17 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "bill_date", 
+   "fieldname": "due_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "label": "Supplier Invoice Date", 
+   "label": "Due Date", 
    "length": 0, 
    "no_copy": 0, 
-   "oldfieldname": "bill_date", 
+   "oldfieldname": "due_date", 
    "oldfieldtype": "Date", 
    "permlevel": 0, 
    "print_hide": 1, 
@@ -303,32 +356,6 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "default": "0", 
-   "fieldname": "is_return", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Is Return", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
    "depends_on": "is_return", 
    "fieldname": "return_against", 
    "fieldtype": "Link", 
@@ -2501,32 +2528,6 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "due_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 1, 
-   "in_list_view": 0, 
-   "label": "Due Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "due_date", 
-   "oldfieldtype": "Date", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
    "fieldname": "against_expense_account", 
    "fieldtype": "Small Text", 
    "hidden": 1, 
@@ -3031,7 +3032,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-06-30 13:40:39.440648", 
+ "modified": "2016-08-10 02:45:28.746569", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.html b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.html
new file mode 100644
index 0000000..e26636e
--- /dev/null
+++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.html
@@ -0,0 +1,132 @@
+
+<head>
+	
+	
+	<link href="/assets/frappe/css/c3.min.css" rel="stylesheet" type="text/css">
+	
+	
+	<script type="text/javascript" src="/assets/frappe/js/lib/d3.min.js"></script>
+	<script type="text/javascript" src="/assets/frappe/js/lib/c3.min.js"></script>
+    <script type="text/javascript">
+
+		onReady("#chart_div", function() {
+			var chartData = [];
+			{% var q = 0; %}
+			{% for(var j=0, m=data.length+1; j<m; j++) { %}
+			
+				var tempData{%=j%} = [];
+				
+				{% for(var i=1, l=report.columns.length; i<l; i++) { %}
+					{% if(__(report.columns[i].label) != __("Quotation")) { %}
+					
+						{% if(j == 0) { %}
+							{% if(i == 1) { %}
+								tempData{%=j%}[{%=i%}-1] = \"x\";
+							{% } else { %}
+
+								tempData{%=j%}[{%=i%}-1] = Math.log(parseInt(\"{%= report.columns[i].label %}\".replace(\"Qty: \",\"\"))) / Math.LN10;
+							{% } %}
+						{% } else { %}
+							{% if(i == 1) { %}
+								tempData{%=j%}[{%=i%}-1] = \"{%= data[j-1][report.columns[i].field] %} \";
+							{% } else { %}
+							tempData{%=j%}[{%=i%}-1] = {% if(data[j-1][report.columns[i].field] == "") { if (i > 2) { %} 
+										tempData{%=j%}[{%=i%}-2] 
+									{% } else { %} 
+										0 
+								{% } } else { %} 
+									{%= data[j-1][report.columns[i].field] %} 
+							{% } %};
+							{% } %};
+						{% } %}
+					{% } else { %}
+						{% if(j == 0) { %}
+							{% if(i < l-1) { %}
+								tempData{%=j%}[{%=i%}-1] = Math.log(parseInt(\"{%= report.columns[i+1].label %}\".replace(\"Qty: \",\"\"))-1) / Math.LN10;
+							{% } else { %}
+								tempData{%=j%}[{%=i%}-1] = Math.log(2*parseInt(\"{%= report.columns[i-1].label %}\".replace(\"Qty: \",\"\"))) / Math.LN10;
+							{% } %}
+						{% } else { %}
+
+							tempData{%=j%}[{%=i%}-1] = tempData{%=j%}[{%=i%}-2];
+						{% } %}
+
+					{% } %}
+					
+				{% } %}
+				chartData[{%=j%}] = tempData{%=j%};
+			{% } %}
+			console.log(chartData);
+			
+			hold = {
+			bindto: "#chart_div" ,data: {
+				x: "x",
+				columns: chartData
+			},
+			axis: {
+				x: {
+					tick: {
+					   format: function (x22) { return Math.pow(10,x22).toFixed(0); },
+						culling: {
+							max: {%=report.columns.length%} / 2
+						}
+
+					}
+				}
+			},
+			point: {
+			  show: false
+			}
+			};
+			console.log(hold);
+			var chart = c3.generate(hold);
+		});
+		
+		function onReady(selector, callback) {
+        var intervalID = window.setInterval(function() {
+          if (document.querySelector(selector) !== undefined) {
+            window.clearInterval(intervalID);
+            callback.call(this);
+          }
+        }, 500);}
+				
+		
+    </script>
+
+ </head>
+<div style="margin-bottom: 7px;" class="text-center">
+	{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
+</div>
+<h2 class="text-center">{%= __(report.report_name) %}</h2>
+<h4 class="text-center">{%= filters.item %} </h4>
+
+<hr>
+<table class="table table-bordered">
+	<thead>
+		<tr>
+			{% for(var i=0, l=report.columns.length; i<l; i++) { %}
+				<th style="width: 15%">{%= report.columns[i].label %}</th>
+			{% } %}
+
+		</tr>
+	</thead>
+	<tbody>
+
+		{% for(var i=0, l=data.length; i<l; i++) { %}
+			<tr>
+			
+				{% for(var j=0,m=report.columns.length; j<m; j++) { %}
+					<td style="width: 15%">{%= data[i][report.columns[j].field] %}</td>
+				{% } %}
+
+		</tr>
+		{% } %}
+	</tbody>
+</table>
+
+<h4 class="text-center"> Analysis Chart </h4>
+<div id="chart_div"></div>
+
+
+		
+<p class="text-right text-muted">Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}</p>
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/migrate_schools_to_erpnext.py b/erpnext/patches/v7_0/migrate_schools_to_erpnext.py
index 2376cc4..c222da8 100644
--- a/erpnext/patches/v7_0/migrate_schools_to_erpnext.py
+++ b/erpnext/patches/v7_0/migrate_schools_to_erpnext.py
@@ -21,7 +21,5 @@
 		remove_from_installed_apps("schools")
 
 def reload_doctypes_for_schools_icons():
-	for name in ('student', 'student_group', 'course_schedule', 'student_attendance', 'room', 
-		'program_enrollment', 'course', 'program', 'student_applicant', 'fees', 
-		'instructor', 'announcement'):
-			frappe.reload_doc('schools', 'doctype', name)
+	for d in frappe.get_all('DocType', filters={'module': 'Schools'}):
+		frappe.reload_doc('schools', 'doctype', d.name)
diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css
index b8d51c0..d67f9e0 100644
--- a/erpnext/public/css/erpnext.css
+++ b/erpnext/public/css/erpnext.css
@@ -46,9 +46,10 @@
   line-height: 0;
   color: #d1d8dd;
   font-size: 30px;
-  background-size: cover;
+  background-size: contain;
   border: 1px solid transparent;
-  background-position: top center;
+  background-position: center;
+  background-repeat: no-repeat;
 }
 .pos-item-area {
   border: 1px solid #d1d8dd;
diff --git a/erpnext/public/less/erpnext.less b/erpnext/public/less/erpnext.less
index 896aee7..d39f924 100644
--- a/erpnext/public/less/erpnext.less
+++ b/erpnext/public/less/erpnext.less
@@ -58,9 +58,10 @@
 	line-height: 0;
 	color: @text-extra-muted;
 	font-size: 30px;
-	background-size: cover;
+	background-size: contain;
 	border: 1px solid transparent;
-	background-position: top center;
+	background-position: center;
+	background-repeat: no-repeat;
 }
 
 .pos-item-area {
diff --git a/erpnext/schools/doctype/course/course.py b/erpnext/schools/doctype/course/course.py
index beeb6ec..b590acb 100644
--- a/erpnext/schools/doctype/course/course.py
+++ b/erpnext/schools/doctype/course/course.py
@@ -14,9 +14,9 @@
 	user = frappe.session.user
 	student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user)
 	if student:
-		return frappe.db.sql('''select group_name, course, academic_term, academic_year, SG.name from `tabStudent Group`
-			as SG, `tabStudent Group Student` as SGS where SG.group_name = SGS.parent and SGS.student = %s
-			order by SG.group_name asc limit {0} , {1}'''.format(limit_start, limit_page_length), student, as_dict=True)
+		return frappe.db.sql('''select course, academic_term, academic_year, SG.name from `tabStudent Group`
+			as SG, `tabStudent Group Student` as SGS where SG.name = SGS.parent and SGS.student = %s
+			order by SG.name asc limit {0} , {1}'''.format(limit_start, limit_page_length), student, as_dict=True)
 
 def get_list_context(context=None):
 	return {
diff --git a/erpnext/templates/includes/course/course_row.html b/erpnext/templates/includes/course/course_row.html
index 9b9317b..fddfc3c 100644
--- a/erpnext/templates/includes/course/course_row.html
+++ b/erpnext/templates/includes/course/course_row.html
@@ -5,7 +5,7 @@
 				{{ doc.course }}
 			</div>
 			<div class="col-xs-3">
-				{{ doc.group_name }}
+				{{ doc.name }}
 			</div>
 			<div class="col-xs-2">
 				{{doc.academic_term }}