def calculate_battery_state_of_charge(prev_battery_state_of_charge,
    battery_capacity, delta_time, battery_current, prev_battery_current=None):
    """
    Calculates the state of charge of the battery [%].

    :param prev_battery_state_of_charge:
        Previous state of charge of the battery [%].

        .. note::

            `prev_battery_state_of_charge` = 99 is equivalent to 99%.
    :type prev_battery_state_of_charge: float

    :param battery_capacity:
        Battery capacity [Ah].
    :type battery_capacity: float

    :param delta_time:
        Time step [s].
    :type delta_time: float

    :param battery_current:
        Low voltage battery current [A].
    :type battery_current: float

    :param prev_battery_current:
        Previous low voltage battery current [A].
    :type prev_battery_current: float

    :return:
        State of charge of the battery [%].
    :rtype: float
    """
    if prev_battery_current is None:
        prev_battery_current = battery_current
    c = battery_capacity * 36.0
    b = (battery_current + prev_battery_current) / 2.0 * delta_time
    return min(prev_battery_state_of_charge + b / c, 100.0)
