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


import xhiveframework


def execute():
	xhiveframework.reload_doc("manufacturing", "doctype", "job_card")
	xhiveframework.reload_doc("manufacturing", "doctype", "job_card_item")
	xhiveframework.reload_doc("manufacturing", "doctype", "work_order_operation")

	xhiveframework.db.sql(
		""" update `tabJob Card` jc, `tabWork Order Operation` wo
		SET	jc.hour_rate =  wo.hour_rate
		WHERE
			jc.operation_id = wo.name and jc.docstatus < 2 and wo.hour_rate > 0
	"""
	)
