Merge pull request #5373 from rohitwaghchaure/tax_rule_fixes
[Fixes] tax rule, tax rule working even if tax template inside the rule is disabled.
This commit is contained in:
commit
a1f7e070ec
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
||||||
|
|
||||||
@ -19,6 +20,12 @@ def valdiate_taxes_and_charges_template(doc):
|
|||||||
where is_default = 1 and name != %s and company = %s""".format(doc.doctype),
|
where is_default = 1 and name != %s and company = %s""".format(doc.doctype),
|
||||||
(doc.name, doc.company))
|
(doc.name, doc.company))
|
||||||
|
|
||||||
|
validate_disabled(doc)
|
||||||
|
|
||||||
for tax in doc.get("taxes"):
|
for tax in doc.get("taxes"):
|
||||||
validate_taxes_and_charges(tax)
|
validate_taxes_and_charges(tax)
|
||||||
validate_inclusive_tax(tax, doc)
|
validate_inclusive_tax(tax, doc)
|
||||||
|
|
||||||
|
def validate_disabled(doc):
|
||||||
|
if doc.is_default and doc.disabled:
|
||||||
|
frappe.throw(_("Disabled template must not be default template"))
|
||||||
|
@ -140,4 +140,11 @@ def get_tax_template(posting_date, args):
|
|||||||
if rule.get(key): rule.no_of_keys_matched += 1
|
if rule.get(key): rule.no_of_keys_matched += 1
|
||||||
|
|
||||||
rule = sorted(tax_rule, lambda b, a: cmp(a.no_of_keys_matched, b.no_of_keys_matched) or cmp(a.priority, b.priority))[0]
|
rule = sorted(tax_rule, lambda b, a: cmp(a.no_of_keys_matched, b.no_of_keys_matched) or cmp(a.priority, b.priority))[0]
|
||||||
return rule.sales_tax_template or rule.purchase_tax_template
|
|
||||||
|
tax_template = rule.sales_tax_template or rule.purchase_tax_template
|
||||||
|
doctype = "{0} Taxes and Charges Template".format(rule.tax_type)
|
||||||
|
|
||||||
|
if frappe.db.get_value(doctype, tax_template, 'disabled')==1:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return tax_template
|
||||||
|
Loading…
x
Reference in New Issue
Block a user