Total Complexity | 5 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from babel.dates import format_date |
||
2 | from num2words import num2words |
||
3 | |||
4 | LANG = 'es_CO' |
||
5 | |||
6 | |||
7 | def pesos(amount): |
||
8 | decimal_part = "{:.2f}".format(amount).split(".")[1] |
||
9 | integer_part = num2words(int(amount), lang=LANG, to='currency').upper() |
||
10 | |||
11 | return "${0:,.2f} (SON: {1} {2}/100M.N.)".format(amount, integer_part, decimal_part) |
||
12 | |||
13 | |||
14 | def porcentaje(amount, decimals=2): |
||
15 | percentage = round(amount * 100, decimals) |
||
16 | return "{0}% ({1} POR CIENTO)".format( |
||
17 | percentage, |
||
18 | num2words(percentage, lang=LANG).upper() |
||
19 | ) |
||
20 | |||
21 | |||
22 | def num_letras(number): |
||
23 | return num2words(number, lang=LANG).upper() |
||
24 | |||
25 | |||
26 | def fecha(date): |
||
27 | return format_date(date, locale='es_MX', format="d 'de' MMMM 'del' y").upper() |
||
28 | |||
29 | |||
30 | def fecha_mes(date): |
||
31 | return format_date(date, locale='es_MX', format="'Mes de' MMMM 'del' y").upper() |
||
32 |