Merge pull request #6211 from rohitwaghchaure/v7.1_fixes

[Fix] Billing Hours showing blank on sales invoice
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 599e9b1..5336b54 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -23,7 +23,8 @@
 		frappe.msgprint('<a href="#List/POS Profile">'
 			+ _("Welcome to POS: Create your POS Profile") + '</a>');
 
-	update_pos_profile_data(doc, pos_profile)
+	company_data = get_company_data(doc.company)
+	update_pos_profile_data(doc, pos_profile, company_data)
 	update_multi_mode_option(doc, pos_profile)
 	default_print_format = pos_profile.get('print_format') or "Point of Sale"
 	print_template = frappe.db.get_value('Print Format', default_print_format, 'html')
@@ -32,7 +33,7 @@
 		'doc': doc,
 		'default_customer': pos_profile.get('customer'),
 		'items': get_items(doc, pos_profile),
-		'customers': get_customers(pos_profile, doc),
+		'customers': get_customers(pos_profile, doc, company_data.default_currency),
 		'pricing_rules': get_pricing_rules(doc),
 		'print_template': print_template,
 		'meta': {
@@ -42,8 +43,10 @@
 		}
 	}
 
-def update_pos_profile_data(doc, pos_profile):
-	company_data = frappe.db.get_value('Company', doc.company, '*', as_dict=1)
+def get_company_data(company):
+	return frappe.get_all('Company', fields = ["*"], filters= {'name': company})[0]
+
+def update_pos_profile_data(doc, pos_profile, company_data):
 	doc.campaign = pos_profile.get('campaign')
 
 	doc.write_off_account = pos_profile.get('write_off_account') or \
@@ -148,14 +151,14 @@
 
 	return serial_no_list
 
-def get_customers(pos_profile, doc):
+def get_customers(pos_profile, doc, company_currency):
 	filters = {'disabled': 0}
 	customer_list = []
 	customers = frappe.get_all("Customer", fields=["*"], filters = filters)
 
 	for customer in customers:
 		customer_currency = get_party_account_currency('Customer', customer.name, doc.company) or doc.currency
-		if customer_currency == doc.currency:
+		if customer_currency == doc.currency or customer_currency == company_currency:
 			customer_list.append(customer)
 	return customer_list
 
