Exemplo n.º 1
0
def buySell(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = BuyForm()
    else:
        form = BuyForm(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            security = form.cleaned_data['security']
            shares = form.cleaned_data['shares']
            price = form.cleaned_data['price']
            action = form.cleaned_data['action']
            commission = form.cleaned_data['commission']
            currency = form.cleaned_data['currency']
            exchange_rate = form.cleaned_data['exchange_rate']
            a.buySellSecurity(security=security,
                              shares=shares,
                              date=date,
                              price=price,
                              commission=commission,
                              action=action,
                              currency=currency,
                              exchange_rate=exchange_rate)
            return redirect('/portfolio/account/' + account_id + '/')
    return render(request, 'portfolio/transaction.html', {
        'form': form,
        'account': a,
        'sub_title': 'Buy or sell'
    })
Exemplo n.º 2
0
def buy(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = BuyForm()
    else:
        form = BuyForm(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            security = form.cleaned_data['security']
            shares = form.cleaned_data['shares']
            price = form.cleaned_data['price']
            commission = form.cleaned_data['commission']
            a.buy_security(security=security, shares=shares, date=date,
                           price=price, commission=commission)
            return redirect('/portfolio/account/' + account_id)
    return render(request, 'portfolio/buy.html', {'form': form})
Exemplo n.º 3
0
def buy(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = BuyForm()
    else:
        form = BuyForm(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            security = form.cleaned_data['security']
            shares = form.cleaned_data['shares']
            price = form.cleaned_data['price']
            commission = form.cleaned_data['commission']
            a.buy_security(security=security,
                           shares=shares,
                           date=date,
                           price=price,
                           commission=commission)
            return redirect('/portfolio/account/' + account_id)
    return render(request, 'portfolio/buy.html', {'form': form})
Exemplo n.º 4
0
def buySell(request, account_id):
    a = get_object_or_404(Account, pk=account_id)
    if request.method == 'GET':
        form = BuyForm()
    else:
        form = BuyForm(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            security = form.cleaned_data['security']
            shares = form.cleaned_data['shares']
            price = form.cleaned_data['price']
            action = form.cleaned_data['action']
            commission = form.cleaned_data['commission']
            currency = form.cleaned_data['currency']
            exchange_rate = form.cleaned_data['exchange_rate']
            a.buySellSecurity(security=security, shares=shares, date=date,
                              price=price, commission=commission, action=action,
                              currency=currency, exchange_rate=exchange_rate)
            return redirect('/portfolio/account/' + account_id + '/')
    return render(request, 'portfolio/transaction.html', 
                  {'form': form,
                   'account': a,
                   'sub_title': 'Buy or sell'})