Fixed merge conflict
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..aa3a104
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,68 @@
+---
+name: Bug report
+about: Create a report to help us improve
+
+---
+
+Issue: Bug report
+
+Our project, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
+
+**Do the checklist before filing an issue:**
+ - [ ] Have a usage question? Ask your question on  [Discuss Forum](https://discuss.erpnext.com). We use [Discuss Forum](https://discuss.erpnext.com) for usage question and GitHub for bugs.
+ - [ ] Can you replicate the issue? 
+ - [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome
+
+**Describe the bug** :chart_with_downwards_trend: 
+A clear and concise description of what the bug is.
+
+**To Reproduce** :page_with_curl:
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior** :chart_with_upwards_trend:
+A clear and concise description of what you expected to happen.
+
+**Screenshots** :crystal_ball:
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):** :cyclone:
+ - OS:
+    - [ ] Linux
+    - [ ] macOS
+    - [ ] Windows
+    - [ ] Others? Please mention: 
+ - Browser:
+    - [ ] Safari
+    - [ ] Chrome
+    - [ ] Firefox
+    - [ ] Other? Please mention: 
+
+**Smartphone (please complete the following information):** :iphone: :computer:
+ - Device:
+    - [ ] iPhone
+    - [ ] Android
+ - Browser:
+    - [ ] Safari
+    - [ ] Chrome
+    - [ ] Firefox
+    - [ ] Other? Please mention: 
+
+**Version Information**
+- Which branch are you on?
+    - [ ] `master` :star2: 
+    - [ ] `develop` :fire:
+- Frappe Version: 
+- ERPNext Version: 
+
+**Additional context** :page_facing_up:
+Add any other context about the problem here.
+
+**Possible Solution** :bookmark_tabs:
+Any idea what might be causing the issue. Or if you have a proposed solution to the problem,
+
+**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to replicate and fix the issue** :grin: 
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..e09e5e9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,21 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+
+---
+
+Issue: Feature Request
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
+
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..8e2bd85
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,28 @@
+Pull-Request
+
+- [ ] Have you followed the guidelines in our Contributing document?
+- [ ] Have you checked to ensure there aren't other open [Pull Requests](../pulls) for the same update/change?
+- [ ] Have you lint your code locally prior to submission?
+- [ ] Have you successfully run tests with your changes locally?
+- [ ] Does your commit message have an explanation for your changes and why you'd like us to include them?
+- [ ] Docs have been added / updated
+- [ ] Tests for the changes have been added (for bug fixes / features)
+- [ ] Did you modify the existing test cases? If yes, why?
+
+---
+
+What type of a PR is this? 
+
+- [ ] Changes to Existing Features
+- [ ] New Feature Submissions
+- [ ] Bug Fix
+- [ ] Breaking Change
+
+--- 
+
+- Motivation and Context (What existing problem does the pull request solve):
+- Related Issue: 
+- Screenshots (if applicable, remember, a picture tells a thousand words): 
+
+**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to test and get your pull request merged** :grin: 
+
diff --git a/.gitignore b/.gitignore
index 68272c7..2b52a49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,9 @@
 dist/
 erpnext/docs/current
 *.swp
+<<<<<<< HEAD
 *.swo
 __pycache__
 *~
+=======
+>>>>>>> master
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 28212c5..b9e3cfc 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
 from erpnext.hooks import regional_overrides
 from frappe.utils import getdate
 
-__version__ = '10.1.35'
+__version__ = '10.1.36'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/hr/doctype/additional_salary_component/__init__.py b/erpnext/accounts/doctype/bank_account/__init__.py
similarity index 100%
copy from erpnext/hr/doctype/additional_salary_component/__init__.py
copy to erpnext/accounts/doctype/bank_account/__init__.py
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.js b/erpnext/accounts/doctype/bank_account/bank_account.js
new file mode 100644
index 0000000..5ac41e4
--- /dev/null
+++ b/erpnext/accounts/doctype/bank_account/bank_account.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Bank Account', {
+	setup: function(frm) {
+		frm.set_query("account", function() {
+			return {
+				filters: {
+					'account_type': 'Bank',
+					'company': frm.doc.company,
+					'is_group': 0
+				}
+			};
+		});
+	},
+	refresh: function(frm) {
+		frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Bank Account' }
+		
+		frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
+
+		if (frm.doc.__islocal) {
+			frappe.contacts.clear_address_and_contact(frm);
+		}
+		else {
+			frappe.contacts.render_address_and_contact(frm);
+		}
+	}
+});
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json
new file mode 100644
index 0000000..4f84cbb
--- /dev/null
+++ b/erpnext/accounts/doctype/bank_account/bank_account.json
@@ -0,0 +1,533 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 1,
+ "autoname": "field:account_name",
+ "beta": 0,
+ "creation": "2017-05-29 21:35:13.136357",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 0,
+ "engine": "InnoDB",
+ "fields": [
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "account_name",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Account Name",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 1,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Account",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Account",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Company",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Company",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Bank",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_7",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 1,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank_account_no",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Bank Account No",
+   "length": 30,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "iban",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "IBAN",
+   "length": 25,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "branch_code",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Branch Code",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "swift_number",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "SWIFT number",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "address_and_contact",
+   "fieldtype": "Section Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Address and Contact",
+   "length": 0,
+   "no_copy": 0,
+   "options": "fa fa-map-marker",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "address_html",
+   "fieldtype": "HTML",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Address HTML",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "website",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Website",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_12",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "contact_html",
+   "fieldtype": "HTML",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Contact HTML",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2018-05-30 17:44:06.032697",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Bank Account",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+  {
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
+   "write": 1
+  },
+  {
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
+   "write": 1
+  }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "search_fields": "bank,account",
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.py b/erpnext/accounts/doctype/bank_account/bank_account.py
new file mode 100644
index 0000000..e3aef15
--- /dev/null
+++ b/erpnext/accounts/doctype/bank_account/bank_account.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
+
+class BankAccount(Document):
+	def onload(self):
+		"""Load address and contacts in `__onload`"""
+		load_address_and_contact(self)
+
+	def on_trash(self):
+		delete_contact_and_address('BankAccount', self.name)
diff --git a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js b/erpnext/accounts/doctype/bank_account/test_bank_account.js
similarity index 65%
rename from erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
rename to erpnext/accounts/doctype/bank_account/test_bank_account.js
index 118290b..c20a799 100644
--- a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
+++ b/erpnext/accounts/doctype/bank_account/test_bank_account.js
@@ -2,15 +2,15 @@
 // rename this file from _test_[name] to test_[name] to activate
 // and remove above this line
 
