anchor.diff:  %% @doc Scheduled function runs recurring charging and reschedules itself.
   %% @private
   run_recurring() ->
  -	case product_charge() of
  -		ok ->
  -			{ok, ScheduledTime} = application:get_env(ocs, charging_scheduler_time),
  -			{ok, Interval} = application:get_env(ocs, charging_interval),
  -			StartDelay = start_delay(ScheduledTime, Interval),
  -			case timer:apply_after(StartDelay, ?MODULE, run_recurring, []) of
  -				{ok, _TRef} ->
  -					ok;
  -				{error, Reason} ->
  -					error_logger:error_report(["Scheduler Failed",
  -							{module, ?MODULE}, {delay, StartDelay},
  -							{interval, Interval}, {error, Reason}])
  -			end;
  +	ok = product_charge(),
  +	{ok, ScheduledTime} = application:get_env(ocs, charging_scheduler_time),
  +	{ok, Interval} = application:get_env(ocs, charging_interval),
  +	StartDelay = start_delay(ScheduledTime, Interval),
  +	case timer:apply_after(StartDelay, ?MODULE, run_recurring, []) of
  +		{ok, _TRef} ->
  +			ok;
   		{error, Reason} ->
   			error_logger:error_report(["Scheduler Failed",
  -					{module, ?MODULE}, {error, Reason}])
  +					{module, ?MODULE}, {delay, StartDelay},
  +					{interval, Interval}, {error, Reason}])
   	end.
   
   %%----------------------------------------------------------------------
  
positive.code: 		Reason :: term().
  %% @doc Apply recurring charges to all subscriptions.
  product_charge() ->
  	case get_offers() of
  		{error, Reason} ->
  			{error, Reason};
  		Offers ->
  			Now = erlang:system_time(?MILLISECOND),
  			product_charge1(get_product(start), Now, frp(Offers))
  	end.
  %% @hidden
  product_charge1('$end_of_table', _Now, _Offers) ->
  	ok;
  product_charge1(ProdRef, Now, Offers) ->
  	F = fun() ->
  			case mnesia:read(product, ProdRef, write) of
  				[#product{product = OfferId,
  						payment = Payments,
  						balance = BucketRefs} = Product] ->
  					case if_recur(OfferId, Offers) of
  						{true, Offer} ->
  							case if_dues(Payments, Now) of
  								true ->
  									Buckets1 = lists:flatten([mnesia:select(bucket,
  											[{'$1',
  											[
  												{'==', Id, {element, #bucket.id, '$1'}}
  											],
  											['$1']}]) || Id <- BucketRefs]),
  									{NewProduct1, Buckets3} = ocs:subscription(Product, Offer,
  											Buckets1, false),
  									NewBRefs = update_buckets(BucketRefs, Buckets1, Buckets3),
  									NewProduct2 = NewProduct1#product{balance = NewBRefs},
  									ok = mnesia:write(NewProduct2);
  								false ->
  									ok
  							end;
  						false ->
  							ok
  					end;
  				[] ->
  					throw(product_ref_nof_found)
  			end
  	end,
  	case mnesia:transaction(F) of
  		{atomic, ok} ->
  			product_charge1(get_product(ProdRef), Now, Offers);
  		{aborted, Reason} ->
  			error_logger:error_report("Scheduler Update Failed",
  					[{module, ?MODULE}, {product_id, ProdRef},
  					{time, erlang:system_time(?MILLISECOND)},
  					{reason, Reason}]),
  			product_charge1(get_product(ProdRef), Now, Offers)
  	end.
  
  %%----------------------------------------------------------------------
  
negative.code: if_dues([], _Now)  ->
  	false.
  
  -spec if_recur(Prices) -> Result
  	when
  		Prices :: [#price{}],
  		Result :: boolean().
  %% @private
  if_recur(Prices) ->
  	F = fun(#price{type = Bundle}) when Bundle /= [] ->
  				true;
  			(#price{type = recurring}) ->
  				true;
  			(#price{alteration
  					= #alteration{type = recurring}}) ->
  				true;
  			(_) ->
  				false
  	end,
  	case lists:any(F, Prices) of
  		false ->
  			false;
  		true ->
  			true
  	end.
  
  %% @private
  