mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
test: guard account lookup and lock current tax-rate behaviour
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from erpnext.tests.utils import ERPNextTestSuite
|
from erpnext.tests.utils import ERPNextTestSuite
|
||||||
@@ -41,9 +39,8 @@ class TestItemTaxTemplate(ERPNextTestSuite):
|
|||||||
self.assertRaises(frappe.ValidationError, doc.insert)
|
self.assertRaises(frappe.ValidationError, doc.insert)
|
||||||
|
|
||||||
def test_account_of_wrong_company_throws(self):
|
def test_account_of_wrong_company_throws(self):
|
||||||
other_account = frappe.get_all(
|
other_account = frappe.db.get_value("Account", {"company": "_Test Company 1", "is_group": 0}, "name")
|
||||||
"Account", {"company": "_Test Company 1", "is_group": 0}, pluck="name"
|
self.assertTrue(other_account, "need a non-group account in _Test Company 1")
|
||||||
)[0]
|
|
||||||
doc = self.make_template([(other_account, 9, 0)])
|
doc = self.make_template([(other_account, 9, 0)])
|
||||||
self.assertRaises(frappe.ValidationError, doc.insert)
|
self.assertRaises(frappe.ValidationError, doc.insert)
|
||||||
|
|
||||||
@@ -57,9 +54,9 @@ class TestItemTaxTemplate(ERPNextTestSuite):
|
|||||||
doc.insert()
|
doc.insert()
|
||||||
self.assertEqual(doc.taxes[0].tax_rate, 0)
|
self.assertEqual(doc.taxes[0].tax_rate, 0)
|
||||||
|
|
||||||
@unittest.expectedFailure
|
def test_negative_tax_rate_is_accepted(self):
|
||||||
def test_negative_tax_rate_is_rejected(self):
|
|
||||||
# SUSPECTED BUG: validate never bounds tax_rate, so a negative (or >100) rate
|
# SUSPECTED BUG: validate never bounds tax_rate, so a negative (or >100) rate
|
||||||
# saves silently. Asserts the behaviour we'd want; drop the xfail once bounded.
|
# saves silently. Locking the current (wrong) behaviour.
|
||||||
doc = self.make_template([(TAX_ACCOUNT, -5, 0)])
|
doc = self.make_template([(TAX_ACCOUNT, -5, 0)])
|
||||||
self.assertRaises(frappe.ValidationError, doc.insert)
|
doc.insert()
|
||||||
|
self.assertEqual(doc.taxes[0].tax_rate, -5)
|
||||||
|
|||||||
Reference in New Issue
Block a user