Skip to main content
July 15, 2024
Question

a!currency: force recognize "," instead of "." as decimal

  • July 15, 2024
  • 4 replies
  • 0 views

My application is specifically for a local where the decimal symbol used is comma " , " and not a period " . ".
So, the decimals will be inputted by the portal users as `5,55` instead of `5.55`

So my current code is the following:

a!textField(
  label: "The amount of money for payment",
  labelPosition: "ABOVE",
  instructions: "",
  helpTooltip: "The amount of money for payment",
  value: if(
    local!variant_value_for_payment > 0,
    a!currency(
      isoCode: "BRL",
      value: local!variant_value_for_payment,
      format: "LOCALE"
    ),
    null
  ),
  saveInto: {
    a!save(
      local!variant_value_for_payment,
      todecimal(save!value)
    )
  },
  refreshAfter: "KEYPRESS"
),

I've read the a!currency docs and the main question for the best solution for me should be:

→ How may I be able to forcely make the system reads "100.50" and recognizes as " 100.00" and keeps that format?

Thanks from now on

4 replies

July 16, 2024
What are you looking for? It's not clear.
Enter 100.50 and recognize it as 100.00 or Enter 100,50 and recognize it as 100.50?
Add some more details.
karumurua531442
July 16, 2024

hi [mention:a80a5ee5cb3647d68fc33debeeda2795:e9ed411860ed4f2ba0265705b8793d05]  need more details on your requirement it is not clear. if you want to convert 100.50 as 100.00  you can use the below code

fixed(rounddown(100.50,0),2)

venkatrea696188
July 16, 2024

For your first question of reading with ","... Use Substitute(), Hope the following code helps

a!localVariables(
  local!variant_value_for_payment,
  local!valueforpayment: a!refreshVariable(
    value: if(
      a!isNullOrEmpty(local!variant_value_for_payment),
      null,
      todecimal(
        fn!substitute(
          local!variant_value_for_payment,
          ",",
          "."
        )
      )
    ),
    refreshOnVarChange: local!variant_value_for_payment
  ),
  a!textField(
    label: "The amount of money for payment",
    labelPosition: "ABOVE",
    instructions: "",
    helpTooltip: "The amount of money for payment",
    value: if(
      local!variant_value_for_payment > 0,
      a!currency(
        isoCode: "BRL",
        value: local!valueforpayment,
        format: "LOCALE"
      ),
      null
    ),
    saveInto: {
      a!save(
        local!variant_value_for_payment,
        save!value
      )
    },
    refreshAfter: "KEYPRESS"
  ),
  
)

How may I be able to forcely make the system reads "100.50" and recognizes as " 100.00" and keeps that format

For this Abhishek's code might help

July 16, 2024

Thank you very much, this has definitely solved the issue for me!