refactor: tax rule validity query (#30934)

This commit is contained in:
Ankush Menat 2022-05-09 19:26:13 +05:30 committed by GitHub
parent e5ebbf4799
commit 05dd1d6d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View File

@ -163,17 +163,15 @@ def get_party_details(party, party_type, args=None):
def get_tax_template(posting_date, args):
"""Get matching tax rule"""
args = frappe._dict(args)
from_date = to_date = posting_date
if not posting_date:
from_date = "1900-01-01"
to_date = "4000-01-01"
conditions = []
conditions = [
"""(from_date is null or from_date <= '{0}')
and (to_date is null or to_date >= '{1}')""".format(
from_date, to_date
if posting_date:
conditions.append(
f"""(from_date is null or from_date <= '{posting_date}')
and (to_date is null or to_date >= '{posting_date}')"""
)
]
else:
conditions.append("(from_date is null) and (to_date is null)")
conditions.append(
"ifnull(tax_category, '') = {0}".format(frappe.db.escape(cstr(args.get("tax_category"))))

View File

@ -139,7 +139,7 @@ class TestShoppingCart(unittest.TestCase):
tax_rule_master = set_taxes(
quotation.party_name,
"Customer",
quotation.transaction_date,
None,
quotation.company,
customer_group=None,
supplier_group=None,