[Fixes] Tax Rule preparation and test taxes creation, remove dummy quotation
This commit is contained in:
parent
8f7317175d
commit
7c867ae9ad
@ -213,5 +213,35 @@
|
|||||||
"territory": "_Test Territory Rest Of The World"
|
"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"
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
26
erpnext/accounts/doctype/tax_rule/test_records.json
Normal file
26
erpnext/accounts/doctype/tax_rule/test_records.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
@ -182,6 +182,7 @@ class AccountsController(TransactionBase):
|
|||||||
self.append_taxes_from_master(tax_master_doctype)
|
self.append_taxes_from_master(tax_master_doctype)
|
||||||
|
|
||||||
def append_taxes_from_master(self, tax_master_doctype=None):
|
def append_taxes_from_master(self, tax_master_doctype=None):
|
||||||
|
print "append_taxes_from_master"
|
||||||
if self.get("taxes_and_charges"):
|
if self.get("taxes_and_charges"):
|
||||||
if not tax_master_doctype:
|
if not tax_master_doctype:
|
||||||
tax_master_doctype = self.meta.get_field("taxes_and_charges").options
|
tax_master_doctype = self.meta.get_field("taxes_and_charges").options
|
||||||
|
@ -35,7 +35,6 @@ def get_quotation(user=None):
|
|||||||
quotation = frappe.new_doc("Quotation")
|
quotation = frappe.new_doc("Quotation")
|
||||||
quotation.update(values)
|
quotation.update(values)
|
||||||
if party.doctype == "Customer":
|
if party.doctype == "Customer":
|
||||||
print "create quoation for cutomer"
|
|
||||||
quotation.contact_person = frappe.db.get_value("Contact", {"customer": party.name, "email_id": user})
|
quotation.contact_person = frappe.db.get_value("Contact", {"customer": party.name, "email_id": user})
|
||||||
quotation.insert(ignore_permissions=True)
|
quotation.insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
}
|
|
@ -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
|
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
from erpnext.shopping_cart import get_quotation, set_item_in_cart, get_party
|
from erpnext.shopping_cart import get_quotation, set_item_in_cart, get_party
|
||||||
import random
|
|
||||||
|
|
||||||
class TestShoppingCart(unittest.TestCase):
|
class TestShoppingCart(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
@ -113,10 +112,9 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_taxe_rule(self):
|
def test_taxe_rule(self):
|
||||||
self.create_tax_rule()
|
|
||||||
self.login_as_customer()
|
self.login_as_customer()
|
||||||
quotation = self.create_quotation()
|
quotation = self.create_quotation()
|
||||||
|
|
||||||
from erpnext.accounts.party import set_taxes
|
from erpnext.accounts.party import set_taxes
|
||||||
|
|
||||||
tax_rule_master = set_taxes(quotation.customer, "Customer", \
|
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.taxes_and_charges, tax_rule_master)
|
||||||
self.assertEquals(quotation.total_taxes_and_charges, 1000.0)
|
self.assertEquals(quotation.total_taxes_and_charges, 1000.0)
|
||||||
|
|
||||||
def create_tax_rule(self):
|
self.remove_test_quotation(quotation)
|
||||||
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()
|
|
||||||
|
|
||||||
def create_quotation(self):
|
def create_quotation(self):
|
||||||
quotation = frappe.new_doc("Quotation")
|
quotation = frappe.new_doc("Quotation")
|
||||||
@ -176,16 +143,19 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
"qty": 1
|
"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.update(values)
|
||||||
|
|
||||||
quotation.insert(ignore_permissions=True)
|
quotation.insert(ignore_permissions=True)
|
||||||
|
|
||||||
frappe.reload_doc("selling", "Quotation", quotation.name)
|
|
||||||
|
|
||||||
return quotation
|
return quotation
|
||||||
|
|
||||||
|
def remove_test_quotation(self, quotation):
|
||||||
|
frappe.set_user("Administrator")
|
||||||
|
quotation.delete()
|
||||||
|
|
||||||
# helper functions
|
# helper functions
|
||||||
def enable_shopping_cart(self):
|
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",
|
settings.set("shipping_rules", {"doctype": "Shopping Cart Shipping Rule", "parentfield": "shipping_rules",
|
||||||
"shipping_rule": "_Test Shipping Rule - India"})
|
"shipping_rule": "_Test Shipping Rule - India"})
|
||||||
|
|
||||||
|
|
||||||
settings.save()
|
settings.save()
|
||||||
frappe.local.shopping_cart_settings = None
|
frappe.local.shopping_cart_settings = None
|
||||||
@ -273,7 +244,6 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
quotation = get_quotation()
|
quotation = get_quotation()
|
||||||
quotation.set("items", [])
|
quotation.set("items", [])
|
||||||
quotation.save(ignore_permissions=True)
|
quotation.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
|
||||||
test_dependencies = ["Sales Taxes and Charges Template", "Price List", "Item Price", "Shipping Rule", "Currency Exchange",
|
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"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user