diff --git a/erpnext/docs/assets/img/schools/admission/__init__.py b/erpnext/docs/assets/img/schools/admission/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/docs/assets/img/schools/admission/__init__.py
diff --git a/erpnext/docs/assets/img/schools/student/program-enrollment.png b/erpnext/docs/assets/img/schools/admission/program-enrollment.png
similarity index 100%
rename from erpnext/docs/assets/img/schools/student/program-enrollment.png
rename to erpnext/docs/assets/img/schools/admission/program-enrollment.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-applicant-enroll.png b/erpnext/docs/assets/img/schools/admission/student-applicant-enroll.png
similarity index 100%
rename from erpnext/docs/assets/img/schools/student/student-applicant-enroll.png
rename to erpnext/docs/assets/img/schools/admission/student-applicant-enroll.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/admission/student-applicant.png b/erpnext/docs/assets/img/schools/admission/student-applicant.png
new file mode 100644
index 0000000..aa10807
--- /dev/null
+++ b/erpnext/docs/assets/img/schools/admission/student-applicant.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/module.png b/erpnext/docs/assets/img/schools/module.png
new file mode 100644
index 0000000..eae84b3
--- /dev/null
+++ b/erpnext/docs/assets/img/schools/module.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-applicant.png b/erpnext/docs/assets/img/schools/student/student-applicant.png
deleted file mode 100644
index 4834cf6..0000000
--- a/erpnext/docs/assets/img/schools/student/student-applicant.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-batch.png b/erpnext/docs/assets/img/schools/student/student-batch.png
new file mode 100644
index 0000000..75a3314
--- /dev/null
+++ b/erpnext/docs/assets/img/schools/student/student-batch.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-group.png b/erpnext/docs/assets/img/schools/student/student-group.png
index 894ef91..c562b00 100644
--- a/erpnext/docs/assets/img/schools/student/student-group.png
+++ b/erpnext/docs/assets/img/schools/student/student-group.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-log.png b/erpnext/docs/assets/img/schools/student/student-log.png
new file mode 100644
index 0000000..ba89b78
--- /dev/null
+++ b/erpnext/docs/assets/img/schools/student/student-log.png
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student-section.png b/erpnext/docs/assets/img/schools/student/student-section.png
deleted file mode 100644
index 009443d..0000000
--- a/erpnext/docs/assets/img/schools/student/student-section.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/schools/student/student.png b/erpnext/docs/assets/img/schools/student/student.png
index 79dc0f9..af3e78e 100644
--- a/erpnext/docs/assets/img/schools/student/student.png
+++ b/erpnext/docs/assets/img/schools/student/student.png
Binary files differ
diff --git a/erpnext/docs/user/manual/en/schools/admission/__init__.py b/erpnext/docs/user/manual/en/schools/admission/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/docs/user/manual/en/schools/admission/__init__.py
diff --git a/erpnext/docs/user/manual/en/schools/admission/index.md b/erpnext/docs/user/manual/en/schools/admission/index.md
new file mode 100644
index 0000000..87cdfe5
--- /dev/null
+++ b/erpnext/docs/user/manual/en/schools/admission/index.md
@@ -0,0 +1,7 @@
+# Admission
+
+This section contains student admission related documents.
+
+### Topics
+
+{index}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/admission/index.txt b/erpnext/docs/user/manual/en/schools/admission/index.txt
new file mode 100644
index 0000000..ec9e768
--- /dev/null
+++ b/erpnext/docs/user/manual/en/schools/admission/index.txt
@@ -0,0 +1,2 @@
+student-applicant
+program-enrollment
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/program-enrollment.md b/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
similarity index 72%
rename from erpnext/docs/user/manual/en/schools/student/program-enrollment.md
rename to erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
index 2c8ec12..060033c 100644
--- a/erpnext/docs/user/manual/en/schools/student/program-enrollment.md
+++ b/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
@@ -1,5 +1,5 @@
 This form allows you to enroll a student to a program. A student can be enrolled to multiple programs.  
 
-<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/student/program-enrollment.png">
+<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/admission/program-enrollment.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/student/student-applicant.md b/erpnext/docs/user/manual/en/schools/admission/student-applicant.md
similarity index 90%
rename from erpnext/docs/user/manual/en/schools/student/student-applicant.md
rename to erpnext/docs/user/manual/en/schools/admission/student-applicant.md
index cd4426c..2b33cf9 100644
--- a/erpnext/docs/user/manual/en/schools/student/student-applicant.md
+++ b/erpnext/docs/user/manual/en/schools/admission/student-applicant.md
@@ -3,7 +3,7 @@
 A Student Applicant record needs to be created when a student applies for a program at your institute.
 You can Approve or Reject a student applicant. By accepting a student applicant you can add them to the student master.
 
-<img class="screenshot" alt="Student Applicant" src="{{url_prefix}}/assets/img/schools/student/student-applicant.png">
+<img class="screenshot" alt="Student Applicant" src="{{url_prefix}}/assets/img/schools/admission/student-applicant.png">
 
 ### Application Status
 
@@ -23,6 +23,6 @@
 Once you approve a Student Applicant you can enroll them to a program. When you click the 'Enroll' buttom,
 the system shall create a student against that applicant and redirect you to the [Program Enrollment form]({{docs_base_url}}/user/manual/en/schools/student/program-enrollment.html).
 
-<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/student/student-applicant-enroll.png">
+<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/admission/student-applicant-enroll.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/index.md b/erpnext/docs/user/manual/en/schools/index.md
index 0dff60b..e2172ff 100644
--- a/erpnext/docs/user/manual/en/schools/index.md
+++ b/erpnext/docs/user/manual/en/schools/index.md
@@ -1 +1,6 @@
+
+The School Modules is designed to meet requirements of Schools, Colleges & Educational Institutes.
+
+<img class="screenshot" alt="Fees Section" src="{{url_prefix}}/assets/img/schools/module.png">
+
 {index}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/index.txt b/erpnext/docs/user/manual/en/schools/index.txt
