fix: Item tax validity comparison fixes (#34784)
fix: Item tax validity comparsion fixes
This commit is contained in:
parent
02d5d43eb1
commit
6f6928fa7b
@ -36,8 +36,24 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
|
|
||||||
self.make_route()
|
self.make_route()
|
||||||
self.validate_item_group_defaults()
|
self.validate_item_group_defaults()
|
||||||
|
self.check_item_tax()
|
||||||
ECommerceSettings.validate_field_filters(self.filter_fields, enable_field_filters=True)
|
ECommerceSettings.validate_field_filters(self.filter_fields, enable_field_filters=True)
|
||||||
|
|
||||||
|
def check_item_tax(self):
|
||||||
|
"""Check whether Tax Rate is not entered twice for same Tax Type"""
|
||||||
|
check_list = []
|
||||||
|
for d in self.get("taxes"):
|
||||||
|
if d.item_tax_template:
|
||||||
|
if (d.item_tax_template, d.tax_category) in check_list:
|
||||||
|
frappe.throw(
|
||||||
|
_("{0} entered twice {1} in Item Taxes").format(
|
||||||
|
frappe.bold(d.item_tax_template),
|
||||||
|
"for tax category {0}".format(frappe.bold(d.tax_category)) if d.tax_category else "",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
check_list.append((d.item_tax_template, d.tax_category))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
NestedSet.on_update(self)
|
NestedSet.on_update(self)
|
||||||
invalidate_cache_for(self)
|
invalidate_cache_for(self)
|
||||||
|
@ -351,10 +351,15 @@ class Item(Document):
|
|||||||
check_list = []
|
check_list = []
|
||||||
for d in self.get("taxes"):
|
for d in self.get("taxes"):
|
||||||
if d.item_tax_template:
|
if d.item_tax_template:
|
||||||
if d.item_tax_template in check_list:
|
if (d.item_tax_template, d.tax_category) in check_list:
|
||||||
frappe.throw(_("{0} entered twice in Item Tax").format(d.item_tax_template))
|
frappe.throw(
|
||||||
|
_("{0} entered twice {1} in Item Taxes").format(
|
||||||
|
frappe.bold(d.item_tax_template),
|
||||||
|
"for tax category {0}".format(frappe.bold(d.tax_category)) if d.tax_category else "",
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
check_list.append(d.item_tax_template)
|
check_list.append((d.item_tax_template, d.tax_category))
|
||||||
|
|
||||||
def validate_barcode(self):
|
def validate_barcode(self):
|
||||||
import barcodenumber
|
import barcodenumber
|
||||||
|
@ -637,7 +637,9 @@ def _get_item_tax_template(args, taxes, out=None, for_validate=False):
|
|||||||
taxes_with_no_validity.append(tax)
|
taxes_with_no_validity.append(tax)
|
||||||
|
|
||||||
if taxes_with_validity:
|
if taxes_with_validity:
|
||||||
taxes = sorted(taxes_with_validity, key=lambda i: i.valid_from, reverse=True)
|
taxes = sorted(
|
||||||
|
taxes_with_validity, key=lambda i: i.valid_from or tax.maximum_net_rate, reverse=True
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
taxes = taxes_with_no_validity
|
taxes = taxes_with_no_validity
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user