def process_balances(stmt):
    """
    Based on `ofxstatement.statement.recalculate_balance`. Uses the "Ending Balance" field
    from the Betterment transaction data for fetching the start and end balance for this statement.
    If the statement has no transactions, it is returned unmodified.

    :param stmt: The statement data to process.
    :return: Whether the balances were calculated.
    """
    if not stmt.lines:
        return False
    date_sorted_lines = sorted(stmt.lines, key=lambda k: k.date)
    first_line = date_sorted_lines[0]
    stmt.start_balance = first_line.end_balance - first_line.amount
    stmt.start_date = first_line.date
    last_line = date_sorted_lines[-1]
    stmt.end_balance = last_line.end_balance
    stmt.end_date = last_line.date
    return True
