Passed
Push — main ( df5ee1...bea1c2 )
by Sat CFDI
02:04
created

satdigitalinvoice.formatting_functions.common   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 21
dl 0
loc 38
rs 10
c 0
b 0
f 0

7 Functions

Rating   Name   Duplication   Size   Complexity  
A fecha_mes() 0 2 1
A fecha() 0 2 1
A num_letras() 0 2 1
A pesos() 0 5 1
A get_month_name() 0 2 1
A numero() 0 2 1
A porcentaje() 0 2 1
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