import influxframework
from influxframework.utils import cint


def execute():
	"""Get 'Disable CWIP Accounting value' from Asset Settings, set it in 'Enable Capital Work in Progress Accounting' field
	in Company, delete Asset Settings"""

	if influxframework.db.exists("DocType", "Asset Settings"):
		influxframework.reload_doctype("Asset Category")
		cwip_value = influxframework.db.get_single_value("Asset Settings", "disable_cwip_accounting")

		influxframework.db.sql("""UPDATE `tabAsset Category` SET enable_cwip_accounting = %s""", cint(cwip_value))

		influxframework.db.sql("""DELETE FROM `tabSingles` where doctype = 'Asset Settings'""")
		influxframework.delete_doc_if_exists("DocType", "Asset Settings")
