{
  "name": "query/manager/product/production_order/lead_time_grid.json",
  "database": "4d",
  "parameter": {
    "show_sql": true,
		"finished_state": ["LT"],
		"order_with_row": [],
		"subquery": "SELECT record_id FROM work_order WHERE CONCAT(CONCAT(sales_order_id, '.'), sales_order_row_id) IN ({{order_with_row}})"
	},
	"query": [
		["wo_record_id", "in", "subquery"],
		"and",
		["wo_state", "in", "finished_state"]	
	],
	"order": ["wo_sales_order_id", ">","wo_sales_order_row_id", ">","wo_production_lot", ">"],
	"aggregateX": {
		"sum": [
			"wpa_work_time__amount"
		],
		"minX": [
			"wpa_date_"
		],
		"maxX": [
			"wpa_date_"
		]
	},
	"field": [
		"wo_record_id",
		"wo_sales_order_id",
		"wo_sales_order_row_id",
		"wo_work_order_id",
		"wo_produced_amount",
		"wo_production_lot",
		"wo_act_finish_date",
		"wo_print_date",
		"wpa_work_time__amount",
		"wpa_start_date",
		"wpa_date_",
		"pr_product_id",
		"pr_name"
	]
}
