{
	"name": "query/manager/product/production_order/lead_time_grid.json",
	"table": [
		{
			"record_type": [""],
			"table": "production_order"
		},
		{
			"record_type": ["actual"],
			"table": "product_work"
		},
		{
			"record_type": [""],
			"table": "product"
		}
	],
	"database": "4d",
	"parameter": {
		"finished_state": ["LT"],
		"order_with_row": [
				
			],
		"show_sql": false,
		"subquery": "SELECT record_id FROM work_order WHERE CONCAT(CONCAT(sales_order_id, '.'), sales_order_row_id) IN ({{order_with_row}})",
		"subqueryX": "SELECT record_id FROM production_order WHERE CONCAT(CONCAT(sales_order_id, '.'), sales_order_row) IN ({{order_with_row}})",
		"subqueryZ": "query/manager/product/production_order/lead_time_grid_subquery.json"
	},
	"field": [
		"pro.record_id",
		"pro.sales_order_id",
		"pro.sales_order_row",
		"pro.production_order_id",
		"pro.produced_amount",
		"pro.production_lot",
		"pro.json_data.print_date",
		"prwo.work_hours",
		"prwo.json_data.start_date",
		"prwo.json_data.end_date",
		"pr.product_id",
		"pr.name"
	],
	"aggregateX": {
		"maxX": ["prwo.json_data.end_date"],
		"minX": ["prwo.json_data.end_date"],
		"sum": ["prwo.work_hours"]
	},
	"order": [
		"pro.sales_order_id",
		">",
		"pro.sales_order_row",
		">",
		"pro.production_lot",
		">"
	],
	"query": [
		["pro.record_id", "in", "subquery"],
		"and",
		["pro.production_order_state", "in", "finished_state"]
	]
}