# Buggy code
def after_create_object(self, order, data, view_kwargs):
    """
    after create object method for OrderListPost Class
    :param order: Object created from mashmallow_jsonapi
    :param data:
    :param view_kwargs:
    :return:
    """
    order_tickets = {}
    for holder in order.ticket_holders:
        if holder.id != current_user.id:
            pdf = create_save_pdf(
                render_template("pdf/ticket_attendee.html", order=order, holder=holder),
                UPLOAD_PATHS["pdf"]["ticket_attendee"],
                dir_path="/static/uploads/pdf/tickets/",
            )
        else:
            pdf = create_save_pdf(
                render_template("pdf/ticket_purchaser.html", order=order),
                UPLOAD_PATHS["pdf"]["ticket_attendee"],
                dir_path="/static/uploads/pdf/tickets/",
            )
        holder.pdf_url = pdf
        save_to_db(holder)
        if not order_tickets.get(holder.ticket_id):
            order_tickets[holder.ticket_id] = 1
        else:
            order_tickets[holder.ticket_id] += 1
    for ticket in order_tickets:
        od = OrderTicket(
            order_id=order.id, ticket_id=ticket, quantity=order_tickets[ticket]
        )
        save_to_db(od)
    order.quantity = order.tickets_count()
    order.user = current_user
    save_to_db(order)
    if not has_access("is_coorganizer", event_id=data["event"]):
        TicketingManager.calculate_update_amount(order)

    # send e-mail and notifications if the order status is completed
    if order.status == "completed":
        send_email_to_attendees(order, current_user.id)
        send_notif_to_attendees(order, current_user.id)

        order_url = make_frontend_url(
            path="/orders/{identifier}".format(identifier=order.identifier)
        )
        for organizer in order.event.organizers:
            send_notif_ticket_purchase_organizer(
                organizer, order.invoice_number, order_url, order.event.name
            )

    data["user_id"] = current_user.id


# Traceback (TypeError)
ERROR:flask.app:Exception on /v1/orders [POST]
Traceback (most recent call last):
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/app/api/helpers/permissions.py", line 45, in decorator
return fn(*args, **kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 32, in wrapper
return func(*args, **kwargs)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 68, in dispatch_request
response = method(*args, **kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 56, in wrapper
return func(*args, **kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 204, in post
obj = self._data_layer.create_object(data, kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/src/flask-rest-jsonapi/flask_rest_jsonapi/data_layers/alchemy.py", line 51, in create_object
self.after_create_object(obj, data, view_kwargs)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/app/api/orders.py", line 122, in after_create_object
order.quantity = order.tickets_count()
TypeError: 'int' object is not callable

# Fixed code
def after_create_object(self, order, data, view_kwargs):
    """
    after create object method for OrderListPost Class
    :param order: Object created from mashmallow_jsonapi
    :param data:
    :param view_kwargs:
    :return:
    """
    order_tickets = {}
    for holder in order.ticket_holders:
        if holder.id != current_user.id:
            pdf = create_save_pdf(
                render_template("pdf/ticket_attendee.html", order=order, holder=holder),
                UPLOAD_PATHS["pdf"]["ticket_attendee"],
                dir_path="/static/uploads/pdf/tickets/",
            )
        else:
            pdf = create_save_pdf(
                render_template("pdf/ticket_purchaser.html", order=order),
                UPLOAD_PATHS["pdf"]["ticket_attendee"],
                dir_path="/static/uploads/pdf/tickets/",
            )
        holder.pdf_url = pdf
        save_to_db(holder)
        if not order_tickets.get(holder.ticket_id):
            order_tickets[holder.ticket_id] = 1
        else:
            order_tickets[holder.ticket_id] += 1
    for ticket in order_tickets:
        od = OrderTicket(
            order_id=order.id, ticket_id=ticket, quantity=order_tickets[ticket]
        )
        save_to_db(od)
    order.quantity = order.tickets_count
    order.user = current_user
    save_to_db(order)
    if not has_access("is_coorganizer", event_id=data["event"]):
        TicketingManager.calculate_update_amount(order)

    # send e-mail and notifications if the order status is completed
    if order.status == "completed":
        send_email_to_attendees(order, current_user.id)
        send_notif_to_attendees(order, current_user.id)

        order_url = make_frontend_url(
            path="/orders/{identifier}".format(identifier=order.identifier)
        )
        for organizer in order.event.organizers:
            send_notif_ticket_purchase_organizer(
                organizer, order.invoice_number, order_url, order.event.name
            )

    data["user_id"] = current_user.id