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


import influxframework


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

	influxframework.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
	"""
	)
