info:
  name: Ritenuta 2 max messaggio
  type: http
  seq: 8

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: "37031"
  body:
    type: json
    data: |-
      {
        "userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
        "userContext": {
          "lang": "IT"
        }
      }
  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]
        [VAR name="numberIterable" type="iterable"][SPLIT regex="\."][TAG]SCHEMAID,341,COL0009,IUQOID, , [/TAG][/SPLIT][/VAR]
        [VAR name="first" type="number"][% first = 0; %][/VAR]
        [VAR name="second" type="number"][% second = 1; %][/VAR]
        [VAR name="numberIntegerPart" type="string"][VALUE_OF varname="numberIterable" index="first" /][/VAR]
        [VAR name="numberDecimalPart" type="string"][VALUE_OF varname="numberIterable" index="second" /][/VAR]

        [IF][CONDITION][IS_EMPTY varname="numberDecimalPart" /][/CONDITION][THEN][% numberDecimalPart = "00"; %][/THEN][/IF]
        [VAR name="valueAsNumber" type="number"][% valueAsNumber = numberIntegerPart + "," + numberDecimalPart; %][/VAR]

        [VAR name="fattoreRitenuta2max" type="string"][TAG]SCHEMAID,341,COL0030,IUQOID, , [/TAG][/VAR]
        [VAR name="ritenuta2max" type="number"][% ritenuta2max = valueAsNumber * fattoreRitenuta2max; %][/VAR]

        [%= "L'importo massimo (" %][FORMAT type="number" pattern="#,##0.##"][% fattoreRitenuta2max * 100 %][/FORMAT][%= "%) dell'ulteriore ritenuta deliberata dalla struttura è: " + ritenuta2max + " €" %]

        [/EFTL]
        `);

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