From 7c867ae9ad04df6f62f232cdf14e572baad3c02b Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 14 Sep 2015 16:59:10 +0530 Subject: [PATCH] [Fixes] Tax Rule preparation and test taxes creation, remove dummy quotation --- .../test_records.json | 30 +++++++++++ .../doctype/tax_rule/test_records.json | 26 ++++++++++ erpnext/controllers/accounts_controller.py | 1 + erpnext/shopping_cart/__init__.py | 1 - .../__init__.py | 0 ...hopping_cart_taxes_and_charges_master.json | 49 ----------------- .../shopping_cart_taxes_and_charges_master.py | 12 ----- erpnext/shopping_cart/test_shopping_cart.py | 52 ++++--------------- 8 files changed, 68 insertions(+), 103 deletions(-) create mode 100644 erpnext/accounts/doctype/tax_rule/test_records.json delete mode 100644 erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/__init__.py delete mode 100644 erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.json delete mode 100644 erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json index 5c25517f7f3..69dbd8e9a67 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json @@ -213,5 +213,35 @@ "territory": "_Test Territory Rest Of The World" } ] + }, + { + "doctype" : "Sales Taxes and Charges Template", + "title": "_Test Tax 1", + "company": "_Test Company", + "taxes":[{ + "charge_type": "Actual", + "account_head": "Sales Expenses - _TC", + "cost_center": "Main - _TC", + "description": "Test Shopping cart taxes with Tax Rule", + "tax_amount": 1000 + }], + "territories":[{ + "territory" : "All Territories" + }] + }, + { + "doctype" : "Sales Taxes and Charges Template", + "title": "_Test Tax 2", + "company": "_Test Company", + "taxes":[{ + "charge_type": "Actual", + "account_head": "Sales Expenses - _TC", + "cost_center": "Main - _TC", + "description": "Test Shopping cart taxes with Tax Rule", + "tax_amount": 200 + }], + "territories":[{ + "territory" : "All Territories" + }] } ] diff --git a/erpnext/accounts/doctype/tax_rule/test_records.json b/erpnext/accounts/doctype/tax_rule/test_records.json new file mode 100644 index 00000000000..ebfb0c5b1b7 --- /dev/null +++ b/erpnext/accounts/doctype/tax_rule/test_records.json @@ -0,0 +1,26 @@ +[ + { + "doctype": "Tax Rule", + "tax_type" : "Sales", + "sales_tax_template": "_Test Tax 1", + "use_for_shopping_cart": 1, + "billing_city": "_Test City", + "billing_country": "India", + "shipping_city": "_Test City", + "shipping_country": "India", + "priority": 1, + "company": "_Test Company" + }, + { + "doctype": "Tax Rule", + "tax_type" : "Sales", + "sales_tax_template": "_Test Tax 2", + "use_for_shopping_cart": 0, + "billing_city": "_Test City", + "billing_country": "India", + "shipping_city": "_Test City", + "shipping_country": "India", + "priority": 2, + "company": "_Test Company" + } +] \ No newline at end of file diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ceb993096ac..8c61005a71c 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -182,6 +182,7 @@ class AccountsController(TransactionBase): self.append_taxes_from_master(tax_master_doctype) def append_taxes_from_master(self, tax_master_doctype=None): + print "append_taxes_from_master" if self.get("taxes_and_charges"): if not tax_master_doctype: tax_master_doctype = self.meta.get_field("taxes_and_charges").options diff --git a/erpnext/shopping_cart/__init__.py b/erpnext/shopping_cart/__init__.py index e92f94e9a7f..1858c0d8421 100644 --- a/erpnext/shopping_cart/__init__.py +++ b/erpnext/shopping_cart/__init__.py @@ -35,7 +35,6 @@ def get_quotation(user=None): quotation = frappe.new_doc("Quotation") quotation.update(values) if party.doctype == "Customer": - print "create quoation for cutomer" quotation.contact_person = frappe.db.get_value("Contact", {"customer": party.name, "email_id": user}) quotation.insert(ignore_permissions=True) diff --git a/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/__init__.py b/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.json b/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.json deleted file mode 100644 index e15dcab5af0..00000000000 --- a/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "allow_copy": 0, - "allow_import": 0, - "allow_rename": 0, - "creation": "2013-06-20 16:57:03", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "fields": [ - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "sales_taxes_and_charges_master", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Tax Master", - "no_copy": 0, - "options": "Sales Taxes and Charges Template", - "permlevel": 0, - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 1, - "in_create": 0, - "in_dialog": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 1, - "modified": "2013-12-20 19:30:47", - "modified_by": "Administrator", - "module": "Shopping Cart", - "name": "Shopping Cart Taxes and Charges Master", - "owner": "Administrator", - "permissions": [], - "read_only": 0, - "read_only_onload": 0 -} \ No newline at end of file diff --git a/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py b/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py deleted file mode 100644 index d2ec545c7ef..00000000000 --- a/erpnext/shopping_cart/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe - -from frappe.model.document import Document - -class ShoppingCartTaxesandChargesMaster(Document): - pass diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py index c0945a1c4f4..bd0b138d450 100644 --- a/erpnext/shopping_cart/test_shopping_cart.py +++ b/erpnext/shopping_cart/test_shopping_cart.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import unittest import frappe from erpnext.shopping_cart import get_quotation, set_item_in_cart, get_party -import random class TestShoppingCart(unittest.TestCase): """ @@ -113,10 +112,9 @@ class TestShoppingCart(unittest.TestCase): def test_taxe_rule(self): - self.create_tax_rule() self.login_as_customer() quotation = self.create_quotation() - + from erpnext.accounts.party import set_taxes tax_rule_master = set_taxes(quotation.customer, "Customer", \ @@ -126,38 +124,7 @@ class TestShoppingCart(unittest.TestCase): self.assertEquals(quotation.taxes_and_charges, tax_rule_master) self.assertEquals(quotation.total_taxes_and_charges, 1000.0) - def create_tax_rule(self): - for tax_rule_setting in [{"priority": 1, "use_for_shopping_cart": 1}, {"priority": 2, "use_for_shopping_cart": 0}]: - tax_template = self.get_tax_template(tax_rule_setting['priority']).name - tax_rule = frappe.get_doc({ - "doctype": "Tax Rule", - "tax_type" : "Sales", - "sales_tax_template": tax_template, - "use_for_shopping_cart": tax_rule_setting["use_for_shopping_cart"], - "billing_city": "_Test City", - "billing_country": "India", - "shipping_city": "_Test City", - "shipping_country": "India", - "priority": tax_rule_setting['priority'], - "company": frappe.get_value("Global Defaults", "Global Defaults", "default_company") - }).insert() - - def get_tax_template(self, priority): - return frappe.get_doc({ - "doctype" : "Sales Taxes and Charges Template", - "title": "_Test Tax %s"%priority, - "company": frappe.get_value("Global Defaults", "Global Defaults", "default_company"), - "taxes":[{ - "charge_type": "Actual", - "account_head": "Sales Expenses - _TC", - "cost_center": "Main - _TC", - "description": "Test Shopping cart taxes with Tax Rule", - "tax_amount": 1000*priority - }], - "territories":[{ - "territory" : "All Territories" - }] - }).insert() + self.remove_test_quotation(quotation) def create_quotation(self): quotation = frappe.new_doc("Quotation") @@ -176,16 +143,19 @@ class TestShoppingCart(unittest.TestCase): "item_code": "_Test Item", "qty": 1 }], - "taxes": frappe.get_doc("Sales Taxes and Charges Template", "_Test Tax 1").taxes + "taxes": frappe.get_doc("Sales Taxes and Charges Template", "_Test Tax 1").taxes, + "company": "_Test Company" } quotation.update(values) quotation.insert(ignore_permissions=True) - frappe.reload_doc("selling", "Quotation", quotation.name) - return quotation + + def remove_test_quotation(self, quotation): + frappe.set_user("Administrator") + quotation.delete() # helper functions def enable_shopping_cart(self): @@ -210,6 +180,7 @@ class TestShoppingCart(unittest.TestCase): ]) settings.set("shipping_rules", {"doctype": "Shopping Cart Shipping Rule", "parentfield": "shipping_rules", "shipping_rule": "_Test Shipping Rule - India"}) + settings.save() frappe.local.shopping_cart_settings = None @@ -273,7 +244,6 @@ class TestShoppingCart(unittest.TestCase): quotation = get_quotation() quotation.set("items", []) quotation.save(ignore_permissions=True) - - + test_dependencies = ["Sales Taxes and Charges Template", "Price List", "Item Price", "Shipping Rule", "Currency Exchange", - "Customer Group", "Lead", "Customer", "Contact", "Address", "Item"] + "Customer Group", "Lead", "Customer", "Contact", "Address", "Item", "Tax Rule"]