{
  "name": "wpa/productivity_report/time_period_after.json",
  "database": "4d",
  "parameter": {
    "show_sql": false,
    "track_time_type": "OA",
    "end_date": "",
    "end_date2": "",
    "load_group": [],
    "production_lot": [],
    "subqueryXX": "SELECT CONCAT(production_lot, CONCAT('#', work_phase_est_id)) AS id, SUM(work_time__amount) FROM work_phase_actual WHERE date_ >= '{{end_date}}' AND (date_ <> '{{end_date}}' OR (end_time >= '12:00:00' AND shift_number = 1)) AND (date_ <> '{{end_date2}}' OR end_time >= '12:00:00' OR shift_number < 3) AND work_load_group_id IN ({{load_group}}) GROUP BY id",
    "subqueryX": "SELECT record_id FROM work_phase_actual WHERE CONCAT(production_lot, CONCAT('#', work_phase_est_id)) IN (SELECT CONCAT(production_lot, CONCAT('#', work_phase_est_id)) FROM work_phase_actual WHERE date_ BETWEEN '{{start_date2}}' AND '{{end_date2}}' AND work_load_group_id IN ({{load_group}}))"
  },
 "query": [
   ["wpa_date_", ">=", "end_date"], "and",
   ["wpa_type_", "<>", "track_time_type"],"and",
   ["take_shift_in_end_date"], "and",
   ["remove_next_day_shift"], "and",
   ["wpa_work_load_group_id", "in", "load_group"], "and",
   ["wpa_production_lot", "in", "production_lot"]
 ],
 "set": {
   "take_shift_in_end_date": [
      ["wpa_date_", "<>", "end_date"], "or", "shift_in_end_date"
   ],
   "shift_in_end_date": [
     ["wpa_end_time", ">=", "12:00:00"], "and",
     ["wpa_shift_number", "=", 1]
   ],
   "remove_next_day_shift": [
      ["wpa_date_", "<>", "end_date2"], "or",
      ["wpa_end_time", ">=", "12:00:00"], "or",
      ["wpa_shift_number", "<", 3]
   ]
 },
 "aggregate": {
   "sum": [
     "wpa_work_time__amount"
   ]
 },
 "orderXX": ["wpa_date_", ">"],
 "field": [
   "wpa_work_load_group_id",
   "wpa_production_lot",
   "wpa_work_phase_est_id",
   "wpa_work_time__amount"
 ]
}
