# License: GNU General Public License v3. See license.txt


import xhiveframework


def execute():
	if xhiveframework.db.table_exists("POS Closing Voucher"):
		if not xhiveframework.db.exists("DocType", "POS Closing Entry"):
			xhiveframework.rename_doc("DocType", "POS Closing Voucher", "POS Closing Entry", force=True)

		if not xhiveframework.db.exists("DocType", "POS Closing Entry Taxes"):
			xhiveframework.rename_doc("DocType", "POS Closing Voucher Taxes", "POS Closing Entry Taxes", force=True)

		if not xhiveframework.db.exists("DocType", "POS Closing Voucher Details"):
			xhiveframework.rename_doc(
				"DocType", "POS Closing Voucher Details", "POS Closing Entry Detail", force=True
			)

		xhiveframework.reload_doc("Accounts", "doctype", "POS Closing Entry")
		xhiveframework.reload_doc("Accounts", "doctype", "POS Closing Entry Taxes")
		xhiveframework.reload_doc("Accounts", "doctype", "POS Closing Entry Detail")

	if xhiveframework.db.exists("DocType", "POS Closing Voucher"):
		xhiveframework.delete_doc("DocType", "POS Closing Voucher")
		xhiveframework.delete_doc("DocType", "POS Closing Voucher Taxes")
		xhiveframework.delete_doc("DocType", "POS Closing Voucher Details")
		xhiveframework.delete_doc("DocType", "POS Closing Voucher Invoices")
