示例#1
0
def decimal_to_string(value, currency):
    """ Convert value to currency string """
    if currency == 'euro':
        return euro(value)
    elif currency == 'gbp':
        return pound(value)
    return sek(value)
示例#2
0
def decimal_to_string(value, currency):
    """ Convert value to currency string """
    if currency == 'euro':
        return euro(value)
    elif currency == 'gbp':
        return pound(value)
    return sek(value)
示例#3
0
def total_monetized(self):
    """ Shows currency in admin, currently only euro's, pounds and dollars """
    if self.currency == 'euro':
        return '€ %s' % euro(self.total)
    elif self.currency == 'gbp':
        return '£ %s' % pound(self.total)
    elif self.currency == 'dollar':
        return '$ %s' % pound(self.total)
示例#4
0
def total_monetized(self):
    """ Shows currency in admin, currently only euro's, pounds, sek and dollars """
    if self.currency == 'euro':
        return '€ %s' % euro(self.total)
    elif self.currency == 'gbp':
        return '£ %s' % pound(self.total)
    elif self.currency == 'dollar':
        return '$ %s' % pound(self.total)
    elif self.currency == 'sek':
        return '&kronor; %s' % sek(self.total)
示例#5
0
def total_monetized(self):
    """ Shows currency in admin, currently only euro's, pounds, sek and dollars """
    if self.currency == "euro":
        return "€ %s" % euro(self.total)
    elif self.currency == "gbp":
        return "£ %s" % pound(self.total)
    elif self.currency == "dollar":
        return "$ %s" % pound(self.total)
    elif self.currency == "sek":
        return "&kronor; %s" % sek(self.total)
示例#6
0
    def changelist_view(self, request, extra_context=None):
        from django.contrib.admin.views.main import ChangeList
        cl = ChangeList(request, self.model, list(self.list_display),
                        self.list_display_links, self.list_filter,
                        self.date_hierarchy, self.search_fields,
                        self.list_select_related,
                        self.list_per_page,
                        self.list_editable,
                        self)

        total_per_currency = Decimal(0)
        total_with_tax = Decimal(0)
        total_dict = dict()
        for item in cl.get_query_set():
            if item.currency in total_dict:
                # Currency in dict
                total_dict[item.currency][0] += item.subtotal
                total_dict[item.currency][1] += item.total
            else:
                # Currency not in dict
                total_dict[item.currency] = [item.subtotal, item.total]

        # Convert variables to currencies
        for k,v in total_dict.items():
            if k == 'euro':
                new_value = (euro(v[0]), euro(v[1]))
                total_dict[k] = new_value
            elif k == 'gbp':
                new_value = (pound(v[0]), pound(v[1]))
                total_dict[k] = new_value
            else:
                new_value = (dollar(v[0]), dollar(v[1]))
                total_dict[k] = new_value

        extra_context = dict()
        extra_context['total_dict'] = total_dict
        return super(InvoiceAdmin, self).changelist_view(request,
                                                         extra_context=extra_context)