info:
  name: Limiti - Calcolo MIN ore fuori orario
  type: http
  seq: 7

http:
  method: POST
  url: "{{elixFormsApiUrl}}/eftl/process/v1"
  headers:
    - name: x-requested-with
      value: XMLHttpRequest
    - name: x-api-key
      value: "{{elixFormsWsAuthenticationToken}}"
    - name: x-ef-request-id
      value: "31418"
  body:
    type: json
    data: |-
      {
        "userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
        "userContext": {
          "lang": "IT",
          "crlf": "\r\n"
        }
      }
  auth: inherit

runtime:
  scripts:
    - type: before-request
      code: |-
        const { prepareEftlDocument } = require("./elixFormsJs.js")
        // Copy-pasta your EFTL document below inside the template literals (`)
        prepareEftlDocument(String.raw`
        [EFTL][HEADER name="trimDocument" value="true" type="boolean" /]
        [VAR name="percentualePartTime" type="number"][TAG]GETVALUEBYTAG,DIPENDENTE_PERC_PARTTIME,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="oreEquivalenti" type="number"][TAG]GETVALUEBYTAG,ORE_RIPARTIZIONE_ASSEGNATA,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="maxOre" type="number"][TAG]GETVALUEBYTAG,MAX_ORE_FUORI_ORARIO,REQUEST,IUQOID[/TAG][/VAR]

        [VAR name="limiteOre" type="number"][% limiteOre = (percentualePartTime * maxOre); %][/VAR]

        [IF]
          [CONDITION][% limiteOre > oreEquivalenti %][/CONDITION]
          [THEN][% limiteOre = oreEquivalenti; %][/THEN]
        [/IF]

        [FORMAT type="number" pattern="integer"][% limiteOre %][/FORMAT]
        [/EFTL]
        `);

settings:
  encodeUrl: true
  timeout: 0
  followRedirects: true
  maxRedirects: 5
  forwardAuthorizationHeader: true
