From bd7218979e81f289ffd0ff00612cdb893285a9eb Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 26 Jun 2013 13:53:01 +0530 Subject: [PATCH] [shipping rule] added doctypes shipping rule and shipping rule conditions --- .../sales_taxes_and_charges_master.txt | 19 ++- accounts/doctype/shipping_rule/__init__.py | 0 .../doctype/shipping_rule/shipping_rule.py | 25 +++ .../doctype/shipping_rule/shipping_rule.txt | 151 ++++++++++++++++++ .../shipping_rule_condition/__init__.py | 0 .../shipping_rule_condition.py | 8 + .../shipping_rule_condition.txt | 50 ++++++ accounts/page/accounts_home/accounts_home.js | 5 + selling/page/selling_home/selling_home.js | 5 + setup/doctype/price_list/price_list.txt | 9 +- 10 files changed, 254 insertions(+), 18 deletions(-) create mode 100644 accounts/doctype/shipping_rule/__init__.py create mode 100644 accounts/doctype/shipping_rule/shipping_rule.py create mode 100644 accounts/doctype/shipping_rule/shipping_rule.txt create mode 100644 accounts/doctype/shipping_rule_condition/__init__.py create mode 100644 accounts/doctype/shipping_rule_condition/shipping_rule_condition.py create mode 100644 accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt 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 5de944204c..9aa7053661 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 0000000000..e69de29bb2 diff --git a/accounts/doctype/shipping_rule/shipping_rule.py b/accounts/doctype/shipping_rule/shipping_rule.py new file mode 100644 index 0000000000..5ed4ed38e0 --- /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 0000000000..dd4fe8dfed --- /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 0000000000..e69de29bb2 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 0000000000..928aa9ff9f --- /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 0000000000..2fe43db24d --- /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 a998818767..f7e476af30 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -100,6 +100,11 @@ wn.module_page["Accounts"] = [ "doctype":"Purchase Taxes and Charges Master", "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", diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 73cc7185c8..3b3156d5c8 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -63,6 +63,11 @@ wn.module_page["Selling"] = [ description: wn._("Sales taxes template."), 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."), diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt index 9bc18dc062..5113a3e080 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" }, @@ -116,13 +116,6 @@ "label": "How to upload", "options": "
Use the Data Import Tool to upload, update Item Prices in bulk:\n
    \n
  1. Go to Data Import Tool.\n
  2. Select \"Item\"\n
  3. Check on \"With Data\"\n
  4. Download \"Item Price\" from Child Tables.\n
  5. Update the prices required and add new rows if required.\n
  6. Check on \"Overwrite\"\n
  7. Upload the modified sheet.\n
\n" }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 0 - }, { "cancel": 0, "create": 0,