index 780bfa5..f054827 100644
--- a/erpnext/docs/user/manual/en/schools/index.txt
+++ b/erpnext/docs/user/manual/en/schools/index.txt
@@ -1,4 +1,5 @@
 student
+admission
 schedule
 fees
 setup
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/index.md b/erpnext/docs/user/manual/en/schools/student/index.md
index 12d8b82..5e2d153 100644
--- a/erpnext/docs/user/manual/en/schools/student/index.md
+++ b/erpnext/docs/user/manual/en/schools/student/index.md
@@ -2,8 +2,6 @@
 
 This section contains student related documents.
 
-<img class="screenshot" alt="Student Section" src="{{url_prefix}}/assets/img/schools/student/student-section.png">
-
 ### Topics
 
 {index}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/index.txt b/erpnext/docs/user/manual/en/schools/student/index.txt
index 1e34141..9b31be4 100644
--- a/erpnext/docs/user/manual/en/schools/student/index.txt
+++ b/erpnext/docs/user/manual/en/schools/student/index.txt
@@ -1,5 +1,5 @@
-student-applicant
 student
-program-enrollment
+student-log
+student-batch
 student-group
 student-group-creation-tool
diff --git a/erpnext/docs/user/manual/en/schools/student/student-batch.md b/erpnext/docs/user/manual/en/schools/student/student-batch.md
new file mode 100644
index 0000000..0f29d46
--- /dev/null
+++ b/erpnext/docs/user/manual/en/schools/student/student-batch.md
@@ -0,0 +1,7 @@
+# Student Batch
+
+Student batch is a collection of students from Student Groups.
+
+<img class="screenshot" alt="Student" src="{{url_prefix}}/assets/img/schools/student/student-batch.png">
+
+{next}
diff --git a/erpnext/docs/user/manual/en/schools/student/student-log.md b/erpnext/docs/user/manual/en/schools/student/student-log.md
new file mode 100644
index 0000000..787dacb
--- /dev/null
+++ b/erpnext/docs/user/manual/en/schools/student/student-log.md
@@ -0,0 +1,8 @@
+# Student Log
+
+You can make a note of student activities using student log.
+Logs can be categorised as 'General', 'Academic', 'Medical' or 'Achievement'
+
+<img class="screenshot" alt="Student" src="{{url_prefix}}/assets/img/schools/student/student-log.png">
+
+{next}
diff --git a/erpnext/docs/user/manual/en/schools/student/student.md b/erpnext/docs/user/manual/en/schools/student/student.md
index d0b1089..a86d36e 100644
--- a/erpnext/docs/user/manual/en/schools/student/student.md
+++ b/erpnext/docs/user/manual/en/schools/student/student.md
@@ -1,7 +1,7 @@
 # Student
 
