{
	"name": "form/manager/productivity_report/map.json",
	"definition": {
		"wos_production_lot_phase": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wos_production_lot_phase"},
			"table": "wos",
			"map": [
				["wos_finished", "=", ["prwo.work_phase_state", "==", "LT"]],
				["wos_produced", "=", "prwo.produced_amount"],
				["wos_failed", "=", "prwo.failed_amount"]
			]
		},
		"wpe_work_phase": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wpe_work_phase"},
			"table": "wpe",
			"map": [["estimated_work_time__unit", "=", "prwo.work_hours"]]
		},
		"wpa_previous_work_order": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wpa_previous_work_order"},
			"table": "wpa",
			"map": [
				["previous_batch_number", "=", "pro.row_number"],
				["previous_measured_track_time", "=", "prwo.json_data.measured_track_time"]
			]
		},
		"wpa_speed": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wpa_speed"},
			"table": "wpa",
			"map": [
				[
					"if",
					["rec.query_name", "==", "no_fms"],
					[
						["prwo.work_hours", "=", ["work_time_not_fms_machine", "+", "work_time_other"]],
						["work_time_all", "=", ["all_work_time_not_fms_machine", "+", "all_work_time_other"]]
					],
					"elseif",
					["rec.query_name", "==", "only_fms"],
					[
						["prwo.work_hours", "=", ["work_time_not_fms_machine", "+", "work_time_fms"]],
						["work_time_all", "=", ["all_work_time_not_fms_machine", "+", "all_work_time_fms"]]
					],
					"else",
					[
						["prwo.work_hours", "=", ["work_time_not_fms_machine", "+", ["work_time_fms", "+", "work_time_other"]]],
						[
							"work_time_all",
							"=",
							["all_work_time_not_fms_machine", "+", ["all_work_time_fms", "+", "all_work_time_other"]]
						]
					]
				],
				["std_time", "=", [["prwo.work_hours", "/", "work_time_all"], "*", "prwo.json_data.target_time"]],
				["work_time__unit", "=", ["prwo.work_hours", "/", ["wos_produced", "+", "wos_failed"]]],
				["estimated_speed_percent", "=", [["estimated_work_time__unit", "/", "work_time__unit"], "*", 100]],
				["finished_work_time", "=", ["prwo.work_hours", "*", "wos_finished"]],
				["finished_std_time", "=", ["std_time", "*", "wos_finished"]],
				["finished_work_time__unit", "=", ["work_time__unit", "*", "wos_finished"]],
				["finished_estimated_work_time__unit", "=", ["estimated_work_time__unit", "*", "wos_finished"]]
			]
		},
		"wpa_fms": {
			"table": "wpa",
			"mapX": [
				["if", ["res.json_data.use_automatic_receipt", "<=", 0], ["work_time_not_fms_machine", "=", "prwo.work_hours"]],
				[
					"if",
					[["res.json_data.use_automatic_receipt", ">", 0], "and", ["prwo.person_id", "==", "FMS"]],
					["work_time_fms", "=", "prwo.work_hours"]
				],
				[
					"if",
					[["res.json_data.use_automatic_receipt", ">", 0], "and", ["prwo.person_id", "<>", "FMS"]],
					["work_time_other", "=", "prwo.work_hours"]
				]
			]
		},
		"wpa_speed_before": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wpa_speed"},
			"table": "wpa",
			"sum": [["work_time_before", "=", "prwo.work_hours"]],
			"count": [["before_time_period_count"]]
		},
		"wpa_speed_after": {
			"filter": {"name": "form/manager/productivity_report/filter_lua.json", "definition": "wpa_speed"},
			"table": "wpa",
			"sum": [["work_time_after", "=", "prwo.work_hours"]],
			"count": [["after_time_period_count"]]
		}
	}
}
