info:
  name: Inserimento Ore Fuori - Dati attività CSV copy
  type: http
  seq: 13

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: "31470"
  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="importoAssegnato" type="number"][TAG]SCHEMAID,709,COL0118,IUQOID, ,,,0.00[/TAG][/VAR]
        [VAR name="oreTotali" type="number"][TAG]SCHEMAID,709,COL0119,IUQOID, ,,,0[/TAG][/VAR]

        [VAR name="anno" type="string"][TAG]GETVALUEBYTAG,ATTIVITA_ANNO,REQUEST,IUQOID,UPDATED_LAST[/TAG][/VAR]
        [VAR name="ore" type="string"][TAG]GETVALUEBYTAG,ATTIVITA_ORE;ORE_FUORI_ORARIO,REQUEST,IUQOID,UPDATED_LAST[/TAG][/VAR]

        [VAR name="importoProporzionato" type="number"][% importoProporzionato = (importoAssegnato * ore) / oreTotali; %][/VAR]

        [%= anno %];[%= ore %];[FORMAT type="number" pattern="0.00"][% importoProporzionato %][/FORMAT]
        [/EFTL]
        `);

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