def fv(rate_ : float, nper : int, pmt : float, pv_ : float = 0, type_ : int = 0) -> float:
    """
    Calculates the future value of a loan based on a constant interest rate.

    Parameters
    ----------
    rate_ : float
        The interest rate per period.
    nper : int
        The total number of payment periods in an annuity.
    pmt : float
        The constant payment amount made each period.
    pv_ : float [optional]
        The present value of the annuity.
    type_ : int [optional]
        Indicates when payments are due.
            - 0 [default] : at the end of the period.
            - 1 : at the beginning of the period

    Returns
    -------
    float
        The future value of the loan based on a constant interest rate.
    """
    
    if rate_ != 0:
        _fv = -(pv_ * (1 + rate_)**nper + pmt * (1 + rate_*type_) * (((1 + rate_)**nper - 1)/rate_))
    else:
        _fv = -(pmt * nper + pv_)

    return _fv