import xhiveframework


def execute():
	xhiveframework.reload_doc("loan_management", "doctype", "loan")
	loan = xhiveframework.qb.DocType("Loan")

	for company in xhiveframework.get_all("Company", pluck="name"):
		default_cost_center = xhiveframework.db.get_value("Company", company, "cost_center")
		xhiveframework.qb.update(loan).set(loan.cost_center, default_cost_center).where(
			loan.company == company
		).run()
