info:
  name: Calcolo D.1.3 5% con virgole
  type: http
  seq: 21

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: "22737"
      disabled: true
    - name: x-ef-request-id
      value: "22224"
      disabled: true
    - name: x-ef-request-id
      value: "22748"
  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][HEADER name="trimDocument" value="true" type="boolean" /]
        [VAR name="D1_1" type="number"][TAG]GETVALUEBYTAG,PROPOSTA_CCT_CONTRATTO_D_1_1,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="D1_2" type="number"][TAG]GETVALUEBYTAG,PROPOSTA_CCT_CONTRATTO_D_1_2,REQUEST,IUQOID[/TAG][/VAR]

        [VAR name="numberIterable" type="iterable"][SPLIT regex="\."][TAG]GETVALUEBYTAG,PROPOSTA_CCT_CONTRATTO_A,REQUEST,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="A" type="number"][% A = numberIntegerPart + "," + numberDecimalPart; %][/VAR]

        [VAR name="D1_3" type="number"][% D1_3 = D1_1 + D1_2 - (A * 0.20); %][/VAR]
        [VAR name="QuotaAteneo" type="number"][% QuotaAteneo = 0; %][/VAR]

        [IF]
          [CONDITION][% D1_3 > 0 %][/CONDITION]
          [THEN][% QuotaAteneo = D1_3 * 0.05; %][/THEN]
        [/IF]

        [FORMAT type="number" pattern="#,##0.00"][% QuotaAteneo %][/FORMAT]
        [/EFTL]
        `);

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