Passed
Push — main ( 69a617...5e9c42 )
by Sat CFDI
01:47
created

data_range_length_months()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
from babel.dates import format_date
2
from num2words import num2words
3
4
5
def pesos(amount):
6
    amount = round(amount, 2)
7
    decimal_part = "{:.2f}".format(amount).split(".")[1]
8
    integer_part = int(amount)
9
    integer_part = number_to_currency(integer_part).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 = amount * 100
16
    percentage = round(percentage, decimals)
17
    percentage_text = number_to_text(percentage).upper()
18
19
    return "{0}% ({1} POR CIENTO)".format(percentage, percentage_text)
20
21
22
def number_to_currency(number):
23
    return num2words(number, lang='es_CO', to='currency')
24
25
26
def number_to_text(number):
27
    return num2words(number, lang='es_CO')
28
29
30
def date_range(start, end):
31
    return "{0} AL {1}".format(fecha(start), fecha(end))
32
33
34
def fecha(date):
35
    return format_date(date, locale='es_MX', format="d 'de' MMMM 'del' y").upper()
36
37
38
# def data_range_length_months(start, end):
39
#     months = len(list(rrule.rrule(rrule.MONTHLY, dtstart=start, until=end)))
40
#     months_text = number_to_text(months).upper()
41
#     return "{0} ({1} MESES)".format(months, months_text)
42
43
44
def meses(count):
45
    months = count
46
    months_text = number_to_text(months).upper()
47
    return "{0} ({1} MESES)".format(months, months_text)
48