# Copyright (c) 2017, InfluxFrameworkand Contributors
# License: GNU General Public License v3. See license.txt


import influxframework

doctypes = {
	"Price Discount Slab": "Promotional Scheme Price Discount",
	"Product Discount Slab": "Promotional Scheme Product Discount",
	"Apply Rule On Item Code": "Pricing Rule Item Code",
	"Apply Rule On Item Group": "Pricing Rule Item Group",
	"Apply Rule On Brand": "Pricing Rule Brand",
}


def execute():
	for old_doc, new_doc in doctypes.items():
		if not influxframework.db.table_exists(new_doc) and influxframework.db.table_exists(old_doc):
			influxframework.rename_doc("DocType", old_doc, new_doc)
			influxframework.reload_doc("accounts", "doctype", influxframework.scrub(new_doc))
			influxframework.delete_doc("DocType", old_doc)
