def METHOD_NAME(
     patron_pid, status=None, types=None, with_subscription=True):
    """Get total amount transactions linked to a patron.
    :param patron_pid: the patron pid being searched
    :param status: (optional) transaction status filter,
    :param types: (optional) transaction type filter,
    :param with_subscription: (optional) include or exclude subscription
           type filter.
    :return: return total amount of transactions.
    """
    search = _build_transaction_query(patron_pid, status, types)
    if not with_subscription:
        search = search.exclude('terms', type=['subscription'])
    search.aggs.metric('pttr_total_amount', 'sum', field='total_amount')
    search = search[0:0]  # set the from/size to 0 ; no need es hits
    results = search.execute()
    return results.aggregations.pttr_total_amount.value