def METHOD_NAME(ticket_id, status):
    """calculated_sale_by_status"""
    query_ = OrderTicket.query.join(Order).join(Order.discount_code, isouter=True)
    order_ticket_ids: OrderTicket = query_.filter(
        OrderTicket.ticket_id == ticket_id, Order.status == status
    ).all()
    total_amount = 0
    if order_ticket_ids:
        for order_ticket_id in order_ticket_ids:
            if order_ticket_id.price and order_ticket_id.quantity:
                discount_amount = 0
                if order_ticket_id.order.discount_code:
                    discount_amount = order_ticket_id.order.discount_code.value
                total_amount += (
                    order_ticket_id.price - discount_amount
                ) * order_ticket_id.quantity
    return total_amount