from django import template
from django.contrib.humanize.templatetags.humanize import intcomma

register = template.Library()

def currency_dolares(dollars):
    dollars = round(float(dollars), 2)
    return "$ %s%s" % (intcomma(int(dollars)), ("%0.2f" % dollars)[-3:])

register.filter('currency_dolares', currency_dolares)


def currency_euros(euros):
    euros = round(float(euros), 2)
    return "%s%s €" % (intcomma(int(euros)), ("%0.2f" % euros)[-3:])

register.filter('currency_euros', currency_euros)


def no_currency(numero):
    numero = round(float(numero), 0)
    return "%s" % (intcomma(int(numero)))

register.filter('no_currency', no_currency)
