Total Complexity | 9 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from babel.dates import format_date, get_month_names |
||
2 | from num2words import num2words |
||
3 | |||
4 | LANG = 'es_CO' |
||
5 | LOCALE = 'es_MX' |
||
6 | |||
7 | |||
8 | def pesos(amount): |
||
9 | decimal_part = "{:.2f}".format(amount).split(".")[1] |
||
10 | integer_part = num2words(int(amount), lang=LANG, to='currency').upper() |
||
11 | |||
12 | return "${0:,.2f} (SON: {1} {2}/100M.N.)".format(amount, integer_part, decimal_part) |
||
13 | |||
14 | |||
15 | def num_letras(number): |
||
16 | return num2words(number, lang=LANG).upper() |
||
17 | |||
18 | |||
19 | def numero(k): |
||
20 | return str(k) + ' (' + num_letras(k) + ')' |
||
21 | |||
22 | |||
23 | def porcentaje(k): |
||
24 | return str(k) + '% (' + num_letras(k) + ' POR CIENTO)' |
||
25 | |||
26 | |||
27 | def fecha(date): |
||
28 | return format_date(date, locale=LOCALE, format="d 'de' MMMM 'del' y").upper() |
||
29 | |||
30 | |||
31 | def fecha_mes(date): |
||
32 | return format_date(date, locale=LOCALE, format="'Mes de' MMMM 'del' y").upper() |
||
33 | |||
34 | |||
35 | # function to get month name from number |
||
36 | def get_month_name(month_number): |
||
37 | return get_month_names('wide', locale=LOCALE)[month_number].upper() |
||
38 | |||
39 | |||
40 | def delta_tiempo(duracion): |
||
41 | months = duracion.years * 12 + duracion.months |
||
42 | if months == 12: |
||
43 | return 'UN AÑO' |
||
44 | return num_letras(duracion.months) + ' MESES' |
||
45 |