def add_expense(current_user): category = request.args.get('category') amount = request.args.get('amount') dt = request.args.get('date') private = request.args.get('private') if not category or not amount: return jsonify({'message': 'Insufficient parameters'}), 400 exp = Expense(category=category, amount=amount, SpentBy=current_user) if dt: exp.date = dt if private: exp.private = private db.session.add(exp) db.session.commit() return jsonify({'message': 'Expense added'}), 201