{
  "name": "dialog/productivity_report/map.json",
  "definition": {
    "wos_production_lot_phase": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wos_production_lot_phase"},
      "table": "wos",
      "map": [
        ["wos_finished", "=", ["wos_work_phase_state", "==", "LT"]],
        ["wos_produced", "=", "wos_produced_amount"],
        ["wos_failed", "=", "wos_failed_amount"]
      ]
    },
    "wpe_work_phase": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wpe_work_phase"},
      "table": "wpe",
      "map": [
        ["estimated_work_time__unit", "=", "wpe_work_time__unit"]
      ]
    },
    "wpa_previous_work_order": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wpa_previous_work_order"},
      "table": "wpa",
      "map": [
        ["previous_batch_number", "=", "wo_row_number"],
        ["previous_measured_track_time", "=", "wpa_measured_track_time"]
      ]
    },
    "wpa_speed": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wpa_speed"},
      "table": "wpa",
      "map": [
        ["if", ["rec.query_name", "==", "no_fms"], [
          ["wpa_work_time__amount", "=", ["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"], [
          ["wpa_work_time__amount", "=", ["work_time_not_fms_machine", "+", "work_time_fms"]],
          ["work_time_all", "=", ["all_work_time_not_fms_machine", "+", "all_work_time_fms"]]
        ], "else", [
          ["wpa_work_time__amount", "=", ["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", "=", [["wpa_work_time__amount", "/", "work_time_all"], "*", "wpa_target_time"]],
        ["work_time__unit", "=", ["wpa_work_time__amount", "/", ["wos_produced", "+", "wos_failed"]]],
        ["estimated_speed_percent", "=", [["estimated_work_time__unit", "/", "work_time__unit"], "*", 100]],
        ["finished_work_time", "=", ["wpa_work_time__amount", "*", "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", ["wlg_use_automatic_receipt", "<=", 0],
          ["work_time_not_fms_machine", "=", "wpa_work_time__amount"]
        ],
        ["if", [["wlg_use_automatic_receipt", ">", 0], "and", ["wpa_employee_id", "==", "FMS"]],
          ["work_time_fms", "=", "wpa_work_time__amount"]
        ],
        ["if", [["wlg_use_automatic_receipt", ">", 0], "and", ["wpa_employee_id", "<>", "FMS"]],
          ["work_time_other", "=", "wpa_work_time__amount"]
        ]
      ]
    },
    "wpa_speed_before": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wpa_speed"},
      "table": "wpa",
      "sum": [
        ["work_time_before", "=", "wpa_work_time__amount"]],
      "count": [
        ["before_time_period_count"]
      ]
    },
    "wpa_speed_after": {
      "filter": {"name": "dialog/productivity_report/filter_lua.json", "definition": "wpa_speed"},
      "table": "wpa",
      "sum": [
        ["work_time_after", "=", "wpa_work_time__amount"]],
      "count": [
        ["after_time_period_count"]
      ]
    }
  }
}
