def etrago_convert_overnight_cost(annuity_cost, json_file, t=40, p=0.05):
    """ Get annuity cost of simulation and calculation total
    ``overnight_costs`` by given capital costs and lifetime.

    Parameters
    ----------
    json_file : :obj:dict
        Dictionary of the ``scenario_setting.json`` file
    _start_snapshot : int
        Start point of calculation from ``scenario_setting.json`` file
    _end_snapshot : int
        End point of calculation from ``scenario_setting.json`` file
    _p : numeric
        interest rate of investment
    _T : int
        lifetime of investment

    Returns
    -------
    overnight_cost : numeric
        Scenario and calculation total ``overnight_costs`` by given
        annuity capital costs and lifetime.

    Examples
    --------
    .. math::

        PVA =   (1 / p) - (1 / (p*(1 + p)^t))

        K_{ON} = K_a*PVA*((t/(period+1))

    """
    PVA = 1 / p - 1 / (p * (1 + p) ** t)
    year = 8760
    period = json_file['eTraGo']['end_snapshot'] - json_file['eTraGo'][
        'start_snapshot']
    overnight_cost = annuity_cost * (PVA * (year / (period + 1)))
    return overnight_cost
