anchor.diff:  		Validity :: integer(),
   		Final :: boolean(),
   		Buckets :: [#bucket{}],
  -		Result :: {RemainingCharge, Charged, NewBuckets},
  -		RemainingCharge :: integer(),
  -		Charged :: integer(),
  +		Result :: {RemainingUnits, UnitsCharged, NewBuckets},
  +		RemainingUnits :: integer(),
  +		UnitsCharged :: integer(),
   		NewBuckets :: [#bucket{}].
   %% @doc Manage usage pricing and debit monetary amount buckets.
   %%
  
positive.code: 				{R1, C1, NB1}
  		end
  	of
  		{RemainingCharge, ReservedAmount, NewBuckets} ->
  			rate3(Subscriber#subscriber{buckets = NewBuckets},
  					RemainingCharge, Flag, ReservedAmount, SessionIdentification)
  	catch
  		_:_ ->
  			throw(price_not_found)
  	end.
  %% @hidden
  rate3(#subscriber{session_attributes = SessionList} = Subscriber,
  		Charged, _Flag, _ReserveAmount, _SessionIdentification)
  		when Charged > 0 ->
  	Entry = Subscriber#subscriber{session_attributes = []},
  	ok = mnesia:write(Entry),
  	{out_of_credit, SessionList};
  rate3(#subscriber{session_attributes = SessionList} = Subscriber,
  		_Charged, initial, ReserveAmount, SessionIdentification) ->
  	NewSessionList = update_session(SessionIdentification, SessionList),
  	Entry = Subscriber#subscriber{session_attributes = NewSessionList},
  	ok = mnesia:write(Entry),
  	{grant, Entry, ReserveAmount};
  rate3(#subscriber{session_attributes = SessionList} = Subscriber,
  		_Charged, final, ReserveAmount, SessionIdentification) ->
  	NewSessionList = remove_session(SessionList, SessionIdentification),
  	Entry = Subscriber#subscriber{session_attributes = NewSessionList},
  	ok = mnesia:write(Entry),
  	{grant, Entry, ReserveAmount};
  rate3(Subscriber, _Charged, interim, ReserveAmount, _SessionIdentification) ->
  	ok = mnesia:write(Subscriber),
  	{grant, Subscriber, ReserveAmount}.
  
  
negative.code: 	case charge(cents, Charge, true, Buckets) of
  		{0, Charge, NewBuckets} when Final == true,
  				(UnitsNeeded * Size - Used) == 0 ->
  			{0, UnitsNeeded * Size, NewBuckets};
  		{0, Charge, NewBuckets} when Final == false ->
  			Bucket = #bucket{bucket_type = Type,
  				remain_amount = UnitsNeeded * Size,
  				termination_date = Validity,
  				start_date = erlang:system_time(?MILLISECOND)},
  			{0, UnitsNeeded * Size, [Bucket | NewBuckets]};
  		{0, Charge, NewBuckets} when Final == true ->
  			Bucket = #bucket{bucket_type = Type,
  				remain_amount = UnitsNeeded * Size - Used,
  				termination_date = Validity,
  				start_date = erlang:system_time(?MILLISECOND)},
  			{0, UnitsNeeded * Size, [Bucket | NewBuckets]};
  		{_RemainingCharge, Charged, NewBuckets} ->
  			UnitsCharged = Charged div Price,
  			{UnitsNeeded - UnitsCharged, UnitsCharged, NewBuckets}
  	end.
  
  %% @hidden
  