-A Student is defined as a person who has enrolled at your institute and you have accepted their application.
-The student doctype maintains personal details of the student. 
+A Student is a person who has enrolled at your institute and you have accepted their application.
+The student doctype maintains personal details of the student.
 
 You can view everything related to a particular student on this page. Eg : Fees, Student Group, etc
 
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py
index c7162b8..d17ab4e 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.py
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.py
@@ -66,6 +66,8 @@
 			Creates salary slip for selected employees if already not created
 		"""
 
+		self.check_permission('write')
+
 		emp_list = self.get_emp_list()
 		ss_list = []
 		for emp in emp_list:
@@ -111,6 +113,8 @@
 		"""
 			Submit all salary slips based on selected criteria
 		"""
+		self.check_permission('write')
+
 		ss_list = self.get_sal_slip_list()
 		not_submitted_ss = []
 		for ss in ss_list:
@@ -168,6 +172,8 @@
 
 
 	def make_journal_entry(self, salary_account = None):
+		self.check_permission('write')
+
 		amount = self.get_total_salary()
 		default_bank_account = frappe.db.get_value("Company", self.company,
 			"default_bank_account")
diff --git a/erpnext/hr/doctype/salary_component/salary_component.json b/erpnext/hr/doctype/salary_component/salary_component.json
index 5595fcc..ca7378b 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.json
+++ b/erpnext/hr/doctype/salary_component/salary_component.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "salary_component", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -40,6 +41,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "salary_component_abbr", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -67,6 +69,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "description", 
    "fieldtype": "Small Text", 
    "hidden": 0, 
@@ -92,6 +95,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "accounts", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -113,6 +117,33 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "type", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Earning\nDeduction", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }
  ], 
  "hide_heading": 0, 
@@ -126,7 +157,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-07-27 17:40:18.335540", 
+ "modified": "2016-08-29 05:33:22.495594", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Component", 
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js
index a108e38..0dce0a4 100755
--- a/erpnext/hr/doctype/salary_structure/salary_structure.js
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.js
@@ -13,6 +13,23 @@
 }
 
 frappe.ui.form.on('Salary Structure', {
+	onload: function(frm) {
+		frm.set_query("salary_component", "earnings", function() {
+			return {
+				filters: {
+					type: "earning"
+				}
+			}
+		})
+		frm.set_query("salary_component", "deductions", function() {
+			return {
+				filters: {
+					type: "deduction"
+				}
+			}
+		})
+	},
+	
 	refresh: function(frm) {
 		frm.trigger("toggle_fields")
 		frm.fields_dict['earnings'].grid.set_column_disp("default_amount", false);
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ba82a23..436bbdb 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -316,3 +316,4 @@
 erpnext.patches.v7_0.move_employee_parent_to_child_in_salary_structure
 erpnext.patches.v7_0.repost_gle_for_pos_sales_return
 erpnext.patches.v7_1.update_total_billing_hours
+erpnext.patches.v7_1.update_component_type
diff --git a/erpnext/patches/v7_1/update_component_type.py b/erpnext/patches/v7_1/update_component_type.py
new file mode 100644
index 0000000..aecbc9f
--- /dev/null
+++ b/erpnext/patches/v7_1/update_component_type.py
@@ -0,0 +1,14 @@
+import frappe
+from frappe.utils import flt
+
+def execute():
+	frappe.reload_doc('hr', 'doctype', 'salary_component')
+	sal_components = frappe.db.sql("""
+		select DISTINCT salary_component, parentfield from `tabSalary Detail`""", as_dict=True)
+
+	if sal_components:
+		for sal_component in sal_components:
+			if sal_component.parentfield == "earnings":
+				frappe.db.sql("""update `tabSalary Component` set type='Earning' where salary_component=%(sal_comp)s""",{"sal_comp": sal_component.salary_component})
+			else:
+				frappe.db.sql("""update `tabSalary Component` set type='Deduction' where salary_component=%(sal_comp)s""",{"sal_comp": sal_component.salary_component})
\ No newline at end of file
diff --git a/erpnext/portal/doctype/homepage/homepage.json b/erpnext/portal/doctype/homepage/homepage.json
index 51d7955..e0e47d1 100644
--- a/erpnext/portal/doctype/homepage/homepage.json
+++ b/erpnext/portal/doctype/homepage/homepage.json
@@ -1,236 +1,262 @@
 {
- "allow_copy": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "autoname": "", 
- "beta": 1, 
- "creation": "2016-04-22 05:27:52.109319", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Setup", 
- "editable_grid": 0, 
+ "allow_copy": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "",
+ "beta": 1,
+ "creation": "2016-04-22 05:27:52.109319",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 0,
  "fields": [
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Company", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Company", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "Company",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Company",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "title", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "TItle", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "fieldname": "title",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "TItle",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "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, 
-   "description": "Company Tagline for website homepage", 
-   "fieldname": "tag_line", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Tag Line", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "description": "Company Tagline for website homepage",
+   "fieldname": "tag_line",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "Tag Line",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "description": "Company Description for website homepage", 
-   "fieldname": "description", 
-   "fieldtype": "Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "description": "Company Description for website homepage",
+   "fieldname": "description",
+   "fieldtype": "Text",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "Description",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "products_section", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Products", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "fieldname": "products_section",
+   "fieldtype": "Section Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "Products",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "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, 
-   "description": "Products to be shown on website homepage", 
-   "fieldname": "products", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Products", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Homepage Featured Product", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "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,
+   "default": "/products",
+   "fieldname": "products_url",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "URL for \"All Products\"",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "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,
+   "description": "Products to be shown on website homepage",
+   "fieldname": "products",
+   "fieldtype": "Table",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_list_view": 0,
+   "label": "Products",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Homepage Featured Product",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0,
    "width": "40px"
   }
- ], 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "in_dialog": 0, 
- "is_submittable": 0, 
- "issingle": 1, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2016-08-09 05:01:30.287861", 
- "modified_by": "Administrator", 
- "module": "Portal", 
- "name": "Homepage", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "in_dialog": 0,
+ "is_submittable": 0,
+ "issingle": 1,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2016-08-29 01:28:00.961623",
+ "modified_by": "Administrator",
+ "module": "Portal",
+ "name": "Homepage",
+ "name_case": "",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 0, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 0, 
-   "role": "System Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "apply_user_permissions": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 0,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 0,
+   "role": "System Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 0, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 0, 
-   "role": "Administrator", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "apply_user_permissions": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 0,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 0,
+   "role": "Administrator",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "company", 
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "company",
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/portal/doctype/homepage/homepage.py b/erpnext/portal/doctype/homepage/homepage.py
index 20ce767..f8f73fd 100644
--- a/erpnext/portal/doctype/homepage/homepage.py
+++ b/erpnext/portal/doctype/homepage/homepage.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.document import Document
+from frappe.website.utils import delete_page_cache
 
 class Homepage(Document):
 	def validate(self):
@@ -12,6 +13,7 @@
 			self.setup_items()
 		if not self.description:
 			self.description = frappe._("This is an example website auto-generated from ERPNext")
+		delete_page_cache('home')
 
 	def setup_items(self):
 		for d in frappe.get_all('Item', fields=['name', 'item_name', 'description', 'image'],
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 9204657..70e464d 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -575,7 +575,8 @@
 		if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){
 			$.each(this.frm.doc['payments'] || [], function(index, data){
 				if(data.type == "Cash" && payment_status) {
-					data.amount = total_amount_to_pay;
+					data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
+					data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
 					payment_status = false;
 				}else if(me.frm.doc.paid_amount){
 					data.amount = 0.0;
@@ -588,7 +589,7 @@
 		var me = this;
 		var paid_amount = base_paid_amount = 0.0;
 		$.each(this.frm.doc['payments'] || [], function(index, data){
-			data.base_amount = flt(data.amount * me.frm.doc.conversion_rate);
+			data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount"));
 			paid_amount += data.amount;
 			base_paid_amount += data.base_amount;
 		})
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 258331c..20630b2 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -47,8 +47,9 @@
 
 	def validate(self):
 		super(PurchaseReceipt, self).validate()
-
-		self.set_status()
+		
+		if not self._action=="submit":
+			self.set_status()
 		self.po_required()
 		self.validate_with_previous_doc()
 		self.validate_inspection()
diff --git a/erpnext/templates/pages/home.html b/erpnext/templates/pages/home.html
index 790a430..b91cd73 100644
--- a/erpnext/templates/pages/home.html
+++ b/erpnext/templates/pages/home.html
@@ -26,9 +26,8 @@
 					{% endfor %}
 				</div>
 			</div>
-			<!-- TODO: remove hardcoding of /products -->
 			<div class="text-center padding">
-				<a href="/products" class="btn btn-primary all-products">
+				<a href="{{ homepage.products_url or "/products" }}" class="btn btn-primary all-products">
 					{{ _("View All Products") }}</a></div>
 		</div>
 		{% endif %}