예제 #1
0
    def total_value(self):
        t_value = Decimal(0)
        total_estimate = defaultdict(lambda: Decimal(0.0))
        accounts = BankAccount.objects.filter(owner=self.owner)
        for account in accounts:
            total_estimate[account.cur_code] += Decimal(
                convert(account.balance, account.cur_code, 'USD'))
            t_value += total_estimate[account.cur_code]

        return t_value.quantize(Decimal("0.01"))
예제 #2
0
def convert_currency(request):
    from_code = request.GET.get('from_code')
    to_code = request.GET.get('to_code')
    amount = request.GET.get('amount')
    # print (code)
    # print (amount)
    response_data = {}
    value = convert(amount, from_code, to_code)
    response_data['result'] = value.__str__()
    # response_data['postpk'] = post.pk
    # response_data['text'] = post.text
    # response_data['created'] = post.created.strftime('%B %d, %Y %I:%M %p')
    # response_data['author'] = post.author.username

    return HttpResponse(json.dumps(response_data),
                        content_type="application/json")
예제 #3
0
def currency_convert(amount, from_, to_, *args, **kwargs):
    return convert(amount, from_, to_)
예제 #4
0
def my_tag(amount, from_, to_, *args, **kwargs):
    return convert(amount, from_, to_)