Example #1
0
def transaction_delete():
    id_ = request.form.get('id')
    t = Transaction.query_one({'_id': ObjectId(id_)})

    # 做一次反向操作
    if t.type_ == 'sell':
        t.type_ = 'buy'
    elif t.type_ == 'buy':
        t.type_ = 'sell'
    Position.do_op(t, reverse=True)

    t.remove()
    return jsonify(status=200)