2015-08-21 10:23:10 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
2015-09-24 09:35:06 +00:00
|
|
|
frappe.reload_doc("accounts", "doctype", "tax_rule")
|
2015-09-24 09:34:15 +00:00
|
|
|
|
|
|
|
customers = frappe.db.sql("""select name, default_taxes_and_charges from tabCustomer where
|
2015-08-21 10:23:10 +00:00
|
|
|
ifnull(default_taxes_and_charges, '') != '' """, as_dict=1)
|
2015-09-24 09:34:15 +00:00
|
|
|
|
2015-08-21 10:23:10 +00:00
|
|
|
for d in customers:
|
2015-12-08 11:20:20 +00:00
|
|
|
if not frappe.db.sql("select name from `tabTax Rule` where customer=%s", d.name):
|
2015-12-08 07:26:14 +00:00
|
|
|
tr = frappe.new_doc("Tax Rule")
|
|
|
|
tr.tax_type = "Sales"
|
|
|
|
tr.customer = d.name
|
|
|
|
tr.sales_tax_template = d.default_taxes_and_charges
|
|
|
|
tr.save()
|
2015-08-21 10:23:10 +00:00
|
|
|
|
2015-09-24 09:34:15 +00:00
|
|
|
|
|
|
|
suppliers = frappe.db.sql("""select name, default_taxes_and_charges from tabSupplier where
|
2015-08-21 10:23:10 +00:00
|
|
|
ifnull(default_taxes_and_charges, '') != '' """, as_dict=1)
|
2015-09-24 09:34:15 +00:00
|
|
|
|
2015-08-21 10:23:10 +00:00
|
|
|
for d in suppliers:
|
2015-12-08 11:20:20 +00:00
|
|
|
if not frappe.db.sql("select name from `tabTax Rule` where supplier=%s", d.name):
|
2015-12-08 07:26:14 +00:00
|
|
|
tr = frappe.new_doc("Tax Rule")
|
|
|
|
tr.tax_type = "Purchase"
|
|
|
|
tr.supplier = d.name
|
|
|
|
tr.purchase_tax_template = d.default_taxes_and_charges
|
|
|
|
tr.save()
|