Aller au contenu principal

money_format

Formats a number as a currency string.

MONEY_FORMAT

NAME

money_format - Changes the format of a number as a currency string

SYNOPSIS

money_format(number,lg,dollar,dot,separator,iffloat,fr,before,after)

money_format(number, options:context)

PARAMETERS

number
The number to be formatted.
lg
Language dollar
dollar
Dollar symbol
dot
Dot symbol separator Separator symbol
iffloat
Returns float format if the value has decimals, it returns an integer otherwise
fr
Fractional part size (default 2)
before
String before value (default dollar symbol for en, nothing for fr)
after
String after value (default dollar symbol for fr, nothing for en)
 
options
use to specify the parameter in a context with the following name:
 

- dot : specify the separator between number and fractional part

- separator  : specify the separator for large number

- sign_separator : specify the separator between the $ sign and the. umber 

- lg : support fr or en and defined wheer the $ will be place and the default separator for large number

- before : replace the $ sign by this before the number

- after : replace the $ sign by this after the number

- fr : specify the number of digit in the fractional part

- float : if the fractional part is 00 and this is false, then 00 will not be displayed

- dollar : specify the dollar sign

- sign_possition: left or right

 

RETURN

string
Returns the formatted string.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

in:  res={_{money_format(1234567.3,"en")}}.
out: res=$ 1,234,567.30.

in:  res={_{money_format(1234567.345,"fr")}}.
out: res=1 234 567,35 $.

a = 1899.8;

money_format(a,"fr","$",","," ", true, 1); //return 1 899,8$
money_format(a,"en","$",".",",", true, 1);//return $1,899.8

money_format(12, options: { "float": false }); // return 12 $
money_format(12, options: { "after": '%' }); // return 12,00%


 

 

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pusnei Sergey and Caroline Laplante, <sergey@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

1.1 2021-10-18 laplante@sednove.com add sign_position

Edit

© 2024 extenso Inc. All rights reserved.