{
  "name": "query/manager/product/production_order/lead_time_grid.json",
  "database": "4d",
  "parameter": {
    "show_sql": true,
    "start_date": "",
		"end_date": "",
		"finished_state": ["LT"],
		"delivery_state": "LT"
	},
	"query": [
    ["wo_act_finish_date", ">=", "start_date"],
    "and",
		["wo_act_finish_date", "<=", "end_date"],
		"and",
		["wo_state", "in", "finished_state"]	
  ],
	"order": ["wo_production_lot", ">"],
	"aggregate": {
		"sum": [
			"wpa_work_time__amount"
		],
		"max": [
			"sor_delivery_date", "sor_sales_order_id", "so_order_date"
		]
	},
	"field": [
		"wo_produced_amount",
		"wo_production_lot",
		"wo_act_finish_date",
		"wpa_work_time__amount",
		"w_product_id",
		"sor_delivery_date",
		"sor_sales_order_id",
		"so_order_date"
	],
	
	"queryX": [
		["sor_delivery_state", "=", "delivery_state"],
		"or",
		["sor_delivery_state", "=", "NULL"]
  ],
	"queryY": [
    ["wo_act_finish_date", ">=", "start_date"],
    "and",
		["wo_act_finish_date", "<=", "end_date"],
		"and",
		["wo_state", "in", "finished_state"],
		"and",
		"order_row_state"
  ],
  "queryZ": [
		["sor_delivery_state", "=", "delivery_state"],
		"and",
    ["wo_act_finish_date", ">=", "start_date"],
    "and",
		["wo_act_finish_date", "<=", "end_date"],
		"and",
		["wo_state", "in", "finished_state"]	
	],
	"set":{
		"order_row_state": [
			["sor_delivery_state", "=", "delivery_state"]
		],
		"order_row_stateX": [
			["sor_delivery_state", "=", "NULL"]
		]
	}
}
