Reply
New Member
Posts: 8
Registered: ‎03-28-2017
Kudos: 32
Solutions: 1
Accepted Solution

How to Convert string value "145.500,35 COP" to float value "145.500,35" ??

Hello everyone, how can I convert a value of string type to decimal type in the invoice template? I require it for a formula where I rest two values, but they are in string and with "COP" at the end, I tried with replace but it is not allowed, if I do it with "145.500,35"|format_mumber (2, ",", " . ") returns the following "145.35" (attention to separators of decimal and thousands). I appreciate your ideas.

 

Robert G. Churión R.


Accepted Solutions
Highlighted
Ubiquiti Employee
Posts: 1,325
Registered: ‎03-21-2016
Kudos: 214
Solutions: 150

Re: How to Convert string value "145.500,35 COP" to float value "145.500,35" ??

Hello @rgchurion , you can use the "raw" variables. If you go to the new/edit invoice template form, you can see all the available variables listed in the "Twig template variables" box.

For example for invoice item's total, you would normally use {{ item.total }}", but you can use "{{ item.totalRaw }}" to get the raw number and use number_format on that.

This should be available for all pre-formatted values.

View solution in original post

New Member
Posts: 8
Registered: ‎03-28-2017
Kudos: 32
Solutions: 1

Re: How to Convert string value "145.500,35 COP" to float value "145.500,35" ??

Excellent, I've recently tried it and it has worked perfect!

View solution in original post


All Replies
Highlighted
Ubiquiti Employee
Posts: 1,325
Registered: ‎03-21-2016
Kudos: 214
Solutions: 150

Re: How to Convert string value "145.500,35 COP" to float value "145.500,35" ??

Hello @rgchurion , you can use the "raw" variables. If you go to the new/edit invoice template form, you can see all the available variables listed in the "Twig template variables" box.

For example for invoice item's total, you would normally use {{ item.total }}", but you can use "{{ item.totalRaw }}" to get the raw number and use number_format on that.

This should be available for all pre-formatted values.

New Member
Posts: 8
Registered: ‎03-28-2017
Kudos: 32
Solutions: 1

Re: How to Convert string value "145.500,35 COP" to float value "145.500,35" ??

Excellent, I've recently tried it and it has worked perfect!
Reply