Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
index 5de9442..9aa7053 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-01-10 16:34:09", 
   "docstatus": 0, 
-  "modified": "2013-06-20 16:49:12", 
+  "modified": "2013-06-25 12:06:45", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -30,8 +30,7 @@
   "parenttype": "DocType", 
   "permlevel": 0, 
   "read": 1, 
-  "report": 1, 
-  "submit": 0
+  "report": 1
  }, 
  {
   "doctype": "DocType", 
@@ -101,21 +100,20 @@
   "create": 0, 
   "doctype": "DocPerm", 
   "role": "Sales User", 
+  "submit": 0, 
   "write": 0
  }, 
  {
+  "doctype": "DocPerm", 
+  "role": "Accounts User"
+ }, 
+ {
   "amend": 0, 
   "cancel": 1, 
   "create": 1, 
   "doctype": "DocPerm", 
   "role": "Accounts Manager", 
-  "write": 1
- }, 
- {
-  "cancel": 1, 
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "role": "System Manager", 
+  "submit": 0, 
   "write": 1
  }, 
  {
@@ -124,6 +122,7 @@
   "create": 1, 
   "doctype": "DocPerm", 
   "role": "Sales Master Manager", 
+  "submit": 0, 
   "write": 1
  }
 ]
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/__init__.py b/accounts/doctype/shipping_rule/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/doctype/shipping_rule/__init__.py
diff --git a/accounts/doctype/shipping_rule/shipping_rule.py b/accounts/doctype/shipping_rule/shipping_rule.py
new file mode 100644
index 0000000..5ed4ed3
--- /dev/null
+++ b/accounts/doctype/shipping_rule/shipping_rule.py
@@ -0,0 +1,25 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _, msgprint
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+		
+	def validate(self):
+		self.validate_to_value_of_shipping_rule_conditions()
+		self.validate_overlapping_shipping_rule_conditions()
+		
+		
+	def validate_to_value_of_shipping_rule_conditions(self):
+		"""check if more than two or more rows has To Value = 0"""
+		shipping_rule_conditions_with_0_to_value = self.doclist.get({
+			"parentfield": "shipping_rule_conditions", "to_value": ["in", [0, None]]})
+		if len(shipping_rule_conditions_with_0_to_value) >= 2:
+			msgprint(_('''There can only be one shipping rule with 0 or blank value for "To Value"'''),
+				raise_exception=True)
+				
+	def validate_overlapping_shipping_rule_conditions(self):
+		pass
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/shipping_rule.txt b/accounts/doctype/shipping_rule/shipping_rule.txt
new file mode 100644
index 0000000..dd4fe8d
--- /dev/null
+++ b/accounts/doctype/shipping_rule/shipping_rule.txt
@@ -0,0 +1,151 @@
+[
+ {
+  "creation": "2013-06-25 11:48:03", 
+  "docstatus": 0, 
+  "modified": "2013-06-25 12:15:21", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "description": "Specify conditions to calculate shipping amount", 
+  "doctype": "DocType", 
+  "module": "Accounts", 
+  "name": "__common__"
+ }, 
+ {
+  "doctype": "DocField", 
+  "name": "__common__", 
+  "parent": "Shipping Rule", 
+  "parentfield": "fields", 
+  "parenttype": "DocType", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocPerm", 
+  "name": "__common__", 
+  "parent": "Shipping Rule", 
+  "parentfield": "permissions", 
+  "parenttype": "DocType", 
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 1
+ }, 
+ {
+  "doctype": "DocType", 
+  "name": "Shipping Rule"
+ }, 
+ {
+  "description": "example: Next Day Shipping", 
+  "doctype": "DocField", 
+  "fieldname": "shipping_rule_label", 
+  "fieldtype": "Data", 
+  "in_list_view": 1, 
+  "label": "Shipping Rule Label", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break_2", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "default": "Amount", 
+  "doctype": "DocField", 
+  "fieldname": "calculate_based_on", 
+  "fieldtype": "Select", 
+  "in_list_view": 1, 
+  "label": "Calculate Based On", 
+  "options": "Amount\nNet Weight", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rule_conditions_section", 
+  "fieldtype": "Section Break", 
+  "label": "Shipping Rule Conditions"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "shipping_rule_conditions", 
+  "fieldtype": "Table", 
+  "label": "Shipping Rule Conditions", 
+  "options": "Shipping Rule Condition", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "section_break_6", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "description": "Specify a list of Territories, for which, this Shipping Rule is valid", 
+  "doctype": "DocField", 
+  "fieldname": "valid_for_territories", 
+  "fieldtype": "Table", 
+  "label": "Valid For Territories", 
+  "options": "For Territory", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break_8", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "company", 
+  "fieldtype": "Link", 
+  "in_list_view": 0, 
+  "label": "Company", 
+  "options": "Company", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "section_break_10", 
+  "fieldtype": "Section Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "account", 
+  "fieldtype": "Link", 
+  "label": "Shipping Account", 
+  "options": "Account", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "column_break_12", 
+  "fieldtype": "Column Break"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "cost_center", 
+  "fieldtype": "Link", 
+  "label": "Cost Center", 
+  "options": "Cost Center", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocPerm", 
+  "role": "Accounts User"
+ }, 
+ {
+  "doctype": "DocPerm", 
+  "role": "Sales User"
+ }, 
+ {
+  "cancel": 1, 
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "role": "Accounts Manager", 
+  "write": 1
+ }, 
+ {
+  "cancel": 1, 
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "role": "Sales Master Manager", 
+  "write": 1
+ }
+]
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule_condition/__init__.py b/accounts/doctype/shipping_rule_condition/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/doctype/shipping_rule_condition/__init__.py
diff --git a/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
new file mode 100644
index 0000000..928aa9f
--- /dev/null
+++ b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
@@ -0,0 +1,8 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt
new file mode 100644
index 0000000..2fe43db
--- /dev/null
+++ b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt
@@ -0,0 +1,50 @@
+[
+ {
+  "creation": "2013-06-25 11:54:50", 
+  "docstatus": 0, 
+  "modified": "2013-06-25 11:58:04", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "description": "A condition for a Shipping Rule", 
+  "doctype": "DocType", 
+  "istable": 1, 
+  "module": "Accounts", 
+  "name": "__common__"
+ }, 
+ {
+  "doctype": "DocField", 
+  "name": "__common__", 
+  "parent": "Shipping Rule Condition", 
+  "parentfield": "fields", 
+  "parenttype": "DocType", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocType", 
+  "name": "Shipping Rule Condition"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "from_value", 
+  "fieldtype": "Float", 
+  "label": "From Value", 
+  "reqd": 1
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "to_value", 
+  "fieldtype": "Float", 
+  "label": "To Value", 
+  "reqd": 0
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "shipping_amount", 
+  "fieldtype": "Currency", 
+  "label": "Shipping Amount", 
+  "options": "Company:company:default_currency", 
+  "reqd": 1
+ }
+]
\ No newline at end of file
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index a998818..f7e476a 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -101,6 +101,11 @@
 				"description": wn._("Tax Template for Purchase")
 			},
 			{
+				"label": wn._("Shipping Rules"),
+				"doctype":"Shipping Rule",
+				"description": wn._("Rules to calculate shipping amount for a sale")
+			},
+			{
 				"label": wn._("Point-of-Sale Setting"),
 				"doctype":"POS Setting",
 				"description": "User settings for Point-of-sale (POS)"
diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js
index ef419c5..91848b5 100644
--- a/selling/page/selling_home/selling_home.js
+++ b/selling/page/selling_home/selling_home.js
@@ -70,6 +70,11 @@
 				doctype:"Sales Taxes and Charges Master"
 			},
 			{
+				label: wn._("Shipping Rules"),
+				description: wn._("Rules to calculate shipping amount for a sale"),
+				doctype:"Shipping Rule"
+			},
+			{
 				label: wn._("Price List"),
 				description: wn._("Mupltiple Item prices."),
 				doctype:"Price List"
diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt
index 9bc18dc..5113a3e 100644
--- a/setup/doctype/price_list/price_list.txt
+++ b/setup/doctype/price_list/price_list.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-01-25 11:35:09", 
   "docstatus": 0, 
-  "modified": "2013-06-20 12:53:10", 
+  "modified": "2013-06-25 12:05:12", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -120,13 +120,6 @@
   "cancel": 0, 
   "create": 0, 
   "doctype": "DocPerm", 
-  "role": "Sales Manager", 
-  "write": 0
- }, 
- {
-  "cancel": 0, 
-  "create": 0, 
-  "doctype": "DocPerm", 
   "role": "Sales User", 
   "write": 0
  },