-QUnit.test("test: Additional Salary Component", function (assert) {
+QUnit.test("test: Bank Account", function (assert) {
 	let done = assert.async();
 
 	// number of asserts
 	assert.expect(1);
 
 	frappe.run_serially([
-		// insert a new Additional Salary Component
-		() => frappe.tests.make('Additional Salary Component', [
+		// insert a new Bank Account
+		() => frappe.tests.make('Bank Account', [
 			// values to be set
 			{key: 'value'}
 		]),
diff --git a/erpnext/accounts/doctype/bank_account/test_bank_account.py b/erpnext/accounts/doctype/bank_account/test_bank_account.py
new file mode 100644
index 0000000..43a3298
--- /dev/null
+++ b/erpnext/accounts/doctype/bank_account/test_bank_account.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+# test_records = frappe.get_test_records('Bank Account')
+
+class TestBankAccount(unittest.TestCase):
+	pass
diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js
index f7ffc6c..2a44cb3 100644
--- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js
+++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js
@@ -1,20 +1,33 @@
 // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
 
+cur_frm.add_fetch('bank_account','account','account');
+cur_frm.add_fetch('bank_account','bank_account_no','bank_account_no');
+cur_frm.add_fetch('bank_account','iban','iban');
+cur_frm.add_fetch('bank_account','branch_code','branch_code');
+cur_frm.add_fetch('bank_account','swift_number','swift_number');
+
 frappe.ui.form.on('Bank Guarantee', {
 	setup: function(frm) {
-		cur_frm.set_query("account", function() {
+		frm.set_query("bank", function() {
 			return {
-				"filters": {
-					"account_type": "Bank",
-					"is_group": 0
+				filters: {
+					company: frm.doc.company
 				}
 			};
 		});
-		cur_frm.set_query("project", function() {
+		frm.set_query("bank_account", function() {
 			return {
-				"filters": {
-					"customer": cur_frm.doc.customer
+				filters: {
+					company: frm.doc.company,
+					bank: frm.doc.bank
+				}
+			}
+		});
+		frm.set_query("project", function() {
+			return {
+				filters: {
+					customer: frm.doc.customer
 				}
 			};
 		});
@@ -60,4 +73,4 @@
 		var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1);
 		cur_frm.set_value("end_date", end_date);
 	}
-});
\ No newline at end of file
+});
diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.json b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.json
index b3cd157..0d21cab 100644
--- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.json
+++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.json
@@ -1,807 +1,1055 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "autoname": "BG-.#####", 
- "beta": 0, 
- "creation": "2016-12-17 10:43:35.731631", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "BG-.#####",
+ "beta": 0,
+ "creation": "2016-12-17 10:43:35.731631",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "bg_type", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Bank Guarantee Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nReceiving\nProviding", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bg_type",
+   "fieldtype": "Select",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank Guarantee Type",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\nReceiving\nProviding",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reference_doctype", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reference Document Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "DocType", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "reference_doctype",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Reference Document Type",
+   "length": 0,
+   "no_copy": 0,
+   "options": "DocType",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reference_docname", 
-   "fieldtype": "Dynamic Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reference Document Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "reference_doctype", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "reference_docname",
+   "fieldtype": "Dynamic Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Reference Document Name",
+   "length": 0,
+   "no_copy": 0,
+   "options": "reference_doctype",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval: doc.bg_type == \"Receiving\"", 
-   "fieldname": "customer", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Customer", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Customer", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval: doc.bg_type == \"Receiving\"",
+   "fieldname": "customer",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Customer",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Customer",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval: doc.bg_type == \"Providing\"", 
-   "fieldname": "supplier", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Supplier", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Supplier", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval: doc.bg_type == \"Providing\"",
+   "fieldname": "supplier",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Supplier",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Supplier",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 1, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "project", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Project", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Project", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "project",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Project",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Project",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_6", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_6",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "account", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Bank Account", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Account", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "amount",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Amount",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Amount", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "start_date",
+   "fieldtype": "Date",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Start Date",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "start_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Start Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "description": "",
+   "fieldname": "validity",
+   "fieldtype": "Int",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Validity in Days",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "description": "", 
-   "fieldname": "validity", 
-   "fieldtype": "Int", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Validity in Days", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "end_date",
+   "fieldtype": "Date",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "End Date",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "end_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "End Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank_account_info",
+   "fieldtype": "Section Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank Account Info",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_14", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Bank",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "more_information", 
-   "fieldtype": "Text Editor", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Clauses and Conditions", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank_account",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank Account",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Bank Account",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "margin_details", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Other Details", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Account",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Account",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "bank_guarantee_number", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Bank Guarantee Number", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank_account_no",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank Account No",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "iban",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "IBAN",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "branch_code",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Branch Code",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "swift_number",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "SWIFT number",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "section_break_14",
+   "fieldtype": "Section Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "more_information",
+   "fieldtype": "Text Editor",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Clauses and Conditions",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "margin_details",
+   "fieldtype": "Section Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Other Details",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "bank_guarantee_number",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Bank Guarantee Number",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 1
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "name_of_beneficiary", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Name of Beneficiary", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "name_of_beneficiary",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Name of Beneficiary",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "name_of_bank", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Name of Bank", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_19",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_19", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "margin_money",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Margin Money",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "margin_money", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Margin Money", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "default": "",
+   "depends_on": "",
+   "fieldname": "charges",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Charges Incurred",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "", 
-   "depends_on": "", 
-   "fieldname": "charges", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Charges Incurred", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fieldname": "fixed_deposit_number",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Fixed Deposit Number",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "fixed_deposit_number", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Fixed Deposit Number", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Bank Guarantee", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Amended From",
+   "length": 0,
+   "no_copy": 1,
+   "options": "Bank Guarantee",
+   "permlevel": 0,
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "translatable": 0,
    "unique": 0
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 1, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-05-08 06:27:08.959864", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Bank Guarantee", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 1,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2018-05-30 17:35:43.391115",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Bank Guarantee",
+ "name_case": "",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 0, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Accounts User", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 1, 
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 0,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "cancel": 1, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Accounts Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 1, 
+   "amend": 0,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 1,
    "write": 1
   }
- ], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "search_fields": "customer", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "customer", 
- "track_changes": 0, 
+ ],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "search_fields": "customer",
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "customer",
+ "track_changes": 0,
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.js
similarity index 65%
copy from erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
copy to erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.js
index 118290b..0c60920 100644
--- a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
+++ b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.js
@@ -2,15 +2,15 @@
 // rename this file from _test_[name] to test_[name] to activate
 // and remove above this line
 
-QUnit.test("test: Additional Salary Component", function (assert) {
+QUnit.test("test: Bank Guarantee", function (assert) {
 	let done = assert.async();
 
 	// number of asserts
 	assert.expect(1);
 
 	frappe.run_serially([
-		// insert a new Additional Salary Component
-		() => frappe.tests.make('Additional Salary Component', [
+		// insert a new Bank Guarantee
+		() => frappe.tests.make('Bank Guarantee', [
 			// values to be set
 			{key: 'value'}
 		]),
diff --git a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py
similarity index 74%
copy from erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py
copy to erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py
index eda2f79..816743a 100644
--- a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py
+++ b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py
@@ -2,7 +2,9 @@
 # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
 # See license.txt
 from __future__ import unicode_literals
+
+import frappe
 import unittest
 
-class TestAdditionalSalaryComponent(unittest.TestCase):
+class TestBankGuarantee(unittest.TestCase):
 	pass
diff --git a/erpnext/accounts/doctype/budget/budget.json b/erpnext/accounts/doctype/budget/budget.json
index 7c273ee..63322a7 100644
--- a/erpnext/accounts/doctype/budget/budget.json
+++ b/erpnext/accounts/doctype/budget/budget.json
@@ -13,6 +13,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -46,6 +47,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -78,6 +80,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -111,6 +114,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -144,6 +148,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -176,6 +181,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -206,6 +212,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -239,6 +246,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -270,6 +278,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -301,6 +310,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -332,6 +342,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -366,6 +377,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -400,6 +412,38 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_13", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -431,6 +475,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -465,6 +510,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -499,6 +545,38 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_16", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -530,6 +608,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -564,6 +643,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -598,6 +678,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -640,7 +721,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-15 19:26:13.840265", 
+ "modified": "2018-05-31 00:21:23.449225", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Budget", 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 7ea33bf..b62a0f0 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -3712,6 +3712,65 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_112",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "select_print_heading", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -4264,7 +4323,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2018-05-17 12:53:46.687257", 
+ "modified": "2018-05-28 02:38:40.310899",
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 86491f8..43a0d01 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -158,9 +158,8 @@
 		# Get items based on the item groups defined in the POS profile
 		for d in pos_profile.get('item_groups'):
 			args_list.extend([d.name for d in get_child_nodes('Item Group', d.item_group)])
-		cond = "and i.item_group in (%s)" % (', '.join(['%s'] * len(args_list)))
-		
-		args_list = [company] + args_list
+		if args_list:
+			cond = "and i.item_group in (%s)" % (', '.join(['%s'] * len(args_list)))
 
 	return frappe.db.sql("""
 		select
@@ -172,7 +171,7 @@
 		where
 			i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
 			{cond}
-		""".format(cond=cond), tuple(args_list), as_dict=1)
+		""".format(cond=cond), tuple([company] + args_list), as_dict=1)
 
 
 def get_item_groups(pos_profile):
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index c35242e..92fc610 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -400,10 +400,21 @@
 	from frappe.desk.form.load import get_communication_data
 
 	out = {}
+	fields = 'date(creation), count(name)'
+	after = add_years(None, -1).strftime('%Y-%m-%d')
+	group_by='group by date(creation)'
+
 	data = get_communication_data(doctype, name,
-		fields = 'date(creation), count(name)',
-		after = add_years(None, -1).strftime('%Y-%m-%d'),
-		group_by='group by date(creation)', as_dict=False)
+		fields=fields, after=after, group_by=group_by, as_dict=False)
+
+	# fetch and append data from Activity Log
+	data += frappe.db.sql("""select {fields}
+		from `tabActivity Log`
+		where reference_doctype='{doctype}' and reference_name='{name}'
+		and status!='Success' and creation > {after}
+		{group_by} order by creation desc
+		""".format(doctype=doctype, name=name, fields=fields,
+			group_by=group_by, after=after), as_dict=False)
 
 	timeline_items = dict(data)
 
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 710099e..72661ff 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -49,7 +49,7 @@
 
 		row += [
 			d.credit_to, d.mode_of_payment, d.project, d.company, d.purchase_order,
-			purchase_receipt, expense_account, d.stock_qty, d.stock_uom, d.base_net_rate, d.base_net_amount
+			purchase_receipt, expense_account, d.stock_qty, d.stock_uom, d.base_net_amount / d.stock_qty, d.base_net_amount
 		]
 
 		total_tax = 0
@@ -120,8 +120,7 @@
 			`tabPurchase Invoice Item`.`project`, `tabPurchase Invoice Item`.`purchase_order`,
 			`tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`,
 			`tabPurchase Invoice Item`.`expense_account`, `tabPurchase Invoice Item`.`stock_qty`,
-			`tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_rate`,
-			`tabPurchase Invoice Item`.`base_net_amount`,
+			`tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_amount`,
 			`tabPurchase Invoice`.supplier_name, `tabPurchase Invoice`.mode_of_payment {0}
 		from `tabPurchase Invoice`, `tabPurchase Invoice Item`
 		where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.`parent` and
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
index caa5fc5..27f24bf 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
@@ -2279,6 +2279,65 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_72",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "letter_head", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -2602,7 +2661,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2018-05-17 12:57:42.384971", 
+ "modified": "2018-05-28 02:45:48.616334", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Supplier Quotation", 
diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py
index cd2ddd9..7ead572 100644
--- a/erpnext/config/hr.py
+++ b/erpnext/config/hr.py
@@ -96,6 +96,10 @@
 				},
 				{
 					"type": "doctype",
+					"name": "Additional Salary",
+				},
+				{
+					"type": "doctype",
 					"name": "Employee Tax Exemption Declaration",
 				},
 				{
@@ -125,10 +129,6 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Additional Salary Component",
-				},
-				{
-					"type": "doctype",
 					"name": "Salary Structure",
 				},
 				{
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index e3f7d1e..76be942 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -102,7 +102,8 @@
 			self.validate_non_invoice_documents_schedule()
 
 	def before_print(self):
-		if self.doctype in ['Purchase Order', 'Sales Order']:
+		if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice',
+			'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']:
 			if self.get("group_same_items"):
 				self.group_similar_items()
 
@@ -684,6 +685,7 @@
 			if item.item_code in group_item_qty:
 				item.qty = group_item_qty[item.item_code]
 				item.amount = group_item_amount[item.item_code]
+				item.rate = flt(flt(item.amount)/flt(item.qty), item.precision("rate"))
 				del group_item_qty[item.item_code]
 			else:
 				duplicate_list.append(item)
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index d1a75a9..a595b4b 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -38,6 +38,7 @@
 		self.manipulate_grand_total_for_inclusive_tax()
 		self.calculate_totals()
 		self._cleanup()
+		self.calculate_total_net_weight()
 
 	def validate_conversion_rate(self):
 		# validate conversion rate
@@ -329,6 +330,13 @@
 
 		self.set_rounded_total()
 
+	def calculate_total_net_weight(self):
+		if self.doc.meta.get_field('total_net_weight'):
+			self.doc.total_net_weight = 0.0
+			for d in self.doc.items:
+				if d.total_weight:
+					self.doc.total_net_weight += d.total_weight
+
 	def set_rounded_total(self):
 		if self.doc.meta.get_field("rounded_total"):
 			if self.doc.is_rounded_total_disabled():
diff --git a/erpnext/docs/assets/img/accounts/make-inter-company-invoice.png b/erpnext/docs/assets/img/accounts/make-inter-company-invoice.png
new file mode 100644
index 0000000..af55847
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/make-inter-company-invoice.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/make-internal-customer.png b/erpnext/docs/assets/img/accounts/make-internal-customer.png
new file mode 100644
index 0000000..cf7e040
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/make-internal-customer.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/make-internal-supplier.png b/erpnext/docs/assets/img/accounts/make-internal-supplier.png
new file mode 100644
index 0000000..598eb65
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/make-internal-supplier.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/allowance-percentage-1.png b/erpnext/docs/assets/img/articles/allowance-percentage-1.png
deleted file mode 100644
index 4fbed90..0000000
--- a/erpnext/docs/assets/img/articles/allowance-percentage-1.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/allowance-percentage-2.png b/erpnext/docs/assets/img/articles/allowance-percentage-2.png
deleted file mode 100644
index a7b9688..0000000
--- a/erpnext/docs/assets/img/articles/allowance-percentage-2.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/limit-1.png b/erpnext/docs/assets/img/articles/limit-1.png
new file mode 100644
index 0000000..5e3cb27
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/limit-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/limit-2.png b/erpnext/docs/assets/img/articles/limit-2.png
new file mode 100644
index 0000000..ffa72b3
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/limit-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee-job-profile.png b/erpnext/docs/assets/img/human-resources/employee-job-profile.png
new file mode 100644
index 0000000..a0decd4
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/employee-job-profile.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee-view.gif b/erpnext/docs/assets/img/human-resources/employee-view.gif
new file mode 100644
index 0000000..52633d0
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/employee-view.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee.png b/erpnext/docs/assets/img/human-resources/employee.png
index ec2e70e..0120a76 100644
--- a/erpnext/docs/assets/img/human-resources/employee.png
+++ b/erpnext/docs/assets/img/human-resources/employee.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/supplier1.1.png b/erpnext/docs/assets/img/human-resources/supplier1.1.png
new file mode 100644
index 0000000..48aa485
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/supplier1.1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/manufacturing/manufacturing-settings.png b/erpnext/docs/assets/img/manufacturing/manufacturing-settings.png
new file mode 100644
index 0000000..dd37fee
--- /dev/null
+++ b/erpnext/docs/assets/img/manufacturing/manufacturing-settings.png
Binary files differ
diff --git a/erpnext/docs/assets/img/manufacturing/scrap-1.png b/erpnext/docs/assets/img/manufacturing/scrap-1.png
new file mode 100644
index 0000000..3be19e3
--- /dev/null
+++ b/erpnext/docs/assets/img/manufacturing/scrap-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/manufacturing/scrap-2.gif b/erpnext/docs/assets/img/manufacturing/scrap-2.gif
new file mode 100644
index 0000000..0b9d42e
--- /dev/null
+++ b/erpnext/docs/assets/img/manufacturing/scrap-2.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/profitability-analysis.png b/erpnext/docs/assets/img/project/profitability-analysis.png
new file mode 100644
index 0000000..2c43adf
--- /dev/null
+++ b/erpnext/docs/assets/img/project/profitability-analysis.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-1.1.png b/erpnext/docs/assets/img/project/project-1.1.png
new file mode 100644
index 0000000..ea23665
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-1.1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-1.png b/erpnext/docs/assets/img/project/project-1.png
new file mode 100644
index 0000000..f416cd6
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-2.png b/erpnext/docs/assets/img/project/project-2.png
new file mode 100644
index 0000000..cadb20d
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-budgeting.png b/erpnext/docs/assets/img/project/project-budgeting.png
new file mode 100644
index 0000000..989cff2
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-budgeting.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-expense-claim-1.png b/erpnext/docs/assets/img/project/project-expense-claim-1.png
new file mode 100644
index 0000000..3ed5955
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-expense-claim-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-expense-claim-2.png b/erpnext/docs/assets/img/project/project-expense-claim-2.png
new file mode 100644
index 0000000..380a9a6
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-expense-claim-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-percent-complete.png b/erpnext/docs/assets/img/project/project-percent-complete.png
deleted file mode 100644
index cebfde3..0000000
--- a/erpnext/docs/assets/img/project/project-percent-complete.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-portal-2.png b/erpnext/docs/assets/img/project/project-portal-2.png
new file mode 100644
index 0000000..f86d707
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-portal-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-portal-user.png b/erpnext/docs/assets/img/project/project-portal-user.png
new file mode 100644
index 0000000..c12f203
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-portal-user.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-portal.gif b/erpnext/docs/assets/img/project/project-portal.gif
new file mode 100644
index 0000000..a89fb0b
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-portal.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-profitability-1.png b/erpnext/docs/assets/img/project/project-profitability-1.png
new file mode 100644
index 0000000..1928ee2
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-profitability-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project-profitability-2.png b/erpnext/docs/assets/img/project/project-profitability-2.png
new file mode 100644
index 0000000..39ba059
--- /dev/null
+++ b/erpnext/docs/assets/img/project/project-profitability-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project.png b/erpnext/docs/assets/img/project/project.png
deleted file mode 100644
index c6bcd92..0000000
--- a/erpnext/docs/assets/img/project/project.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_cost_center.png b/erpnext/docs/assets/img/project/project_cost_center.png
deleted file mode 100644
index 09bd557..0000000
--- a/erpnext/docs/assets/img/project/project_cost_center.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_costing.png b/erpnext/docs/assets/img/project/project_costing.png
deleted file mode 100644
index c55976d..0000000
--- a/erpnext/docs/assets/img/project/project_costing.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_expense_claim_link.png b/erpnext/docs/assets/img/project/project_expense_claim_link.png
deleted file mode 100644
index 077cea1..0000000
--- a/erpnext/docs/assets/img/project/project_expense_claim_link.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_gantt_chart.png b/erpnext/docs/assets/img/project/project_gantt_chart.png
deleted file mode 100644
index 3eba443..0000000
--- a/erpnext/docs/assets/img/project/project_gantt_chart.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_sales_order.png b/erpnext/docs/assets/img/project/project_sales_order.png
deleted file mode 100644
index ff4030d..0000000
--- a/erpnext/docs/assets/img/project/project_sales_order.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_task.png b/erpnext/docs/assets/img/project/project_task.png
deleted file mode 100644
index 88f1e68..0000000
--- a/erpnext/docs/assets/img/project/project_task.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_task_grid.png b/erpnext/docs/assets/img/project/project_task_grid.png
deleted file mode 100644
index 935fba6..0000000
--- a/erpnext/docs/assets/img/project/project_task_grid.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_task_list.png b/erpnext/docs/assets/img/project/project_task_list.png
deleted file mode 100644
index 2a59caf..0000000
--- a/erpnext/docs/assets/img/project/project_task_list.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_time_log_link.png b/erpnext/docs/assets/img/project/project_time_log_link.png
deleted file mode 100644
index 08ac36c..0000000
--- a/erpnext/docs/assets/img/project/project_time_log_link.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_time_log_list.png b/erpnext/docs/assets/img/project/project_time_log_list.png
deleted file mode 100644
index 3b3724b..0000000
--- a/erpnext/docs/assets/img/project/project_time_log_list.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_total_expense_claim.png b/erpnext/docs/assets/img/project/project_total_expense_claim.png
deleted file mode 100644
index cbd3c01..0000000
--- a/erpnext/docs/assets/img/project/project_total_expense_claim.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_view_expense_claim.png b/erpnext/docs/assets/img/project/project_view_expense_claim.png
deleted file mode 100644
index 32056ca..0000000
--- a/erpnext/docs/assets/img/project/project_view_expense_claim.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_view_gantt_chart.png b/erpnext/docs/assets/img/project/project_view_gantt_chart.png
deleted file mode 100644
index 7039a45..0000000
--- a/erpnext/docs/assets/img/project/project_view_gantt_chart.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_view_task.png b/erpnext/docs/assets/img/project/project_view_task.png
deleted file mode 100644
index dfdff8b..0000000
--- a/erpnext/docs/assets/img/project/project_view_task.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/project/project_view_time_log.png b/erpnext/docs/assets/img/project/project_view_time_log.png
deleted file mode 100644
index dbf184e..0000000
--- a/erpnext/docs/assets/img/project/project_view_time_log.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/stock/customer-warehouse-2.png b/erpnext/docs/assets/img/stock/customer-warehouse-2.png
new file mode 100644
index 0000000..d44f88f
--- /dev/null
+++ b/erpnext/docs/assets/img/stock/customer-warehouse-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/stock/customer-warehouse.gif b/erpnext/docs/assets/img/stock/customer-warehouse.gif
new file mode 100644
index 0000000..c587b98
--- /dev/null
+++ b/erpnext/docs/assets/img/stock/customer-warehouse.gif
Binary files differ
diff --git a/erpnext/docs/user/manual/en/accounts/index.txt b/erpnext/docs/user/manual/en/accounts/index.txt
index 61e0db4..3b84be9 100644
--- a/erpnext/docs/user/manual/en/accounts/index.txt
+++ b/erpnext/docs/user/manual/en/accounts/index.txt
@@ -4,6 +4,7 @@
 point-of-sale-pos-invoice
 point-of-sales
 purchase-invoice
+inter-company-invoices
 payments
 journal-entry
 inter-company-journal-entry
diff --git a/erpnext/docs/user/manual/en/accounts/inter-company-invoices.md b/erpnext/docs/user/manual/en/accounts/inter-company-invoices.md
new file mode 100644
index 0000000..ed2ec42
--- /dev/null
+++ b/erpnext/docs/user/manual/en/accounts/inter-company-invoices.md
@@ -0,0 +1,32 @@
+
+# Inter Company Invoices
+
+Along with creating Purchase Invoices or Sales Invoices for a single company, you can create inter-linked invoices for multiple companies.
+
+Such as, you can create a Purchase Invoice for a company say 'Company ABC', and create a Sales Invoice against this Purchase Invoice for a company say 'Company XYZ' and link them together.
+
+#### To create Inter Company Invoices as mentioned in the above process, you need to follow the below steps:
+
+ - Go to the Customer list, select the customer which you would want to choose for the inter-linked invoices, enable the checkbox, **Is Internal Customer** as shown below:
+
+ <img class="screenshot" alt="Internal Customer" src="{{docs_base_url}}/assets/img/accounts/make-internal-customer.png">
+
+ - Along with that, add the company which the Customer represents, i.e. the company for which the Sales Invoice will be created.
+ - Next, fill up the child table **Allowed To Transact With** as shown in the image and add the company against which you will be creating a Purchase Invoice, which will be linked with the Sales Invoice created  using this Customer.
+ - *Easy peasy, right?* Now, you need to follow the similar procedure for setting up a Supplier for inter-linked invoices. And, in the **Represents Company** field, add the company which you added in the child table **Allowed To Transact With** for the Customer.
+ - And, in the child table **Allowed To Transact With** for the Supplier, add the company which the Customer represents or against which you are going to make an inter-linked Purchase Invoice. You can refer the below image to avoid any confusion.
+
+ <img class="screenshot" alt="Internal Supplier" src="{{docs_base_url}}/assets/img/accounts/make-internal-supplier.png">
+
+- Now, create a new Sales Invoice, fill up the fields, and remember to select the Customer who is an internal customer and company which the Customer represents.
+- Submit the Invoice.
+
+ <img class="screenshot" alt="Inter company invoice" src="{{docs_base_url}}/assets/img/accounts/make-inter-company-invoice.png">
+
+- Under the **Make** button dropdown, you will find a link **Inter Company Invoice**, on clicking the link, you will be routed to a new Purchase Invoice form page.
+- Here, the supplier and company will be auto-fetched depending on the company you selected in the Sales Invoice. ***Remember**: There can only be a single Internal Supplier or Customer per company.*
+- Submit the invoice, done! Now, both the invoices are inter-linked. *Also, on cancelling any of the invoices, the link will break as well.*
+
+You can follow the same process to create a Purchase Invoice and then an inter-linked Sales Invoice from the submitted Purchase Invoice.
+
+{next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/accounts/pricing-rule.md b/erpnext/docs/user/manual/en/accounts/pricing-rule.md
index c4a3eb9..02c6c8b 100644
--- a/erpnext/docs/user/manual/en/accounts/pricing-rule.md
+++ b/erpnext/docs/user/manual/en/accounts/pricing-rule.md
@@ -11,7 +11,7 @@
 
 3. Items categorized under specific Item Group has same selling or buying price.
 
-4. Customers balonging to specific Customer Group should get ### selling price, ot % of Discount on Items.
+4. Customers balonging to specific Customer Group should get ### selling price, or % of Discount on Items.
 
 5. Supplier's categorized under specific Supplier Type should have ### buying rate applied.
 
@@ -106,4 +106,4 @@
 
 For more details about pricing rule [Click Here](/docs/user/manual/en/selling/articles/adding-margin.html)
 
-<!-- markdown -->
\ No newline at end of file
+<!-- markdown -->
diff --git a/erpnext/docs/user/manual/en/buying/supplier.md b/erpnext/docs/user/manual/en/buying/supplier.md
index f116c88..2f8a154 100644
--- a/erpnext/docs/user/manual/en/buying/supplier.md
+++ b/erpnext/docs/user/manual/en/buying/supplier.md
@@ -6,18 +6,11 @@
 
 `Explore > Supplier > New Supplier`
 
-<img class="screenshot" alt="Supplier Master" src="{{docs_base_url}}/assets/img/buying/supplier-master.png">
-
-<div>
-    <div class='embed-container'>
-        <iframe src='https://www.youtube.com/embed//zsrrVDk6VBs?start=213' frameborder='0' allowfullscreen>
-        </iframe>
-    </div>
-</div>
+<img class="screenshot" alt="Supplier Master" src="{{docs_base_url}}/assets/img/buying/supplier1.1.png">
 
 ### Contacts and Addresses
 
-Contacts and Addresses in ERPNext are stored separately so that you can create multiple Contacts and Addresses for a Suppliers. Once Supplier is saved, you will find option to create Contact and Address for that Supplier.
+Contacts and Addresses in ERPNext are stored separately so that you can create multiple Contacts and Addresses for a Suppliers. Once Supplier is saved, you will find the option to create Contact and Address for that Supplier.
 
 <img class="screenshot" alt="Supplier Master" src="{{docs_base_url}}/assets/img/buying/supplier-new-address-contact.png">
 
@@ -37,8 +30,12 @@
 
 You can add multiple companies in your ERPNext instance, and one Supplier can be used across multiple companies. In this case, you should define Companywise Payable Account for the Supplier in the "Default Payable Accounts" table.
 
-<iframe width="660" height="371" src="https://www.youtube.com/embed/anoGi_RpQ20" frameborder="0" allowfullscreen></iframe>
-(Check from 2:20)
+<div>
+    <div class='embed-container'>
+        <iframe src='https://www.youtube.com/embed//zsrrVDk6VBs?start=213' frameborder='0' allowfullscreen>
+        </iframe>
+    </div>
+</div>
 
 ### Place Supplier On Hold
 In the Supplier form, check the "Block Supplier" checkbox. Next, choose the "Hold Type".
diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field
new file mode 100644
index 0000000..8caf8f5
--- /dev/null
+++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field
@@ -0,0 +1,17 @@
+## Example to fetch value in a child table field from master doctype
+
+
+### Sample Script to fetch expiry_date field from Batch doctype to Sales Invoice Item table
+
+Step 1: Create Custom Script for _**Sales Invoice**_ (parent) doctype
+
+Step 2: Script as below & Save
+
+```
+frappe.ui.form.on("Sales Invoice Item", "batch_no", function(frm, cdt, cdn) {
+	var d = locals[cdt][cdn];
+    	frappe.db.get_value("Batch", {"name": d.batch_no}, "expiry_date", function(value) {
+    		d.expiry_date = value.expiry_date;
+    	});
+});
+```
diff --git a/erpnext/docs/user/manual/en/human-resources/employee.md b/erpnext/docs/user/manual/en/human-resources/employee.md
index 092d11d..c6aed24 100644
--- a/erpnext/docs/user/manual/en/human-resources/employee.md
+++ b/erpnext/docs/user/manual/en/human-resources/employee.md
@@ -1,6 +1,20 @@
 # Employee
 
-There are many fields you can add in your Employee records.
+An individual who works part-time or full-time under a contract of employment, and has recognized rights and duties is your Employee.
+
+In ERPNext, you can manage Employee master. The Employee master captures demographics, personal and professional details. 
+
+<img class="screenshot" alt="Employee" src="{{docs_base_url}}/assets/img/human-resources/employee-view.gif">
+
+You can further use this Employee master for performing various HR functions like:
+
+1. Processing Payroll
+1. Leave Allocation and Application
+1. Employee Advance and Expense Claim
+1. Loan Application
+1. Performance Appraisal
+
+### New Employee
 
 To create new Employee go to:
 
@@ -8,6 +22,14 @@
 
 <img class="screenshot" alt="Employee" src="{{docs_base_url}}/assets/img/human-resources/employee.png">
 
+### Employee Deputation
+
+Once an Employee is created, you can update Department, Designation, Employee to whom he/she will report to etc.
+
+<img class="screenshot" alt="Employee" src="{{docs_base_url}}/assets/img/human-resources/employee-job-profile.png">
+
+<hr>
+
 <div class="embed-container">    
     <iframe src="https://www.youtube.com/embed/kkwOzeU4wFU?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
 </div>
diff --git a/erpnext/docs/user/manual/en/manufacturing/articles/scrap-management.md b/erpnext/docs/user/manual/en/manufacturing/articles/scrap-management.md
new file mode 100644
index 0000000..25c1eea
--- /dev/null
+++ b/erpnext/docs/user/manual/en/manufacturing/articles/scrap-management.md
@@ -0,0 +1,23 @@
+# Production Scrap Management
+
+Scrap means waste that either has no economic value or only the value of its basic material content recoverable through recycling.
+
+Scrap is generally availed at the end of the manufacture process. Also you can find some products that are damaged or that are unusable due to expiry or for some other reason, which needs to be scraped.
+
+In ERPNext, at the end of manufacturing process, scrap items are accounted in the scrap warehouse.s
+
+### Scrap in Bill of Materials
+
+You can update estimated scrap quantity of an item in the BOM, Scrap table. If required, you can reselect a raw-material item as scrap.
+
+<img class="screenshot" alt="Scrap in BOM" src="{{docs_base_url}}/assets/img/manufacturing/scrap-1.png">
+
+### Scrap in Manufacture Entry
+
+When production is completed, Finish / Manufacture Entry is created against a Production Order. In this entry, scrap item is fetched in the Item table, with only Target Warehouse updated for it. Ensure that Valuation Rate is updated for this item for the accounts posting purposes.
+
+<img class="screenshot" alt="Scrap in Manufacture Entry" src="{{docs_base_url}}/assets/img/manufacturing/scrap-2.gif">
+
+> Scrap from the BOM will only work if Manufacture Entry is created based on BOM, and not based on Material Transfer. This is configurable from Manufacturing Settings.
+
+<img class="screenshot" alt="Manufacturing Settings" src="{{docs_base_url}}/assets/img/manufacturing/manufacturing-settings.png">
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/index.txt b/erpnext/docs/user/manual/en/projects/index.txt
index 2f450ac..11f5901 100644
--- a/erpnext/docs/user/manual/en/projects/index.txt
+++ b/erpnext/docs/user/manual/en/projects/index.txt
@@ -1,7 +1,9 @@
 tasks
 project
-time-log-batch
+timesheet
+project-customer-portal
+project-profitability
+project-expense-claims
 activity-type
 activity-cost
 articles
-timesheet
diff --git a/erpnext/docs/user/manual/en/projects/project-customer-portal.md b/erpnext/docs/user/manual/en/projects/project-customer-portal.md
new file mode 100644
index 0000000..24ea099
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/project-customer-portal.md
@@ -0,0 +1,21 @@
+# Project from Customer Portal
+
+If you are doing a Project for a Customer, then Customer will need to be updated on its progress on timely bases. In ERPNext, since it is a Customer Portal feature, you can let Customer update oneself on the Project's progress via Customer Portal.
+
+### Add User as a Website User
+
+For a Customer to be able to access Project from the portal, should be added as a Website User. A Customer can also sign up from the Login Page of your ERPNext account, using the same Email ID as mentioned in the Contact master. Or you can invite that User from the Contact master.
+
+<img class="screenshot" alt="Customer in Project" src="{{docs_base_url}}/assets/img/project/project-portal-2.png">
+
+### Add Customer and User in Project
+
+In the Project master, check Customer Details section. Select a Customer and Sales Order associated with this Project.
+
+<img class="screenshot" alt="Customer in Project" src="{{docs_base_url}}/assets/img/project/project-portal-user.png">
+
+### Portal View of Project
+
+When a Customer logins from the Portal, he/she will be able to view all the Task for that Project. Also, the customer will be able to update the status of the Tasks or comment when needed.
+
+<img class="screenshot" alt="Customer in Project" src="{{docs_base_url}}/assets/img/project/project-portal.gif">
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/project-expense-claims.md b/erpnext/docs/user/manual/en/projects/project-expense-claims.md
new file mode 100644
index 0000000..76e0389
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/project-expense-claims.md
@@ -0,0 +1,15 @@
+# Project and Managing Expenses
+
+The Employees working on the Project incur various expenses, sometimes from their own pocket. In ERPNext, then can claim such expenses using [Expense Claim](/docs/user/manual/en/human-resources/expense-claim.html)
+
+In this Expense Claim, they can also select a Project for which that expense was incurred.
+
+Based on the Expense Claims made for a particular project, total Expense Claim Amount is updated in the Project master, under project costing section.
+
+* You can create an Expense Claims directly and link it to the Project.
+
+<img class="screenshot" alt="Project - Link Expense Claim" src="{{docs_base_url}}/assets/img/project/project-expense-claim-1.png">
+
+* Total amount of Expense Claims booked against a project is shown under 'Total Expense Claim' in the Project Costing Section
+
+<img class="screenshot" alt="Project - Total Expense Claim" src="{{docs_base_url}}/assets/img/project/project-expense-claim-2.png">
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/project-profitability.md b/erpnext/docs/user/manual/en/projects/project-profitability.md
new file mode 100644
index 0000000..cea7050
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/project-profitability.md
@@ -0,0 +1,36 @@
+# Project Profitability
+
+Project and related activities are generally active for longer time periods. While developments happen on the Project, there are various income and expense incurred against it. Hence, it becomes important to track the Profitability of a Project and ensure that you don't overspend.
+
+### Project in Sales Transactions
+
+You can link a Project in all the sales transactions like Sales Order, Delivery Note, Sales Invoice, and Payment. Linking Project with the sales transactions will help you in tracking income received against that Project.
+
+In sales transactions, Project field is generally available in the More Information section.
+
+<img class="screenshot" alt="Project in Sales" src="{{docs_base_url}}/assets/img/project/project-profitability-1.png">
+
+
+#### Project in Purchase Transactions
+
+The project can also be linked to the purchase transactions like Purchase Order, Purchase Receipt, and Purchase Invoice.
+
+In the purchase transactions, Project's link field is available in the Item table. This is because you could be procuring material for multiple Projects from the same purchase entry.
+
+<img class="screenshot" alt="Project in Purchases" src="{{docs_base_url}}/assets/img/project/project-profitability-2.png">
+
+### Budgeting against Project
+
+You can create Budget for a Project as well. The expense limit defined in the Budget master will be validated in the expense transactions.
+
+<img class="screenshot" alt="Project Budgeting" src="{{docs_base_url}}/assets/img/project/project-budgeting.png">
+
+### Project Profitability
+
+Based on the all the income and expense entries created for the Project, you can get its profitability.
+
+> Accounts > Profitability Analysis
+
+Filter report based on Project to check Projectwise Profitability.
+
+<img class="screenshot" alt="Project Profitability" src="{{docs_base_url}}/assets/img/project/profitability-analysis.png">
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/project.md b/erpnext/docs/user/manual/en/projects/project.md
index 82f0e6d..a8091b8 100644
--- a/erpnext/docs/user/manual/en/projects/project.md
+++ b/erpnext/docs/user/manual/en/projects/project.md
@@ -1,13 +1,20 @@
 # Project
 
-Project management in ERPNext is Task driven. You can create Project and assign multiple Tasks against it.
+The project is an individual or collaborative enterprise, possibly involving research or design, that is carefully planned, usually by a project team, to achieve a particular aim
 
-<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/project.png">
+In ERPNext, Project management in is Task driven. You can a create Project and divide into multiple and assignable Tasks.
 
-<div class="embed-container">
-  <iframe src="https://www.youtube.com/embed/gCzShu9Niu4?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>
-  </iframe>
-</div>
+<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/project-1.1.png">
+
+### Managing Tasks
+
+The project is generally has a broader scope, and hence not assignable to an individual. Hence, you can divide the Project into multiple Tasks. These can be assigned to an individual and tracked better. 
+
+These Tasks can be created from a Project itself or a [Task](/docs/user/manual/en/projects/tasks.html) can be created separately as well.
+
+<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/project-1.png">
+
+### Task Completion
 
 You can also track % Completion of a Project using different methods.
 
@@ -15,100 +22,39 @@
   2. Task Progress
   3. Task Weight
 
-<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/project-percent-complete.png">
+<img class="screenshot" alt="Project 2" src="{{docs_base_url}}/assets/img/project/project-2.png">
 
 Some examples of how the % Completion is calculated based on Tasks.
 
-<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/percent-complete-calc.png">
+<img class="screenshot" alt="Project 3" src="{{docs_base_url}}/assets/img/project/percent-complete-calc.png">
 
-<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/percent-complete-formula.png">
+<img class="screenshot" alt="Project 4" src="{{docs_base_url}}/assets/img/project/percent-complete-formula.png">
 
-### Managing tasks
-Project can be divided into multiple Tasks.
-Task can be created via Project document itself or can be created via  [Task](/docs/user/manual/en/projects/tasks.html)
-
-<img class="screenshot" alt="Project" src="{{docs_base_url}}/assets/img/project/project_task.png">
-
-* To view Task made against a Project click on 'Tasks'
-
-<img class="screenshot" alt="Project - View Task" src="{{docs_base_url}}/assets/img/project/project_view_task.png">
-
-<img class="screenshot" alt="Project - Task List" src="{{docs_base_url}}/assets/img/project/project_task_list.png">
-
-* You can also view the Tasks from the Project document itself
-
-<img class="screenshot" alt="Project - Task Grid" src="{{docs_base_url}}/assets/img/project/project_task_grid.png">
-
-* To add Weights to Tasks you can follow the below steps
-
-<img class="screenshot" alt="Project - Task Grid" src="{{docs_base_url}}/assets/img/project/tasks.png">
-<img class="screenshot" alt="Project - Task Grid" src="{{docs_base_url}}/assets/img/project/task-weights.png">
-
-
-### Managing time
-
-ERPNext uses [Time Log](/docs/user/manual/en/projects/time-log.html) to track the progress of a Project.
-You can create Time Logs against each task.
-The Actual Start and End Time along with the costing shall then be updated based on the Time Log.
-
-* To view Time Log made against a Project click on 'Time Logs'
-
-<img class="screenshot" alt="Project - View Time Log" src="{{docs_base_url}}/assets/img/project/project_view_time_log.png">
-
-<img class="screenshot" alt="Project - Time Log List" src="{{docs_base_url}}/assets/img/project/project_time_log_list.png">
-
-* You can also create a Time Log directlly and link it to the Project.
-
-<img class="screenshot" alt="Project - Link Time Log" src="{{docs_base_url}}/assets/img/project/project_time_log_link.png">
-
-### Managing expenses
-
-You can book [Expense Claim](/docs/user/manual/en/human-resources/expense-claim.html) against a project task.
-The system shall update the total amount from expense claims in the project costing section.
-
-* To view Expense Claims made against a Project click on 'Expense Claims'
-
-<img class="screenshot" alt="Project - View Expense Claim" src="{{docs_base_url}}/assets/img/project/project_view_expense_claim.png">
-
-* You can also create a Expense Claims directlly and link it to the Project.
-
-<img class="screenshot" alt="Project - Link Expense Claim" src="{{docs_base_url}}/assets/img/project/project_expense_claim_link.png">
-
-* Total amount of Expense Claims booked against a project is shown under 'Total Expense Claim' in the Project Costing Section
-
-<img class="screenshot" alt="Project - Total Expense Claim" src="{{docs_base_url}}/assets/img/project/project_total_expense_claim.png">
-
-### Cost Center
-
-You can make a [Cost Center](/docs/user/manual/en/accounts/setup/cost-center.html) against a Project or use an existing cost center to track all expenses made against that project.
-
-<img class="screenshot" alt="Project - Cost Center" src="{{docs_base_url}}/assets/img/project/project_cost_center.png">
-
-###Project Costing
+### Project Costing
 
 The Project Costing section helps you track the time, expenses and purchases incurred against the project.
 
 <img class="screenshot" alt="Project - Costing" src="{{docs_base_url}}/assets/img/project/project_costing.png">
 
-* The Total Cost is composed of the costing amount from timesheets, the total cost from expense claims and the total cost from purchase invoices created against this project.
+* The Total Cost is composed of the costing amount from timesheets, the total cost of expense claims and the total cost of purchase invoices created against this project.
 
 * The Gross Margin is the difference between Total Billed Amount and the Total Cost Amount for this project.
 
-###Billing
+### Gantt Chart
 
-You can make/link a [Sales Order](/docs/user/manual/en/selling/sales-order.html) against a project. Once linked you can use the standard sales module to bill your customer against the Project.
+ERPNext gives you an illustrated view of tasks scheduled for that project in Gantt Chart View.
 
-<img class="screenshot" alt="Project - Sales Order" src="{{docs_base_url}}/assets/img/project/project_sales_order.png">
+* To view Gantt chart against a project, go to the Task list and Apply filter on the Project.
 
-###Gantt Chart
+<img class="screenshot" alt="Project Gantt" src="{{docs_base_url}}/assets/img/project/project-1.1.png">
 
-A Gantt Chart illustrates a project schedule.
-ERPNext gives you a illustrated view of tasks scheduled against that project in Gantt Chart View.
+### Project Help Video
 
-* To view gantt chart against a project, go to that project and click on 'Gantt Chart'
+This is a tutorial video on how to manage Project and associate Tasks in ERPNext.
 
-<img class="screenshot" alt="Project - View Gantt Chart" src="{{docs_base_url}}/assets/img/project/project_view_gantt_chart.png">
+<div class="embed-container">
+  <iframe src="https://www.youtube.com/embed/gCzShu9Niu4?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>
+  </iframe>
+</div>
 
-<img class="screenshot" alt="Project - Gantt Chart" src="{{docs_base_url}}/assets/img/project/project_gantt_chart.png">
-
-{next}
+{next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/time-log-batch.md b/erpnext/docs/user/manual/en/projects/time-log-batch.md
deleted file mode 100644
index 6904f4e..0000000
--- a/erpnext/docs/user/manual/en/projects/time-log-batch.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Time Log Batch
-
-You can bill Time Logs by batching them together. This gives you the flexiblity to manage your customer billing in the way you want. To create a new Time Sheet, go to 
-
-> Projects > Time Sheet > New Time Sheet
-
-OR
-
-Just open your Time Log list and check the Items to you want to add to the Time Log. Then click on "Make Time Sheet" button and these Time Logs will be selected.
-
-<img class="screenshot" alt="Time Log - Drag Calender" src="{{docs_base_url}}/assets/img/project/time_sheet.gif">
-
-###Making Sales Invoice
-
-* After submitting the Time Sheet, "Make Invoice" button shall appear.
-
-<img class="screenshot" alt="Time Log - Drag Calender" src="{{docs_base_url}}/assets/img/project/time_sheet_make_invoice.png">
-
-* Click on that button to raise a Sales Invoice against the Time Sheet.
-
-<img class="screenshot" alt="Time Log - Drag Calender" src="{{docs_base_url}}/assets/img/project/time_sheet_sales_invoice.png">
-
-* When you "Submit" the Sales Invoice, the Sales Invoice number will get updated in the Time Logs and Time Sheet and their status will change to "Billed".
-
-{next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/stock/articles/allow-over-delivery-billing-against-sales-order-upto-certain-limit.md b/erpnext/docs/user/manual/en/stock/articles/allow-over-delivery-billing-against-sales-order-upto-certain-limit.md
index 9b140a6..f5a589d 100644
--- a/erpnext/docs/user/manual/en/stock/articles/allow-over-delivery-billing-against-sales-order-upto-certain-limit.md
+++ b/erpnext/docs/user/manual/en/stock/articles/allow-over-delivery-billing-against-sales-order-upto-certain-limit.md
@@ -1,22 +1,24 @@
 #Allow Over Delivery/Billing
 
-While creating Delivery Note, system validates if item's Qty mentined is same as in the Sales Order. If Item Qty has been increased, you will get over-delivery validation. If you want to be able to deliver more items than mentioned in the Sales Order, you should update "Allow over delivery or receipt upto this percent" in the Item master.
+When creating a Delivery Note, system validates if item's qty is same as in the Sales Order. If item's qty has been increased, you will get the validation message of over-delivery or receipt. 
 
-<img alt="Item wise Allowance percentage" class="screenshot" src="{{docs_base_url}}/assets/img/articles/allowance-percentage-1.png">
+Considering the case fo sales, if you want to be able to deliver more items than mentioned in the Sales Order, you should update "Allow over delivery or receipt upto this percent" in the Item master.
 
-Item's and Rate is also validated when creating Sales Invoice from Sales Order. Also when creating Purchase Receipt and Purchaes Invoice from Purchase Order. Updating "Allow over delivery or receipt upto this percent" will be affective in all sales and purchase transactions.
+<img alt="Itemised Limit Percentage" class="screenshot" src="{{docs_base_url}}/assets/img/articles/limit-1.png">
 
-For example, if you have ordered 100 units of an item, and if item's over receipt percent is 50%, then you are allowed to make Purchase Receipt for upto 150 units.
+When creating an invoice, item's rate is also validated based on the preceding transaction like Sales Order. This also applies when creating Purchase Receipt or Purchaes Invoice from Purchase Order. Updating "Allow over delivery or receipt upto this percent" will be affective in all sales and purchase transactions.
+
+For example, if you have ordered 100 units of an item, and if item's over receipt percent is 50, then you are allowed to make Purchase Receipt for upto 150 units.
 
 Update global value for "Allow over delivery or receipt upto this percent" from Stock Settings. Value updated here will be applicable for all the items.
 
 1. Go to `Stock > Setup > Stock Settings`
 
-2. Set `Allowance Percentage`.
+2. Set `Limit Percentage`.
 
 3. Save Stock Settings.
 
-<img alt="Item wise Allowance percentage" class="screenshot" src="{{docs_base_url}}/assets/img/articles/allowance-percentage-2.png">
+<img alt="Item wise Allowance percentage" class="screenshot" src="{{docs_base_url}}/assets/img/articles/limit-2.png">
 
 
 <!-- markdown -->
diff --git a/erpnext/docs/user/manual/en/stock/articles/material-transfer-from-delivery-note.md b/erpnext/docs/user/manual/en/stock/articles/material-transfer-from-delivery-note.md
new file mode 100644
index 0000000..02bdadf
--- /dev/null
+++ b/erpnext/docs/user/manual/en/stock/articles/material-transfer-from-delivery-note.md
@@ -0,0 +1,29 @@
+# Material Transfer from Delivery Note
+
+In ERPNext, you can create Material Transfer entry from [Stock Entry](/docs/user/manual/en/stock/stock-entry.html) document. However, there are some scenarios in the Material Transfer where it needs to be presented as a Delivery Note. 
+
+### Scenarios
+
+1. One of the examples is when you transfer a Material from your stores to project site, however, you need to present it as a Delivery Note to the client.
+
+2. Also, there are statutory requirements where taxes are to be applied on each transfer of Material. It is easier to manage in a transaction like Delivery Note, than in the Stock Entry.
+
+Considering these scenarios, the provision of Material Transfer has been added in the Delivery Note as well. Following are the steps to use Delivery Note for creating Material Transfer entry.
+
+### Steps
+
+#### Enable Customer Warehouse
+
+Delivery Note Item doctype as a hidden field of Customer Warehouse. You can enable it from [Customize Form](/docs/user/manual/en/customize-erpnext/customize-form.html). Here is the quick demonstration of the same.
+
+<img class="screenshot" alt="Delivery Note Material Transfer" src="{{docs_base_url}}/assets/img/stock/customer-warehouse.gif">
+
+### Select Warehouses
+
+When creating a Delivery Note for Material Transfer, for an item select source Warehouse as From Warehouse.
+
+In the Customer Warehouse, select a Warehouse where Material is to be transferred or select a target warehouse.
+
+<img class="screenshot" alt="Delivery Note Material Transfer" src="{{docs_base_url}}/assets/img/stock/customer-warehouse-2.png">
+
+On the submission of a Delivery Note, item's stock will be deducted from "From Warehouse" and added to the "Customer Warehouse".
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/advance-payments.md b/erpnext/docs/user/videos/learn/advance-payments.md
index f08053f..5abcd83 100644
--- a/erpnext/docs/user/videos/learn/advance-payments.md
+++ b/erpnext/docs/user/videos/learn/advance-payments.md
@@ -1,7 +1,7 @@
 # Advance Payment
 
-<iframe width="660" height="371" src="https://www.youtube.com/embed/J46-6qtyZ9U" frameborder="0" allowfullscreen></iframe>
+<iframe width="660" height="371" src="https://www.youtube.com/embed/3wiIXId6dzg" frameborder="0" allowfullscreen></iframe>
 
-**Duration: 2:52**
+**Duration: 3:11**
 
 In sales and purchase transaction, generally advance payments are involved. This tutorial covers how you can create advance payment entries against Sales Order and Purchase Order, and adjust the same in the final invoice.
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/discounts.md b/erpnext/docs/user/videos/learn/discounts.md
new file mode 100644
index 0000000..e4668bb
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/discounts.md
@@ -0,0 +1,7 @@
+# Applying Discounts
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/0850LAIPUBU" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 2:23**
+
+This is a video tutorial on how to apply discounts in the sales and purchase transactions.
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/email-account.md b/erpnext/docs/user/videos/learn/email-account.md
index 0ac4e98..b2b40d6 100644
--- a/erpnext/docs/user/videos/learn/email-account.md
+++ b/erpnext/docs/user/videos/learn/email-account.md
@@ -1,7 +1,7 @@
 # Email Account
 
-<iframe width="660" height="371" src="https://www.youtube.com/embed/YFYe0DrB95o" frameborder="0" allowfullscreen></iframe>
+<iframe width="660" height="371" src="https://www.youtube.com/embed/ChsFbIuG06g" frameborder="0" allowfullscreen></iframe>
 
-**Duration: 2:27**
+**Duration: 4:00**
 
 This video walks you through setting up Email Account for incoming and outgoing emails. For hosted users, outgoing email gateway is set by default. Based on incoming email, you can have new document (like Issue, Lead etc.) auto-created, and have email received on these id's appended to specified document.
diff --git a/erpnext/docs/user/videos/learn/email-inbox.md b/erpnext/docs/user/videos/learn/email-inbox.md
new file mode 100644
index 0000000..dd69bb8
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/email-inbox.md
@@ -0,0 +1,7 @@
+# Email Inbox
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/KkKwtRwGvKw" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 2:51**
+
+This is video tutorial on how a user can configure an Email Inbox for his/her ID. Email Inbox is integrated well with other functionalities like Support Issues, Opportuniies and Communication.
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/employee-advance.md b/erpnext/docs/user/videos/learn/employee-advance.md
new file mode 100644
index 0000000..48b9f08
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/employee-advance.md
@@ -0,0 +1,7 @@
+# Employee Advance
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/ja-zY0-7NsQ" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 3:46**
+
+In this video, we will learn how an advance amount is given to an Employee, and how to adjust the same against an Expense Claim.
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/index.md b/erpnext/docs/user/videos/learn/index.md
index f10061c..fde6b48 100644
--- a/erpnext/docs/user/videos/learn/index.md
+++ b/erpnext/docs/user/videos/learn/index.md
@@ -79,9 +79,17 @@
             Opening Account Balances</a>
             <span class="text-muted pull-right">4:40</span>
         </li>
+        <li><a href="/docs/user/videos/learn/opening-invoice-creation-tool.html">
+            Opening Invoices Creation Tool</a>
+            <span class="text-muted pull-right">2:30</span>
+        </li>
         <li><a href="/docs/user/videos/learn/email-account.html">
             Email Account</a>
-            <span class="text-muted pull-right">2:27</span>
+            <span class="text-muted pull-right">4:00</span>
+        </li>
+        <li><a href="/docs/user/videos/learn/email-inbox.html">
+            Email Inbox</a>
+            <span class="text-muted pull-right">2:51</span>
         </li>
         <li><a href="/docs/user/videos/learn/file-manager.html">
             File Manager</a>
@@ -119,6 +127,14 @@
 			Drop Ship</a>
             <span class="text-muted pull-right">2:26</span>
         </li>
+        <li><a href="/docs/user/videos/learn/pricing-rule.html">
+			Pricing Rule</a>
+            <span class="text-muted pull-right">3:56</span>
+        </li>
+        <li><a href="/docs/user/videos/learn/discounts.html">
+			Discounts</a>
+            <span class="text-muted pull-right">2:23</span>
+        </li>
     </ul>
     <br>
     <h3>Buying</h3>
@@ -143,6 +159,14 @@
             Taxes</a>
             <span class="text-muted pull-right">5:13</span>
         </li>
+        <li><a href="/docs/user/videos/learn/pricing-rule.html">
+			Pricing Rule</a>
+            <span class="text-muted pull-right">3:56</span>
+        </li>
+        <li><a href="/docs/user/videos/learn/discounts.html">
+			Discounts</a>
+            <span class="text-muted pull-right">2:23</span>
+        </li>
     </ul>
     <br>
     <h3>Stock</h3>
@@ -201,12 +225,16 @@
         </li>
         <li><a href="/docs/user/videos/learn/advance-payments.html">
             Advance Payments</a>
-              <span class="text-muted pull-right">2:52</span>
+              <span class="text-muted pull-right">3:11</span>
         </li>
         <li><a href="/docs/user/videos/learn/budgeting.html">
               Budgeting</a>
             <span class="text-muted pull-right">3:26</span>
         </li>
+        <li><a href="/docs/user/videos/learn/subscription.html">
+              Subscription Management</a>
+            <span class="text-muted pull-right">2:09</span>
+        </li>
     </ul>
     <br>
     <h3>Manufacturing</h3>
@@ -245,6 +273,10 @@
             Expense Claims</a>
             <span class="text-muted pull-right">2:52</span>
         </li>
+        <li><a href="/docs/user/videos/learn/employee-advance.html">
+            Employee Advance</a>
+            <span class="text-muted pull-right">3:46</span>
+        </li>
     </ul>
     <br>
     <h3>Retail</h3>
diff --git a/erpnext/docs/user/videos/learn/index.txt b/erpnext/docs/user/videos/learn/index.txt
index 956703b..116ac6c 100644
--- a/erpnext/docs/user/videos/learn/index.txt
+++ b/erpnext/docs/user/videos/learn/index.txt
@@ -42,4 +42,10 @@
 services
 distributors
 manufacturing-make-to-order
-manufacturing-enigneer-to-order
\ No newline at end of file
+manufacturing-enigneer-to-order
+opening-invoice-creation-tool
+pricing-rule
+discounts
+email-inbox
+subscription
+employee-advance
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/opening-invoice-creation-tool.md b/erpnext/docs/user/videos/learn/opening-invoice-creation-tool.md
new file mode 100644
index 0000000..0670fa1
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/opening-invoice-creation-tool.md
@@ -0,0 +1,7 @@
+# Opening Invoices Creation Tool
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/vfWmugaO1zw" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 2:30**
+
+An important on-boarding step for an E R P software includes updating opening sales and purchase invoices. In E R P Next, it is made simple with Opening Invoices Creation Tool. You can use this tool for quickly creatio opening Sales and Purchase Invoices.
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/learn/payment-terms.md b/erpnext/docs/user/videos/learn/payment-terms.md
index 1832b7f..a3821a8 100644
--- a/erpnext/docs/user/videos/learn/payment-terms.md
+++ b/erpnext/docs/user/videos/learn/payment-terms.md
@@ -5,10 +5,8 @@
     </iframe>
 </div>    
 
-**Duration: 2:55**
+**Duration: 2:56**
 
 This tutorial shows you how to set payment terms in ERPNext. Payment Terms help in defining the multiple payment slabs during sales or purchase transactions.
 
 In Payment Terms you can define the breakup of the payment to be received (or made) in terms of different payment modes and the period after the due date. You can also create templates to quickly load the payment terms in a transaction.
-
-
diff --git a/erpnext/docs/user/videos/learn/pricing-rule.md b/erpnext/docs/user/videos/learn/pricing-rule.md
new file mode 100644
index 0000000..fcc808a
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/pricing-rule.md
@@ -0,0 +1,8 @@
+# Pricing Rule
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/y-9BIWZ5x8Q" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 3:56**
+
+If you apply discounts on the item based on certain conditions, you can use Pricing Rule to define these conditions. In the Pricing Rule, you define criterias based on these parameters for the auto application
+of discount or margin.
diff --git a/erpnext/docs/user/videos/learn/product-bundle.md b/erpnext/docs/user/videos/learn/product-bundle.md
index c17456a..c63fe89 100644
--- a/erpnext/docs/user/videos/learn/product-bundle.md
+++ b/erpnext/docs/user/videos/learn/product-bundle.md
@@ -1,6 +1,6 @@
 # Product Bundle
 
-<iframe width="660" height="371" src="https://www.youtube.com/embed/yk3kPrRyRRc" frameborder="0" allowfullscreen></iframe>
+<iframe width="660" height="371" src="https://www.youtube.com/embed/dxv78E3UF0U" frameborder="0" allowfullscreen></iframe>
 
 **Duration: 2:31**
 
diff --git a/erpnext/docs/user/videos/learn/serialized-inventory.md b/erpnext/docs/user/videos/learn/serialized-inventory.md
index e3b97e1..da2c036 100644
--- a/erpnext/docs/user/videos/learn/serialized-inventory.md
+++ b/erpnext/docs/user/videos/learn/serialized-inventory.md
@@ -1,8 +1,8 @@
 # Serialized Inventory
 
-<iframe width="660" height="371" src="https://www.youtube.com/embed/gvOVlEwFDAk" frameborder="0" allowfullscreen></iframe>
+<iframe width="660" height="371" src="https://www.youtube.com/embed/Q4tYKYTbVek" frameborder="0" allowfullscreen></iframe>
 
-**Duration: 4:11**
+**Duration: 5:33**
 
 If an Item is serialized, a Serial Number (Serial No) record is maintained for each unit of that Item. This information is helpful in tracking the location of the Serial No, its warranty and end-of-life (expiry) information.
 
diff --git a/erpnext/docs/user/videos/learn/subscription.md b/erpnext/docs/user/videos/learn/subscription.md
new file mode 100644
index 0000000..8193e58
--- /dev/null
+++ b/erpnext/docs/user/videos/learn/subscription.md
@@ -0,0 +1,7 @@
+# Subscription Management
+
+<iframe width="660" height="371" src="https://www.youtube.com/embed/CRQfGiMm3_U" frameborder="0" allowfullscreen></iframe>
+
+**Duration: 2:09**
+
+In this video, we will learn about subscription management in ERPNext. Let's suppose you have to create a purchase invoice every month for paying the property rent. You should only create first Purchase Invoice manually, and then create a Subscription for it, so that purchase invoice is auto-created for subsequent each month.
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py
index b647c2e..ace5ac0 100755
--- a/erpnext/healthcare/doctype/consultation/consultation.py
+++ b/erpnext/healthcare/doctype/consultation/consultation.py
@@ -5,7 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.document import Document
-from frappe.utils import getdate
+from frappe.utils import getdate, cstr
 import json
 from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
 
@@ -120,7 +120,7 @@
 def set_subject_field(consultation):
 	subject = "No Diagnosis "
 	if(consultation.diagnosis):
-		subject = "Diagnosis: "+ str(consultation.diagnosis)+". "
+		subject = "Diagnosis: \n"+ cstr(consultation.diagnosis)+". "
 	if(consultation.drug_prescription):
 		subject +="\nDrug(s) Prescribed. "
 	if(consultation.test_prescription):
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index c910d7c..4e07ed6 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe.model.document import Document
 import json
-from frappe.utils import getdate
+from frappe.utils import getdate, cstr
 from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account
 from frappe import _
 
@@ -228,9 +228,10 @@
 	return employee
 
 def insert_lab_test_to_medical_record(doc):
-	subject = str(doc.test_name)
+	subject = cstr(doc.test_name)
 	if(doc.test_comment):
-		subject += ", "+str(doc.test_comment)
+		subject += ", \n"+ cstr(doc.test_comment)
+
 	medical_record = frappe.new_doc("Patient Medical Record")
 	medical_record.patient = doc.patient
 	medical_record.subject = subject
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
index 41d9258..bf4dace 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.document import Document
+from frappe.utils import cstr
 
 class VitalSigns(Document):
 	def on_submit(self):
@@ -33,16 +34,16 @@
 def set_subject_field(doc):
 	subject = ""
 	if(doc.temperature):
-		subject += "Temperature: "+ str(doc.temperature)+".\n"
+		subject += "Temperature: \n"+ cstr(doc.temperature)+". "
 	if(doc.pulse):
-		subject += "Pulse: "+ str(doc.pulse)+".\n"
+		subject += "Pulse: \n"+ cstr(doc.pulse)+". "
 	if(doc.respiratory_rate):
-		subject += "Respiratory Rate: "+ str(doc.respiratory_rate)+".\n"
+		subject += "Respiratory Rate: \n"+ cstr(doc.respiratory_rate)+". "
 	if(doc.bp):
-		subject += "BP: "+ str(doc.bp)+".\n"
+		subject += "BP: \n"+ cstr(doc.bp)+". "
 	if(doc.bmi):
-		subject += "BMI: "+ str(doc.bmi)+".\n"
+		subject += "BMI: \n"+ cstr(doc.bmi)+". "
 	if(doc.nutrition_note):
-		subject += "Note: "+ str(doc.nutrition_note)+"."
+		subject += "Note: \n"+ cstr(doc.nutrition_note)+". "
 
 	return subject
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 938f7fa..815e2eb 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -238,7 +238,8 @@
 		"erpnext.assets.doctype.asset.asset.make_post_gl_entry"
   ],
 	"monthly": [
-		"erpnext.accounts.doctype.sales_invoice.sales_invoice.booked_deferred_revenue"
+		"erpnext.accounts.doctype.sales_invoice.sales_invoice.booked_deferred_revenue",
+		"erpnext.hr.utils.allocate_earned_leaves"
 	]
 }
 
diff --git a/erpnext/hr/doctype/additional_salary_component/__init__.py b/erpnext/hr/doctype/additional_salary/__init__.py
similarity index 100%
rename from erpnext/hr/doctype/additional_salary_component/__init__.py
rename to erpnext/hr/doctype/additional_salary/__init__.py
diff --git a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.js b/erpnext/hr/doctype/additional_salary/additional_salary.js
similarity index 78%
rename from erpnext/hr/doctype/additional_salary_component/additional_salary_component.js
rename to erpnext/hr/doctype/additional_salary/additional_salary.js
index 13ed239..94e06ad 100644
--- a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.js
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.js
@@ -1,12 +1,13 @@
 // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
 
-frappe.ui.form.on('Additional Salary Component', {
+frappe.ui.form.on('Additional Salary', {
 	setup: function(frm) {
 		frm.set_query("salary_component", function() {
 			return {
 				filters: {
-					type: "earning"
+					type: "earning",
+					is_additional_component: true
 				}
 			};
 		});
diff --git a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.json b/erpnext/hr/doctype/additional_salary/additional_salary.json
similarity index 84%
rename from erpnext/hr/doctype/additional_salary_component/additional_salary_component.json
rename to erpnext/hr/doctype/additional_salary/additional_salary.json
index ea73917..420d599 100644
--- a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.json
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -42,11 +43,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -74,11 +76,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -106,16 +109,17 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -139,11 +143,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -171,11 +176,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -201,11 +207,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -232,11 +239,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -263,11 +271,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -294,48 +303,50 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.department",
-   "fieldname": "department",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Department",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Department",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "fetch_from": "employee.department", 
+   "fieldname": "department", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Department", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Department", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -348,7 +359,7 @@
    "label": "Amended From", 
    "length": 0, 
    "no_copy": 1, 
-   "options": "Additional Salary Component", 
+   "options": "Additional Salary", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -358,7 +369,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }
  ], 
@@ -372,10 +383,10 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 10:22:03.004640",
+ "modified": "2018-05-30 11:44:06.422122", 
  "modified_by": "Administrator", 
  "module": "HR", 
- "name": "Additional Salary Component", 
+ "name": "Additional Salary", 
  "name_case": "", 
  "owner": "Administrator", 
  "permissions": [
@@ -427,4 +438,4 @@
  "title_field": "employee", 
  "track_changes": 1, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
similarity index 85%
rename from erpnext/hr/doctype/additional_salary_component/additional_salary_component.py
rename to erpnext/hr/doctype/additional_salary/additional_salary.py
index 7a07ae0..7482c8b 100644
--- a/erpnext/hr/doctype/additional_salary_component/additional_salary_component.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -8,7 +8,7 @@
 from frappe import _
 from frappe.utils import getdate, date_diff
 
-class AdditionalSalaryComponent(Document):
+class AdditionalSalary(Document):
 	def validate(self):
 		self.validate_dates()
 		if self.amount <= 0:
@@ -25,6 +25,11 @@
  			frappe.throw(_("To date can not greater than employee's relieving date"))
 
 	def get_amount(self, sal_start_date, sal_end_date):
+		# If additional salary dates in between the salary slip dates
+		# then return complete additional salary amount
+		if getdate(sal_start_date) <= getdate(self.from_date) <= getdate(sal_end_date)\
+			and getdate(sal_end_date) >= getdate(self.to_date) >= getdate(sal_start_date):
+			return self.amount
 		start_date = getdate(sal_start_date)
 		end_date = getdate(sal_end_date)
 		total_days = date_diff(getdate(self.to_date), getdate(self.from_date)) + 1
@@ -42,7 +47,7 @@
 @frappe.whitelist()
 def get_additional_salary_component(employee, start_date, end_date):
 	additional_components = frappe.db.sql("""
-	select name from `tabAdditional Salary Component`
+	select name from `tabAdditional Salary`
 	where employee=%(employee)s
 	and docstatus = 1
 	and (
@@ -60,7 +65,7 @@
 		for additional_component in additional_components:
 			struct_row = {}
 			additional_components_dict = {}
-			additional_component_obj = frappe.get_doc("Additional Salary Component", additional_component[0])
+			additional_component_obj = frappe.get_doc("Additional Salary", additional_component[0])
 			amount = additional_component_obj.get_amount(start_date, end_date)
 			salary_component = frappe.get_doc("Salary Component", additional_component_obj.salary_component)
 			struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
diff --git a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js b/erpnext/hr/doctype/additional_salary/test_additional_salary.js
similarity index 65%
copy from erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
copy to erpnext/hr/doctype/additional_salary/test_additional_salary.js
index 118290b..c18e187 100644
--- a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.js
+++ b/erpnext/hr/doctype/additional_salary/test_additional_salary.js
@@ -2,15 +2,15 @@
 // rename this file from _test_[name] to test_[name] to activate
 // and remove above this line
 
-QUnit.test("test: Additional Salary Component", function (assert) {
+QUnit.test("test: Additional Salary", function (assert) {
 	let done = assert.async();
 
 	// number of asserts
 	assert.expect(1);
 
 	frappe.run_serially([
-		// insert a new Additional Salary Component
-		() => frappe.tests.make('Additional Salary Component', [
+		// insert a new Additional Salary
+		() => frappe.tests.make('Additional Salary', [
 			// values to be set
 			{key: 'value'}
 		]),
diff --git a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py b/erpnext/hr/doctype/additional_salary/test_additional_salary.py
similarity index 75%
rename from erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py
rename to erpnext/hr/doctype/additional_salary/test_additional_salary.py
index eda2f79..949ba20 100644
--- a/erpnext/hr/doctype/additional_salary_component/test_additional_salary_component.py
+++ b/erpnext/hr/doctype/additional_salary/test_additional_salary.py
@@ -4,5 +4,5 @@
 from __future__ import unicode_literals
 import unittest
 
-class TestAdditionalSalaryComponent(unittest.TestCase):
+class TestAdditionalSalary(unittest.TestCase):
 	pass
diff --git a/erpnext/hr/doctype/attendance_request/attendance_request.json b/erpnext/hr/doctype/attendance_request/attendance_request.json
index d152a70..c626941 100644
--- a/erpnext/hr/doctype/attendance_request/attendance_request.json
+++ b/erpnext/hr/doctype/attendance_request/attendance_request.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,11 +48,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -80,6 +82,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -144,6 +147,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -175,6 +179,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -206,6 +211,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -238,6 +244,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -268,6 +275,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -299,6 +307,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -331,6 +340,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -363,6 +373,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -403,7 +414,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 12:04:20.334541",
+ "modified": "2018-05-25 12:02:39.993839", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Attendance Request", 
@@ -496,4 +507,4 @@
  "title_field": "employee_name", 
  "track_changes": 1, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/compensatory_leave_request/compensatory_leave_request.json b/erpnext/hr/doctype/compensatory_leave_request/compensatory_leave_request.json
index 44c76c5..9d2a966 100644
--- a/erpnext/hr/doctype/compensatory_leave_request/compensatory_leave_request.json
+++ b/erpnext/hr/doctype/compensatory_leave_request/compensatory_leave_request.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,11 +48,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -80,6 +82,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -144,6 +147,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -175,6 +179,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -205,6 +210,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -237,6 +243,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -268,6 +275,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -300,6 +308,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -340,7 +349,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 10:09:21.089982",
+ "modified": "2018-05-25 12:02:05.585184", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Compensatory Leave Request", 
@@ -433,4 +442,4 @@
  "title_field": "employee_name", 
  "track_changes": 1, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
index 7859a47..f96f262 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
@@ -5,39 +5,41 @@
 	setup: function(frm) {
 		frm.set_query("earning_component", "employee_benefits", function() {
 			return {
-				filters: {
-					type: "Earning",
-					is_flexible_benefit: true,
-					disabled: false
-				}
+				query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
+				filters: {date: frm.doc.date, employee: frm.doc.employee}
 			};
 		});
 	},
 	employee: function(frm) {
-		frappe.call({
-			method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
-			args:{
-				employee: frm.doc.employee,
-				on_date: frm.doc.date
-			},
-			callback: function (data) {
-				if(!data.exc){
-					if(data.message){
-						frm.set_value("max_benefits", data.message);
+		if(frm.doc.employee && frm.doc.date){
+			frappe.call({
+				method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
+				args:{
+					employee: frm.doc.employee,
+					on_date: frm.doc.date
+				},
+				callback: function (data) {
+					if(!data.exc){
+						if(data.message){
+							frm.set_value("max_benefits", data.message);
+						}
 					}
 				}
-			}
-		});
+			});
+		}
 	}
 });
 
 frappe.ui.form.on("Employee Benefit Application Detail",{
-	amount:  function(frm, cdt, cdn) {
-		calculate_all(frm.doc, cdt, cdn);
+	amount:  function(frm) {
+		calculate_all(frm.doc);
+	},
+	employee_benefits_remove: function(frm) {
+		calculate_all(frm.doc);
 	}
 });
 
-var calculate_all = function(doc, dt, dn) {
+var calculate_all = function(doc) {
 	var tbl = doc.employee_benefits || [];
 	var pro_rata_dispensed_amount = 0;
 	var total_amount = 0;
@@ -46,7 +48,7 @@
 			total_amount += flt(tbl[i].amount);
 		}
 		if(tbl[i].is_pro_rata_applicable == 1){
-			pro_rata_dispensed_amount += flt(tbl[i].amount)
+			pro_rata_dispensed_amount += flt(tbl[i].amount);
 		}
 	}
 	doc.total_amount = total_amount;
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.json b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.json
index cf17854..7a8803a 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.json
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,11 +48,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -80,6 +82,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -111,6 +114,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -142,6 +146,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -172,6 +177,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -204,6 +210,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -236,6 +243,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -267,6 +275,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -298,6 +307,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -362,6 +372,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -392,6 +403,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -433,7 +445,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 12:43:32.220595",
+ "modified": "2018-05-25 12:01:01.490375", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee Benefit Application", 
@@ -526,4 +538,4 @@
  "title_field": "employee_name", 
  "track_changes": 1, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
index 8e59bf5..2d33ce8 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
@@ -5,18 +5,50 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
-from frappe.utils import nowdate, date_diff, getdate
+from frappe.utils import date_diff, getdate
 from frappe.model.document import Document
 from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
+from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import get_assigned_salary_structure
 
 class EmployeeBenefitApplication(Document):
 	def validate(self):
+		self.validate_duplicate_on_payroll_period()
 		if self.max_benefits <= 0:
 			frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
 		self.validate_max_benefit_for_component()
+		if self.remainig_benefits > 0:
+			self.validate_remaining_benefit_amount()
 
-	def before_submit(self):
-		self.validate_duplicate_on_payroll_period()
+	def validate_remaining_benefit_amount(self):
+		# check salary structure earnings have flexi component (sum of max_benefit_amount)
+		# without pro-rata which satisfy the remainig_benefits
+		# else pro-rata component for the amount
+		# again comes the same validation and satisfy or throw
+		benefit_components = []
+		if self.employee_benefits:
+			for employee_benefit in self.employee_benefits:
+				benefit_components.append(employee_benefit.earning_component)
+		salary_struct_name = get_assigned_salary_structure(self.employee, self.date)
+		if salary_struct_name:
+			non_pro_rata_amount = 0
+			pro_rata_amount = 0
+			salary_structure = frappe.get_doc("Salary Structure", salary_struct_name)
+			if salary_structure.earnings:
+				for earnings in salary_structure.earnings:
+					if earnings.is_flexible_benefit == 1 and earnings.salary_component not in benefit_components:
+						is_pro_rata_applicable, max_benefit_amount = frappe.db.get_value("Salary Component", earnings.salary_component, ["is_pro_rata_applicable", "max_benefit_amount"])
+						if is_pro_rata_applicable == 1:
+							pro_rata_amount += max_benefit_amount
+						else:
+							non_pro_rata_amount += max_benefit_amount
+			if pro_rata_amount == 0  and non_pro_rata_amount == 0:
+				frappe.throw(_("Please add the remainig benefits {0} to any of the existing component").format(self.remainig_benefits))
+			elif non_pro_rata_amount > 0 and non_pro_rata_amount < self.remainig_benefits:
+				frappe.throw(_("You can claim only an amount of {0}, the rest amount {1} should be in the application \
+				as pro-rata component").format(non_pro_rata_amount, self.remainig_benefits - non_pro_rata_amount))
+			elif non_pro_rata_amount == 0:
+				frappe.throw(_("Please add the remainig benefits {0} to the application as \
+				pro-rata component").format(self.remainig_benefits))
 
 	def validate_max_benefit_for_component(self):
 		if self.employee_benefits:
@@ -50,9 +82,9 @@
 
 @frappe.whitelist()
 def get_max_benefits(employee, on_date):
-	sal_struct = get_assigned_salary_sturecture(employee, on_date)
+	sal_struct = get_assigned_salary_structure(employee, on_date)
 	if sal_struct:
-		max_benefits = frappe.db.get_value("Salary Structure", sal_struct[0][0], "max_benefits")
+		max_benefits = frappe.db.get_value("Salary Structure", sal_struct, "max_benefits")
 		if max_benefits > 0:
 			return max_benefits
 		else:
@@ -60,76 +92,74 @@
 	else:
 		frappe.throw(_("Employee {0} has no salary structure assigned").format(employee))
 
-
-@frappe.whitelist()
-def get_assigned_salary_sturecture(employee, _date):
-	if not _date:
-		_date = nowdate()
-	salary_structure = frappe.db.sql("""
-		select salary_structure from `tabSalary Structure Assignment`
-		where employee=%(employee)s
-		and docstatus = 1
-		and (
-			(%(_date)s between from_date and ifnull(to_date, '2199-12-31'))
-		)""", {
-			'employee': employee,
-			'_date': _date,
-		})
-	if salary_structure:
-		return salary_structure
-
-def get_employee_benefit_application(salary_slip):
-	employee_benefits = frappe.db.sql("""
+def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal_struct):
+	# Considering there is only one application for an year
+	benefit_application_name = frappe.db.sql("""
 	select name from `tabEmployee Benefit Application`
 	where employee=%(employee)s
 	and docstatus = 1
 	and (date between %(start_date)s and %(end_date)s)
 	""", {
-		'employee': salary_slip.employee,
-		'start_date': salary_slip.start_date,
-		'end_date': salary_slip.end_date
+		'employee': employee,
+		'start_date': start_date,
+		'end_date': end_date
 	})
 
-	if employee_benefits:
-		for employee_benefit in employee_benefits:
-			employee_benefit_obj = frappe.get_doc("Employee Benefit Application", employee_benefit[0])
-			return get_components(employee_benefit_obj, salary_slip)
+	payroll_period_days = get_payroll_period_days(start_date, end_date, frappe.db.get_value("Employee", employee, "company"))
+	if payroll_period_days:
+		# If there is application for benefit claim then fetch the amount from it.
+		if benefit_application_name:
+			benefit_application = frappe.get_doc("Employee Benefit Application", benefit_application_name[0][0])
+			return get_benefit_amount(benefit_application, start_date, end_date, struct_row, payroll_period_days)
 
-def get_components(employee_benefit_application, salary_slip):
-	salary_components_array = []
-	group_component_amount = {}
-	payroll_period_days = get_payroll_period_days(salary_slip.start_date, salary_slip.end_date, salary_slip.company)
-	for employee_benefit in employee_benefit_application.employee_benefits:
-		if employee_benefit.is_pro_rata_applicable == 1:
-			struct_row = {}
-			salary_components_dict = {}
-			amount = get_amount(payroll_period_days, salary_slip.start_date, salary_slip.end_date, employee_benefit.amount)
-			sc = frappe.get_doc("Salary Component", employee_benefit.earning_component)
-			salary_component = sc
-			if sc.earning_component_group and not sc.is_group and not sc.flexi_default:
-				salary_component = frappe.get_doc("Salary Component", sc.earning_component_group)
-				if group_component_amount and group_component_amount.has_key(sc.earning_component_group):
-					group_component_amount[sc.earning_component_group] += amount
-				else:
-					group_component_amount[sc.earning_component_group] = amount
-				amount = group_component_amount[sc.earning_component_group]
-			struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
-			struct_row['salary_component'] = salary_component.name
-			struct_row['abbr'] = salary_component.salary_component_abbr
-			struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
-			salary_components_dict['amount'] = amount
-			salary_components_dict['struct_row'] = struct_row
-			salary_components_array.append(salary_components_dict)
-
-	if len(salary_components_array) > 0:
-		return salary_components_array
+		# TODO: Check if there is benefit claim for employee then pro-rata devid the rest of amount (Late Benefit Application)
+		# else Split the max benefits to the pro-rata components with the ratio of thier max_benefit_amount
+		else:
+			component_max = frappe.db.get_value("Salary Component", struct_row.salary_component, "max_benefit_amount")
+			if component_max > 0:
+				return get_benefit_pro_rata_ratio_amount(sal_struct, component_max, payroll_period_days, start_date, end_date)
 	return False
 
+def get_benefit_pro_rata_ratio_amount(sal_struct, component_max, payroll_period_days, start_date, end_date):
+	total_pro_rata_max = 0
+	for sal_struct_row in sal_struct.get("earnings"):
+		is_pro_rata_applicable, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["is_pro_rata_applicable", "max_benefit_amount"])
+		if sal_struct_row.is_flexible_benefit == 1 and is_pro_rata_applicable == 1:
+			total_pro_rata_max += max_benefit_amount
+	if total_pro_rata_max > 0:
+		benefit_amount = component_max * sal_struct.max_benefits / total_pro_rata_max
+		if benefit_amount > component_max:
+			benefit_amount = component_max
+		return get_amount(payroll_period_days, start_date, end_date, benefit_amount)
+	return False
+
+def get_benefit_amount(application, start_date, end_date, struct_row, payroll_period_days):
+	amount = 0
+	for employee_benefit in application.employee_benefits:
+		if employee_benefit.earning_component == struct_row.salary_component:
+			amount += get_amount(payroll_period_days, start_date, end_date, employee_benefit.amount)
+	return amount if amount > 0 else False
+
 def get_amount(payroll_period_days, start_date, end_date, amount):
 	salary_slip_days = date_diff(getdate(end_date), getdate(start_date)) + 1
 	amount_per_day = amount / payroll_period_days
 	total_amount = amount_per_day * salary_slip_days
-	if total_amount > amount:
-		return amount
-	else:
-		return total_amount
+	return total_amount
+
+def get_earning_components(doctype, txt, searchfield, start, page_len, filters):
+	if len(filters) < 2:
+		return {}
+	employee = filters['employee']
+	date = filters['date']
+	salary_structure = get_assigned_salary_structure(employee, date)
+
+	if salary_structure:
+		query = """select salary_component from `tabSalary Detail` where parent = '{salary_structure}'
+		and is_flexible_benefit = 1
+		order by name"""
+
+		return frappe.db.sql(query.format(**{
+			"salary_structure": salary_structure
+		}))
+
+	return {}
diff --git a/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json b/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json
index d2b1d2a..eba9b19 100644
--- a/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json
+++ b/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,6 +48,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -80,6 +82,41 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_from": "earning_component.max_benefit_amount", 
+   "fieldname": "max_benefit_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Max Benefit Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -120,7 +157,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2018-05-25 12:03:25.545041", 
+ "modified": "2018-05-26 12:00:37.588822", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee Benefit Application Detail", 
@@ -130,6 +167,7 @@
  "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
+ "search_fields": "", 
  "show_name_in_global_search": 0, 
  "sort_field": "modified", 
  "sort_order": "DESC", 
diff --git a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.js b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.js
index 64fde03..5e12828 100644
--- a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.js
+++ b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.js
@@ -5,12 +5,12 @@
 	setup: function(frm) {
 		frm.set_query("earning_component", function() {
 			return {
-				filters: {
-					type: "Earning",
-					is_flexible_benefit: true,
-					disabled: false
-				}
+				query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
+				filters: {date: frm.doc.claim_date, employee: frm.doc.employee}
 			};
 		});
+	},
+	employee: function(frm) {
+		frm.set_value("earning_component", null);
 	}
 });
diff --git a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json
index a5b707f..a59aaea 100644
--- a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json
+++ b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,11 +48,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -80,6 +82,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -116,7 +119,8 @@
    "allow_on_submit": 0,
    "bold": 0,
    "collapsible": 0,
-   "columns": 0,
+   "columns": 0, 
+   "default": "Today", 
    "fieldname": "claim_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -144,6 +148,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -174,6 +179,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -206,6 +212,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -239,6 +246,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -272,6 +280,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -303,6 +312,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -335,6 +345,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -366,6 +377,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -396,6 +408,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -436,7 +449,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-25 12:43:21.082282",
+ "modified": "2018-05-26 12:43:21.082282",
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee Benefit Claim", 
@@ -529,4 +542,4 @@
  "title_field": "employee_name", 
  "track_changes": 1, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py
index 39b3540..1aed7ce 100644
--- a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py
+++ b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py
@@ -7,59 +7,127 @@
 from frappe import _
 from frappe.model.document import Document
 from erpnext.hr.doctype.employee_benefit_application.employee_benefit_application import get_max_benefits
+from erpnext.hr.utils import get_payroll_period
+from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import get_assigned_salary_structure
 
 class EmployeeBenefitClaim(Document):
 	def validate(self):
-		if not self.is_pro_rata_applicable:
-			self.validate_max_benefit_for_sal_struct()
-		# TODO: Validate all cases
-
-	def validate_max_benefit_for_sal_struct(self):
 		max_benefits = get_max_benefits(self.employee, self.claim_date)
+		payroll_period = get_payroll_period(self.claim_date, self.claim_date, frappe.db.get_value("Employee", self.employee, "company"))
+		self.validate_max_benefit_for_component(payroll_period)
+		self.validate_max_benefit_for_sal_struct(max_benefits)
+		self.validate_benefit_claim_amount(max_benefits, payroll_period)
+		if not self.is_pro_rata_applicable:
+			self.validate_non_pro_rata_benefit_claim(max_benefits, payroll_period)
+
+	def validate_benefit_claim_amount(self, max_benefits, payroll_period):
+		claimed_amount = self.claimed_amount
+		claimed_amount += self.get_previous_claimed_amount(payroll_period)
+		if max_benefits < claimed_amount:
+			frappe.throw(_("Maximum benefit of employee {0} exceeds {1} by the sum {2} of previous claimed\
+			amount").format(self.employee, max_benefits, claimed_amount-max_benefits))
+
+	def validate_max_benefit_for_sal_struct(self, max_benefits):
 		if self.claimed_amount > max_benefits:
 			frappe.throw(_("Maximum benefit amount of employee {0} exceeds {1}").format(self.employee, max_benefits))
 
+	def validate_max_benefit_for_component(self, payroll_period):
+		claimed_amount = self.claimed_amount
+		claimed_amount += self.get_previous_claimed_amount(payroll_period, self.earning_component)
+		if claimed_amount > self.max_amount_eligible:
+			frappe.throw(_("Maximum amount eligible for the component {0} exceeds {1}").format(self.earning_component, self.max_amount_eligible))
 
-def get_employee_benefit_claim(salary_slip):
-	employee_benefits = frappe.db.sql("""
-	select name from `tabEmployee Benefit Claim`
+	def validate_non_pro_rata_benefit_claim(self, max_benefits, payroll_period):
+		claimed_amount = self.claimed_amount
+		pro_rata_amount = self.get_pro_rata_amount_in_application(payroll_period.name)
+		if not pro_rata_amount:
+			# Get pro_rata_amount if there is no application,
+			# get salary structure for the date and calculate pro-rata amount
+			pro_rata_amount = self.get_benefit_pro_rata_ratio_amount()
+		if not pro_rata_amount:
+			pro_rata_amount = 0
+
+		claimed_amount += self.get_previous_claimed_amount(payroll_period, True)
+		if max_benefits < pro_rata_amount + claimed_amount:
+			frappe.throw(_("Maximum benefit of employee {0} exceeds {1} by the sum {2} of benefit application pro-rata component\
+			amount and previous claimed amount").format(self.employee, max_benefits, pro_rata_amount+claimed_amount-max_benefits))
+
+	def get_benefit_pro_rata_ratio_amount(self):
+		sal_struct_name = get_assigned_salary_structure(self.employee, self.claim_date)
+		if sal_struct_name:
+			sal_struct = frappe.get_doc("Salary Structure", sal_struct_name)
+			total_pro_rata_max = 0
+			benefit_amount_total = 0
+			for sal_struct_row in sal_struct.get("earnings"):
+				is_pro_rata_applicable, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["is_pro_rata_applicable", "max_benefit_amount"])
+				if sal_struct_row.is_flexible_benefit == 1 and is_pro_rata_applicable == 1:
+					total_pro_rata_max += max_benefit_amount
+			if total_pro_rata_max > 0:
+				for sal_struct_row in sal_struct.get("earnings"):
+					is_pro_rata_applicable, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["is_pro_rata_applicable", "max_benefit_amount"])
+					if sal_struct_row.is_flexible_benefit == 1 and is_pro_rata_applicable == 1:
+						component_max = max_benefit_amount
+						benefit_amount = component_max * sal_struct.max_benefits / total_pro_rata_max
+						if benefit_amount > component_max:
+							benefit_amount = component_max
+						benefit_amount_total += benefit_amount
+				return benefit_amount_total
+		return False
+
+	def get_pro_rata_amount_in_application(self, payroll_period):
+		application = frappe.db.exists(
+			"Employee Benefit Application",
+			{
+				'employee': self.employee,
+				'payroll_period': payroll_period,
+				'docstatus': 1
+			}
+		)
+		if application:
+			return frappe.db.get_value("Employee Benefit Application", application, "pro_rata_dispensed_amount")
+		return False
+
+	def get_previous_claimed_amount(self, payroll_period, non_pro_rata=False, component=False):
+		total_claimed_amount = 0
+		query = """
+		select sum(claimed_amount) as 'total_amount'
+		from `tabEmployee Benefit Claim`
+		where employee=%(employee)s
+		and docstatus = 1
+		and (claim_date between %(start_date)s and %(end_date)s)
+		"""
+		if non_pro_rata:
+			query += "and is_pro_rata_applicable = 0"
+		if component:
+			query += "and earning_component = %(component)s"
+
+		sum_of_claimed_amount = frappe.db.sql(query, {
+			'employee': self.employee,
+			'start_date': payroll_period.start_date,
+			'end_date': payroll_period.end_date,
+			'component': component
+		}, as_dict=True)
+		if sum_of_claimed_amount and sum_of_claimed_amount[0].total_amount > 0:
+			total_claimed_amount = sum_of_claimed_amount[0].total_amount
+		return total_claimed_amount
+
+def get_benefit_claim_amount(employee, start_date, end_date, struct_row):
+	benefit_claim_details = frappe.db.sql("""
+	select claimed_amount from `tabEmployee Benefit Claim`
 	where employee=%(employee)s
 	and docstatus = 1 and is_pro_rata_applicable = 0
+	and earning_component = %(earning_component)s
 	and (claim_date between %(start_date)s and %(end_date)s)
 	""", {
-		'employee': salary_slip.employee,
-		'start_date': salary_slip.start_date,
-		'end_date': salary_slip.end_date
-	})
+		'employee': employee,
+		'start_date': start_date,
+		'end_date': end_date,
+		'earning_component': struct_row.salary_component
+	}, as_dict = True)
 
-	if employee_benefits:
-		salary_components_array = []
-		for employee_benefit in employee_benefits:
-			struct_row = {}
-			salary_components_dict = {}
-			group_component_amount = {}
-
-			employee_benefit_claim = frappe.get_doc("Employee Benefit Claim", employee_benefit[0])
-			amount = employee_benefit_claim.claimed_amount
-			sc = frappe.get_doc("Salary Component", employee_benefit_claim.earning_component)
-
-			salary_component = sc
-			if sc.earning_component_group and not sc.is_group and not sc.flexi_default:
-				salary_component = frappe.get_doc("Salary Component", sc.earning_component_group)
-				if group_component_amount and group_component_amount.has_key(sc.earning_component_group):
-					group_component_amount[sc.earning_component_group] += amount
-				else:
-					group_component_amount[sc.earning_component_group] = amount
-				amount = group_component_amount[sc.earning_component_group]
-
-			struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
-			struct_row['salary_component'] = salary_component.name
-			struct_row['abbr'] = salary_component.salary_component_abbr
-			struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
-			salary_components_dict['amount'] = amount
-			salary_components_dict['struct_row'] = struct_row
-			salary_components_array.append(salary_components_dict)
-
-		if len(salary_components_array) > 0:
-			return salary_components_array
+	if benefit_claim_details:
+		claimed_amount = 0
+		for claim_detail in benefit_claim_details:
+			claimed_amount += claim_detail.claimed_amount
+		return claimed_amount
 	return False
diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
index 84970d8..dff02ea 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
+++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
@@ -84,10 +84,8 @@
 			doctype = 'Payroll Period',
 			name = "_Test Payroll Period",
 			company = "_Test Company",
-			periods = [
-				dict(start_date = date(date.today().year, 1, 1),
-				end_date = date(date.today().year, 12, 31))
-			]
+			start_date = date(date.today().year, 1, 1),
+			end_date = date(date.today().year, 12, 31)
 		)).insert()
 
 def create_exemption_category():
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
index 8432cfe..7cffa4c 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
@@ -43,16 +43,16 @@
 	def on_update_after_submit(self):
 		self.validate_new_leaves_allocated_value()
 		self.set_total_leaves_allocated()
-		
+
 		frappe.db.set(self,'carry_forwarded_leaves', flt(self.carry_forwarded_leaves))
 		frappe.db.set(self,'total_leaves_allocated',flt(self.total_leaves_allocated))
-		
+
 		self.validate_against_leave_applications()
 
 	def validate_period(self):
 		if date_diff(self.to_date, self.from_date) <= 0:
 			frappe.throw(_("To date cannot be before from date"))
-			
+
 	def validate_lwp(self):
 		if frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
 			frappe.throw(_("Leave Type {0} cannot be allocated since it is leave without pay").format(self.leave_type))
@@ -66,45 +66,45 @@
 		leave_allocation = frappe.db.sql("""
 			select name from `tabLeave Allocation`
 			where employee=%s and leave_type=%s and docstatus=1
-			and to_date >= %s and from_date <= %s""", 
+			and to_date >= %s and from_date <= %s""",
 			(self.employee, self.leave_type, self.from_date, self.to_date))
 
 		if leave_allocation:
 			frappe.msgprint(_("{0} already allocated for Employee {1} for period {2} to {3}")
 				.format(self.leave_type, self.employee, formatdate(self.from_date), formatdate(self.to_date)))
-			
+
 			frappe.throw(_('Reference') + ': <a href="#Form/Leave Allocation/{0}">{0}</a>'
 				.format(leave_allocation[0][0]), OverlapError)
-				
+
 	def validate_back_dated_allocation(self):
 		future_allocation = frappe.db.sql("""select name, from_date from `tabLeave Allocation`
-			where employee=%s and leave_type=%s and docstatus=1 and from_date > %s 
+			where employee=%s and leave_type=%s and docstatus=1 and from_date > %s
 			and carry_forward=1""", (self.employee, self.leave_type, self.to_date), as_dict=1)
-		
+
 		if future_allocation:
 			frappe.throw(_("Leave cannot be allocated before {0}, as leave balance has already been carry-forwarded in the future leave allocation record {1}")
-				.format(formatdate(future_allocation[0].from_date), future_allocation[0].name), 
+				.format(formatdate(future_allocation[0].from_date), future_allocation[0].name),
 					BackDatedAllocationError)
 
 	def set_total_leaves_allocated(self):
-		self.carry_forwarded_leaves = get_carry_forwarded_leaves(self.employee, 
+		self.carry_forwarded_leaves = get_carry_forwarded_leaves(self.employee,
 			self.leave_type, self.from_date, self.carry_forward)
-			
+
 		self.total_leaves_allocated = flt(self.carry_forwarded_leaves) + flt(self.new_leaves_allocated)
-		
-		if not self.total_leaves_allocated:
-			frappe.throw(_("Total leaves allocated is mandatory"))
+
+		if not self.total_leaves_allocated and not frappe.db.get_value("Leave Type", self.leave_type, "is_earned_leave"):
+			frappe.throw(_("Total leaves allocated is mandatory for Leave Type {0}".format(self.leave_type)))
 
 	def validate_total_leaves_allocated(self):
 		# Adding a day to include To Date in the difference
 		date_difference = date_diff(self.to_date, self.from_date) + 1
 		if date_difference < self.total_leaves_allocated:
 			frappe.throw(_("Total allocated leaves are more than days in the period"), OverAllocationError)
-			
+
 	def validate_against_leave_applications(self):
-		leaves_taken = get_approved_leaves_for_period(self.employee, self.leave_type, 
+		leaves_taken = get_approved_leaves_for_period(self.employee, self.leave_type,
 			self.from_date, self.to_date)
-		
+
 		if flt(leaves_taken) > flt(self.total_leaves_allocated):
 			if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
 				frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken))
@@ -137,10 +137,10 @@
 @frappe.whitelist()
 def get_carry_forwarded_leaves(employee, leave_type, date, carry_forward=None):
 	carry_forwarded_leaves = 0
-	
+
 	if carry_forward:
 		validate_carry_forward(leave_type)
-		
+
 		previous_allocation = frappe.db.sql("""
 			select name, from_date, to_date, total_leaves_allocated
 			from `tabLeave Allocation`
@@ -148,14 +148,13 @@
 			order by to_date desc limit 1
 		""", (employee, leave_type, date), as_dict=1)
 		if previous_allocation:
-			leaves_taken = get_approved_leaves_for_period(employee, leave_type, 
+			leaves_taken = get_approved_leaves_for_period(employee, leave_type,
 				previous_allocation[0].from_date, previous_allocation[0].to_date)
-		
+
 			carry_forwarded_leaves = flt(previous_allocation[0].total_leaves_allocated) - flt(leaves_taken)
-			
+
 	return carry_forwarded_leaves
-		
+
 def validate_carry_forward(leave_type):
 	if not frappe.db.get_value("Leave Type", leave_type, "is_carry_forward"):
 		frappe.throw(_("Leave Type {0} cannot be carry-forwarded").format(leave_type))
-	
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index b4f4c1c..5506d60 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -7,7 +7,7 @@
 
 from erpnext.hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError, NotAnOptionalHoliday, get_leave_balance_on
 from frappe.permissions import clear_user_permissions_for_doctype
-from frappe.utils import add_days, nowdate, now_datetime
+from frappe.utils import add_days, nowdate, now_datetime, get_datetime
 
 test_dependencies = ["Leave Allocation", "Leave Block List"]
 
@@ -387,25 +387,32 @@
 
 		self.assertRaises(frappe.ValidationError, leave_application.insert)
 
-	# def test_earned_leave(self):
-	# 	leave_period = get_leave_period()
-	# 	employee = get_employee()
-	#
-	# 	leave_type = frappe.get_doc(dict(
-	# 		leave_type_name = 'Test Earned Leave Type',
-	# 		doctype = 'Leave Type',
-	# 		is_earned_leave = 1,
-	# 		earned_leave_frequency = 'Monthly',
-	# 		rounding = 0.5
-	# 	)).insert()
-	#
-	# 	allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
-	#
-	# 	# this method will be called by scheduler
-	# 	allocate_earned_leaves(leave_type.name, leave_period, as_on = half_of_leave_period)
-	#
-	# 	self.assertEqual(get_leave_balance(employee, leave_period, leave_type.name), 6)
+	def test_earned_leave(self):
+		leave_period = get_leave_period()
+		employee = get_employee()
 
+		leave_type = frappe.get_doc(dict(
+			leave_type_name = 'Test Earned Leave Type',
+			doctype = 'Leave Type',
+			is_earned_leave = 1,
+			earned_leave_frequency = 'Monthly',
+			rounding = 0.5,
+			max_leaves_allowed = 6
+		)).insert()
+		leave_policy = frappe.get_doc({
+			"doctype": "Leave Policy",
+			"leave_policy_details": [{"leave_type": leave_type.name, "annual_allocation": 6}]
+		}).insert()
+		frappe.db.set_value("Employee", employee.name, "leave_policy", leave_policy.name)
+
+		allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
+
+		from erpnext.hr.utils import allocate_earned_leaves
+		i = 0
+		while(i<14):
+			allocate_earned_leaves()
+			i += 1
+		self.assertEqual(get_leave_balance_on(employee.name, leave_type.name, nowdate()), 6)
 
 def make_allocation_record(employee=None, leave_type=None):
 	frappe.db.sql("delete from `tabLeave Allocation`")
diff --git a/erpnext/hr/doctype/leave_encashment/leave_encashment.json b/erpnext/hr/doctype/leave_encashment/leave_encashment.json
index fff50c4..e9a99fa 100644
--- a/erpnext/hr/doctype/leave_encashment/leave_encashment.json
+++ b/erpnext/hr/doctype/leave_encashment/leave_encashment.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -42,11 +43,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -74,16 +76,17 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -107,48 +110,50 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.department",
-   "fieldname": "department",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Department",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Department",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "fetch_from": "employee.department", 
+   "fieldname": "department", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Department", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Department", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "leave_type", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -172,11 +177,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -202,11 +208,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -234,11 +241,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -265,11 +273,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -296,11 +305,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -327,11 +337,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -358,11 +369,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -389,11 +401,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -421,16 +434,17 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "additional_component", 
+   "fieldname": "additional_salary", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -439,10 +453,10 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Additional Salary Component", 
+   "label": "Additional Salary", 
    "length": 0, 
    "no_copy": 1, 
-   "options": "Additional Salary Component", 
+   "options": "Additional Salary", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -453,7 +467,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "translatable": 0,
+   "translatable": 0, 
    "unique": 0
   }
  ], 
@@ -467,7 +481,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 10:46:20.719555",
+ "modified": "2018-05-31 11:41:04.053874", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Leave Encashment", 
diff --git a/erpnext/hr/doctype/leave_encashment/leave_encashment.py b/erpnext/hr/doctype/leave_encashment/leave_encashment.py
index 24096ab..a61210c 100644
--- a/erpnext/hr/doctype/leave_encashment/leave_encashment.py
+++ b/erpnext/hr/doctype/leave_encashment/leave_encashment.py
@@ -26,25 +26,25 @@
 	def on_submit(self):
 		if not self.leave_allocation:
 			self.leave_allocation = self.get_leave_allocation()
-		additional_component = frappe.new_doc("Additional Salary Component")
-		additional_component.company = frappe.get_value("Employee", self.employee, "company")
-		additional_component.employee = self.employee
-		additional_component.salary_component = frappe.get_value("Leave Type", self.leave_type, "earning_component")
-		additional_component.from_date = self.encashment_date
-		additional_component.to_date = self.encashment_date
-		additional_component.amount = self.encashment_amount
-		additional_component.submit()
+		additional_salary = frappe.new_doc("Additional Salary")
+		additional_salary.company = frappe.get_value("Employee", self.employee, "company")
+		additional_salary.employee = self.employee
+		additional_salary.salary_component = frappe.get_value("Leave Type", self.leave_type, "earning_component")
+		additional_salary.from_date = self.encashment_date
+		additional_salary.to_date = self.encashment_date
+		additional_salary.amount = self.encashment_amount
+		additional_salary.submit()
 
-		self.db_set("additional_component", additional_component.name)
+		self.db_set("additional_salary", additional_salary.name)
 
 		# Set encashed leaves in Allocation
 		frappe.db.set_value("Leave Allocation", self.leave_allocation, "total_leaves_encashed",
 				frappe.db.get_value('Leave Allocation', self.leave_allocation, 'total_leaves_encashed') + self.encashable_days)
 
 	def on_cancel(self):
-		if self.additional_component:
-			frappe.get_doc("Additional Salary Component", self.additional_component).cancel()
-			self.db_set("additional_component", "")
+		if self.additional_salary:
+			frappe.get_doc("Additional Salary", self.additional_salary).cancel()
+			self.db_set("additional_salary", "")
 
 		if self.leave_allocation:
 			frappe.db.set_value("Leave Allocation", self.leave_allocation, "total_leaves_encashed",
diff --git a/erpnext/hr/doctype/leave_period/leave_period.json b/erpnext/hr/doctype/leave_period/leave_period.json
index 0f3cad4..91f97e7 100644
--- a/erpnext/hr/doctype/leave_period/leave_period.json
+++ b/erpnext/hr/doctype/leave_period/leave_period.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -41,10 +42,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -71,10 +74,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -100,10 +105,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -131,10 +138,12 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -161,10 +170,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -192,10 +203,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -222,10 +235,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -252,15 +267,17 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "employee_grade", 
+   "fieldname": "grade", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -283,10 +300,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -314,10 +333,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -345,10 +366,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -376,10 +399,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -406,10 +431,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -435,10 +462,12 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -465,6 +494,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }
  ], 
@@ -478,7 +508,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-07 18:25:06.719932", 
+ "modified": "2018-05-25 14:43:02.871669", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Leave Period", 
@@ -487,7 +517,6 @@
  "permissions": [
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
    "cancel": 0, 
    "create": 1, 
    "delete": 1, 
@@ -507,7 +536,6 @@
   }, 
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
    "cancel": 0, 
    "create": 1, 
    "delete": 1, 
@@ -527,7 +555,6 @@
   }, 
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
    "cancel": 0, 
    "create": 1, 
    "delete": 1, 
diff --git a/erpnext/hr/doctype/leave_period/leave_period.py b/erpnext/hr/doctype/leave_period/leave_period.py
index 4097169..39001ee 100644
--- a/erpnext/hr/doctype/leave_period/leave_period.py
+++ b/erpnext/hr/doctype/leave_period/leave_period.py
@@ -71,7 +71,8 @@
 		allocation.leave_type = leave_type
 		allocation.from_date = self.from_date
 		allocation.to_date = self.to_date
-		allocation.new_leaves_allocated = new_leaves_allocated
+		'''Earned Leaves are allocated by scheduler, initially allocate 0'''
+		allocation.new_leaves_allocated = new_leaves_allocated if not frappe.db.get_value("Leave Type", leave_type, "is_earned_leave") else 0
 		allocation.leave_period = self.name
 		if self.carry_forward_leaves:
 			if frappe.db.get_value("Leave Type", leave_type, "is_carry_forward"):
diff --git a/erpnext/hr/doctype/leave_type/leave_type.json b/erpnext/hr/doctype/leave_type/leave_type.json
index ef66a0a..8f7b5a8 100644
--- a/erpnext/hr/doctype/leave_type/leave_type.json
+++ b/erpnext/hr/doctype/leave_type/leave_type.json
@@ -584,7 +584,7 @@
    "default": "0.5",
    "depends_on": "is_earned_leave",
    "fieldname": "rounding",
-   "fieldtype": "Float",
+   "fieldtype": "Select",
    "hidden": 0,
    "ignore_user_permissions": 0,
    "ignore_xss_filter": 0,
@@ -595,6 +595,7 @@
    "label": "Rounding",
    "length": 0,
    "no_copy": 0,
+   "options": "0.5\n1.0",
    "permlevel": 0,
    "precision": "",
    "print_hide": 0,
@@ -620,7 +621,7 @@
  "issingle": 0,
  "istable": 0,
  "max_attachments": 0,
- "modified": "2018-05-08 18:32:51.803472",
+ "modified": "2018-06-03 18:32:51.803472",
  "modified_by": "Administrator",
  "module": "HR",
  "name": "Leave Type",
diff --git a/erpnext/hr/doctype/payroll_period/payroll_period.json b/erpnext/hr/doctype/payroll_period/payroll_period.json
index 44ead2b..d3a9612 100644
--- a/erpnext/hr/doctype/payroll_period/payroll_period.json
+++ b/erpnext/hr/doctype/payroll_period/payroll_period.json
@@ -15,6 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -47,6 +48,134 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "start_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Start Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "end_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "End Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_5", 
+   "fieldtype": "Section Break", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Payroll Periods", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -71,7 +200,72 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_7", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Taxable Salary Slabs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "taxable_salary_slabs", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Taxable Salary Slabs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Taxable Salary Slab", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
    "translatable": 0, 
@@ -88,7 +282,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-04-13 19:38:28.013664", 
+ "modified": "2018-05-25 12:29:07.207927", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Payroll Period", 
diff --git a/erpnext/hr/doctype/payroll_period/payroll_period.py b/erpnext/hr/doctype/payroll_period/payroll_period.py
index a818bc4..66d6a45 100644
--- a/erpnext/hr/doctype/payroll_period/payroll_period.py
+++ b/erpnext/hr/doctype/payroll_period/payroll_period.py
@@ -4,21 +4,54 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe.utils import date_diff, getdate
+from frappe import _
+from frappe.utils import date_diff, getdate, formatdate
 from frappe.model.document import Document
 
 class PayrollPeriod(Document):
-	pass
+	def validate(self):
+		self.validate_dates()
+		self.validate_overlap()
+
+	def validate_dates(self):
+		if getdate(self.start_date) > getdate(self.end_date):
+			frappe.throw(_("End date can not be less than start date"))
+
+	def validate_overlap(self):
+		query = """
+			select name
+			from `tab{0}`
+			where name != %(name)s
+			and company = %(company)s and (start_date between %(start_date)s and %(end_date)s \
+				or end_date between %(start_date)s and %(end_date)s \
+				or (start_date < %(start_date)s and end_date > %(end_date)s))
+			"""
+		if not self.name:
+			# hack! if name is null, it could cause problems with !=
+			self.name = "New "+self.doctype
+
+		overlap_doc = frappe.db.sql(query.format(self.doctype),{
+				"start_date": self.start_date,
+				"end_date": self.end_date,
+				"name": self.name,
+				"company": self.company
+			}, as_dict = 1)
+
+		if overlap_doc:
+			msg = _("A {0} exists between {1} and {2} (").format(self.doctype,
+				formatdate(self.start_date), formatdate(self.end_date)) \
+				+ """ <b><a href="#Form/{0}/{1}">{1}</a></b>""".format(self.doctype, overlap_doc[0].name) \
+				+ _(") for {0}").format(self.company)
+			frappe.throw(msg)
 
 def get_payroll_period_days(start_date, end_date, company):
 	payroll_period_dates = frappe.db.sql("""
-	select ppd.start_date, ppd.end_date from `tabPayroll Period Date` ppd, `tabPayroll Period` pp
-	where pp.company=%(company)s
-	and ppd.parent = pp.name
+	select start_date, end_date from `tabPayroll Period`
+	where company=%(company)s
 	and (
-		(%(start_date)s between ppd.start_date and ppd.end_date)
-		or (%(end_date)s between ppd.start_date and ppd.end_date)
-		or (ppd.start_date between %(start_date)s and %(end_date)s)
+		(%(start_date)s between start_date and end_date)
+		or (%(end_date)s between start_date and end_date)
+		or (start_date between %(start_date)s and %(end_date)s)
 	)""", {
 		'company': company,
 		'start_date': start_date,
diff --git a/erpnext/hr/doctype/salary_component/salary_component.js b/erpnext/hr/doctype/salary_component/salary_component.js
index e58a05e..0b8bd12 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.js
+++ b/erpnext/hr/doctype/salary_component/salary_component.js
@@ -14,7 +14,7 @@
 				}
 			};
 		});
-		frm.set_query("earning_component_group", function(frm) {
+		frm.set_query("earning_component_group", function() {
 			return {
 				filters: {
 					"is_group": 1,
@@ -22,5 +22,40 @@
 				}
 			};
 		});
+	},
+	is_flexible_benefit: function(frm) {
+		if(frm.doc.is_flexible_benefit){
+			set_value_for_condition_and_formula(frm);
+		}
+	},
+	type: function(frm) {
+		if(frm.doc.type=="Earning"){
+			frm.set_value("variable_based_on_taxable_salary", 0);
+		}
+		if(frm.doc.type=="Deduction"){
+			frm.set_value("is_flexible_benefit", 0);
+		}
+	},
+	variable_based_on_taxable_salary: function(frm) {
+		if(frm.doc.variable_based_on_taxable_salary){
+			set_value_for_condition_and_formula(frm);
+		}
+	},
+	create_separate_payment_entry_against_benefit_claim: function(frm) {
+		if(frm.doc.create_separate_payment_entry_against_benefit_claim){
+			frm.set_df_property("accounts", "reqd", 1);
+		}
+		else{
+			frm.set_df_property("accounts", "reqd", 0);
+		}
 	}
 });
+
+var set_value_for_condition_and_formula = function(frm) {
+	frm.set_value("formula", null);
+	frm.set_value("condition", null);
+	frm.set_value("amount_based_on_formula", 0);
+	frm.set_value("statistical_component", 0);
+	frm.set_value("do_not_include_in_total", 0);
+	frm.set_value("depends_on_lwp", 0);
+};
diff --git a/erpnext/hr/doctype/salary_component/salary_component.json b/erpnext/hr/doctype/salary_component/salary_component.json
index 6764e0c..f22bfc3 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.json
+++ b/erpnext/hr/doctype/salary_component/salary_component.json
@@ -14,6 +14,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -45,6 +46,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -78,6 +80,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -110,6 +113,106 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:doc.type == \"Earning\"", 
+   "fieldname": "is_additional_component", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Additional Component", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:doc.type == \"Earning\"", 
+   "fieldname": "is_tax_applicable", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Tax Applicable", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "1", 
+   "fieldname": "is_payable", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Payable", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -140,6 +243,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -171,6 +275,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -202,6 +307,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -234,6 +340,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -265,6 +372,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -297,6 +405,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -329,11 +438,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "depends_on": "eval:doc.is_flexible_benefit && !doc.is_group && !doc.flexi_default", 
+   "depends_on": "eval:doc.is_flexible_benefit && !doc.is_group", 
    "fieldname": "earning_component_group", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -362,6 +472,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -392,6 +503,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -424,38 +536,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:doc.is_flexible_benefit && doc.is_pro_rata_applicable", 
-   "fieldname": "flexi_default", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Default Flexible Component", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -488,10 +569,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "is_flexible_benefit", 
    "fieldname": "create_separate_payment_entry_against_benefit_claim", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -519,6 +602,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -550,6 +634,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -581,43 +666,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "depends_on": "variable_based_on_taxable_salary", 
-   "fieldname": "taxable_salary_slabs", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Taxable Salary Slabs", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Taxable Salary Slab", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
+   "depends_on": "eval:doc.is_payable == 1", 
    "fieldname": "section_break_5", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -645,6 +699,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -677,10 +732,13 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
+   "collapsible_depends_on": "", 
    "columns": 0, 
+   "depends_on": "eval:doc.is_flexible_benefit != 1 && doc.variable_based_on_taxable_salary != 1", 
    "fieldname": "condition_and_formula", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -708,6 +766,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -739,6 +798,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -771,6 +831,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -802,6 +863,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -833,6 +895,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -865,6 +928,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -897,6 +961,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -929,6 +994,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -959,6 +1025,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1001,7 +1068,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-16 12:27:03.005070", 
+ "modified": "2018-05-25 12:28:03.454487", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Component", 
@@ -1036,4 +1103,4 @@
  "sort_order": "DESC", 
  "track_changes": 0, 
  "track_seen": 0
-}
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_component/salary_component.py b/erpnext/hr/doctype/salary_component/salary_component.py
index 132930f..7c92631 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.py
+++ b/erpnext/hr/doctype/salary_component/salary_component.py
@@ -3,28 +3,12 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
-from frappe import _
 from frappe.model.document import Document
 from frappe.model.naming import append_number_if_name_exists
 
 class SalaryComponent(Document):
 	def validate(self):
 		self.validate_abbr()
-		self.validate_flexi_default()
-
-	def validate_flexi_default(self):
-		if self.is_flexible_benefit and self.is_pro_rata_applicable and self.flexi_default:
-			salary_component = frappe.db.exists(
-				'Salary Component',
-				{
-					'is_flexible_benefit': 1,
-					'is_pro_rata_applicable': 1,
-					'flexi_default': 1
-				}
-			)
-			if salary_component and salary_component != self.name:
-				frappe.throw(_("{0} is already marked as default flexible component").format(salary_component))
 
 	def validate_abbr(self):
 		if not self.salary_component_abbr:
@@ -34,12 +18,3 @@
 		self.salary_component_abbr = self.salary_component_abbr.strip()
 		self.salary_component_abbr = append_number_if_name_exists('Salary Component', self.salary_component_abbr,
 			'salary_component_abbr', separator='_', filters={"name": ["!=", self.name]})
-
-	def calculate_tax(self, annual_earning):
-		taxable_amount = 0
-		for slab in self.taxable_salary_slabs:
-			if annual_earning > slab.from_amount and annual_earning < slab.to_amount:
-				taxable_amount += (annual_earning - slab.from_amount) * slab.percent_deduction *.01
-			elif annual_earning > slab.from_amount and annual_earning > slab.to_amount:
-				taxable_amount += (slab.to_amount - slab.from_amount) * slab.percent_deduction * .01
-		return taxable_amount
diff --git a/erpnext/hr/doctype/salary_detail/salary_detail.json b/erpnext/hr/doctype/salary_detail/salary_detail.json
index 82b0af2..a0d699a 100644
--- a/erpnext/hr/doctype/salary_detail/salary_detail.json
+++ b/erpnext/hr/doctype/salary_detail/salary_detail.json
@@ -238,6 +238,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:doc.is_flexible_benefit != 1", 
    "fieldname": "section_break_2", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -566,7 +567,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2018-05-17 12:43:22.606298",
+ "modified": "2018-05-22 15:11:02.341840", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Detail", 
@@ -581,4 +582,4 @@
  "sort_order": "DESC", 
  "track_changes": 0, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index e19f722..15a4653 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -14,6 +14,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -46,6 +47,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -79,11 +81,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.employee_name",
+   "fetch_from": "employee.employee_name", 
    "fieldname": "employee_name", 
    "fieldtype": "Read Only", 
    "hidden": 0, 
@@ -113,11 +116,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.department",
+   "fetch_from": "employee.department", 
    "fieldname": "department", 
    "fieldtype": "Link",
    "hidden": 0, 
@@ -132,7 +136,7 @@
    "no_copy": 0, 
    "oldfieldname": "department", 
    "oldfieldtype": "Link", 
-   "options": "Department",
+   "options": "Department", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -147,12 +151,13 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.designation", 
-   "fetch_from": "employee.designation",
+   "fetch_from": "employee.designation", 
    "fieldname": "designation", 
    "fieldtype": "Read Only", 
    "hidden": 0, 
@@ -182,11 +187,12 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fetch_from": "employee.branch",
+   "fetch_from": "employee.branch", 
    "fieldname": "branch", 
    "fieldtype": "Read Only", 
    "hidden": 0, 
@@ -216,6 +222,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -247,6 +254,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -279,6 +287,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -311,6 +320,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -342,6 +352,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
@@ -373,6 +384,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -403,6 +415,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -436,6 +449,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -468,6 +482,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -501,6 +516,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -531,6 +547,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -564,6 +581,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -598,6 +616,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -631,6 +650,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -664,6 +684,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -697,6 +718,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -729,6 +751,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -762,6 +785,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -792,6 +816,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -823,6 +848,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -855,6 +881,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -887,6 +914,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -919,6 +947,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -951,6 +980,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -981,6 +1011,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1014,6 +1045,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1044,6 +1076,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1075,6 +1108,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1106,6 +1140,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1137,6 +1172,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1169,6 +1205,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1203,6 +1240,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1235,6 +1273,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1268,6 +1307,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1299,6 +1339,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1332,6 +1373,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1361,6 +1403,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1394,6 +1437,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1426,6 +1470,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1458,6 +1503,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1488,6 +1534,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1521,6 +1568,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1554,6 +1602,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1584,6 +1633,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1617,6 +1667,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1648,6 +1699,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1682,6 +1734,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1712,6 +1765,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -1743,6 +1797,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1773,6 +1828,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1816,7 +1872,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-17 10:30:09.007581",
+ "modified": "2018-05-25 12:33:27.147636", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Slip", 
@@ -1890,4 +1946,4 @@
  "title_field": "employee_name", 
  "track_changes": 0, 
  "track_seen": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 87511b6..ace9628 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -12,11 +12,10 @@
 from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee
 from erpnext.utilities.transaction_base import TransactionBase
 from frappe.utils.background_jobs import enqueue
-from erpnext.hr.doctype.additional_salary_component.additional_salary_component import get_additional_salary_component
-from erpnext.hr.doctype.employee_benefit_application.employee_benefit_application import get_employee_benefit_application, get_amount
-from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
-from erpnext.hr.doctype.employee_benefit_claim.employee_benefit_claim import get_employee_benefit_claim
+from erpnext.hr.doctype.additional_salary.additional_salary import get_additional_salary_component
 from erpnext.hr.utils import get_payroll_period
+from erpnext.hr.doctype.employee_benefit_application.employee_benefit_application import get_benefit_component_amount
+from erpnext.hr.doctype.employee_benefit_claim.employee_benefit_claim import get_benefit_claim_amount
 
 class SalarySlip(TransactionBase):
 	def autoname(self):
@@ -62,8 +61,12 @@
 				amount = self.eval_condition_and_formula(struct_row, data)
 				if amount and struct_row.statistical_component == 0:
 					self.update_component_row(struct_row, amount, key)
+
+				if key=="earnings" and struct_row.is_flexible_benefit == 1:
+					self.add_employee_flexi_benefits(struct_row)
+
 				if key=="deductions" and struct_row.variable_based_on_taxable_salary:
-					tax_row, amount = self.calculate_pro_rata_tax(struct_row.salary_component)
+					tax_row, amount = self.calculate_variable_based_on_taxable_salary(struct_row.salary_component)
 					if tax_row and amount:
 						self.update_component_row(frappe._dict(tax_row), amount, key)
 
@@ -71,58 +74,26 @@
 		if additional_components:
 			for additional_component in additional_components:
 				additional_component = frappe._dict(additional_component)
-				amount = self.update_amount_for_other_component(frappe._dict(additional_component.struct_row).salary_component, additional_component.amount)
+				amount = additional_component.amount + self.get_amount_from_exisiting_component(frappe._dict(additional_component.struct_row).salary_component)
 				self.update_component_row(frappe._dict(additional_component.struct_row), amount, "earnings")
 
-		max_benefits = self._salary_structure_doc.get("max_benefits")
-		if max_benefits > 0:
-			employee_benefits = get_employee_benefit_application(self)
-			if employee_benefits:
-				for employee_benefit in employee_benefits:
-					benefit_component = frappe._dict(employee_benefit)
-					amount = self.update_amount_for_other_component(frappe._dict(benefit_component.struct_row).salary_component, benefit_component.amount)
-					self.update_component_row(frappe._dict(benefit_component.struct_row), amount, "earnings")
-			else:
-				default_flexi_compenent = frappe.db.exists(
-					'Salary Component',
-					{
-						'is_flexible_benefit': 1,
-						'is_pro_rata_applicable': 1,
-						'flexi_default': 1
-					}
-				)
-				if default_flexi_compenent:
-					flexi_struct_row = self.create_flexi_struct_row(default_flexi_compenent)
-					payroll_period_days = get_payroll_period_days(self.start_date, self.end_date, self.company)
-					amount = self.update_amount_for_other_component(default_flexi_compenent, get_amount(payroll_period_days, self.start_date, self.end_date, max_benefits))
-					self.update_component_row(flexi_struct_row, amount, "earnings")
-				else:
-					frappe.throw(_("Configure default flexible benefit salary component for apply pro-rata benefit"))
+	def add_employee_flexi_benefits(self, struct_row):
+		if frappe.db.get_value("Salary Component", struct_row.salary_component, "is_pro_rata_applicable") == 1:
+			benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, struct_row, self._salary_structure_doc)
+			if benefit_component_amount:
+				self.update_component_row(struct_row, benefit_component_amount, "earnings")
+		else:
+			benefit_claim_amount = get_benefit_claim_amount(self.employee, self.start_date, self.end_date, struct_row)
+			if benefit_claim_amount:
+				self.update_component_row(struct_row, benefit_claim_amount, "earnings")
 
-			benefit_claims = get_employee_benefit_claim(self)
-			if benefit_claims:
-				for benefit_claim in benefit_claims:
-					benefit_component = frappe._dict(benefit_claim)
-					amount = self.update_amount_for_other_component(frappe._dict(benefit_component.struct_row).salary_component, benefit_component.amount)
-					self.update_component_row(frappe._dict(benefit_component.struct_row), amount, "earnings")
-
-	def update_amount_for_other_component(self, salary_component, new_amount):
-		amount = new_amount
+	def get_amount_from_exisiting_component(self, salary_component):
+		amount = 0
 		for d in self.get("earnings"):
 			if d.salary_component == salary_component:
-				d.amount += new_amount
 				amount = d.amount
 		return amount
 
-	def create_flexi_struct_row(self, default_flexi_compenent):
-		salary_component = frappe.get_doc("Salary Component", default_flexi_compenent)
-		flexi_struct_row = {}
-		flexi_struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
-		flexi_struct_row['salary_component'] = salary_component.name
-		flexi_struct_row['abbr'] = salary_component.salary_component_abbr
-		flexi_struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
-		return frappe._dict(flexi_struct_row)
-
 	def update_component_row(self, struct_row, amount, key):
 		component_row = None
 		for d in self.get(key):
@@ -523,51 +494,171 @@
 			status = "Cancelled"
 		return status
 
-	def calculate_pro_rata_tax(self, salary_component):
-		# Calculate total tax payable earnings
-		tax_applicable_components = []
-		for earning in self._salary_structure_doc.earnings:
-			#all tax applicable earnings which are not flexi
-			if earning.is_tax_applicable and not earning.is_flexible_benefit:
-				tax_applicable_components.append(earning.salary_component)
-		total_taxable_earning = 0
-		for earning in self.earnings:
-			if earning.salary_component in tax_applicable_components:
-				total_taxable_earning += earning.amount
-
-		# Get payroll period, prorata frequency
-		days = date_diff(self.end_date, self.start_date) + 1
+	def calculate_variable_based_on_taxable_salary(self, tax_component):
+		# TODO case both checked - restrict to and make this mandatory on final period of payroll?
+		# case only deduct_tax_for_unsubmitted_tax_exemption_proof checked not handled, calculate_variable_tax called
 		payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
 		if not payroll_period:
-			frappe.throw(_("Start and end dates not in a valid Payroll Period"))
-		total_days = date_diff(payroll_period.end_date, payroll_period.start_date) + 1
-		prorata_frequency = flt(total_days)/flt(days)
-		annual_earning = total_taxable_earning * prorata_frequency
+			frappe.msgprint(_("Start and end dates not in a valid Payroll Period, \
+			cannot calculate {0}.").format(tax_component))
+			return
+		if self.deduct_tax_for_unclaimed_employee_benefits and not self.deduct_tax_for_unsubmitted_tax_exemption_proof:
+			total_taxable_benefit = self.calculate_unclaimed_benefit_amount(payroll_period)
+			total_taxable_benefit += self.get_taxable_earnings(only_flexi=True)
+			return self.calculate_variable_tax(tax_component, payroll_period, benefit_amount=total_taxable_benefit)
+		elif self.deduct_tax_for_unclaimed_employee_benefits and self.deduct_tax_for_unsubmitted_tax_exemption_proof:
+			return self.calculate_tax_for_payroll_period(tax_component, payroll_period)
+		else:
+			return self.calculate_variable_tax(tax_component, payroll_period)
+
+	def calculate_variable_tax(self, tax_component, payroll_period, benefit_amount=0):
+		total_taxable_earning = self.get_taxable_earnings()
+		period_factor = self.get_period_factor(payroll_period.start_date, payroll_period.end_date)
+		annual_earning = total_taxable_earning * period_factor
 
 		# Calculate total exemption declaration
 		exemption_amount = 0
 		if frappe.db.exists("Employee Tax Exemption Declaration", {"employee": self.employee,
 		"payroll_period": payroll_period.name, "docstatus": 1}):
 			exemption_amount = frappe.db.get_value("Employee Tax Exemption Declaration",
-				{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1}, #fix period
+				{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1},
 				"total_exemption_amount")
-		annual_earning = annual_earning - exemption_amount
+		annual_taxable_earning = annual_earning - exemption_amount
 
-		# Get tax calc by component
-		component = frappe.get_doc("Salary Component", salary_component)
-		annual_tax = component.calculate_tax(annual_earning)
+		# Get tax calc by period
+		annual_tax = self.calculate_tax(payroll_period.name, annual_taxable_earning)
 
 		# Calc prorata tax
-		pro_rata_tax = annual_tax/prorata_frequency
+		pro_rata_tax = annual_tax / period_factor
+		struct_row = self.get_salary_slip_row(tax_component)
 
+		# find the annual tax diff caused by benefit, add to pro_rata_tax
+		if benefit_amount > 0:
+			annual_tax_with_benefit = self.calculate_tax(payroll_period.name, annual_taxable_earning + benefit_amount)
+			pro_rata_tax += annual_tax_with_benefit - annual_tax
+		return struct_row, pro_rata_tax
+
+	def calculate_tax_for_payroll_period(self, tax_component, payroll_period):
+		# get total taxable income, total tax paid in payroll period
+		taxable_income, tax_paid = self.get_tax_detail_till_date(payroll_period, tax_component)
+		total_tax_exemption_proof = 0
+		if self.deduct_tax_for_unsubmitted_tax_exemption_proof:
+			sum_exemption_proof = frappe.db.sql("""select sum(total_amount) from
+			`tabEmployee Tax Exemption Proof Submission` where payroll_period='{0}' and docstatus=1
+			and employee='{1}'""".format(payroll_period.name, self.employee))
+			if sum_exemption_proof and sum_exemption_proof[0][0]:
+				total_tax_exemption_proof = sum_exemption_proof[0][0]
+		total_benefit_claim = 0
+		if self.deduct_tax_for_unclaimed_employee_benefits:
+			sum_benefit_claim = frappe.db.sql("""select sum(claimed_amount) from
+			`tabEmployee Benefit Claim` where docstatus=1 and employee='{0}' and claim_date between
+			'{1}' and '{2}'""".format(self.employee, payroll_period.start_date, self.end_date))
+			if sum_benefit_claim and sum_benefit_claim[0][0]:
+				total_benefit_claim = sum_benefit_claim[0][0]
+		total_taxable_earning = taxable_income - total_tax_exemption_proof - total_benefit_claim
+		# add taxable earnings of current salary_slip, include flexi
+		total_taxable_earning += self.get_taxable_earnings(include_flexi=1)
+		# calc annual tax by tax slab
+		annual_tax = self.calculate_tax(payroll_period.name, total_taxable_earning)
+		# get balance amount to tax, even if -ve add to deduction
+		pay_slip_tax = annual_tax - tax_paid
+		struct_row = self.get_salary_slip_row(tax_component)
+		return struct_row, pay_slip_tax
+
+	def calculate_unclaimed_benefit_amount(self, payroll_period):
+		total_benefit = 0
+		start_date = payroll_period.start_date
+		# if tax for unclaimed benefit deducted earlier set the start date
+		last_deducted =	frappe.db.sql("""select end_date from `tabSalary Slip` where
+				deduct_tax_for_unclaimed_employee_benefits=1 and docstatus=1 and
+				employee='{0}' and start_date between '{1}' and '{2}' and end_date
+				between '{1}' and '{2}' order by end_date desc limit 1""".format(
+				self.employee, payroll_period.start_date, payroll_period.end_date))
+		if last_deducted and last_deducted[0][0]:
+			start_date = getdate(last_deducted[0][0])
+		sum_benefit = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join
+					`tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='earnings'
+					and sd.is_tax_applicable=1 and is_flexible_benefit=1 and ss.docstatus=1
+					and ss.employee='{0}' and ss.start_date between '{1}' and '{2}' and
+					ss.end_date between '{1}' and '{2}'""".format(self.employee,
+					start_date, payroll_period.end_date))
+		if sum_benefit and sum_benefit[0][0]:
+			total_benefit = sum_benefit[0][0]
+		total_benefit_claim = 0
+		sum_benefit_claim = frappe.db.sql("""select sum(claimed_amount) from
+		`tabEmployee Benefit Claim` where docstatus=1 and employee='{0}' and claim_date
+		between '{1}' and '{2}'""".format(self.employee, start_date, self.end_date))
+		if sum_benefit_claim and sum_benefit_claim[0][0]:
+			total_benefit_claim = sum_benefit_claim[0][0]
+		return total_benefit - total_benefit_claim
+
+	def get_taxable_earnings(self, include_flexi=0, only_flexi=0):
+		# TODO remove this, iterate in self.earnings. map_doc fails to copy field values from Salary Structure to Slary Slip
+		tax_applicable_components = []
+		for earning in self._salary_structure_doc.earnings:
+			if only_flexi:
+				if earning.is_tax_applicable and earning.is_flexible_benefit:
+					tax_applicable_components.append(earning.salary_component)
+				continue
+			if include_flexi:
+				if earning.is_tax_applicable or (earning.is_tax_applicable and earning.is_flexible_benefit):
+					tax_applicable_components.append(earning.salary_component)
+			else:
+				if earning.is_tax_applicable and not earning.is_flexible_benefit:
+					tax_applicable_components.append(earning.salary_component)
+
+		taxable_earning = 0
+		for earning in self.earnings:
+			if earning.salary_component in tax_applicable_components:
+				taxable_earning += earning.amount
+		return taxable_earning
+
+	def calculate_tax(self, payroll_period, annual_earning):
+		payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
+		taxable_amount = 0
+		for slab in payroll_period_obj.taxable_salary_slabs:
+			if annual_earning > slab.from_amount and annual_earning < slab.to_amount:
+				taxable_amount += (annual_earning - slab.from_amount) * slab.percent_deduction *.01
+			elif annual_earning > slab.from_amount and annual_earning > slab.to_amount:
+				taxable_amount += (slab.to_amount - slab.from_amount) * slab.percent_deduction * .01
+		return taxable_amount
+
+	def get_period_factor(self, start_date, end_date):
+		# period length is hard coded to keep tax calc consistent
+		frequency_days = {"Daily": 1, "Weekly": 7, "Fortnightly": 15, "Monthly": 30, "Bimonthly": 60}
+		payroll_days = date_diff(end_date, start_date) + 1
+		return flt(payroll_days)/frequency_days[self.payroll_frequency]
+
+	def get_tax_detail_till_date(self, payroll_period, tax_component):
+		total_taxable_income = 0
+		total_tax_paid = 0
+		sum_income = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join
+					`tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='earnings'
+					and sd.is_tax_applicable=1 and ss.docstatus=1 and ss.employee='{0}' and
+					ss.start_date between '{1}' and '{2}' and ss.end_date between '{1}' and
+					'{2}'""".format(self.employee, payroll_period.start_date,
+							payroll_period.end_date))
+		if sum_income and sum_income[0][0]:
+			total_taxable_income = sum_income[0][0]
+		sum_tax_paid = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join
+					`tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='deductions'
+					and sd.salary_component='{0}' and sd.variable_based_on_taxable_salary=1 and
+					ss.docstatus=1 and ss.employee='{1}' and ss.start_date between '{2}' and
+					'{3}' and ss.end_date between '{2}' and '{3}'""".format(tax_component,
+					self.employee, payroll_period.start_date, payroll_period.end_date))
+		if sum_tax_paid and sum_tax_paid[0][0]:
+			total_tax_paid = sum_tax_paid[0][0]
+		return total_taxable_income, total_tax_paid
+
+	def get_salary_slip_row(self, salary_component):
+		component = frappe.get_doc("Salary Component", salary_component)
 		# Data for update_component_row
 		struct_row = {}
-		struct_row['depends_on_lwp'] = 0
+		struct_row['depends_on_lwp'] = component.depends_on_lwp
 		struct_row['salary_component'] = component.name
 		struct_row['abbr'] = component.salary_component_abbr
-		struct_row['do_not_include_in_total'] = 0
-
-		return struct_row, pro_rata_tax
+		struct_row['do_not_include_in_total'] = component.do_not_include_in_total
+		return struct_row
 
 def unlink_ref_doc_from_salary_slip(ref_no):
 	linked_ss = frappe.db.sql_list("""select name from `tabSalary Slip`
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js
index 9e62b66..56f5992 100755
--- a/erpnext/hr/doctype/salary_structure/salary_structure.js
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.js
@@ -19,7 +19,9 @@
 		frm.set_query("salary_component", "earnings", function() {
 			return {
 				filters: {
-					type: "earning"
+					type: "earning",
+					is_additional_component: 0,
+					is_group: 0
 				}
 			}
 		});
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 23c57de..12e3445 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -13,6 +13,7 @@
 	def validate(self):
 		self.validate_amount()
 		self.strip_condition_and_formula_fields()
+		self.validate_max_benefits_with_flexi()
 
 	def validate_amount(self):
 		if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet:
@@ -28,11 +29,29 @@
 			row.condition = row.condition.strip() if row.condition else ""
 			row.formula = row.formula.strip() if row.formula else ""
 
+	def validate_max_benefits_with_flexi(self):
+		have_a_flexi = False
+		if self.earnings:
+			flexi_amount = 0
+			for earning_component in self.earnings:
+				if earning_component.is_flexible_benefit == 1:
+					have_a_flexi = True
+					max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
+					flexi_amount += max_of_component
+			if have_a_flexi and self.max_benefits == 0:
+				frappe.throw(_("Max benefits should be greater than zero to despense flexi"))
+			if self.max_benefits > flexi_amount:
+				frappe.throw(_("Total flexi component amount {0} should not be less \
+				than max benefits {1}").format(flexi_amount, self.max_benefits))
+		if not have_a_flexi and self.max_benefits > 0:
+			frappe.throw(_("Flexi component require to add max benefit"))
+
+
 @frappe.whitelist()
 def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None):
 	def postprocess(source, target):
 		if employee:
-			employee_details = frappe.db.get_value("Employee", employee, 
+			employee_details = frappe.db.get_value("Employee", employee,
 				["employee_name", "branch", "designation", "department"], as_dict=1)
 			target.employee = employee
 			target.employee_name = employee_details.employee_name
@@ -62,4 +81,4 @@
 def get_employees(salary_structure):
 	employees = frappe.get_list('Salary Structure Assignment',
 		filters={'salary_structure': salary_structure}, fields=['employee'])
-	return list(set([d.employee for d in employees]))
\ No newline at end of file
+	return list(set([d.employee for d in employees]))
diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py
index cbc3738..01c9784 100644
--- a/erpnext/hr/utils.py
+++ b/erpnext/hr/utils.py
@@ -127,17 +127,6 @@
 	else:
 		return False
 
-def update_employee(employee, details, cancel=False):
-	for item in details:
-		fieldtype = frappe.get_meta("Employee").get_field(item.fieldname).fieldtype
-		new_data = item.new if not cancel else item.current
-		if fieldtype == "Date" and new_data:
-			new_data = getdate(new_data)
-		elif fieldtype =="Datetime" and new_data:
-			new_data = get_datetime(new_data)
-		setattr(employee, item.fieldname, new_data)
-	return employee
-
 def validate_dates(doc, from_date, to_date):
 	date_of_joining, relieving_date = frappe.db.get_value("Employee", doc.employee, ["date_of_joining", "relieving_date"])
 	if getdate(from_date) > getdate(to_date):
@@ -237,12 +226,59 @@
 		return leave_period
 
 def get_payroll_period(from_date, to_date, company):
-	payroll_period = frappe.db.sql("""select pp.name, pd.start_date, pd.end_date from
-		`tabPayroll Period Date` pd join `tabPayroll Period` pp on
-		pd.parent=pp.name where pd.start_date<=%s and pd.end_date>= %s
-		and pp.company=%s""", (from_date, to_date, company), as_dict=1)
+	payroll_period = frappe.db.sql("""select name, start_date, end_date from
+		`tabPayroll Period`
+		where start_date<=%s and end_date>= %s and company=%s""", (from_date, to_date, company), as_dict=1)
 	return payroll_period[0] if payroll_period else None
 
+def allocate_earned_leaves():
+	'''Allocate earned leaves to Employees'''
+	e_leave_types = frappe.get_all("Leave Type",
+		fields=["name", "max_leaves_allowed", "earned_leave_frequency", "rounding"],
+		filters={'is_earned_leave' : 1})
+	today = getdate()
+	divide_by_frequency = {"Yearly": 1, "Quarterly": 4, "Monthly": 12}
+	if e_leave_types:
+		for e_leave_type in e_leave_types:
+			leave_allocations = frappe.db.sql("""select name, employee, from_date, to_date from `tabLeave Allocation` where '{0}'
+				between from_date and to_date and docstatus=1 and leave_type='{1}'"""
+				.format(today, e_leave_type.name), as_dict=1)
+			for allocation in leave_allocations:
+				leave_policy = get_employee_leave_policy(allocation.employee)
+				if not leave_policy:
+					continue
+				if not e_leave_type.earned_leave_frequency == "Monthly":
+					if not check_frequency_hit(allocation.from_date, today, e_leave_type.earned_leave_frequency):
+						continue
+				annual_allocation = frappe.db.sql("""select annual_allocation from `tabLeave Policy Detail`
+					where parent=%s and leave_type=%s""", (leave_policy.name, e_leave_type.name))
+				if annual_allocation and annual_allocation[0]:
+					earned_leaves = flt(annual_allocation[0][0]) / divide_by_frequency[e_leave_type.earned_leave_frequency]
+					if e_leave_type.rounding == "0.5":
+						earned_leaves = round(earned_leaves * 2) / 2
+					else:
+						earned_leaves = round(earned_leaves)
+
+					allocated_leaves = frappe.db.get_value('Leave Allocation', allocation.name, 'total_leaves_allocated')
+					new_allocation = flt(allocated_leaves) + flt(earned_leaves)
+					new_allocation = new_allocation if new_allocation <= e_leave_type.max_leaves_allowed else e_leave_type.max_leaves_allowed
+					frappe.db.set_value('Leave Allocation', allocation.name, 'total_leaves_allocated', new_allocation)
+
+def check_frequency_hit(from_date, to_date, frequency):
+	'''Return True if current date matches frequency'''
+	from_dt = get_datetime(from_date)
+	to_dt = get_datetime(to_date)
+	from dateutil import relativedelta
+	rd = relativedelta.relativedelta(to_dt, from_dt)
+	months = rd.months
+	if frequency == "Quarterly":
+		if not months % 3:
+			return True
+	elif frequency == "Yearly":
+		if not months % 12:
+			return True
+	return False
+
 def get_salary_assignment(employee, date):
 	assignment = frappe.db.sql("""
 		select * from `tabSalary Structure Assignment`
@@ -307,4 +343,4 @@
 	elif frequency == "Monthly":
 		return amount * 12
 	elif frequency == "Bimonthly":
-		return amount * 6
+		return amount * 6
\ No newline at end of file
diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js
index 64d20b8..29d870b 100644
--- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js
+++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.js
@@ -6,8 +6,7 @@
 			}));
 
 		frm.trigger("enabled");
-		frm.add_custom_button(__('View Hub'),
-			() => frappe.set_route('Hub', 'Item'));
+
 		if (frm.doc.enabled) {
 			frm.add_custom_button(__('Sync'),
 				() => frm.call('sync'));
diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
index 0c0c870..461b9ab 100644
--- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
+++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
@@ -1,539 +1,585 @@
 {
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2014-11-27 14:12:07.542534",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Document",
- "editable_grid": 0,
- "engine": "InnoDB",
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2014-11-27 14:12:07.542534", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Document", 
+ "editable_grid": 0, 
+ "engine": "InnoDB", 
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "capacity_planning",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Capacity Planning",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "capacity_planning", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Capacity Planning", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Disables creation of time logs against Work Orders. Operations shall not be tracked against Work Order",
-   "fieldname": "disable_capacity_planning",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Disable Capacity Planning and Time Tracking",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Disables creation of time logs against Work Orders. Operations shall not be tracked against Work Order", 
+   "fieldname": "disable_capacity_planning", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Disable Capacity Planning and Time Tracking", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Plan time logs outside Workstation Working Hours.",
-   "fieldname": "allow_overtime",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Allow Overtime",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Plan time logs outside Workstation Working Hours.", 
+   "fieldname": "allow_overtime", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Allow Overtime", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "",
-   "fieldname": "allow_production_on_holidays",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Allow Production on Holidays",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "fieldname": "allow_production_on_holidays", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Allow Production on Holidays", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "column_break_3",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_3", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "30",
-   "description": "Try planning operations for X days in advance.",
-   "fieldname": "capacity_planning_for_days",
-   "fieldtype": "Int",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Capacity Planning For (Days)",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "30", 
+   "description": "Try planning operations for X days in advance.", 
+   "fieldname": "capacity_planning_for_days", 
+   "fieldtype": "Int", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Capacity Planning For (Days)", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Default 10 mins",
-   "fieldname": "mins_between_operations",
-   "fieldtype": "Int",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Time Between Operations (in mins)",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Default 10 mins", 
+   "fieldname": "mins_between_operations", 
+   "fieldtype": "Int", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Time Between Operations (in mins)", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "section_break_6",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_6", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "over_production_allowance_percentage",
-   "fieldtype": "Percent",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Over Production Allowance Percentage",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "overproduction_percentage_for_sales_order", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Overproduction Percentage For Sales Order", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "BOM",
-   "fieldname": "backflush_raw_materials_based_on",
-   "fieldtype": "Select",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Backflush Raw Materials Based On",
-   "length": 0,
-   "no_copy": 0,
-   "options": "BOM\nMaterial Transferred for Manufacture",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "overproduction_percentage_for_work_order", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Overproduction Percentage For Work Order", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Allow multiple Material Consumption against a Work Order",
-   "fieldname": "material_consumption",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Allow Multiple Material Consumption",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "BOM", 
+   "fieldname": "backflush_raw_materials_based_on", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Backflush Raw Materials Based On", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "BOM\nMaterial Transferred for Manufacture", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Update BOM cost automatically via Scheduler, based on latest valuation rate / price list rate / last purchase rate of raw materials.",
-   "fieldname": "update_bom_costs_automatically",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Update BOM Cost Automatically",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Allow multiple Material Consumption against a Work Order", 
+   "fieldname": "material_consumption", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Allow Multiple Material Consumption", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "column_break_11",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Update BOM cost automatically via Scheduler, based on latest valuation rate / price list rate / last purchase rate of raw materials.", 
+   "fieldname": "update_bom_costs_automatically", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Update BOM Cost Automatically", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "default_wip_warehouse",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Default Work In Progress Warehouse",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Warehouse",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_11", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "default_fg_warehouse",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Default Finished Goods Warehouse",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Warehouse",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "default_wip_warehouse", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Default Work In Progress Warehouse", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Warehouse", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "default_fg_warehouse", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Default Finished Goods Warehouse", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Warehouse", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "icon-wrench",
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 1,
- "istable": 0,
- "max_attachments": 0,
- "menu_index": 0,
- "modified": "2018-03-28 13:56:31.187520",
- "modified_by": "Administrator",
- "module": "Manufacturing",
- "name": "Manufacturing Settings",
- "name_case": "",
- "owner": "Administrator",
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "icon": "icon-wrench", 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 1, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "menu_index": 0, 
+ "modified": "2018-05-28 00:46:25.310621", 
+ "modified_by": "Administrator", 
+ "module": "Manufacturing", 
+ "name": "Manufacturing Settings", 
+ "name_case": "", 
+ "owner": "Administrator", 
  "permissions": [
   {
-   "amend": 0,
-   "apply_user_permissions": 0,
-   "cancel": 0,
-   "create": 1,
-   "delete": 0,
-   "email": 0,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 0,
-   "read": 1,
-   "report": 0,
-   "role": "Manufacturing Manager",
-   "set_user_permissions": 0,
-   "share": 1,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 0, 
+   "email": 0, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 0, 
+   "read": 1, 
+   "report": 0, 
+   "role": "Manufacturing Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
    "write": 1
   }
- ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "track_changes": 1,
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index a9c1491..672ec26 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -158,15 +158,15 @@
 			added_min = 0.5;
 		}
 		message = title;
-
 		// pending qty
 		if(!frm.doc.skip_transfer){
 			var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
 			if(pending_complete) {
 				var title = __('{0} items in progress', [pending_complete]);
+				var width = ((pending_complete / frm.doc.qty * 100) - added_min);
 				bars.push({
 					'title': title,
-					'width': ((pending_complete / frm.doc.qty * 100) - added_min)  + '%',
+					'width': (width > 100 ? "99.5" : width)  + '%',
 					'progress_class': 'progress-bar-warning'
 				})
 				message = message + '. ' + title;
@@ -356,7 +356,7 @@
 							erpnext.work_order.make_se(frm, 'Manufacture');
 						});
 
-						if(doc.material_transferred_for_manufacturing==doc.qty) {
+						if(doc.material_transferred_for_manufacturing>=doc.qty) {
 							// all materials transferred for manufacturing, make this primary
 							finish_btn.addClass('btn-primary');
 						}
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 1cb215a..d10fd21 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -133,7 +133,7 @@
 		so_qty = flt(so_item_qty) + flt(dnpi_qty)
 
 		allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
-			"over_production_allowance_percentage"))
+			"overproduction_percentage_for_sales_order"))
 
 		if total_qty > so_qty + (allowance_percentage/100 * so_qty):
 			frappe.throw(_("Cannot produce more Item {0} than Sales Order quantity {1}")
@@ -168,7 +168,7 @@
 				if stock_entries:
 					status = "In Process"
 					produced_qty = stock_entries.get("Manufacture")
-					if flt(produced_qty) == flt(self.qty):
+					if flt(produced_qty) >= flt(self.qty):
 						status = "Completed"
 		else:
 			status = 'Cancelled'
@@ -179,15 +179,20 @@
 		"""Update **Manufactured Qty** and **Material Transferred for Qty** in Work Order
 			based on Stock Entry"""
 
+		allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
+			"overproduction_percentage_for_work_order"))
+
 		for purpose, fieldname in (("Manufacture", "produced_qty"),
 			("Material Transfer for Manufacture", "material_transferred_for_manufacturing")):
+
 			qty = flt(frappe.db.sql("""select sum(fg_completed_qty)
 				from `tabStock Entry` where work_order=%s and docstatus=1
 				and purpose=%s""", (self.name, purpose))[0][0])
 
-			if qty > self.qty:
+			completed_qty = self.qty + (allowance_percentage/100 * self.qty)
+			if qty > completed_qty:
 				frappe.throw(_("{0} ({1}) cannot be greater than planned quantity ({2}) in Work Order {3}").format(\
-					self.meta.get_label(fieldname), qty, self.qty, self.name), StockOverProductionError)
+					self.meta.get_label(fieldname), qty, completed_qty, self.name), StockOverProductionError)
 
 			self.db_set(fieldname, qty)
 
diff --git a/erpnext/hr/doctype/additional_salary_component/__init__.py b/erpnext/manufacturing/report/bom_variance_report/__init__.py
similarity index 100%
copy from erpnext/hr/doctype/additional_salary_component/__init__.py
copy to erpnext/manufacturing/report/bom_variance_report/__init__.py
diff --git a/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.js b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.js
new file mode 100644
index 0000000..97ba7b9
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["BOM Variance Report"] = {
+	"filters": [
+		{
+			"fieldname":"bom_no",
+			"label": __("BOM No"),
+			"fieldtype": "Link",
+			"options": "BOM"
+		},
+		{
+			"fieldname":"work_order",
+			"label": __("Work Order"),
+			"fieldtype": "Link",
+			"options": "Work Order",
+			"get_query": function() {
+				var bom_no = frappe.query_report_filters_by_name.bom_no.get_value();
+				return{
+					query: "erpnext.manufacturing.report.bom_variance_report.bom_variance_report.get_work_orders",
+					filters: {
+						'bom_no': bom_no
+					}
+				}
+			}
+		},
+	]
+}
diff --git a/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.json b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.json
new file mode 100644
index 0000000..91ed11e
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.json
@@ -0,0 +1,32 @@
+{
+ "add_total_row": 0, 
+ "creation": "2018-05-28 16:22:24.040106", 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2018-05-28 16:22:24.040106", 
+ "modified_by": "Administrator", 
+ "module": "Manufacturing", 
+ "name": "BOM Variance Report", 
+ "owner": "Administrator", 
+ "ref_doctype": "Stock Entry", 
+ "report_name": "BOM Variance Report", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Manufacturing Manager"
+  }, 
+  {
+   "role": "Stock Manager"
+  }, 
+  {
+   "role": "Stock User"
+  }, 
+  {
+   "role": "Manufacturing User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.py b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.py
new file mode 100644
index 0000000..c5627e0
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_variance_report/bom_variance_report.py
@@ -0,0 +1,107 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+
+def execute(filters=None):
+	columns, data = [], []
+	columns = get_columns(filters)
+	data = get_data(filters)
+	return columns, data
+
+def get_columns(filters):
+	columns = [{
+			"label": _("Work Order"),
+			"fieldname": "work_order",
+			"fieldtype": "Link",
+			"options": "Work Order",
+			"width": 120
+		}]
+	
+	if not filters.get('bom_no'):
+		columns.extend([
+			{
+				"label": _("BOM No"),
+				"fieldname": "bom_no",
+				"fieldtype": "Link",
+				"options": "BOM",
+				"width": 180
+			}
+		])
+	
+	columns.extend([
+		{
+			"label": _("Finished Good"),
+			"fieldname": "production_item",
+			"fieldtype": "Link",
+			"options": "Item",
+			"width": 120
+		},
+		{
+			"label": _("Ordered Qty"),
+			"fieldname": "qty",
+			"fieldtype": "Float",
+			"width": 120
+		},
+		{
+			"label": _("Produced Qty"),
+			"fieldname": "produced_qty",
+			"fieldtype": "Float",
+			"width": 120
+		},
+		{
+			"label": _("Raw Material"),
+			"fieldname": "raw_material_code",
+			"fieldtype": "Link",
+			"options": "Item",
+			"width": 120
+		},
+		{
+			"label": _("Required Qty"),
+			"fieldname": "required_qty",
+			"fieldtype": "Float",
+			"width": 120
+		},
+		{
+			"label": _("Consumed Qty"),
+			"fieldname": "consumed_qty",
+			"fieldtype": "Float",
+			"width": 120
+		}
+	])
+
+	return columns
+	
+def get_data(filters):
+	cond = "1=1"
+
+	if filters.get('bom_no') and not filters.get('work_order'):
+		cond += " and bom_no = '%s'" % filters.get('bom_no')
+
+	if filters.get('work_order'):
+		cond += " and name = '%s'" % filters.get('work_order')
+
+	results = []
+	for d in frappe.db.sql(""" select name as work_order, qty, produced_qty, production_item, bom_no
+		from `tabWork Order` where produced_qty > qty and docstatus = 1 and {0}""".format(cond), as_dict=1):
+		results.append(d)
+
+		for data in frappe.get_all('Work Order Item', fields=["item_code as raw_material_code",
+			"required_qty", "consumed_qty"], filters={'parent': d.work_order, 'parenttype': 'Work Order'}):
+			results.append(data)
+
+	return results
+
+@frappe.whitelist()
+def get_work_orders(doctype, txt, searchfield, start, page_len, filters):
+	cond = "1=1"
+	if filters.get('bom_no'):
+		cond += " and bom_no = '%s'" % filters.get('bom_no')
+
+	return frappe.db.sql("""select name from `tabWork Order`
+		where name like %(name)s and {0} and produced_qty > qty and docstatus = 1
+		order by name limit {1}, {2}""".format(cond, start, page_len),{
+			'name': "%%%s%%" % txt
+		}, as_list=1)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 97c6dd6..06ff4b5 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -542,3 +542,5 @@
 erpnext.patches.v11_0.check_buying_selling_in_currency_exchange
 erpnext.patches.v11_0.refactor_erpnext_shopify
 erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany
+erpnext.patches.v11_0.rename_overproduction_percent_field
+erpnext.patches.v10_0.update_status_in_purchase_receipt
diff --git a/erpnext/patches/v10_0/update_status_in_purchase_receipt.py b/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
new file mode 100644
index 0000000..69e2bb8
--- /dev/null
+++ b/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+	frappe.reload_doc("stock", "doctype", "purchase_receipt")
+	frappe.db.sql('''
+		UPDATE `tabPurchase Receipt` SET status = "Completed" WHERE per_billed = 100 AND docstatus = 1
+	''')
\ No newline at end of file
diff --git a/erpnext/patches/v11_0/rename_overproduction_percent_field.py b/erpnext/patches/v11_0/rename_overproduction_percent_field.py
new file mode 100644
index 0000000..077829f
--- /dev/null
+++ b/erpnext/patches/v11_0/rename_overproduction_percent_field.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2018, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+from frappe.model.utils.rename_field import rename_field
+import frappe
+
+def execute():
+	frappe.reload_doc('manufacturing', 'doctype', 'manufacturing_settings')
+	rename_field('Manufacturing Settings', 'over_production_allowance_percentage', 'overproduction_percentage_for_sales_order')
\ No newline at end of file
diff --git a/erpnext/public/images/hub_logo.svg b/erpnext/public/images/hub_logo.svg
index 1612c6d..4af4821 100644
--- a/erpnext/public/images/hub_logo.svg
+++ b/erpnext/public/images/hub_logo.svg
@@ -1,37 +1,112 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
 <svg
-   viewBox="0 0 87.312496 91.397155"
-   class="hub-icon"
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="330"
    height="345.43808"
-   width="330">
+   viewBox="0 0 87.312496 91.397155"
+   version="1.1"
+   id="svg4635"
+   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
+   sodipodi:docname="hub-logo.svg"
+   inkscape:export-filename="/home/raghu/Desktop/hub-logo.png"
+   inkscape:export-xdpi="95.878258"
+   inkscape:export-ydpi="95.878258">
+  <defs
+     id="defs4629" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.7"
+     inkscape:cx="234.27717"
+     inkscape:cy="167.57445"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1920"
+     inkscape:window-height="1149"
+     inkscape:window-x="0"
+     inkscape:window-y="24"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata4632">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
+      </cc:Work>
+      <cc:License
+         rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Reproduction" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Distribution" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Notice" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Attribution" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#ShareAlike" />
+      </cc:License>
+    </rdf:RDF>
+  </metadata>
   <g
-     transform="translate(121.51931,-138.66452)"
-     id="layer1">
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(121.51931,-138.66452)">
     <rect
-       ry="13.229166"
-       y="142.74918"
-       x="-121.51931"
-       height="87.3125"
-       width="87.3125"
-       id="rect828"
+       rx="13.229166"
+       inkscape:export-ydpi="96"
+       inkscape:export-xdpi="96"
+       inkscape:export-filename="/home/raghu/Desktop/send/hub-02.png"
        style="opacity:1;vector-effect:none;fill:#89da29;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
-       rx="13.229166" />
+       id="rect828"
+       width="87.3125"
+       height="87.3125"
+       x="-121.51931"
+       y="142.74918"
+       ry="13.229166" />
     <path
-       id="path830"
+       style="opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
+       clip-path="none"
        d="m -121.51931,202.96343 v 13.86892 c 0,7.32897 5.90017,13.22917 13.22916,13.22917 h 60.854162 c 6.610072,0 12.056133,-4.80013 13.061216,-11.1187 -43.339761,0.1608 -54.359752,-16.03276 -87.144538,-15.97939 z"
-       clip-path="none"
-       style="opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
+       id="path830"
+       inkscape:connector-curvature="0" />
     <path
-       id="path832"
+       style="opacity:1;vector-effect:none;fill:#59b81c;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
+       clip-path="none"
        d="m -34.20681,202.96343 c -32.784694,-0.0533 -43.804846,16.14019 -87.14455,15.97939 1.00509,6.31857 6.45115,11.1187 13.06122,11.1187 h 60.854164 c 7.328992,0 13.229166,-5.9002 13.229166,-13.22917 z"
-       clip-path="none"
-       style="opacity:1;vector-effect:none;fill:#59b81c;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
+       id="path832"
+       inkscape:connector-curvature="0" />
     <path
-       style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.79375005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
+       id="path834"
        d="m -84.351263,175.75725 c -1.30945,0 -2.376091,1.06665 -2.376091,2.37608 v 10.02885 0.001 c 0.06583,4.83083 4.01156,8.73477 8.857351,8.73486 4.8718,5e-5 8.846821,-3.94421 8.871295,-8.81134 v -0.001 -9.95288 c 0,-1.30943 -1.066113,-2.37557 -2.375589,-2.37557 -1.309396,0 -2.376064,1.06614 -2.376064,2.37557 v 9.8888 c 0,2.26045 -1.858169,4.10983 -4.119642,4.10983 -2.263616,0 -4.105699,-1.82766 -4.105699,-4.08968 v -9.90844 c 0,-1.30943 -1.066138,-2.37608 -2.375561,-2.37608 z m -20.887107,0.0925 c -1.30943,0 -2.37609,1.06717 -2.37609,2.3766 v 16.45119 c 0,1.30944 1.06666,2.37609 2.37609,2.37609 1.30945,0 2.37556,-1.06665 2.37556,-2.37609 v -5.97327 h 8.22534 v 5.97327 c 0,1.30944 1.066641,2.37609 2.376091,2.37609 1.309423,0 2.375561,-1.06665 2.375561,-2.37609 v -16.45119 c 0,-1.30943 -1.066138,-2.3766 -2.375561,-2.3766 -1.30945,0 -2.376091,1.06717 -2.376091,2.3766 v 5.72627 h -8.22534 v -5.72627 c 0,-1.30943 -1.06611,-2.3766 -2.37556,-2.3766 z m 41.77419,0 c -0.654712,0 -1.248675,0.26711 -1.678967,0.69764 -0.05368,0.0537 -0.105119,0.10983 -0.153458,0.16846 v 5.3e-4 c -0.04839,0.0586 -0.09427,0.11929 -0.136949,0.18242 v 5.3e-4 c -0.256381,0.37936 -0.406691,0.83617 -0.406691,1.32705 v 16.45119 c 0,0.1635 0.01693,0.3242 0.04858,0.47852 0.09512,0.46331 0.32594,0.87828 0.64852,1.20096 0.161369,0.16136 0.345308,0.29938 0.547264,0.40928 v 0 c 0.134567,0.0732 0.276781,0.13403 0.425318,0.18035 v 0 c 0.148537,0.0463 0.303186,0.0783 0.462518,0.0946 v 0 c 0.07959,0.008 0.160708,0.0124 0.242358,0.0124 h 8.33181 c 0.08747,0 0.167931,-0.0145 0.251142,-0.0238 l 0.09509,0.005 c 0.06019,0.003 0.119407,0.005 0.178779,0.006 h 0.0037 0.0048 c 3.578305,-2e-5 6.487954,-2.90916 6.487981,-6.48747 v -0.001 c -0.0026,-1.51334 -0.578009,-2.9475 -1.540484,-4.10673 0.962448,-1.15892 1.537785,-2.59314 1.540484,-4.10621 v -0.001 c -2.7e-5,-3.57831 -2.909676,-6.48744 -6.487981,-6.48746 h -0.533294 z m 8.865103,4.75062 c 0.96393,0 1.736831,0.77394 1.736831,1.73788 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 v 0 h -0.532792 -5.955718 v -3.47317 h 5.956248 z m 0,8.21552 v 0 c 0.963507,5.3e-4 1.735799,0.77373 1.735799,1.73736 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 h -0.0048 l -0.533294,0.0119 h -5.951591 v -3.4742 h 5.959846 z"
-       id="path834" />
+       style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.79375005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
+       inkscape:connector-curvature="0" />
     <path
-       id="path838"
+       style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.93750048;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
        d="m -77.859375,138.66406 c -9.653316,0 -18.439915,3.93483 -24.767575,10.28125 a 3.9691471,3.9691471 0 1 0 5.621091,5.60352 c 4.899576,-4.9141 11.6422,-7.94727 19.146484,-7.94727 7.501101,0 14.241542,3.03098 19.140625,7.94141 a 3.9691471,3.9691471 0 1 0 5.619141,-5.60547 c -6.327038,-6.34169 -15.110547,-10.27344 -24.759766,-10.27344 z"
-       style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.93750048;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
+       id="path838"
+       inkscape:connector-curvature="0" />
   </g>
 </svg>
diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js
index 01f55a3..6451e1d 100644
--- a/erpnext/public/js/hub/hub_factory.js
+++ b/erpnext/public/js/hub/hub_factory.js
@@ -35,7 +35,7 @@
 							});
 						}
 					});
-				} else {
+				} else if (!route[3]){
 					frappe.require(assets['Form'], () => {
 						erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({
 							unique_id: route[2],
@@ -44,6 +44,15 @@
 							hub_settings: this.hub_settings
 						});
 					});
+				} else {
+					frappe.require(assets['List'], () => {
+						frappe.route_options = {};
+						frappe.route_options["company_name"] = route[2]
+						erpnext.hub.pages[page_name] = new erpnext.hub['ItemListing']({
+							parent: this.make_page(true, page_name),
+							hub_settings: this.hub_settings
+						});
+					});
 				}
 				window.hub_page = erpnext.hub.pages[page_name];
 			} else {
diff --git a/erpnext/public/js/hub/hub_listing.js b/erpnext/public/js/hub/hub_listing.js
index a979d28..0ff7970 100644
--- a/erpnext/public/js/hub/hub_listing.js
+++ b/erpnext/public/js/hub/hub_listing.js
@@ -58,12 +58,7 @@
 				label: __('Favourites'),
 				action: () => frappe.set_route('Hub', 'Favourites'),
 				standard: true
-			},
-			// {
-			// 	label: __('Toggle Sidebar'),
-			// 	action: () => this.toggle_side_bar(),
-			// 	standard: true
-			// }
+			}
 		];
 
 		return items;
@@ -85,7 +80,15 @@
 		});
 	}
 
-	setup_view() { }
+	setup_view() {
+		if(frappe.route_options){
+			const filters = [];
+			for (let field in frappe.route_options) {
+				var value = frappe.route_options[field];
+				this.page.fields_dict[field].set_value(value);
+			}
+		}
+	}
 
 	get_args() {
 		return {
@@ -110,18 +113,7 @@
 		this.data_dict = {};
 	}
 
-	freeze(toggle) {
-		// if(!this.$freeze) return;
-		// this.$freeze.toggle(toggle);
-		// if (this.$freeze.find('.image-view-container').length) return;
-
-		// const html = Array.from(new Array(4)).map(d => this.card_html({
-		// 	name: 'Loading...',
-		// 	item_name: 'Loading...'
-		// })).join('');
-
-		// this.$freeze.html(`<div class="image-view-container border-top">${html}</div>`);
-	}
+	freeze(toggle) { }
 
 	render() {
 		this.data_dict = {};
@@ -360,7 +352,7 @@
 	setup_defaults() {
 		super.setup_defaults();
 		this.doctype = 'Hub Item';
-		this.page_title = __('Products');
+		this.page_title = __('Marketplace');
 		this.fields = ['name', 'hub_item_code', 'image', 'item_name', 'item_code', 'company_name', 'description', 'country'];
 		this.filters = [];
 	}
@@ -529,7 +521,7 @@
 						(${reviewLength})
 					</div>
 					<div class="list-row-col">
-						<a href="${'#Hub/Company/'+company_name}"><p>${ company_name }</p></a>
+						<a href="${'#Hub/Company/'+company_name+'/Items'}"><p>${ company_name }</p></a>
 					</div>
 				</div>
 				<div class="image-view-body">
diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js
index 78def26..eabb81e 100644
--- a/erpnext/public/js/utils/serial_no_batch_selector.js
+++ b/erpnext/public/js/utils/serial_no_batch_selector.js
@@ -55,11 +55,13 @@
 				},
 				get_query: function() {
 					return {
-						filters: {
-							is_group: 0,
-							company: me.frm.doc.company
-						}
-					};
+						query: "erpnext.controllers.queries.warehouse_query",
+						filters: [
+							["Bin", "item_code", "=", me.item_code],
+							["Warehouse", "is_group", "=", 0],
+							["Warehouse", "company", "=", me.frm.doc.company]
+						]
+					}
 				}
 			},
 			{fieldtype:'Column Break'},
diff --git a/erpnext/regional/report/gstr_1/gstr_1.js b/erpnext/regional/report/gstr_1/gstr_1.js
index 3a63527..b2c8aed 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.js
+++ b/erpnext/regional/report/gstr_1/gstr_1.js
@@ -12,6 +12,21 @@
 			"default": frappe.defaults.get_user_default("Company")
 		},
 		{
+			"fieldname":"company_address",
+			"label": __("Address"),
+			"fieldtype": "Link",
+			"options": "Address",
+			"get_query": function() {
+				var company = frappe.query_report_filters_by_name.company.get_value();
+				if (company) {
+					return {
+						"query": 'frappe.contacts.doctype.address.address.address_query',
+						"filters": { link_doctype: 'Company', link_name: company}
+					};
+				}
+			}
+		},
+		{
 			"fieldname":"from_date",
 			"label": __("From Date"),
 			"fieldtype": "Date",
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index 2c128e7..690fbbc 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -102,7 +102,8 @@
 
 		for opts in (("company", " and company=%(company)s"),
 			("from_date", " and posting_date>=%(from_date)s"),
-			("to_date", " and posting_date<=%(to_date)s")):
+			("to_date", " and posting_date<=%(to_date)s"),
+			("company_address", " and company_address=%(company_address)s")):
 				if self.filters.get(opts[0]):
 					conditions += opts[1]
 
diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json
index cf7916b..6dc2c00 100644
--- a/erpnext/selling/doctype/quotation/quotation.json
+++ b/erpnext/selling/doctype/quotation/quotation.json
@@ -2549,8 +2549,8 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "select_print_heading", 
-   "fieldtype": "Link", 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -2558,18 +2558,16 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Print Heading", 
+   "label": "Group same items",
    "length": 0, 
-   "no_copy": 1, 
-   "oldfieldname": "select_print_heading", 
-   "oldfieldtype": "Link", 
-   "options": "Print Heading", 
+   "no_copy": 0,
    "permlevel": 0, 
+   "precision": "",
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "remember_last_selected_value": 0, 
-   "report_hide": 1, 
+   "report_hide": 0,
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
@@ -2608,6 +2606,38 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "select_print_heading",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Print Heading",
+   "length": 0,
+   "no_copy": 1,
+   "oldfieldname": "select_print_heading",
+   "oldfieldtype": "Link",
+   "options": "Print Heading",
+   "permlevel": 0,
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 1,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3005,8 +3035,8 @@
  "istable": 0, 
  "max_attachments": 1, 
  "menu_index": 0, 
- "modified": "2018-05-17 12:56:20.830562", 
- "modified_by": "Administrator", 
+ "modified": "2018-05-28 03:23:15.354674",
+ "modified_by": "Administrator",
  "module": "Selling", 
  "name": "Quotation", 
  "owner": "Administrator", 
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
index e7bb5b4..fd5bc4e 100644
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -98,7 +98,7 @@
 		END as qty,
 		CASE
 			WHEN so.status = "Closed" THEN sum(soi.delivered_qty * soi.conversion_factor * soi.base_net_rate * (st.allocated_percentage/100))
-			ELSE soi.base_net_amount * (st.allocated_percentage/100))
+			ELSE sum(soi.base_net_amount * (st.allocated_percentage/100))
 		END as amount
 		from
 			`tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index 5b4f4b5..9d13657 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -86,8 +86,13 @@
 	def autoname(self):
 		"""Generate random ID for batch if not specified"""
 		if not self.batch_id:
-			if frappe.db.get_value('Item', self.item, 'create_new_batch'):
-				if batch_uses_naming_series():
+			create_new_batch, batch_number_series = frappe.db.get_value('Item', self.item, 
+				['create_new_batch', 'batch_number_series'])
+
+			if create_new_batch:
+				if batch_number_series:
+					self.batch_id = make_autoname(batch_number_series)
+				elif batch_uses_naming_series():
 					self.batch_id = self.get_name_from_naming_series()
 				else:
 					self.batch_id = get_name_from_hash()
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 92219e7..12e5b39 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -3290,6 +3290,36 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -3851,7 +3881,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2018-05-17 12:55:36.474198", 
+ "modified": "2018-05-28 03:03:35.035396",
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note", 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 8886f33..1df07a2 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -82,6 +82,8 @@
 			for f in fieldname:
 				toggle_print_hide(self.meta if key == "parent" else item_meta, f)
 
+		super(DeliveryNote, self).before_print()
+
 	def set_actual_qty(self):
 		for d in self.get('items'):
 			if d.item_code and d.warehouse:
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index c4a3fc1..b7c90d0 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -17,6 +17,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -49,6 +50,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -80,6 +82,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -113,6 +116,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -147,6 +151,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -179,6 +184,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -209,6 +215,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -243,6 +250,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -274,6 +282,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -308,6 +317,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -337,6 +347,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -368,6 +379,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -399,6 +411,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -434,6 +447,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -465,6 +479,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -498,6 +513,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -530,6 +546,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -564,6 +581,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -596,6 +614,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -627,6 +646,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -660,6 +680,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -692,6 +713,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -723,6 +745,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -755,6 +778,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -789,6 +813,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -820,6 +845,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -854,6 +880,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -887,6 +914,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -919,6 +947,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -951,6 +980,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -984,6 +1014,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1016,6 +1047,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1048,6 +1080,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1081,6 +1114,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1114,6 +1148,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1146,6 +1181,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1181,6 +1217,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1214,6 +1251,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1249,6 +1287,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1282,6 +1321,41 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:doc.has_batch_no==1 && doc.create_new_batch==1", 
+   "description": "Example: ABCD.#####. If series is set and Batch No is not mentioned in transactions, then automatic batch number will be created based on this series. If you always want to explicitly mention Batch No for this item, leave this blank. Note: this setting will take priority over the Naming Series Prefix in Stock Settings.", 
+   "fieldname": "batch_number_series", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Batch Number Series", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 1, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1314,6 +1388,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1346,6 +1421,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1379,6 +1455,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1409,6 +1486,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1445,6 +1523,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1477,6 +1556,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1510,6 +1590,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1545,6 +1626,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1579,6 +1661,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1612,6 +1695,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1643,6 +1727,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1675,6 +1760,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1707,6 +1793,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1739,6 +1826,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1771,6 +1859,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1806,6 +1895,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1837,6 +1927,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1868,6 +1959,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1902,6 +1994,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1935,6 +2028,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -1967,6 +2061,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1998,6 +2093,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2030,6 +2126,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2061,6 +2158,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2094,6 +2192,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2126,6 +2225,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2157,6 +2257,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2189,6 +2290,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2219,6 +2321,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2251,6 +2354,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2283,6 +2387,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2315,6 +2420,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2347,6 +2453,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2380,6 +2487,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2413,6 +2521,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2444,6 +2553,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2475,6 +2585,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2508,6 +2619,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2538,6 +2650,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2570,6 +2683,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2601,6 +2715,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2634,6 +2749,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2666,6 +2782,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2700,6 +2817,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2732,6 +2850,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2766,6 +2885,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2797,6 +2917,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2830,6 +2951,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -2863,6 +2985,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2897,6 +3020,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2932,6 +3056,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2962,6 +3087,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2992,6 +3118,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -3023,6 +3150,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3054,6 +3182,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3086,6 +3215,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3118,6 +3248,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3150,6 +3281,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3183,6 +3315,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3216,6 +3349,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3247,6 +3381,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3276,6 +3411,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3309,6 +3445,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3342,6 +3479,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -3374,6 +3512,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3405,6 +3544,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3437,6 +3577,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3468,6 +3609,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3499,6 +3641,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3531,6 +3674,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3564,6 +3708,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -3596,6 +3741,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3628,6 +3774,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -3660,6 +3807,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3692,6 +3840,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3725,6 +3874,7 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -3768,7 +3918,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2018-05-16 16:35:09.518294", 
+ "modified": "2018-05-28 14:18:03.234070", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 5649b3d..fc53794 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -53,7 +53,8 @@
 	pi.qty = flt(qty)
 	pi.description = description
 	if not pi.warehouse:
-		pi.warehouse = item.default_warehouse or main_item_row.warehouse
+		pi.warehouse = (main_item_row.warehouse
+			if (doc.get('is_pos') or not item.default_warehouse) else item.default_warehouse)
 	if not pi.batch_no:
 		pi.batch_no = cstr(main_item_row.get("batch_no"))
 	if not pi.target_warehouse:
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 9bd2ebb..f94e5a5 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -3105,10 +3105,69 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "column_break_97",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "other_details", 
    "fieldtype": "HTML", 
    "hidden": 1, 
@@ -3377,7 +3436,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2018-05-17 13:05:05.772877", 
+ "modified": "2018-05-28 02:59:59.609643",
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Purchase Receipt", 
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 17afba0..fa441b5 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -122,6 +122,8 @@
 		self.update_prevdoc_status()
 		if self.per_billed < 100:
 			self.update_billing_status()
+		else:
+			self.status = "Completed"
 
 		
 		# Updating stock ledger should always be called after updating prevdoc status,
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 7452da8..359d834 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -156,6 +156,29 @@
 				})
 			}, __("Get items from"));
 		}
+		if (frm.doc.docstatus===0 && frm.doc.purpose == "Material Issue") {
+			frm.add_custom_button(__('Expired Batches'), function() {
+				frappe.call({
+					method: "erpnext.stock.doctype.stock_entry.stock_entry.get_expired_batch_items",
+					callback: function(r) {
+						if (!r.exc && r.message) {
+							frm.set_value("items", []);
+							r.message.forEach(function(element) {
+								let d = frm.add_child("items");
+								d.item_code = element.item;
+								d.s_warehouse = element.warehouse;
+								d.qty = element.qty;
+								d.uom = element.stock_uom;
+								d.conversion_factor = 1;
+								d.batch_no = element.batch_no;
+								d.transfer_qty = element.qty;
+								frm.refresh_fields();
+							});
+						}
+					}
+				});
+			}, __("Get items from"));
+		}
 
 		if (frm.doc.company) {
 			frm.trigger("toggle_display_account_head");
@@ -350,7 +373,7 @@
 
 	target_warehouse_address: function(frm) {
 		erpnext.utils.get_address_display(frm, 'target_warehouse_address', 'target_address_display', false);
-	},
+	}
 })
 
 frappe.ui.form.on('Stock Entry Detail', {
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 3862854..412331e 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -252,10 +252,13 @@
 	def check_if_operations_completed(self):
 		"""Check if Time Sheets are completed against before manufacturing to capture operating costs."""
 		prod_order = frappe.get_doc("Work Order", self.work_order)
+		allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
+			"overproduction_percentage_for_work_order"))
 
 		for d in prod_order.get("operations"):
 			total_completed_qty = flt(self.fg_completed_qty) + flt(prod_order.produced_qty)
-			if total_completed_qty > flt(d.completed_qty):
+			completed_qty = d.completed_qty + (allowance_percentage/100 * d.completed_qty)
+			if total_completed_qty > flt(completed_qty):
 				frappe.throw(_("Row #{0}: Operation {1} is not completed for {2} qty of finished goods in Work Order # {3}. Please update operation status via Time Logs")
 					.format(d.idx, d.operation, total_completed_qty, self.work_order), OperationsNotCompleteError)
 
@@ -469,8 +472,11 @@
 	def validate_finished_goods(self):
 		"""validation: finished good quantity should be same as manufacturing quantity"""
 		items_with_target_warehouse = []
+		allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
+			"overproduction_percentage_for_work_order"))
+
 		for d in self.get('items'):
-			if self.purpose != "Subcontract" and d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty) and (d.t_warehouse != getattr(self, "pro_doc", frappe._dict()).scrap_warehouse):
+			if self.purpose != "Subcontract" and d.bom_no and flt(d.transfer_qty) > flt(self.fg_completed_qty) and (d.t_warehouse != getattr(self, "pro_doc", frappe._dict()).scrap_warehouse):
 				frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}"). \
 					format(d.idx, d.transfer_qty, self.fg_completed_qty))
 
@@ -478,8 +484,14 @@
 				items_with_target_warehouse.append(d.item_code)
 
 		if self.work_order and self.purpose == "Manufacture":
-			production_item = frappe.db.get_value("Work Order",
-				self.work_order, "production_item")
+			production_item, wo_qty = frappe.db.get_value("Work Order",
+				self.work_order, ["production_item", "qty"])
+
+			allowed_qty = wo_qty + (allowance_percentage/100 * wo_qty)
+			if self.fg_completed_qty > allowed_qty:
+				frappe.throw(_("For quantity {0} should not be grater than work order quantity {1}")
+					.format(flt(self.fg_completed_qty), wo_qty))
+
 			if production_item not in items_with_target_warehouse:
 				frappe.throw(_("Finished Item {0} must be entered for Manufacture type entry")
 					.format(production_item))
@@ -1154,6 +1166,15 @@
 	return ret
 
 @frappe.whitelist()
+def get_expired_batch_items():
+	return frappe.db.sql("""select b.item, sum(sle.actual_qty) as qty, sle.batch_no, sle.warehouse, sle.stock_uom\
+	from `tabBatch` b, `tabStock Ledger Entry` sle
+	where b.expiry_date <= %s
+	and b.expiry_date is not NULL
+	and b.batch_id = sle.batch_no
+	group by sle.warehouse, sle.item_code, sle.batch_no""",(nowdate()), as_dict=1)
+
+@frappe.whitelist()
 def get_warehouse_details(args):
 	if isinstance(args, string_types):
 		args = json.loads(args)
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index 1a91ab4..ec95561 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -56,7 +56,7 @@
 	item_conditions_sql = ''
 	if items:
 		item_conditions_sql = 'and sle.item_code in ({})'\
-			.format(', '.join(['"' + frappe.db.escape(i,percent=False) + '"' for i in items]))
+			.format(', '.join(['"' + frappe.db.escape(i) + '"' for i in items]))
 
 	return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date,
 			item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate,
diff --git a/erpnext/templates/pages/help.html b/erpnext/templates/pages/help.html
index f7568d5..a49268a 100644
--- a/erpnext/templates/pages/help.html
+++ b/erpnext/templates/pages/help.html
@@ -55,7 +55,7 @@
 	<p><a href="/issues">{{ _("See all open tickets") }}</a></p>
 </div>
 
-<a href="/issues?new=1" class="btn btn-primary btn-new btn-sm">
+<a href="/issues?new=1" class="btn btn-default btn-new btn-sm">
 	{{ _("Open a new ticket") }}
 </a>
 
diff --git a/erpnext/templates/pages/help.py b/erpnext/templates/pages/help.py
index 754a09c..c484d25 100644
--- a/erpnext/templates/pages/help.py
+++ b/erpnext/templates/pages/help.py
@@ -19,7 +19,7 @@
 	context.topics = topics_data[:3]
 
 	# Issues
-	context.issues = frappe.get_list("Issue")[:3]
+	context.issues = frappe.get_list("Issue", fields=["name", "status", "subject", "modified"])[:3]
 
 def get_forum_posts(s):
 	response = requests.get(s.forum_url + '/' + s.get_latest_query)
diff --git a/erpnext/utilities/page/leaderboard/leaderboard.js b/erpnext/utilities/page/leaderboard/leaderboard.js
index 6e4db1b..5563fb0 100644
--- a/erpnext/utilities/page/leaderboard/leaderboard.js
+++ b/erpnext/utilities/page/leaderboard/leaderboard.js
@@ -85,7 +85,7 @@
 
 		this.$sidebar_list.on('click', 'li', function(e) {
 			let $li = $(this);
-			let doctype = $li.find('span').html();
+			let doctype = $li.find('span').attr("doctype-value");
 
 			me.options.selected_company = frappe.defaults.get_default('company');
 			me.options.selected_doctype = doctype;
@@ -172,7 +172,7 @@
 			$container.find(".leaderboard-list").html(me.render_list_view(res.message));
 		} else {
 			me.$graph_area.hide();
-			me.message = "No items found.";
+			me.message = __("No items found.");
 			$container.find(".leaderboard-list").html(me.render_list_view());
 		}
 	},
@@ -301,7 +301,7 @@
 	get_sidebar_item: function(item) {
 		return $(`<li class="strong module-sidebar-item">
 			<a class="module-link">
-			<span>${ item }</span></a>
+			<span doctype-value="${item}">${ __(item) }</span></a>
 		</li>`);
 	}
 });