anchor.diff:  -export([rate/6, rate/7]).
   
   -include("ocs.hrl").
  +-include_lib("radius/include/radius.hrl").
   
   %% support deprecated_time_unit()
   -define(MILLISECOND, milli_seconds).
   %-define(MILLISECOND, millisecond).
   
  --spec rate(Protocol, SubscriberID, Destination, Flag, DebitAmount, ReserveAmount) -> Result
  +-spec rate(Protocol, SubscriberID, Destination, Flag, DebitAmounts, ReserveAmounts) -> Result
   	when
   		Protocol :: radius | diameter,
   		SubscriberID :: string() | binary(),
   		Destination :: string(),
   		Flag :: initial | interim | final,
  -		DebitAmount :: [{Type, Amount}],
  -		ReserveAmount :: [{Type, Amount}],
  +		DebitAmounts :: [{Type, Amount}],
  +		ReserveAmounts :: [{Type, Amount}],
   		Type :: octets | seconds,
   		Amount :: integer(),
  -		Result :: {ok, Subscriber, GrantedAmount} | {out_of_credit, SessionList} | {error, Reason},
  +		Result :: {ok, Subscriber, GrantedAmount} | {disabled, SessionList}
  +				| {out_of_credit, SessionList} | {error, Reason},
   		Subscriber :: #subscriber{},
   		GrantedAmount :: integer(),
  -		SessionList :: [tuple()],
  +		SessionList :: [{pos_integer(), [tuple()]}],
   		Reason :: term().
  -%% @equiv rate(Protocol, SubscriberID, Destination, Flag, DebitAmount, ReserveAmount, [])
  -rate(Protocol, SubscriberID, Destination, Flag, DebitAmount, ReserveAmount) ->
  -	rate(Protocol, SubscriberID, Destination, Flag, DebitAmount, ReserveAmount, []).
  +%% @equiv rate(Protocol, SubscriberID, Destination, Flag, DebitAmounts, ReserveAmounts, [])
  +rate(Protocol, SubscriberID, Destination, Flag, DebitAmounts, ReserveAmounts) ->
  +	rate(Protocol, SubscriberID, Destination, Flag, DebitAmounts, ReserveAmounts, []).
   
   -spec rate(Protocol, SubscriberID, Destination,
  -		Flag, DebitAmount, ReserveAmount, SessionAttributes) -> Result
  +		Flag, DebitAmounts, ReserveAmounts, SessionAttributes) -> Result
   	when
   		Protocol :: radius | diameter,
   		SubscriberID :: string() | binary(),
   		Destination :: string(),
   		Flag :: initial | interim | final,
  -		DebitAmount :: [{Type, Amount}],
  -		ReserveAmount :: [{Type, Amount}],
  +		DebitAmounts :: [{Type, Amount}],
  +		ReserveAmounts :: [{Type, Amount}],
   		SessionAttributes :: [tuple()],
   		Type :: octets | seconds,
   		Amount :: integer(),
  
positive.code: 	end.
  %% @hidden
  rate3(Protocol, TariffTable, Subscriber, Destination, Prices,
  		Validity, Flag, DebitAmount, ReserveAmount, SessionAttributes) ->
  	case catch ocs_gtt:lookup_last(TariffTable, Destination) of
  		Amount when is_integer(Amount) ->
  			case lists:keyfind(tariffUsage, #price.type, Prices) of
  				#price{} = Price ->
  					rate4(Protocol, Subscriber, Price#price{amount = Amount}, Validity,
  							Flag, DebitAmount, ReserveAmount, SessionAttributes);
  				false ->
  					throw(price_not_found)
  			end;
  
negative.code: 				| {disabled, SessionList} | {error, Reason},
  		Subscriber :: #subscriber{},
  		GrantedAmount :: integer(),
  		SessionList :: [{pos_integer(), [tuple()]}],
  		Reason :: term().
  %% @doc Handle rating and balance management for used and reserved unit amounts.
  %%
  %% 	Subscriber balance buckets are permanently reduced by the
  %% 	amount(s) in `DebitAmounts' and `Type' buckets are allocated
  %% 	by the amount(s) in `ReserveAmounts'. The subscribed product
  %% 	determines the price used to calculate the amount to be
  %% 	permanently debited from available `cents' buckets.
  %%
  %% 	Returns `{ok, Subscriber, GrantedAmount}' if successful.
  %%
  %% 	Returns `{out_of_credit, SessionList}' if the subscriber's
  %% 	balance is insufficient to cover the `DebitAmounts' and
  %% 	`ReserveAmounts' or `{disabled, SessionList}' if the subscriber
  %% 	is not enabled. In both cases subscriber's balance is debited.
  %% 	`SessionList' describes the known active sessions which
  %% 	should be disconnected.
  %%
  rate(Protocol, SubscriberID, Destination,
  		Flag, DebitAmounts, ReserveAmounts, SessionAttributes) when is_list(SubscriberID)->
  	rate(Protocol, list_to_binary(SubscriberID), Destination,
  		Flag, DebitAmounts, ReserveAmounts, SessionAttributes);
  rate(Protocol, SubscriberID, Destination, Flag, DebitAmounts, ReserveAmounts, SessionAttributes)
  		when ((Protocol == radius) or (Protocol == diameter)), is_binary(SubscriberID),
  		((Flag == initial) or (Flag == interim) or (Flag == final)),
  		is_list(DebitAmounts), is_list(ReserveAmounts), is_list(SessionAttributes) ->
  	F = fun() ->
  			case mnesia:read(subscriber, SubscriberID, write) of
  				[#subscriber{product = #product_instance{product = ProdID,
  