anchor.diff:         ,[<<"account_name">>
           ]).
   
  --define(ADD_USERS_DOC_FIELDS
  +-define(IMPORT_ONBILL_DATA1
          ,[<<"account_id">>
  -        ,<<"users">>
  +        ,<<"account_name">>
  +        ,<<"account_inn">>
  +        ,<<"account_kpp">>
  +        ,<<"prepaid">>
  +        ,<<"billing_address_line1">>
  +        ,<<"billing_address_line2">>
  +        ,<<"billing_address_line3">>
  +        ,<<"agrm_onnet_number">>
  +        ,<<"agrm_onnet_date">>
  +        ,<<"agrm_beeline_spb_number">>
  +        ,<<"agrm_beeline_spb_date">>
  +        ,<<"agrm_beeline_msk_number">>
  +        ,<<"agrm_beeline_msk_date">>
  +        ]).
  +
  +-define(IMPORT_MANDATORY_ONBILL_DATA1
  +       ,[<<"account_id">>
           ]).
   
   -define(ACCOUNT_REALM_SUFFIX
  
positive.code: create_users(_AccountId, [], _Context) -> 'ok';
  create_users(AccountId, [UserName|Users], Context) -> 
      UserPassword = kz_binary:rand_hex(10),
   %   UUID = kz_datamgr:get_uuid(),
      Props = props:filter_empty([
           {[<<"username">>], UserName}
       %   ,{[<<"id">>], UUID}
       %   ,{[<<"_id">>], UUID}
          ,{[<<"first_name">>], <<"Firstname">>}
          ,{[<<"last_name">>], <<"Surname">>}
          ,{[<<"email">>], UserName}
  
negative.code:             'account_not_created'
      end.
  
  -spec import_onbill_data1(kz_tasks:extra_args(), kz_tasks:iterator(), kz_tasks:args()) ->
                      {kz_tasks:return(), sets:set()}.
  import_onbill_data1(ExtraArgs, init, Args) ->
      case is_allowed(ExtraArgs) of
          'true' ->
              lager:info("import_onbill_data1 is allowed, continuing"),
              kz_datamgr:suppress_change_notice(),
              IterValue = sets:new(),
              import_onbill_data1(ExtraArgs, IterValue, Args);
          'false' ->
              lager:warning("import_onbill_data1 is forbidden for account ~s, auth account ~s"
                           ,[maps:get('account_id', ExtraArgs)
                            ,maps:get('auth_account_id', ExtraArgs)
                            ]
                           ),
              {<<"task execution is forbidden">>, 'stop'}
      end;
  import_onbill_data1(#{account_id := _ResellerId
          ,auth_account_id := _AuthAccountId
          }
        ,_AccountIds
        ,_Args=#{<<"account_id">> := AccountId
                ,<<"account_name">> := AccountName
                ,<<"account_inn">> := AccountINN
                ,<<"account_inn">> := AccountKPP
                ,<<"prepaid">> := _Prepaid
                ,<<"billing_address_line1">> := BillingAddressLine1
                ,<<"billing_address_line2">> := BillingAddressLine2
                ,<<"billing_address_line3">> := BillingAddressLine3
                ,<<"agrm_onnet_number">> := AgrmOnNetNumber
                ,<<"agrm_onnet_date">> := AgrmOnNetDate
                ,<<"agrm_beeline_spb_number">> := AgrmBeelineSPBNumber
                ,<<"agrm_beeline_spb_date">> := AgrmBeelineSPBDate
                ,<<"agrm_beeline_msk_number">> := AgrmBeelineMSKNumber
                ,<<"agrm_beeline_msk_date">> := AgrmBeelineMSKDate
                }
        ) ->
      Values = props:filter_empty(
          [{<<"_id">>, ?ONBILL_DOC}
          ,{<<"pvt_type">>, ?ONBILL_DOC}
          ,{<<"pvt_account_id">>, AccountId}
          ,{<<"account_name">>, AccountName}
          ,{<<"account_inn">>, AccountINN}
          ,{<<"account_kpp">>, AccountKPP}
          ,{[<<"billing_address">>,<<"line1">>], BillingAddressLine1}
          ,{[<<"billing_address">>,<<"line2">>], BillingAddressLine2}
          ,{[<<"billing_address">>,<<"line3">>], BillingAddressLine3}
          ,{[<<"agrm">>,<<"onnet">>,<<"number">>], AgrmOnNetNumber}
          ,{[<<"agrm">>,<<"onnet">>,<<"date">>], AgrmOnNetDate}
          ,{[<<"agrm">>,<<"beeline_spb">>,<<"number">>], AgrmBeelineSPBNumber}
          ,{[<<"agrm">>,<<"beeline_spb">>,<<"date">>], AgrmBeelineSPBDate}
          ,{[<<"agrm">>,<<"beeline_msk">>,<<"number">>], AgrmBeelineMSKNumber}
          ,{[<<"agrm">>,<<"beeline_msk">>,<<"date">>], AgrmBeelineMSKDate}
          ]),
      DbName = kz_util:format_account_id(AccountId,'encoded'),
      case kz_datamgr:open_doc(DbName, ?ONBILL_DOC) of
          {ok, Doc} ->
              NewDoc = kz_json:set_values(Values, Doc),
              kz_datamgr:ensure_saved(DbName, NewDoc),
              AccountId;
          {'error', 'not_found'} ->
              NewDoc = kz_json:set_values(Values ,kz_json:new()),
              kz_datamgr:ensure_saved(DbName, NewDoc),
              AccountId;
          _ ->
              'onbill_data_not_added'
      end.
  
  %%%===================================================================
  