Hello everyone, I want to add two amounts. It is necessary to make them decimal then again in text format.


It displays incorrectly for me = 1060714,23124323400,00

PaymentInfo.TotalAmount +  PaymentInfo.InterestAmount

Hi,

Try the below forge component:

https://www.outsystems.com/forge/component-overview/8359/numbers-to-words-with-decimal  it is somehow relevant to your requirement.

Mahesh Manchala wrote:

Hi,

Try the below forge component:

https://www.outsystems.com/forge/component-overview/8359/numbers-to-words-with-decimal  it is somehow relevant to your requirement.

 

 You did not understand me. It is necessary to show in the form of numbers

Hello Kan,

It seems that your variables are both texts.

PaymentInfo.TotalAmount (text) = "1060714,23"

PaymentInfo.InterestAmount (text) = "124323400,00"

If you concatenate 2 texts (using PaymentInfo.TotalAmount + PaymentInfo.InterestAmount), it will result in this: "1060714,23124323400,00".


What you need to do is to use the TextToDecimal Built-in Function over your variables.

Try this:

TextToDecimal(PaymentInfo.TotalAmount) +  TextToDecimal(PaymentInfo.InterestAmount)


The result should be the sum of your decimal values.


Kind regards,

Rui Barradas

Rui Barradas wrote:

Hello Kan,

It seems that your variables are both texts.

PaymentInfo.TotalAmount (text) = "1060714,23"

PaymentInfo.InterestAmount (text) = "124323400,00"

If you concatenate 2 texts (using PaymentInfo.TotalAmount + PaymentInfo.InterestAmount), it will result in this: "1060714,23124323400,00".


What you need to do is to use the TextToDecimal Built-in Function over your variables.

Try this:

TextToDecimal(PaymentInfo.TotalAmount) +  TextToDecimal(PaymentInfo.InterestAmount)


The result should be the sum of your decimal values.


Kind regards,

Rui Barradas

 

 Following your formula Now outputs 0

Send me your OML please. So I can take a look.


Kind regards,

Rui Barradas

Solution

Oh I just saw what the problem is.

It is because you have a comma instead a dot and OutSystems cannot convert it to a decimal.

Try this:

TextToDecimal(Replace(PaymentInfo.TotalAmount, ",", ".")) + TextToDecimal(Replace(PaymentInfo.InterestAmount, ",", "."))


Kind regards,

Rui Barradas

Solution

Hi kan2332,

i would like to add that it seems like a bad design to have variables that are clearly amounts defined as text type. 

Dorine