repair_orders_fact = dj.create_transform(
    name=f"{NAMESPACE_MAPPING['default']}.repair_orders_fact",
    display_name="Repair Orders Fact",
    description="""Fact transform with all details on repair orders""",
    mode="published",
    primary_key=[],
    tags=[],
    query=f"""SELECT  repair_orders.repair_order_id,
	repair_orders.municipality_id,
	repair_orders.hard_hat_id,
	repair_orders.dispatcher_id,
	repair_orders.order_date,
	repair_orders.dispatched_date,
	repair_orders.required_date,
	repair_order_details.discount,
	repair_order_details.price,
	repair_order_details.quantity,
	repair_order_details.repair_type_id,
	repair_order_details.price * repair_order_details.quantity AS total_repair_cost,
	repair_orders.dispatched_date - repair_orders.order_date AS time_to_dispatch,
	repair_orders.dispatched_date - repair_orders.required_date AS dispatch_delay
 FROM {NAMESPACE_MAPPING['default']}.repair_orders repair_orders JOIN {NAMESPACE_MAPPING['default']}.repair_order_details repair_order_details ON repair_orders.repair_order_id = repair_order_details.repair_order_id""",
    update_if_exists=True,
)
