def loan_iof(
    principal,
    amortizations,
    return_days,
    daily_iof_aliquot,
    complementary_iof_aliquot
):
    """The total IOF of a loan.

    If :math:`s` is the principal, :math:`A_i` is the :math:`i`-th
    amortization, :math:`n_1,\\ldots,n_k` are the return days, :math:`I^*` is
    the daily IOF aliquot and :math:`I^{**}` is the complementary IOF aliquot,
    then the loan IOF tax amount is

    .. math::

        \\mathrm{IOF}(s, I^*, I^{**}, (A_1,\\ldots,A_k),(n_1,\\ldots,n_k)) =
         sI^{**} + \\sum_{i=1}^k A_i \\min(n_i I^*,0.015)

    Parameters
    ----------
    principal: float, required
        Loan principal.
    amortizations: list, required
        List of floats providing the amortization due to each payment.
    return_days: list, required
        List of integers with the numbers of days since the loan was granted.
    daily_iof_aliquot: float, required
        Daily IOF aliquot. Its value is defined by law.
    complementary_iof_aliquot: float, required
        Complementary IOF aliquot. Its value is defined by law.
    """

    p = principal
    d_iof = daily_iof_aliquot
    c_iof = complementary_iof_aliquot

    return c_iof * p + sum(a * min(n * d_iof, 0.015)
                           for a, n in zip(amortizations, return_days))