{
  "name": "wos/postcalc_not_done.json",
  "database": "4d",
  "parameter": {
    "work_order_open_state": ["EK", "KU", "AL"],
    "remove_work": ["07056", "02101"],
		"show_sql": false
  },
  "query": [
    ["wo_state", "in", "work_order_open_state"],
    "and",
    ["wo_work__position_num_id", "not in", "remove_work"]
  ],
  "filter": [
    [
      "if", [["prevRec", "=", "nil"], "or", ["prevRec.wos_production_lot", "<>", "rec.wos_production_lot"]],
      [
        [
          "if", ["rec.wos_work_phase_state", "=", "constantTbl.phase_state.finished"],
          [
            ["filter_value", "=", "true"]
          ],
          "elseif", [["rec.wos_work_phase_state", "=", "constantTbl.phase_state.started"], "and", ["rec.wos_subtype", "=", "constantTbl.phase_state.finished"]],
          [
            ["filter_value", "=", "true"]
          ]
        ]
      ]
    ],
    ["prevRec", "=", "rec"],
    ["filter_value", "=", "false"]
  ],
  "order": ["wos_production_lot__work_ph", "<"],
  "field": [
    "wos_subtype",
    "wos_work_phase_state",
    "wos_production_lot__work_ph",
    "wos_production_lot"
  ]
}
