Beispiel #1
0
def entry_point(userid, key):
    trans = Transactions.query.filter_by(account_id=1)
    res = "<table>"

    for t in trans:
        res += "<tr><td>"+t.date_valuta.strftime("%Y-%m-%d") +\
               "</td><td><b>"+decrypt(t.amount, key).decode('utf-8') +\
               "</b></td><td>"+decrypt(t.description,key).decode('utf-8') + "</tr>"
    return res
Beispiel #2
0
def get_balance_for_account(account_id, encryption_key):
    transactions = Transactions.query.filter_by(account_id=account_id)
    balance = 0.0
    for transaction in transactions:
        balance += float(
            decrypt(transaction.amount, encryption_key).decode('utf-8'))
    currency = Accounts.query.filter_by(id=account_id).first().currency.short
    pair = dict()
    pair['currency'] = currency
    pair['value'] = balance
    return pair
Beispiel #3
0
def create_transaction(date_created, date_valuta, description, amount,
                       account_id, encryption_key, db_session):
    existing_transactions = Transactions.query.filter_by(
        date_created=date_created,
        date_valuta=date_valuta,
        account_id=account_id).all()
    for et in existing_transactions:
        if decrypt(et.description, encryption_key) == description:
            return 1
    transaction = Transactions(date_valuta=date_valuta,
                               date_created=date_created,
                               description=encrypt(description,
                                                   encryption_key),
                               amount=encrypt(amount, encryption_key),
                               account_id=account_id)
    db_session.add(transaction)
    return 0
Beispiel #4
0
def test_decryption():
    data = request.args.get('data').encode('utf-8')
    key = request.cookies.get('lafin_key')
    return decrypt(data, key)