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


import xhiveframework

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 xhiveframework.db.table_exists(new_doc) and xhiveframework.db.table_exists(old_doc):
			xhiveframework.rename_doc("DocType", old_doc, new_doc)
			xhiveframework.reload_doc("accounts", "doctype", xhiveframework.scrub(new_doc))
			xhiveframework.delete_doc("DocType", old_doc)
