{
  "info": "---- ??  tarkoittaa epäselvää, ----<> tarkoittaa inc",
  "field": {
      "wpa": [
        ["wpa_scBEFORE"]
      ],
      "wpa_work_position_num_id": [],
      "wpa_work_load_group_id": [
        ["wpa_C_TUNTIPALKA"],
        ["wpa_scKUORMITUSRY"]
      ],
      "wpa_employee_id": [
        ["if", ["_el_InInput", "=", "true"],
          [
            ["if", ["_sel_RecsInSel", ["em"], ">", "0"],
              [
                ["wpa_emploeename", "=", ["_fld_ValueStr", ["em_whole_name"]]]
              ]
            ],
            ["else",
              ["wpa_emploeename", "=", ""]
            ]
          ]
        ],
        ["wpa_scTYONTEKIJA"]
      ],
      "wpa_type": [
        ["wpa_scTYYPPI"]
      ],
      "wpa_produced_amount": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_work_time_amount": [
        ["if", ["wpa_start_date", "=", "00.00.0000"]],
        ["elseif", ["wpa_start_time", "=", "00:00:00"]],
        ["elseif", ["wpa_automaticworktimeupdate", "=", "false"]],
        ["else",
          ["_wpa_rEnd", "=", ["_dt_ToReal", ["wpa_start_date", "wpa_start_time"]]],
          ["_wpa_rEnd", ["concat", ["_wpa_rEnd", "_dt_HoursToReal", ["wpa_work_time_amount"], "_dt_HoursToReal", ["wpa_unpaid_hours"]]]],
          ["wpa_date", "=", ["_dt_RealToDate", ["_wpa_rEnd"]]],
          ["wpa_end_time", "=", ["_dt_RealToTime", ["_wpa_rEnd"]]],
          ["wpa_EXTRA_HOURS_SET"]
        ],
        ["wpa_SETUP_HOURS_CALCULATE", ["wpa_work_time_amount", "wpa_machine_hours"]],
        ["wpa_C_KENTAT"]
      ],
      "wpa_setup_time_amount": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_setup_salary_hour": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_salary_hour": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_machine_setup_cost_hour": [],
      "wpa_machine_work_cost_hour": [],
      "wpa_contract_price_unit": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_work_salary_amount": [],
      "wpa_hourly_salary": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_date": [
        ["wpa_scEND"]
      ],
      "wpa_work_description": [],
      "wpa_info": [],
      "wpa_work_phase_est_id": [],
      "wpa_production_lot": [],
      "wpa_kind": [],
      "wpa_user_id": [],
      "wpa_contract_salary": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_profit_multiplier": [],
      "wpa_work_cost_price_amount": [
        ["wpa_work_sales_price_amoun", "=", ["Round", ["wpa_work_cost_price_amount", "*", "wpa_profit_multiplier"], "g.wpe_pyordes"]],
        ["w_WPA_FLD_SUM"]
      ],
      "wpa_work_sales_price_amount": [
        ["if", ["wpa_work_cost_price_amount", "<>", "0"],
          [
            ["wpa_profit_multiplier", "=", ["Round", ["wpa_work_sales_price_amount", "/", "wpa_work_cost_price_amount"], "g.wpe_pyordes"]]
          ]
        ],
        ["w_WPA_FLD_SUM"]
      ],
      "wpa_salary_bonus": [],
      "wpa_machine_hours": [
        ["wpa_SETUP_HOURS_CALCULATE", ["wpa_work_time_amount", "wpa_machine_hours"]],
        ["wpa_C_KENTAT"]
      ],
      "wpa_stock_event_id": [],
      "wpa_evening_work_hours": [
        ["wpa_LISATUNNIT", ["wpa_salary_bonus", "wpa_evening_work_hours", "wpa_night_work_hours"]]
      ],
      "wpa_night_work_hours": [
        ["wpa_LISATUNNIT", ["wpa_salary_bonus", "wpa_evening_work_hours", "wpa_night_work_hours"]]
      ],
      "wpa_contract_multiplier": [],
      "wpa_social_cost_multiplier": [],
      "wpa_cost_center": [],
      "wpa_failed_amount": [],
      "wpa_work_phase_actual_id": [],
      "wpa_subcontract": [
        ["wpa_C_KENTAT"]
      ],
      "wpa_supplier_id": [],
      "wpa_end_time": [
        ["wpa_scEND"]
      ],
      "wpa_start_date": [
        ["if", ["wpa_automaticworktimeupdate", "=", "true"],
          [
            ["if", ["wpa_start_date", "<>", "00.00.0000"],
              [
                ["wpa_date", "=", ["wpa_start_date"]]
              ]
            ]
          ]
        ],
        ["wpa_scEND"]
      ],
      "wpa_start_time": [
        ["wpa_scEND"]
      ],
      "wpa_unpaid_hours": [
        ["wpa_scUNPAID_HOURS"]
      ],
      "wpa_shift_number": [
        ["wpa_EXTRA_HOURS_SET"]
      ],
      "wpa_est_work_time_unit": [],
      "wpa_est_setup_time_lot": [],
      "wpa_est_bonus_work_time_unit": [],
      "wpa_est_setup_salary_hour": [],
      "wpa_est_salary_hour": [],
      "wpa_est_machine_setup_cost_ho": [],
      "wpa_est_machine_work_cost_hou": [],
      "wpa_est_contract_price_unit": [],
      "wpa_program_id": [],
      "wpa_started_amount": [],
      "wpa_transfer_if": [],
      "wpa_track_time": [],
      "wpa_track_time_status": [],
      "wpa_parcel_code": [],
      "wpa_subtype": [],
      "wpa_target_time": [],
      "wpa_start_employee_id": [
        ["if", ["_el_InInput", "=", "true"],
          ["if", ["_sel_RecsInSel", ["em"], ">", "0"],
            [
              ["wpa_startemployeename", "=", ["_fld_ValueStr", ["em_whole_name"]]]
            ]
          ],
          [
            ["wpa_startemployeename", "=", ""]
          ]
        ],
        ["wpa_scTYONTEKIJA"]
      ],
      "wpa_start_shift_number": [
        ["wpa_EXTRA_HOURS_SET"]
      ],
      "wpa_start_subtype": [],
      "wpa_additional_data": [],
      "wpa_target_machine_time": [],
      "wpa_measured_track_time": []
  },
  "function": {
    "wpa_scBEFORE": [
      ["wpa_work_position_num_id", "=", ["wo_work_position_num_id"]],
      ["wpa_date", "=", ["_date_Current", ["true"]]],
      ["wpa_user_id", "=", ["_usr_CurrentUser"]],
      ["wpa_social_cost_multiplier", "=", ["g.w_soskuluk"]],
      ["wpa_C_KENTAT"]
    ],
    "wpa_C_TUNTIPALKA": [
      [
        "if", ["wpa_employee_id", "<>", ""],
        [
          ["_sel_RELATE_ONE", ["em_employee_id", "wpa_employee_id"]]
        ],
        "else",
        [
          ["wpa_employee_id", "=", ["_fld_ValueStr", ["wpa_start_employee_id"]]],
          ["_sel_RELATE_ONE", ["em_employee_id", "wpa_start_employee_id"]]
        ]
      ],
      [
        "if", [[["wpa_type", "=", ["g.ld_kTypeStarted"]]], "or", ["wpa_type", "=", ["g.ld_kTypeFinished"]], "or", ["wpa_type", "=", ["g.w_tHourlySalaryType"]], "or", ["wpa_type", "=", ["g.w_tContractSalaryType"]], "or", ["wpa_type", "=", ["String", ["g.wpa_lEndEventType"]]]],
        [
          [
            "if", [["wpa_employee_id", "=", ["g.hlsEI_TYONT"]], "or", ["wpa_employee_id", "=", ""], "or", ["g.wpa_lUseLoadGroupSalary", "=", "true"]],
            [
              ["wpa_setup_salary_hour", "=", ["wlg_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["wlg_work_salary_hour"]]
            ],
            "else",
            [
              ["wpa_setup_salary_hour", "=", ["em_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["em_salary_hour"]]
            ]
          ]
        ],
        "else",
        [
          [
            "if", ["g.wpa_lUseLoadGroupSalary", "=", "true"],
            [
              ["wpa_setup_salary_hour", "=", ["wlg_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["wlg_work_salary_hour"]]
            ],
            "else",
            [
              ["wpa_setup_salary_hour", "=", ["em_average_hourly_salary"]],
              ["wpa_salary_hour", "=", ["em_average_hourly_salary"]]
            ]
          ]
        ]
      ],
      ["wpa_machine_setup_cost_hour", "=", ["wlg_machine_setup_cost_hour"]],
      ["wpa_machine_work_cost_hour", "=", ["wlg_machine_work_cost_hour"]],
      ["wpa_contract_multiplier", "=", ["em_contract_multiplier"]]
    ],
    "wpa_scKUORMITUSRY": [
      ["RELATE_ONE", ["wpa_work_load_group_id"]],
      ["wpa_work_description", "=", ["wlg_name"]],
      ["wpa_profit_multiplier", "=", ["wlg_profit_multiplier"]],
      ["wpa_C_TUNTIPALKA"],
      ["wpa_C_KENTAT"]
    ],
    "wpa_C_TUNTIPALKA": [
      ["_sel_RELATE_ONE", ["wlg_work_load_group_id", "wpa_work_load_group_id"]],
      [
        "if", ["wpa_employee_id", "<>", ""],
        [
          ["_sel_RELATE_ONE", ["em_employee_id", "wpa_employee_id"]]
        ],
        "else",
        [
          ["wpa_employee_id", "=", ["wpa_start_employee_id"]],
          ["_sel_RELATE_ONE", ["em_employee_id", "wpa_start_employee_id"]]
        ]
      ],
      [
        "if", [["wpa_type", "=", ["ld_kTypeStarted"]], "or", ["wpa_type", "=", ["ld_kTypeFinished"]], "or", ["wpa_type", "=", ["g.w_tHourlySalaryType"]], "or", ["wpa_type", "=", ["g.w_tContractSalaryType"]], "or", ["wpa_type", "=", ["String", ["g.wpa_lStartEventType"]]], "or", ["wpa_type", "=", ["String", ["g.wpa_lEndEventType"]]]],
        [
          [
            "if", [["wpa_employee_id", "=", ["g.hlsEI_TYONT"]], "or", ["wpa_employee_id", "=", ""], "or", ["g.wpa_lUseLoadGroupSalary", "=", "true"]],
            [
              ["wpa_setup_salary_hour", "=", ["wlg_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["wlg_work_salary_hour"]]
            ],
            "else",
            [
              ["wpa_setup_salary_hour", "=", ["em_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["em_salary_hour"]]
            ]
          ]
        ],
        "else",
        [
          [
            "if", ["g.wpa_lUseLoadGroupSalary", "=", "true"],
            [
              ["wpa_setup_salary_hour", "=", ["wlg_setup_salary_hour"]],
              ["wpa_salary_hour", "=", ["wlg_work_salary_hour"]]
            ],
            "else",
            [
              ["wpa_setup_salary_hour", "=", ["em_average_hourly_salary"]],
              ["wpa_salary_hour", "=", ["em_average_hourly_salary"]]
            ]
          ]
        ]
      ],
      ["wpa_machine_setup_cost_hour", "=", ["wlg_machine_setup_cost_hour"]],
      ["wpa_machine_work_cost_hour", "=", ["wlg_machine_work_cost_hour"]],
      ["wpa_contract_multiplier", "=", ["em_contract_multiplier"]]
    ],
    "wpa_C_KENTAT": [
      ["wpa_C_HINTAKENTA"],
      [
        "if", ["_el_InInput", "=", "true"],
        [
          ["wpa_C_MUUTTUJAT"]
        ]
      ]
    ],
    "wpa_C_HINTAKENTA":
    [
      [
        "if", ["Count_parameters", ">=", "1"],
        [
          ["_fTyopalkka", "=", ["arg1"]]
        ],
        "else",
        [
          ["_fTyopalkka", "=", "true"]
        ]
      ],
      [
        "if", ["_fTyopalkka"],
        [
          [
            "if", [["g.wpa_lPriceCalculateType"], "=", "2"],
            [
              ["wpa_work_salary_amount", "=", ["wpa_setup_time_amount", "*", "wpa_setup_salary_hour"]]
            ]
          ],
          [
            "if", ["wpa_type", "=", ["g.w_tContractSalaryType"]],
            [
              [
                "if", ["wpa_contract_multiplier", "<>", "0"],
                [
                  ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "+", ["wpa_produced_amount", "*", "wpa_contract_price_unit", "*", "wpa_contract_multiplier"]], "2"]]]
                ],
                "else",
                [
                  ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "+", ["wpa_work_time_amount", "*", "wpa_salary_hour"]], "2"]]]
                ]
              ]
            ],
            "else",
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "+", ["wpa_work_time_amount", "*", "wpa_salary_hour"]], "2"]]]
            ]
          ],
          [
            "if", ["wpa_type", "=", "50@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "0.5"], "2"]]]
            ],
            "elseif", ["wpa_type", "=", "150@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "1.5"], "2"]]]
            ],
            "elseif", ["wpa_type", "=", "200@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "2"], "2"]]]
            ],
            "elseif", ["wpa_type", "=", "250@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "2.5"], "2"]]]
            ],
            "elseif", ["wpa_type", "=", "300@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "3"], "2"]]]
            ],
            "elseif", ["wpa_type", "=", "350@"],
            [
              ["wpa_work_salary_amount", "=", ["Round", [["wpa_work_salary_amount", "*", "3.5"], "2"]]]
            ]
          ]
        ]
      ],
      [
        "if", ["wpa_social_cost_multiplier", "=", "0"],
        [
          ["wpa_social_cost_multiplier", "=", ["g.w_rSosKuluk"]]
        ]
      ],
      [
        "if", ["!wpa_subcontract"],
        [
          ["wpa_work_cost_price_amount", "=", "0"],
          [
            "if", ["g.wpa_lPriceCalculateType", "<", "0"],
            [
              ["wpa_work_cost_price_amount", "=", ["wpa_work_time_amount", "*", "wpa_machine_work_cost_hour"]],
              ["wpa_work_cost_price_amount", "=", ["wpa_work_cost_price_amount", "+", [["wpa_work_salary_amount", "+", "wpa_salary_bonus"], "*", "wpa_social_cost_multiplier"]]]
            ],
            "else",
            [
              [
                "if", [["g.bit", ["wpa_lPriceCalculateType"]], "0"],
                [
                  ["wpa_work_cost_price_amount", "=", ["wpa_machine_hours", "*", "wpa_machine_work_cost_hour"]]
                ]
              ],
              [
                "if", [["g.bit", ["wpa_lPriceCalculateType"]], "1"],
                [
                  ["wpa_work_cost_price_amount", "=", ["wpa_work_cost_price_amount", "+", ["wpa_setup_time_amount", "*", "wpa_machine_setup_cost_hour"]]]
                ]
              ],
              [
                "if", [["g.bit", ["wpa_lPriceCalculateType"]], "2"],
                [
                  ["wpa_work_cost_price_amount", "=", ["wpa_work_cost_price_amount", "+", [["wpa_work_salary_amount", "+", "wpa_salary_bonus"], "*", "wpa_social_cost_multiplier"]]]
                ]
              ]
            ]
          ],
          ["wpa_work_cost_price_amount", "=", ["Round", ["wpa_work_cost_price_amount", "g.wpe_iPyorDes"]]],
          ["wpa_work_sales_price_amount", "=", ["Round", [["wpa_work_cost_price_amount", "*", "wpa_profit_multiplier"], "g.wpe_iPyorDes"]]]
        ]
      ]
    ],
    "wpa_C_MUUTTUJAT": [
      ["wpa_urak_yht", "=", ["wpa_contract_price_unit", "*", "wpa_produced_amount"]],
      [
        "if", ["wpa_produced_amount", "<>", "0"],
        [
          ["wpa_tyo_kpl", "=", ["wpa_work_salary_amount", "/", "wpa_produced_amount"]]
        ],
        "else",
        [
          ["wpa_tyo_kpl", "=", "0"]
        ]
      ]
    ],
    "wpa_scTYONTEKIJA": [
      ["wpa_C_TUNTIPALKA"],
      ["wpa_C_KENTAT"]
    ],
    "wpa_scTYYPPI": [
      ["wpa_C_TUNTIPALKA"],
      ["wpa_C_KENTAT"]
    ],
    "wpa_scEND": [
      [
        "if", ["wpa_start_date", "=", "00.00.0000"],
        [],
        "elseif", ["wpa_start_time", "=", "00:00:00"],
        [],
        "elseif", ["wpa_date", "=", "00.00.0000"],
        [],
        "elseif", ["wpa_end_time", "=", "00:00:00"],
        [],
        "elseif", ["wpa__AutomaticWorkTimeUpdate", "=", "false"],
        [],
        "else",
        [
          ["_wpa_rEnd", "=", ["_dt_ToReal", ["wpa_date", "wpa_end_time"]]],
          ["_wpa_rStart", "=", ["_dt_ToReal", ["wpa_start_date", "wpa_start_time"]]],
          ["wpa_work_time_amount", "=", [["_dt_Difference", ["_wpa_rEnd", "_wpa_rStart"]], "-", "wpa_unpaid_hours"]],
          ["wpa_work_time_amount", "=", ["Round", [["wpa_work_time_amount"], "2"]]],
          [
            "if", ["wpa_work_time_amount", "<", "0"],
            [
              ["wpa_unpaid_hours", "=", ["wpa_unpaid_hours", "-", ["Abs", ["wpa_work_time_amount"]]]],
              [
                "if", ["wpa_work_time_amount", "<", "0"],
                [
                  ["wpa_unpaid_hours", "=", "0"]
                ]
              ],
              ["wpa_work_time_amount", "=", "0"]
            ]
          ]
        ]
      ]
    ],
    "w_WPA_FLD_SUM": [
      ["g._real", "=", ["_sel_Sum", ["wpa_setup_time_amount"]]],
      ["_fld_VALUE_REAL_SET", ["kSet", "w_act_setup_time_total", "g._real"]],
      ["g._real", "=", ["_sel_Sum", ["wpa_machine_hours"]]],
      ["_fld_VALUE_REAL_SET", ["kSet", "w_act_work_time_total", "g._real"]],
      ["g._real", "=", ["_sel_Sum", ["wpa_work_salary_amount"]]],
      ["g._real2", "=", ["_sel_Sum", ["wpa_salary_bonus"]]],
      ["_fld_VALUE_REAL_SET", ["kSet", "w_act_salary_total", "g._real", "+", "g._real2"]],
      ["g._real", "=", ["_sel_Sum", ["wpa_work_cost_price_amount"]]],
      ["_fld_VALUE_REAL_SET", ["kSet", "w_act_work_cost_total", "g._real"]],
      ["g._real", "=", ["_sel_Sum", ["wpa_work_sales_price_amount"]]],
      ["_fld_VALUE_REAL_SET", ["kSet", "w_act_work_sales_price_total", "g._real"]]
    ],
    "wpa_scUNPAID_HOURS": [
      [
        "if", ["wpa_start_date", "=", "00.00.0000"],
        [
        ],
        "elseif", ["wpa_start_time", "=", "00:00:00"],
        [
        ],
        "elseif", ["wpa_AutomaticWorkTimeUpdate", "=", "false"],
        [
        ],
        "else",
        [
          [
            "if", ["wpa_date", "<>", "00.00.0000"],
            [
              ["g._wpa_rWorkTime", "=", ["_dt_HoursBetweenGet", ["wpa_start_date", "wpa_start_time", "wpa_date", "wpa_end_time"]]],
              ["g._wpa_rWorkTime", "=", ["Round", ["g._wpa_rWorkTime", "2"]]],
              ["wpa_work_time_amount", "=", ["g._wpa_rWorkTime", "-", "wpa_unpaid_hours"]],
              [
                "if", ["wpa_work_time_amount", "<", "0"],
                [
                  ["wpa_work_time_amount", "=", "0"]
                ]
              ]
            ]
          ],
          ["_wpa_rEnd", "=", ["_dt_ToReal", ["wpa_start_date", "wpa_start_time"]]],
          ["_wpa_rEnd", "=", ["_wpa_rEnd", "+", ["_dt_HoursToReal", ["wpa_work_time_amount"]], "+", ["_dt_HoursToReal", ["wpa_unpaid_hours"]]]],
          ["wpa_date", "=", ["_dt_RealToDate", "_wpa_rEnd"]],
          ["wpa_end_time", "=", ["_dt_RealToTime", "_wpa_rEnd"]]
        ]
      ]
    ],
    "wpa_EXTRA_HOURS_SET": [
      [
        "if", ["wpa_AutomaticWorkTimeUpdate", "=", "true"],
        [
          ["_wpa_rStart", "=", "_dt_ToReal", ["wpa_start_date", "wpa_start_time"]],
          ["_wpa_rEnd", "=", "_dt_ToReal", ["wpa_date", "wpa_end_time"]],
          [
            "if", ["wpa_work_position_num_id", "<>", ["g.wpa_tc_tTimeCardWorkNum"]],
            [
              ["IDLE"]
            ],
            "elseif", ["wpa_start_date", "=", "00.00.0000"],
            [
            ],
            "elseif", ["wpa_start_time", "=", "00:00:00"],
            [
            ],
            "elseif", ["wpa_date", "=", ["00.00.0000"]],
            [
            ],
            "elseif", ["wpa_end_time", "=", ["00:00:00"]],
            [
            ],
            "else",
            [
              [
                "if", ["wpa_shift_number", "=", "0"],
                [
                  ["IDLE"]
                ],
                "elseif", ["wpa_shift_number", "=", ["g.wpa_lEveningShiftNumber"]],
                [
                  ["_wpa_rBonusStart", "=", ["_dt_ToReal", ["_wpa_dStartDate",  "g.wpa_hEveningBonusStartTime"]]],
                  ["_wpa_rBonusEnd", "=", ["_dt_ToReal", ["_wpa_dEndDate", "g.wpa_hEveningBonusEndTime"]]],
                  [
                    "if", ["_wpa_rStart", ">", ["_wpa_rBonusEnd"]],
                    [
                    ],
                    "elseif", ["_wpa_rEnd", "<", ["_wpa_rBonusStart"]],
                    [
                    ],
                    "else",
                    [
                     [
                       "if", [["_wpa_rStart", "<", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", "<", ["_wpa_rBonusEnd"]]],
                       [
                         ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rEnd", "_wpa_rBonusStart"]]]
                       ],
                       "elseif", [["_wpa_rStart", "<", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", ">=", ["_wpa_rBonusEnd"]]],
                       [
                         ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rBonusEnd", "_wpa_rBonusStart"]]]
                       ],
                       "elseif", [["_wpa_rStart", ">=", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", "<=", ["_wpa_rBonusEnd"]]],
                       [
                         ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rEnd", "_wpa_rStart"]]]
                       ],
                       "elseif", [["_wpa_rStart", ">=", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", ">", ["_wpa_rBonusEnd"]]],
                       [
                         ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rBonusEnd", "_wpa_rBonusStart"]]]
                       ]
                     ]
                   ],
                   ["_wpa_rBonusHours", "=", ["Round", ["_wpa_rBonusHours", 2]]],
                   ["_fld_VALUE_REAL_SET", ["kSet", "wpa_evening_work_hours", "_wpa_rBonusHours"]],
                   ["_fld_VALUE_REAL_SET", ["kSet", "wpa_night_work_hours", "0"]]
                  ]
                ],
                "elseif", ["wpa_shift_number", "=", ["g.wpa_nightshiftnumber"]],
                [
                  [
                    "if", ["g.wpa_nightbonusstarttime", "<", ["g.wpa_eveningbonusstarttime"]],
                    [
                      ["_wpa_rBonusStart", "=", ["_dt_ToReal", ["wpa_date", "g.wpa_nightbonusstarttime"]]]
                    ],
                    "else",
                    [
                      ["_wpa_rBonusStart", "=", ["_dt_ToReal", ["wpa_start_date", "g.wpa_nightbonusstarttime"]]]
                    ]
                  ],
                  ["_wpa_rBonusEnd", "=", ["_dt_ToReal", ["wpa_date", "g.wpa_nightbonusendtime"]]],
                  [
                    "if", ["_wpa_rStart", ">", ["_wpa_rBonusEnd"]],
                    [
                    ],
                    "elseif", ["_wpa_rEnd", "<", ["_wpa_rBonusStart"]],
                    [
                    ],
                    "else",
                    [
                      [
                        "if", [["_wpa_rStart", "<", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", "<", ["_wpa_rBonusEnd"]]],
                        [
                          ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rEnd", "_wpa_rBonusStart"]]]
                        ],
                        "elseif", [["_wpa_rStart", "<", ["_wpa_rBonusStart"]]],
                        [
                          ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rBonusEnd", "_wpa_rBonusStart"]]]
                        ],
                        "elseif", [["_wpa_rStart", ">=", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", "<=", ["_wpa_rBonusEnd"]]],
                        [
                          ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rEnd", "_wpa_rStart"]]]
                        ],
                        "elseif", [["_wpa_rStart", ">=", ["_wpa_rBonusStart"]], "and", ["_wpa_rEnd", ">", ["_wpa_rBonusEnd"]]],
                        [
                          ["_wpa_rBonusHours", "=", ["_dt_Difference", ["_wpa_rBonusEnd", "_wpa_rStart"]]]
                        ]
                      ]
                    ],
                    ["_wpa_rBonusHours", "=", ["Round", ["_wpa_rBonusHours", "2"]]],
                    ["_fld_VALUE_REAL_SET", ["kSet", "wpa_night_work_hours", "_wpa_rBonusHours"]],
                    ["_fld_VALUE_REAL_SET", ["kSet", "wpa_evening_work_hours", "0"]]
                  ]
                ],
                "else",
                [
                  ["_fld_VALUE_REAL_SET", ["kSet", "wpa_evening_work_hours", "0"]],
                  ["_fld_VALUE_REAL_SET", ["kSet", "wpa_night_work_hours", "0"]]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
  }
}
