Passed
Push — main ( a0079b...e072d8 )
by Sat CFDI
01:47
created

satdigitalinvoice.formatting_functions.common   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 24
rs 10
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A pesos() 0 5 1
A num_letras() 0 2 1
A fecha_mes() 0 2 1
A fecha() 0 2 1
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 num_letras(number):
15
    return num2words(number, lang=LANG).upper()
16
17
18
def fecha(date):
19
    return format_date(date, locale='es_MX', format="d 'de' MMMM 'del' y").upper()
20
21
22
def fecha_mes(date):
23
    return format_date(date, locale='es_MX', format="'Mes de' MMMM 'del' y").upper()
24