{
	"name": "form/manager/productivity_report/filter.json",
	"definition": {
		"speed_row_other_lg": [
			{
				"info": "speed_row_other_lg",
				"table": "wpa",
				"rule": [
					["prwo.production_lot", "==", "param.production_lot"],
					["prwo.work_phase_number", "==", "param.work_phase_est_id"]
				]
			}
		],
		"develop_chart": [
			{
				"info": "develop_chart",
				"table": "",
				"rule": [["includes", ["param.load_group", "load_group"]]]
			}
		],
		"wpa_time_period": {
			"info": "wpa_time_period, used elsewhere, must NOT be an array",
			"info2": "shift: yv=1, av=2, iv=3, em=4",
			"info3": "iv or em shift can be within next day, but it isn't next day work shift",
			"info4": "yv shift can be within pevious day, but it is time period work shift",
			"table": "wpa",
			"rule": [
				["includes", ["param.load_group", "prwo.resource_id"]],
				["prwo.json_data.end_date", ">=", "param.start_prev_date"],
				["prwo.json_data.end_date", "<=", "param.end_next_date"],
				[
					[
						["prwo.json_data.end_date", "<>", "param.start_date"],
						"or",
						["prwo.json_data.end_time", ">=", "12:00:00"],
						"or",
						["prwo.json_data.work_shift", "<", 3]
					]
				],
				[
					[
						["prwo.json_data.end_date", "<>", "param.end_date"],
						"or",
						["prwo.json_data.end_time", "<=", "12:00:00"],
						"or",
						["prwo.json_data.work_shift", "<>", 1]
					]
				],
				[
					[
						["prwo.json_data.end_date", "<>", "param.start_prev_date"],
						"or",
						["prwo.json_data.end_time", ">", "12:00:00"]
					]
				],
				[[["prwo.json_data.end_date", "<>", "param.start_prev_date"], "or", ["prwo.json_data.work_shift", "==", 1]]],
				[
					[["prwo.json_data.end_date", "<>", "param.end_next_date"], "or", ["prwo.json_data.end_time", "<", "12:00:00"]]
				],
				[[["prwo.json_data.end_date", "<>", "param.end_next_date"], "or", ["prwo.json_data.work_shift", ">=", 3]]]
			]
		},
		"finished_estimated_work_time": [
			{
				"info": "finished_estimated_work_time",
				"table": "wpa",
				"rule": [["finished_work_time", "<>", 0], ["includes", ["param.load_group", "prwo.resource_id"]]]
			}
		],
		"finished_work_time": [
			{
				"info": "finished_work_time",
				"table": "wpa",
				"rule": [["std_time", ">", 0], ["includes", ["param.load_group", "prwo.resource_id"]]]
			}
		],
		"track_time_asked": [
			{
				"info": "track_time_asked",
				"table": "track_time",
				"rule": [
					[["prwo.json_data.track_time_status", ">=", 1], "and", ["prwo.json_data.track_time_status", "<=", 4]],
					["includes", ["param.load_group", "prwo.resource_id"]]
				]
			}
		],
		"track_time_measured": [
			{
				"info": "track_time_measured",
				"table": "track_time",
				"rule": [
					[["prwo.json_data.track_time_status", ">=", 2], "and", ["prwo.json_data.track_time_status", "<=", 3]],
					["includes", ["param.load_group", "prwo.resource_id"]]
				]
			}
		],
		"track_time_changed": [
			{
				"info": "track_time_changed",
				"table": "track_time",
				"rule": [
					["previous_batch_number", "<>", 0],
					["prwo.json_data.measured_track_time", "<>", 0],
					["includes", ["param.load_group", "prwo.resource_id"]]
				]
			}
		],
		"unproductive": [
			{
				"info": "unproductive",
				"table": "wpa",
				"rule": [["prwo.work_phase_type", "==", "ET"], ["includes", ["param.load_group", "prwo.resource_id"]]]
			}
		],
		"capacity_work_time": [
			{
				"info": "capacity_work_time",
				"table": "wpa",
				"rule": [
					["prwo.work_phase_type", "<>", "ET"],
					["prwo.json_data.work_shift", "==", "param.shift"],
					["includes", ["param.load_group", "prwo.resource_id"]]
				]
			}
		],
		"capacity_unproductive_work_time": [
			{
				"info": "capacity_unproductive_work_time",
				"table": "wpa",
				"rule": [
					["prwo.work_phase_type", "==", "ET"],
					["prwo.json_data.work_shift", "==", "param.shift"],
					["includes", ["param.load_group", "prwo.resource_id"]]
				]
			},
			{
				"info": "wpa_time_period",
				"table": "wpa",
				"rule": "wpa_time_period"
			}
		],
		"capacity_shift": [
			{
				"info": "shift",
				"table": "capacity",
				"rule": [["shift", "==", "param.shift"]]
			}
		],
		"capacity": [
			{
				"info": "time_period",
				"info2": "shift: yv=1, av=2, iv=3, em=4",
				"info3": "em shift can be within next day, but it isn't next day work shift ",
				"table": "capacity",
				"rule": [
					["end_dt", ">=", "param.start_date"],
					["end_dt", "<=", "param.end_next_date"],
					[[["end_dt", "<>", "param.start_date"], "or", ["end_dt", ">=", "12:00:00"], "or", ["shift", "<", 3]]],
					[[["end_dt", "<>", "param.end_next_date"], "or", ["end_dt", "<", "12:00:00"]]],
					[[["end_dt", "<>", "param.end_next_date"], "or", ["shift", ">=", 3]]]
				]
			}
		],
		"reclamation_load_group": [
			{
				"info": "reclamation_load_group",
				"table": "rcl",
				"rule": [["includes", ["param.load_group", "rcl.json_data.fault_made_resource_id"]]]
			}
		],
		"finished_reclamation": [
			{
				"info": "finished_reclamation",
				"table": "rcl",
				"rule": [
					["includes", ["param.load_group", "rcl.json_data.fault_made_resource_id"]],
					["rcl.reclamation_state", "<>", 0],
					["rcl.finished_date", ">=", "param.start_date"],
					["rcl.finished_date", "<=", "param.end_date"]
				]
			}
		],
		"track_time_map": [
			{
				"info": "track_time_map",
				"table": "track_time",
				"rule": [
					["includes", ["param.load_group", "prwo.resource_id"]],
					["prwo.json_data.end_date", ">=", "param.start_date"],
					["prwo.json_data.end_date", "<=", "param.end_date"]
				]
			}
		],
		"wlg_load_group": [
			{
				"info": "wlg_load_group",
				"table": "wlg",
				"rule": [["includes", ["param.load_group", "res.resource_id"]]]
			}
		],
		"speed": [
			{
				"info": "no_unproductivity",
				"table": "wpa",
				"rule": [["includes", ["param.load_group", "prwo.resource_id"]], ["prwo.work_phase_type", "<>", "ET"]]
			},
			{
				"info": "no_fms",
				"use": [["rec.query_name", "==", "no_fms"]],
				"table": "wpa",
				"rule": [
					["includes", ["param.load_group", "prwo.resource_id"]],
					[["work_time_fms", "==", 0], "or", ["res.json_data.use_automatic_receipt", "<=", 0]]
				]
			},
			{
				"info": "only_fms",
				"use": [["rec.query_name", "==", "only_fms"]],
				"table": "wpa",
				"rule": [
					["includes", ["param.load_group", "prwo.resource_id"]],
					[["work_time_fms", "<>", 0], "or", ["res.json_data.use_automatic_receipt", "<=", 0]]
				]
			},
			{
				"info": "time_period",
				"info2": "shift: yv=1, av=2, iv=3, em=4",
				"info3": "em shift can be within next day, but it isn't next day work shift",
				"info4": "productivity_report.lua - createWpaIdTableWithTimePeriod(...)",
				"table": "wpa",
				"rule": "wpa_time_period"
			}
		],
		"quality": [
			{
				"info": "time_period",
				"info2": "shift: yv=1, av=2, iv=3, em=4",
				"info3": "em shift can be within next day, but it isn't next day work shift",
				"info4": "productivity_report.lua - createWpaIdTableWithTimePeriod(...)",
				"table": "wpa",
				"rule": "wpa_time_period"
			}
		]
	}
}
