def initialize_taxes(self): for tax in self.doc.get("taxes"): if not self.discount_amount_applied: validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self.doc) tax.item_wise_tax_detail = {} tax_fields = [ "total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item", ] if tax.charge_type != "Actual" and not ( self.discount_amount_applied and self.doc.apply_discount_on == "Grand Total" ): tax_fields.append("tax_amount") for fieldname in tax_fields: tax.set(fieldname, 0.0) self.doc.round_floats_in(tax)
def initialize_taxes(self): for tax in self.doc.get("taxes"): if not self.discount_amount_applied: validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self.doc) if not (self.doc.get("is_consolidated") or tax.get("dont_recompute_tax")): tax.item_wise_tax_detail = {} tax_fields = [ "total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item", ] if tax.charge_type != "Actual" and not ( self.discount_amount_applied and self.doc.apply_discount_on == "Grand Total"): tax_fields.append("tax_amount") for fieldname in tax_fields: tax.set(fieldname, 0.0) self.doc.round_floats_in(tax)
def initialize_taxes(self): for tax in self.doc.get("taxes"): if not self.discount_amount_applied: validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self.doc) tax.item_wise_tax_detail = {} tax_fields = [ "total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item" ] if tax.charge_type not in ["Actual", "Weighted Distribution"] and \ not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"): tax_fields.append("tax_amount") for fieldname in tax_fields: tax.set(fieldname, 0.0) if self.should_round_transaction_currency(): self.doc.round_floats_in(tax) else: self.doc.round_floats_in(tax, ["rate"])
def valdiate_taxes_and_charges_template(doc): #if not doc.is_default and not frappe.get_all(doc.doctype, filters={"is_default": 1}): # doc.is_default = 1 if doc.is_default == 1: frappe.db.sql("""update `tab{0}` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""".format(doc.doctype), (doc.name, doc.company)) for tax in doc.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, doc)
def validate(self): if self.is_default == 1: frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""", (self.name, self.company)) # at least one territory self.validate_table_has_rows("territories") for tax in self.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self)
def valdiate_taxes_and_charges_template(doc): if not doc.is_default and not frappe.get_all(doc.doctype, filters={"is_default": 1}): doc.is_default = 1 if doc.is_default == 1: frappe.db.sql("""update `tab{0}` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""".format(doc.doctype), (doc.name, doc.company)) for tax in doc.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, doc)
def validate(self): if self.is_default == 1: frappe.db.sql( """update `tabSales Taxes and Charges Master` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""", (self.name, self.company)) # at least one territory self.validate_table_has_rows("territories") for tax in self.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self)
def valdiate_taxes_and_charges_template(doc): if not doc.is_default and not frappe.get_all(doc.doctype, filters={"is_default": 1}): doc.is_default = 1 if doc.is_default == 1: frappe.db.sql("""update `tab{0}` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""".format(doc.doctype), (doc.name, doc.company)) if doc.meta.get_field("territories"): if not doc.territories: doc.append("territories", {"territory": get_root_of("Territory") }) for tax in doc.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, doc)
def valdiate_taxes_and_charges_template(doc): # default should not be disabled # if not doc.is_default and not frappe.get_all(doc.doctype, filters={"is_default": 1}): # doc.is_default = 1 if doc.is_default == 1: frappe.db.sql( """update `tab{0}` set is_default = 0 where is_default = 1 and name != %s and company = %s""".format(doc.doctype), (doc.name, doc.company)) validate_disabled(doc) # Validate with existing taxes and charges template for unique tax category validate_for_tax_category(doc) for tax in doc.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, doc)
def validate(self): for tax in self.get("taxes"): validate_taxes_and_charges(tax) validate_inclusive_tax(tax, self)