Esempio n. 1
0
def txnByName(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = TxnBySecurityForm()
    else:
        form = TxnBySecurityForm(request.POST)
        if form.is_valid():
            security = form.cleaned_data['security']
            a.txnByName(security=security)
        return redirect('/portfolio/txn/' + account_id + '/byname/' + str(security.id) + '/')
    return render(request, 'portfolio/transaction.html', 
                  {'form': form,
                   'account': a,
                   'sub_title': 'Transactions by security'})
Esempio n. 2
0
def txnByName(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = TxnBySecurityForm()
    else:
        form = TxnBySecurityForm(request.POST)
        if form.is_valid():
            security = form.cleaned_data['security']
            a.txnByName(security=security)
        return redirect('/portfolio/txn/' + account_id + '/byname/' +
                        str(security.id) + '/')
    return render(request, 'portfolio/transaction.html', {
        'form': form,
        'account': a,
        'sub_title': 'Transactions by security'
    })
Esempio n. 3
0
def txnDiv(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = TxnBySecurityForm()
        years = Account.div_years.div_years(account_id)
    else:
        form = TxnBySecurityForm(request.POST)
        if form.is_valid():
            security = form.cleaned_data['security']

            sum = Transaction.objects.filter(account_id=account_id).filter(action='DIV').filter(shares__gt=0).aggregate(Sum('cash_amount'))
            
        return redirect('/portfolio/txn/' + account_id + '/div/' + str(security.id) + '/')
    return render(request, 'portfolio/transaction.html', 
                  {'form': form,
                   'yearly_divs' : True,
                   'years' : years,
                   'account' : a,
                   'sub_title': 'Display dividends'})
Esempio n. 4
0
def txnDiv(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = TxnBySecurityForm()
        years = Account.div_years.div_years(account_id)
    else:
        form = TxnBySecurityForm(request.POST)
        if form.is_valid():
            security = form.cleaned_data['security']

            sum = Transaction.objects.filter(account_id=account_id).filter(
                action='DIV').filter(shares__gt=0).aggregate(
                    Sum('cash_amount'))

        return redirect('/portfolio/txn/' + account_id + '/div/' +
                        str(security.id) + '/')
    return render(
        request, 'portfolio/transaction.html', {
            'form': form,
            'yearly_divs': True,
            'years': years,
            'account': a,
            'sub_title': 'Display dividends'
        })