{
  "name": "dialog/productivity_report/filter.json",
  "definition": {
    "wlg_header": [
      {
        "info": "wlg_header",
        "rule": [
          ["includes", ["param.load_group", "wlg_work_load_group_id"]]
        ]
      }
    ],
    "track_time_asked": [
      {
        "info": "track_time_asked",
        "rule": [
          [["wpa_track_time_status", ">=", 1], "and", ["wpa_track_time_status", "<=", 4]]
        ],
        "ruleX": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
        ]
      }
    ],
    "track_time_measured": [
      {
        "info": "track_time_measured",
        "rule": [
          [["wpa_track_time_status", ">=", 2], "and", ["wpa_track_time_status", "<=", 3]]
        ],
         "ruleX": [
           ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "track_time_changed": [
      {
        "info": "track_time_changed",
        "rule": [
          ["previous_batch_number", "<>", 0]
        ],
        "ruleX": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
        ]
      }
    ],
    "work_time_all": [
      {
        "info": "work_time_all",
        "rule": [
           ["wpa_production_lot", "==", "param.wpa_production_lot"],
           ["wpa_work_phase_est_id", "==", "param.wpa_work_phase_est_id"]
         ],
        "ruleX": [
           ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "speed_row_calculate": [
      {
        "info": "speed_row_calculate",
        "rule": [
           ["wpa_record_id", "==", "param.wpa_record_id"],
           ["wos_finished", ">", 0],
           ["wpa_work_time__amount", ">", 0]
         ]
      }
    ],
    "before_time_period_count": [
      {
        "info": "before_time_period_count",
        "rule": [
          ["wpa_production_lot", "==", "param.wpa_production_lot"],
          ["wpa_work_phase_est_id", "==", "param.wpa_work_phase_est_id"]
        ],
        "rule": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "after_time_period_count": [
      {
        "info": "after_time_period_count",
        "rule": [
          ["wpa_production_lot", "==", "param.wpa_production_lot"],
          ["wpa_work_phase_est_id", "==", "param.wpa_work_phase_est_id"]
        ],
        "ruleX": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "estimated_work_time": [
      {
        "info": "estimated_work_time",
        "rule": [
          ["wpe_phase_number", "==", "param.wpa_work_phase_est_id"],
          ["wpe_work__position_num_id", "==", "param.wo_work__position_num_id"]
         ]
      }
    ],
    "previous_measured_track_time": [
      {
        "info": "previous_measured_track_time",
        "info2": "productivity_report.lua - previousTrackTime(wpa) ",
        "info3": "['wo_row_number', '==', ['param.wo_row_number', '-', 1]]",
        "rule": [
          ["param.wo_row_number", ">", 1],
          ["wo_work__position_num_id", "==", "param.wo_work__position_num_id"],
          ["wpa_work_load_group_id", "==", "param.wpa_work_load_group_id"],
          ["wpa_work_phase_est_id", "==", "param.wpa_work_phase_est_id"],
          ["wo_row_number", "<", "param.wo_row_number"]
         ]
      }
    ],
    "unproductive": [
      {
        "info": "unproductive",
        "rule": [
          ["wpa_type_", "==", "ET"]
         ]
      }
    ],
    "open_phase": [
      {
        "info": "open_phase",
        "rule": [
          ["wpa_type_", "<>", "LO"],
          ["wpa_subtype", "<>", "LT"],
          ["wo_state_", "<>", "LT"],
          ["wo_state_", "<>", "PE"]
        ],
        "ruleX": [
          [["includes", ["param.load_group", "wpa_work_load_group_id"]]]
         ]
      }
    ],
    "wos_finished": [
      {
        "info": "wos_finished",
        "rule": [
          ["wos_production_lot", "==", "param.wpa_production_lot"],
          ["wos_work_phase", "==", "param.wpa_work_phase_est_id"],
          ["wos_work_phase_state", "==", "LT"]
         ]
      }
    ],
    "wos_select_phase": [
      {
        "info": "wos_select_phase",
        "rule": [
          ["wos_production_lot", "==", "param.wpa_production_lot"],
          ["wos_work_phase", "==", "param.wpa_work_phase_est_id"]
         ]
      }
    ],
    "capacity_work_time": [
      {
        "info": "AGA: fix, work_time for capacity calculations",
        "rule": [
            ["wpa_shift_number", "==", "param.shift"]
         ],
        "ruleX": [
            ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "capacity": [
      {
        "info": "load_group",
        "rule": [
          ["shift", "==", "param.shift"],
          [["includes", ["param.load_group", "load_group"]]]
        ]
      },
      {
        "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",
        "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": [
      {
        "info": "load_group",
        "rule": [
          ["includes", ["param.load_group", "rcl_fault_made_load_group_id"]]
         ]
      }
    ],
    "finished_reclamation": [
      {
        "info": "finished_reclamation",
        "rule": [
          ["rcl_state", "<>", 0],
          ["rcl_finished_date", ">=", "param.start_date"],
          ["rcl_finished_date", "<=", "param.end_date"]
        ],
        "ruleX": [
          ["includes", ["param.load_group", "rcl_fault_made_load_group_id"]]
         ]
      }
    ],

    "track_time": [
      {
        "info": "track_time",
        "rule": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      }
    ],
    "track_time_map": [
      {
        "info": "track_time_map",
        "rule": [
          ["wpa_date_", ">=", "param.start_date"],
          ["wpa_date_", "<=", "param.end_date"]
        ],
        "ruleX": [
          ["includes", ["param.load_group", "wpa_work_load_group_id"]]
         ]
      },
      {
        "info": "no_fms",
        "use": [
          ["rec.query_name", "==", "no_fms"]
        ],
        "ruleXX": [
          [["lowercase", ["wpa_employee_id"]], "<>", "fms"]
        ],
        "rule": [
          ["wpa_employee_id", "<>", "fms"],
          ["wpa_employee_id", "<>", "FMS"]
        ]
      },
      {
        "info": "only_fms",
        "use": [
          ["rec.query_name", "==", "only_fms"]
        ],
        "ruleXX": [
          [["lowercase", ["wpa_employee_id"]], "==", "fms"]
        ],
        "rule": [
          [["wpa_employee_id", "==", "fms"], "or", ["wpa_employee_id", "==", "FMS"]]
        ]
      }
    ],
    "speed_map": [
      {
        "info": "no_fms",
        "use": [
          ["rec.query_name", "==", "no_fms"]
        ],
        "rule": [
          ["wpa_employee_id", "<>", "fms"],
          ["wpa_employee_id", "<>", "FMS"]
        ]
      },
      {
        "info": "only_fms",
        "use": [
          ["rec.query_name", "==", "only_fms"]
        ],
        "rule": [
          [["wpa_employee_id", "==", "fms"], "or", ["wpa_employee_id", "==", "FMS"]]
        ]
      }
    ],
    "speed": [
     {
       "info": "speed",
       "rule": [
         [["includes", ["param.load_group", "wpa_work_load_group_id"]]]
       ]
     }
    ],
    "speed_mapX": [
      {
        "info": "no_fms",
        "use": [
          ["rec.query_name", "==", "no_fms"]
        ],
        "ruleXX": [
          [["lowercase", ["wpa_employee_id"]], "<>", "fms"]
        ],
        "ruleXXX": [
          ["wlg_use_automatic_receipt", "<", 1]
        ],
        "rule": [
          ["wpa_employee_id", "<>", "fms"],
          ["wpa_employee_id", "<>", "FMS"]
        ]
      },
      {
        "info": "only_fms",
        "use": [
          ["rec.query_name", "==", "only_fms"]
        ],
        "ruleXX": [
          [["lowercase", ["wpa_employee_id"]], "==", "fms"]
        ],
        "rule": [
          [["wpa_employee_id", "==", "fms"], "or", ["wpa_employee_id", "==", "FMS"]]
        ]
      },
      {
        "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(...) ",
        "rule": [
          ["wpa_date_", ">=", "param.start_prev_date"],
          ["wpa_date_", "<=", "param.end_next_date"],
          [[["wpa_date_", "<>", "param.start_date"], "or", ["wpa_end_time", ">=", "12:00:00"], "or", ["wpa_shift_number", "<", 3]]],
          [[["wpa_date_", "<>", "param.end_date"], "or", ["wpa_end_time", "<=", "12:00:00"], "or", ["wpa_shift_number", "<>", 1]]],
          [[["wpa_date_", "<>", "param.start_prev_date"], "or", ["wpa_end_time", ">", "12:00:00"]]],
          [[["wpa_date_", "<>", "param.start_prev_date"], "or", ["wpa_shift_number", "==", 1]]],
          [[["wpa_date_", "<>", "param.end_next_date"], "or", ["wpa_end_time", "<", "12:00:00"]]],
          [[["wpa_date_", "<>", "param.end_next_date"], "or", ["wpa_shift_number", ">=", 3]]]
        ]
      }
    ]
  }
}
