# Date: 25/05/06 # Version: 105 $DOC(SD_ASSET_ENUM) name=Перечень имущества фонда class=6 product=ALD_FUND name_formula=$TEXT(16084305) .TYPE_NAME((.TYPE_ID_FROM_CODE_FUNC('SD_ASSET_ENUM'))) + ' по срезу ' + .ITEM_NAME(@srezdoc_id) $ENDTEXT(16084305) remark_formula=$TEXT(16084305) .TYPE_NAME((.TYPE_ID_FROM_CODE_FUNC('SD_ASSET_ENUM'))) + ' по срезу ' + .ITEM_NAME(@srezdoc_id) $ENDTEXT(16084305) $STATE(CRT) name=Создан class=0 $ENDSTATE $STATE(NEW) name=Начальный class=1 $ENDSTATE $PROP(OUT_DATE) name=Внешняя дата корреспондента field_name=out_date table_name=td_depo_docs field_type=datetime field_length=8 field_scale=null field_prec=null page=1 order=1 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(IN_DATE) name=Внутр дата корреспонденции field_name=in_date table_name=td_depo_docs field_type=datetime field_length=8 field_scale=null field_prec=null page=1 order=2 init_class=1 init_formula=.OPERDAY unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(WHO_GET) name=Кто принял field_name=who_get table_name=td_depo_docs field_type=varchar field_length=100 field_scale=null field_prec=null page=1 order=3 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(WHO_PUT) name=Кто отправил field_name=who_put table_name=td_depo_docs field_type=varchar field_length=100 field_scale=null field_prec=null page=1 order=4 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(OUT_NO) name=Номер контрагента field_name=out_no table_name=td_depo_docs field_type=varchar field_length=50 field_scale=null field_prec=null page=1 order=5 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(IN_NO) name=Номер field_name=in_no table_name=td_depo_docs field_type=varchar field_length=50 field_scale=null field_prec=null page=1 order=6 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(CORRESPONDENT_ID) name=Корреспондент field_name=correspondent_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=7 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PAYER_ID) name=Плательщик field_name=payer_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=8 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PAY_SUM) name=Сумма field_name=pay_sum table_name=td_depo_docs field_type=money field_length=8 field_scale=null field_prec=null page=1 order=9 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(INITIATOR_ID) name=Инициатор field_name=initiator_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=10 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DOCUMENT_FORM_ID) name=Форма документа field_name=document_form_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=11 init_class=1 init_formula=1 unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DEPO_DOC_TYPE) name=Входящий исходящий field_name=depo_doc_type table_name=td_depo_docs field_type=int field_length=4 field_scale=null field_prec=null page=1 order=12 init_class=1 init_formula=2 unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(FOLDER_ID) name=Папка документов field_name=folder_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=13 init_class=1 init_formula=.DEPO_FOLDER_DEFAULT unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(SUM_CUR_ID) name=Валюта суммы field_name=sum_cur_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=14 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DOC_COMMENT) name=Коментарии к документу field_name=doc_comment table_name=td_depo_docs field_type=varchar field_length=255 field_scale=null field_prec=null page=1 order=15 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(FOUNDATION_ID) name=Документ основание field_name=foundation_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=16 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(OWNER_ID) name=Фонд field_name=owner_id table_name=td_depo_docs field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=17 init_class=1 init_formula=.ORGANIZATION unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(SREZDOC_ID) name=Срез field_name=srezdoc_id table_name=td_queries field_type=numeric field_length=9 field_scale=0 field_prec=18 page=2 order=19 init_class=1 init_formula=(select foundation_id from td_depo_docs where id=@id) unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DATE_B) name=Дата отчета field_name=date_b table_name=td_queries field_type=datetime field_length=8 field_scale=null field_prec=null page=2 order=18 init_class=1 init_formula=(dateadd(hh,datepart(hh,getdate()),dateadd(mi,datepart(mi,getdate()),dateadd(ss,datepart(ss,getdate()),(@doc_date))))) unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DOC_DATE) name=Дата среза field_name=doc_date table_name=td_queries field_type=datetime field_length=8 field_scale=null field_prec=null page=2 order=20 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $RELATION(REL1) class=0 type=FUND_GROUP form=null prop=OWNER_ID idname=null order=50 $ENDRELATION $RELATION(REL2) class=0 type=partners form=null prop=CORRESPONDENT_ID idname=null order=10 $ENDRELATION $RELATION(REL4) class=0 type=partners form=null prop=PAYER_ID idname=null order=20 $ENDRELATION $RELATION(REL3) class=0 type=partners form=null prop=INITIATOR_ID idname=null order=30 $ENDRELATION $RELATION(REL6) class=0 type=items form=null prop=FOUNDATION_ID idname=null order=40 $ENDRELATION $RELATION(REL5) class=0 type=items form=null prop=SREZDOC_ID idname=null order=60 $ENDRELATION $FORM(FORM1) name=Просмотр class=5 filter=null target_state= uo=uo_edit dw=d_pif_depooper_p1 procedure=ap_60785000000050396 patterns=GENERIC_VIEW_ITEM_P1 user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084309) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .CHECK_VIEW_ITEM if @id = -1 begin begin tran .GET_PROPS .CHECK_INSERT .INIT_VARS(B) .INSERT_ITEMS .INSERT commit tran end .VIEW_ITEM(ALL,1) .END $ENDTEXT(16084309) $ACTION2RELATION(REL6.ITEM_NAME) relation=REL6 where=null prop=ITEM_NAME order=3 alias=foundation_name $ENDACTION2RELATION $ACTION2RELATION(REL3.PARTNER_CODE) relation=REL3 where=null prop=PARTNER_CODE order=20 alias=initiator_code $ENDACTION2RELATION $ACTION2RELATION(REL3.PARTNER_SHORT_NAME) relation=REL3 where=null prop=PARTNER_SHORT_NAME order=21 alias=initiator_short_name $ENDACTION2RELATION $ACTION2RELATION(REL2.PARTNER_CODE) relation=REL2 where=null prop=PARTNER_CODE order=20 alias=corr_code $ENDACTION2RELATION $ACTION2RELATION(REL2.PARTNER_SHORT_NAME) relation=REL2 where=null prop=PARTNER_SHORT_NAME order=21 alias=corr_short_name $ENDACTION2RELATION $ACTION2RELATION(REL4.PARTNER_CODE) relation=REL4 where=null prop=PARTNER_CODE order=20 alias=payer_code $ENDACTION2RELATION $ACTION2RELATION(REL4.PARTNER_SHORT_NAME) relation=REL4 where=null prop=PARTNER_SHORT_NAME order=21 alias=payer_short_name $ENDACTION2RELATION $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=3 alias=fond_code $ENDACTION2RELATION $ACTION2RELATION(REL1.PARTNER_SHORT_NAME) relation=REL1 where=null prop=PARTNER_SHORT_NAME order=4 alias=fond_name $ENDACTION2RELATION $BIND(BIND1) type=SD_ASSET_ENUM action=FORM2 class=1 order=2 idname=null $ENDBIND $ENDFORM $FORM(FORM2) name=Данные class=5 filter=null target_state= uo=uo_sd_edit dw=d_sd_asset_enum_p2 procedure=ap_60785000000050402 patterns=GENERIC_VIEW_ITEM_P2 user_define=1 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084309) create procedure dbo.%PROC% @sid varchar(30) = null, @foundation_id_s varchar(30) = null as .BEGIN('N') if isnull(@foundation_id_s,'')<>'' begin update td_queries set srezdoc_id=tp_pif_srez.id, doc_date=tp_pif_srez.srez_date from tp_pif_srez where tp_pif_srez.id=convert(numeric,@foundation_id_s) and td_queries.id=@id end .CHECK_USER .VIEW_ITEM(ALL,2) .END $ENDTEXT(16084309) $ACTION2RELATION(REL5.ITEM_NAME) relation=REL5 where=null prop=ITEM_NAME order=3 alias=srez_name $ENDACTION2RELATION $FILTER(FOUNDATION_ID) type=11 label=Срез prop=FOUNDATION_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $CALC(FUND_TYPE_CODE) class=1 type=varchar calc_lenght=255 calc_prec=null calc_scale=null formula=$TEXT(16084309) (select upper(t.type_code) from t_types t, td_depo_docs d, t_items i where t.id=i.type_id and i.id=d.owner_id and d.id=t_items.id) $ENDTEXT(16084309) label=null order=1 $ENDCALC $ENDFORM $FORM(FORM3) name=Список class=4 filter=FORM4 target_state= uo=uo_list dw=d_sd_asset_enum_list procedure=ap_60785000000050406 patterns=GENERIC_VIEW_LIST user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2935 height=1596 proc_text=$TEXT(16084309) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as .BEGIN('N') .CHECK_USER .CHECK_VIEW_LIST .ARGCONVERT_FILTER if @date_b_de is not null select @date_b_ee=dateadd(ms,-1,dateadd(dd,1,@date_b_ee)) .VIEW_LIST .END $ENDTEXT(16084309) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=4 alias=fund_code $ENDACTION2RELATION $ACTION2RELATION(REL5.ITEM_NAME) relation=REL5 where=null prop=ITEM_NAME order=3 alias=srez_name $ENDACTION2RELATION $ENDFORM $FORM(FORM4) name=Фильтр class=6 filter=null target_state= uo=uo_filter dw=d_sd_asset_enum_filter procedure=ap_60785000000050409 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=1714 height=516 proc_text=$TEXT(16084309) create procedure dbo.%PROC% @sid varchar(30) = null as declare @date_e datetime .ID_VAR(@fund_id) select @date_e=.OPERDAY select @fund_id=.ORGANIZATION select convert(datetime,null) as date_b_db, convert(datetime,null) as date_b_de, convert(datetime,null) as doc_date_db, @date_e as doc_date_de, convert(varchar(30),@fund_id) as owner_id_s, (select partner_short_name from t_partners where id=@fund_id) as fund_name $ENDTEXT(16084309) $FILTER(DOC_DATE) type=2 label=Дата среза prop=DOC_DATE arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $FILTER(DATE_B) type=2 label=Дата отчета prop=DATE_B arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $FILTER(OWNER_ID) type=1 label=Фонд prop=OWNER_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $ENDFORM $FORM(OLD_SD_ASSET_ENUM_DET) name=Перечень отчета (старый) class=5 filter=null target_state= uo=null dw=d_old_sd_asset_enum_det procedure=ap_old_sd_asset_enum patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .GET_PROPS --.TRANSACTION_SAVE create table #rep( p_id numeric null, uk_id numeric null, cnt int null, sam int null, asset_id numeric null, asset_type_id numeric null, asset_name varchar(255) null, qty decimal(18,8) null, ocen_sum money null, bal_sum money null, fproc money null, round_rate int null ) .NAME_VAR(@fund_code) .ID_VAR(@plan_id) .ID_VAR(@acc57_id) .ID_VAR(@acc766_id) declare @activ_sum money declare @npf_acc_ctrl varchar(255), @npf_estimate_type varchar(255) declare @acc761_id numeric, @acc7613_id numeric, @acc765_id numeric, @acc7611_id numeric, @acc764_id numeric, @acc7610_id numeric, @acc768_id numeric select @fund_code=upper(.ITEM_TYPE_CODE(@owner_id)) if @fund_code='NPF_FUND' select @plan_id=.ARG_PLAN('NPF_ACCOUNT') if @fund_code='PIF_FUND' select @plan_id=.ARG_PLAN('PIF_ACCOUNT') select @acc57_id=.SD_ACCID_FROM_EFFNO(@plan_id,'57') select @acc766_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.6') select @acc761_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.1') select @acc7613_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.13') select @acc765_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.5') select @acc7611_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.11') select @acc764_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.4') select @acc7610_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.10') select @acc768_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.8') insert into #rep (p_id,uk_id,cnt,asset_id,qty,ocen_sum,bal_sum) select p.id, p.ctrl_comp_id, 2, (case when p.stock_id is null then p.acc_id else p.stock_id end), p.stock_qty, p.stock_sum, p.bal_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and ((p.acc_id not in (@acc766_id, @acc57_id) and p.acc_id is not null) or p.acc_id is null) -- and isnull((select acc_num_eff from t_accounts where id=p.acc_id),'') not in ('76.6') update #rep set asset_type_id=(select type_id from t_items where id=#rep.asset_id) update #rep set uk_id=@owner_id where uk_id is null update #rep set sam=(case when uk_id=@owner_id then 1 else 2 end) update #rep set bal_sum=bal_sum + isnull(( select p.bal_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and isnull((select acc_num_eff from t_accounts where id=p.acc_id),'')='76.6' and p.ctrl_comp_id=#rep.uk_id and p.stock_id=#rep.asset_id ),0) update #rep set round_rate=isnull(f.round_sum,2) from td_pay_fond f where f.id=#rep.uk_id and #rep.uk_id=@owner_id update #rep set round_rate=isnull((select max(b.round_sum) from td_depo_docs d, tb_contracts b where d.id=b.id and b.dog_type_id=3 and d.owner_id=@owner_id and b.client_id=#rep.uk_id),2) where #rep.uk_id<>@owner_id and #rep.uk_id is not null update #rep set round_rate=2 where round_rate is null update #rep set qty=#rep.qty*.STOCK_QTY_MULT(#rep.asset_id) where .ITEMS_EXISTS_BY_TYPE(#rep.asset_id,'TD_STOCK_EMIS') if @fund_code='NPF_FUND' begin -- р.сч. select @npf_acc_ctrl=isnull(max(v.code),'YES') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='NPF_ACC_CTRL' and .ITEMS_EXISTS(i.id) if @npf_acc_ctrl='NO' delete #rep from t_accounts a, tp_pif_srez_portfolio p where #rep.p_id=p.id and a.id=p.acc_id and a.acc_num_eff='51' -- тип выдачи оценочной стоимости select @npf_estimate_type=isnull(max(v.code),'BAL') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='NPF_ESTIMATE_TYPE' and .ITEMS_EXISTS(i.id) update #rep set ocen_sum=bal_sum insert into #rep(uk_id,cnt,sam) select uk_id,0,(case when uk_id=@owner_id then 1 else 2 end) from #rep group by uk_id insert into #rep(uk_id,cnt,sam) select uk_id,3,(case when uk_id=@owner_id then 1 else 2 end) from #rep group by uk_id update #rep set asset_name=(case when uk_id=@owner_id then 'Самостоятельное размещение' else 'Размещение через ' +(select partner_short_name from t_partners where id=#rep.uk_id) end) where cnt=0 insert into #rep(uk_id,cnt,sam,asset_name) select #rep.uk_id,1,2, 'Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from #rep, t_licence l where .ITEMS_EXISTS(l.id) and l.partner_id=#rep.uk_id and l.activity_id=5 group by #rep.uk_id having #rep.uk_id<>@owner_id end -- активы -- .ID_VAR(@p_id) .ID_VAR(@asset_id) .ID_VAR(@srez_place_id) .ID_VAR(@place_id) .ID_VAR(@rate_cur_id) .ID_VAR(@rur_cur_id) .NAME_VAR(@asset_name) .NAME_VAR(@class_value_code) .NAME_VAR(@class_comment) declare @qty decimal(18,8), @ocen_sum money declare @rate_date datetime, @convert_rate_date datetime, @rate_value decimal(18,8), @round_rate int declare @stock_rate decimal(36,12), @stock_rate_rur decimal(36,12) declare @coupon_rate decimal(36,12), @coupon_rate_rur decimal(36,12) select @rur_cur_id=.CUR('RUR') select @srez_place_id=rate_place_id from td_queries where td_queries.srezdoc_id=@srezdoc_id declare assets cursor for select p.id, (case when p.stock_id is null then p.acc_id else p.stock_id end), convert(varchar,null), p.stock_qty from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and ((p.acc_id not in (@acc766_id, @acc57_id) and p.acc_id is not null) or p.acc_id is null) -- and isnull((select acc_num_eff from t_accounts where id=p.acc_id),'') not in ('76.6','57') for read only open assets fetch assets into @p_id, @asset_id, @asset_name, @qty while .CURSOR_STATE=0 begin -- наименование имущества exec ap_sd_asset_name_crt @asset_id, @asset_name out update #rep set asset_name=@asset_name where p_id=@p_id -- оценочная стоимость для НПФ -- if @fund_code='NPF_FUND' and isnull(@qty,0)<>0 and @npf_estimate_type='RATE' begin select @stock_rate=null, @rate_date=null, @place_id=null, @rate_cur_id=null select @round_rate=isnull(round_rate,2) from #rep where p_id=@p_id if @srez_place_id is null begin exec ap_getclassvalue_code @asset_id,'STOCK_RATE_PLACE',null,@owner_id, @class_value_code out, @class_comment out if @class_value_code is not null select @place_id = max(td_rate_places.id) from td_rate_places where upper(td_rate_places.place_code) = upper(@class_value_code) and .ITEMS_EXISTS(td_rate_places.id) end else select @place_id=@srez_place_id if @place_id is not null begin select @stock_rate=tb_stock_rates.stock_rate, @rate_date=tb_stock_rates.rate_date, @rate_cur_id=tb_stock_rates.rate_cur_id from tb_stock_rates where tb_stock_rates.rate_place_id = @place_id and tb_stock_rates.stock_id = @asset_id and tb_stock_rates.rate_date = (select max(tb_stock_rates.rate_date) from tb_stock_rates where tb_stock_rates.rate_place_id = @place_id and tb_stock_rates.rate_date <= @doc_date and tb_stock_rates.stock_rate<>0 and tb_stock_rates.stock_id = @asset_id and .ITEMS_EXISTS(tb_stock_rates.id)) and .ITEMS_EXISTS(tb_stock_rates.id) if @rate_cur_id is null select @rate_cur_id=(select td_rate_places.cur_id from td_rate_places where id=@place_id) end -- ocen_sum if @stock_rate is not null begin if @rur_cur_id=@rate_cur_id select @stock_rate_rur=@stock_rate else begin .CONVERT_SUM_DEC(@rate_cur_id, @rur_cur_id, @doc_date, 0, @stock_rate, @stock_rate_rur, @rate_value, @convert_rate_date) select @stock_rate_rur=round(@stock_rate_rur,@round_rate) end -- NKD select @coupon_rate=tb_stock_rates.coupon_rate from tb_stock_rates where tb_stock_rates.rate_place_id = @place_id and tb_stock_rates.stock_id = @asset_id and tb_stock_rates.rate_date = @doc_date and .ITEMS_EXISTS(tb_stock_rates.id) select @coupon_rate_rur=null if @coupon_rate is not null begin if @rur_cur_id=@rate_cur_id select @coupon_rate_rur=@coupon_rate else begin .CONVERT_SUM_DEC(@rate_cur_id, @rur_cur_id, @doc_date, 0, @coupon_rate, @coupon_rate_rur, @rate_value, @convert_rate_date) select @coupon_rate=round(@coupon_rate,@round_rate) end end select @qty=@qty*isnull((select qty_mult from td_stock_emis where id=@asset_id),1) select @ocen_sum = round(@qty * convert(money,isnull(@stock_rate_rur,0)),2) + round(@qty * convert(money,isnull(@coupon_rate_rur,0)),2) update #rep set ocen_sum=@ocen_sum where p_id=@p_id /* update #rep set ocen_sum=@ocen_sum + isnull(( select p.bal_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and isnull((select acc_num_eff from t_accounts where id=p.acc_id),'')='76.6' and p.ctrl_comp_id=#rep.uk_id and p.stock_id=#rep.asset_id ),0) where p_id=@p_id */ end -- ocen_sum end -- NPF fetch assets into @p_id, @asset_id, @asset_name, @qty end close assets .DEALLOCATE assets -- задолженность -- if @fund_code='NPF_FUND' begin insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Денежные средства в пути',isnull(p.saldo_deb,0),isnull(p.saldo_deb,0) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and p.acc_id=@acc57_id and isnull(p.saldo_deb,0)<>0 and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_BALANCE') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Дебиторская задолженность',sum(isnull(p.saldo_deb,0)),sum(isnull(p.saldo_deb,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_PARTNERS') and p.acc_id in (@acc761_id,@acc7613_id,@acc765_id,@acc7611_id,@acc764_id,@acc7610_id,@acc768_id) insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Кредиторская задолженность',(-1)*sum(isnull(p.saldo_cred,0)),(-1)*sum(isnull(p.saldo_cred,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_PARTNERS') and p.acc_id in (@acc761_id,@acc7613_id,@acc765_id,@acc7611_id,@acc764_id,@acc7610_id,@acc768_id) end if @fund_code='PIF_FUND' begin insert into #rep (cnt,sam) select 1,3 insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Денежные средства в пути',isnull(p.saldo_deb,0),isnull(p.saldo_deb,0) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and p.acc_id=@acc57_id and isnull(p.saldo_deb,0)<>0 and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_BALANCE') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Начисленный купонный доход',sum(isnull(p.coupon_sum,0)),sum(isnull(p.coupon_sum,0)) from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PORTFOLIO') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Дебиторская задолженность',sum(isnull(p.saldo_deb,0)),sum(isnull(p.saldo_deb,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PARTNERS') /* insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Кредиторская задолженность',(-1)*sum(isnull(p.saldo_cred,0)),(-1)*sum(isnull(p.saldo_cred,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PARTNERS') */ end insert into #rep (cnt,sam) select 3,4 -- % от select @activ_sum=activ_sum from tp_pif_srez where id=@srezdoc_id if @activ_sum<>0 begin if @fund_code='NPF_FUND' update #rep set fproc=convert(money, round(convert(double precision,(convert(double precision,#rep.bal_sum)/convert(double precision,@activ_sum))),7)*100) where fproc is null else update #rep set fproc=convert(money, round(convert(double precision,(convert(double precision,#rep.ocen_sum)/convert(double precision,@activ_sum))),7)*100) where fproc is null end if @fund_code='NPF_FUND' and @npf_acc_ctrl='YES' update #rep set fproc=null from t_accounts a, tp_pif_srez_portfolio p where #rep.p_id=p.id and a.id=p.acc_id and a.acc_num_eff='51' select @sid as sid, #rep.cnt as cnt, #rep.sam as sam, #rep.asset_name as asset_name, convert(decimal(18,4),#rep.ocen_sum) as op_sum, convert(decimal(18,8),#rep.qty) as op_qty, convert(decimal(18,4),#rep.bal_sum) as bal_sum, convert(decimal(18,4),#rep.fproc) as fproc from #rep order by #rep.sam, #rep.uk_id, #rep.cnt, #rep.asset_type_id, #rep.asset_name drop table #rep --.TRANSACTION_RESTORE .END $ENDTEXT(16084310) $ENDFORM $FORM(OLD_SD_ASSET_ENUM_REP) name=Просмотр отчета (старый) class=5 filter=null target_state= uo=uo_print dw=d_old_sd_asset_enum_rep procedure=ap_60785000000050414 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .GET_PROPS .NAME_VAR(@fond_name) .NAME_VAR(@fond_code) .NAME_VAR(@control_name) .NAME_VAR(@fond_lic) .NAME_VAR(@control_lic) select @fond_name=f.partner_name, @fond_code=f.partner_code, @control_name=p.partner_name from td_pay_fond, t_partners p, t_partners f where td_pay_fond.id=@owner_id and f.id=@owner_id and p.id=*td_pay_fond.ctrl_comp_id if upper(.ITEM_TYPE_CODE(@owner_id))='NPF_FUND' select @fond_lic='Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from t_licence l, td_pay_fond where td_pay_fond.id=@owner_id and .ITEMS_EXISTS(l.id) and l.partner_id=td_pay_fond.id and l.activity_id=6 else select @control_lic='Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from t_licence l, td_pay_fond where td_pay_fond.id=@owner_id and .ITEMS_EXISTS(l.id) and l.partner_id=td_pay_fond.ctrl_comp_id and l.activity_id=4 declare @show_err varchar(255) select @show_err=isnull(max(v.code),'YES') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='SD_SHOW_ERR' and .ITEMS_EXISTS(i.id) select @sid, @fond_name as fond_name, @fond_code as fond_code, @control_name as control_name, 'на '+convert(varchar,@doc_date,104) as date_str, @fond_lic as fond_lic, @control_lic as contol_lic, convert(decimal(18,4),(select activ_sum from tp_pif_srez where id=@srezdoc_id)) as activ_sum, @date_b as date_b, (case @show_err when 'NO' then 0 else 1 end) as is_show_div .END $ENDTEXT(16084310) $ENDFORM $FORM(SD_ASSET_ENUM_ADD) name=Просмотр отчета (приложение) class=5 filter=null target_state= uo=uo_print dw=d_sd_asset_enum_add procedure=ap_60860000000305250 patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER select @sid .END $ENDTEXT(16084310) $ENDFORM $FORM(SD_ASSET_ENUM_DET) name=Перечень отчета class=5 filter=null target_state= uo=null dw=d_sd_asset_enum_det procedure=ap_sd_asset_enum patterns=GENERIC_VIEW_ITEM user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .GET_PROPS --.TRANSACTION_SAVE create table #rep( p_id numeric null, uk_id numeric null, cnt int null, sam int null, asset_id numeric null, asset_type_id numeric null, asset_name varchar(255) null, qty decimal(18,8) null, ocen_sum money null, bal_sum money null, fproc money null ) .NAME_VAR(@fund_code) .ID_VAR(@plan_id) .ID_VAR(@acc57_id) .ID_VAR(@acc50_id) .ID_VAR(@acc766_id) .ID_VAR(@p_id) .ID_VAR(@asset_id) .NAME_VAR(@asset_name) declare @activ_sum money, @srez_date datetime declare @npf_acc_ctrl varchar(255), @sd043_date_str varchar(255), @npf_estimate_type varchar(255) declare @acc761_id numeric, @acc7613_id numeric, @acc765_id numeric, @acc7611_id numeric, @acc764_id numeric, @acc7610_id numeric, @acc768_id numeric, @acc581_id numeric select @fund_code=upper(.ITEM_TYPE_CODE(@owner_id)) if @fund_code='NPF_FUND' select @plan_id=.ARG_PLAN('NPF_ACCOUNT') if @fund_code='PIF_FUND' select @plan_id=.ARG_PLAN('PIF_ACCOUNT') select @acc57_id=.SD_ACCID_FROM_EFFNO(@plan_id,'57') select @acc50_id=.SD_ACCID_FROM_EFFNO(@plan_id,'50') select @acc766_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.6') select @acc761_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.1') select @acc7613_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.13') select @acc765_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.5') select @acc7611_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.11') select @acc764_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.4') select @acc7610_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.10') select @acc768_id=.SD_ACCID_FROM_EFFNO(@plan_id,'76.8') select @acc581_id=.SD_ACCID_FROM_EFFNO(@plan_id,'58.1') insert into #rep (p_id,uk_id,cnt,asset_id,qty,ocen_sum,bal_sum) select p.id, p.ctrl_comp_id, 2, (case when p.stock_id is null then p.acc_id else p.stock_id end), p.stock_qty, p.stock_sum, p.bal_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and ((p.acc_id not in (@acc766_id, @acc57_id) and p.acc_id is not null) or p.acc_id is null) update #rep set asset_type_id=(select type_id from t_items where id=#rep.asset_id) update #rep set uk_id=@owner_id where uk_id is null update #rep set sam=(case when uk_id=@owner_id then 1 else 2 end) update #rep set bal_sum=bal_sum + isnull(( select p.bal_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and p.acc_id=@acc766_id and p.ctrl_comp_id=#rep.uk_id and p.stock_id=#rep.asset_id ),0) update #rep set qty=#rep.qty*.STOCK_QTY_MULT(#rep.asset_id) where .ITEMS_EXISTS_BY_TYPE(#rep.asset_id,'TD_STOCK_EMIS') if @fund_code='NPF_FUND' begin -- тип выдачи select @npf_estimate_type=isnull(max(v.code),'BAL') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='NPF_ESTIMATE_TYPE' and .ITEMS_EXISTS(i.id) select @npf_estimate_type=isnull(@npf_estimate_type,'BAL') -- р.сч. select @npf_acc_ctrl=isnull(max(v.code),'YES') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='NPF_ACC_CTRL' and .ITEMS_EXISTS(i.id) if @npf_acc_ctrl='NO' delete #rep from t_accounts a, tp_pif_srez_portfolio p where #rep.p_id=p.id and a.id=p.acc_id and a.acc_num_eff='51' -- НКД update #rep set ocen_sum=ocen_sum + isnull((select p.coupon_sum from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and p.acc_id=@acc581_id and p.ctrl_comp_id=#rep.uk_id and p.stock_id=#rep.asset_id ),0) /* -- Оценка по балансу if @npf_estimate_type='BAL' update #rep set ocen_sum=bal_sum */ insert into #rep(uk_id,cnt,sam) select uk_id,0,(case when uk_id=@owner_id then 1 else 2 end) from #rep group by uk_id insert into #rep(uk_id,cnt,sam) select uk_id,3,(case when uk_id=@owner_id then 1 else 2 end) from #rep group by uk_id update #rep set asset_name=(case when uk_id=@owner_id then 'Самостоятельное размещение' else 'Размещение через ' +(select partner_short_name from t_partners where id=#rep.uk_id) end) where cnt=0 insert into #rep(uk_id,cnt,sam,asset_name) select #rep.uk_id,1,2, 'Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from #rep, t_licence l where .ITEMS_EXISTS(l.id) and l.partner_id=#rep.uk_id and l.activity_id=5 group by #rep.uk_id having #rep.uk_id<>@owner_id end -- активы -- declare assets cursor for select p.id, (case when p.stock_id is null then p.acc_id else p.stock_id end), convert(varchar,null) from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS(p.id) and ((p.acc_id not in (@acc766_id, @acc57_id) and p.acc_id is not null) or p.acc_id is null) for read only open assets fetch assets into @p_id, @asset_id, @asset_name while .CURSOR_STATE=0 begin -- наименование имущества exec ap_sd_asset_name_crt @asset_id, @asset_name out update #rep set asset_name=@asset_name where p_id=@p_id fetch assets into @p_id, @asset_id, @asset_name end close assets .DEALLOCATE assets -- задолженность -- if @fund_code='NPF_FUND' begin insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Денежные средства в пути',isnull(p.saldo_deb,0),isnull(p.saldo_deb,0) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and p.acc_id=@acc57_id and isnull(p.saldo_deb,0)<>0 and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_BALANCE') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Касса',isnull(p.saldo_deb,0),isnull(p.saldo_deb,0) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and p.acc_id=@acc50_id and isnull(p.saldo_deb,0)<>0 and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_BALANCE') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Дебиторская задолженность',sum(isnull(p.saldo_deb,0)),sum(isnull(p.saldo_deb,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_PARTNERS') and p.acc_id in (@acc761_id,@acc7613_id,@acc765_id,@acc7611_id,@acc764_id,@acc7610_id,@acc768_id) insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Кредиторская задолженность',(-1)*sum(isnull(p.saldo_cred,0)),(-1)*sum(isnull(p.saldo_cred,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'NPF_SREZ_PARTNERS') and p.acc_id in (@acc761_id,@acc7613_id,@acc765_id,@acc7611_id,@acc764_id,@acc7610_id,@acc768_id) end if @fund_code='PIF_FUND' begin insert into #rep (cnt,sam) select 1,3 insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Денежные средства в пути',isnull(p.saldo_deb,0),isnull(p.saldo_deb,0) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and p.acc_id=@acc57_id and isnull(p.saldo_deb,0)<>0 and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_BALANCE') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Начисленный купонный доход',sum(isnull(p.coupon_sum,0)),sum(isnull(p.coupon_sum,0)) from tp_pif_srez_portfolio p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PORTFOLIO') insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,4,'Дебиторская задолженность',sum(isnull(p.saldo_deb,0)),sum(isnull(p.saldo_deb,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PARTNERS') /* insert into #rep (cnt,sam,asset_name,ocen_sum,bal_sum) select 2,3,'Кредиторская задолженность',(-1)*sum(isnull(p.saldo_cred,0)),(-1)*sum(isnull(p.saldo_cred,0)) from tp_pif_srez_balance p where p.srez_id=@srezdoc_id and .ITEMS_EXISTS_BY_TYPE(p.id,'PIF_SREZ_PARTNERS') */ end insert into #rep (cnt,sam) select 3,4 -- % от select @activ_sum=activ_sum, @srez_date=srez_date from tp_pif_srez where id=@srezdoc_id select @sd043_date_str=.GET_CONST('SD_043') if @sd043_date_str='' select @sd043_date_str=null if @activ_sum<>0 begin if @fund_code='NPF_FUND' and (@srez_date < convert(datetime,@sd043_date_str,3) or @sd043_date_str is null or @npf_estimate_type='BAL') update #rep set fproc=convert(money, round(convert(double precision,(convert(double precision,#rep.bal_sum)/convert(double precision,@activ_sum))),7)*100) where fproc is null else update #rep set fproc=convert(money, round(convert(double precision,(convert(double precision,#rep.ocen_sum)/convert(double precision,@activ_sum))),7)*100) where fproc is null end if @fund_code='NPF_FUND' and @npf_acc_ctrl='YES' update #rep set fproc=null from t_accounts a, tp_pif_srez_portfolio p where #rep.p_id=p.id and a.id=p.acc_id and a.acc_num_eff='51' select @sid as sid, #rep.cnt as cnt, #rep.sam as sam, #rep.asset_name as asset_name, convert(decimal(36,4),#rep.ocen_sum) as op_sum, --(18,4) convert(decimal(18,8),#rep.qty) as op_qty, convert(decimal(36,4),#rep.bal_sum) as bal_sum, --(18,4) convert(decimal(18,4),round(#rep.fproc,2)) as fproc, convert(decimal(36,8),(select qty_in_emission from td_stock_emis where id=#rep.asset_id)*.STOCK_QTY_MULT(#rep.asset_id)) as qty_in_emission, convert(decimal(36,8),(select deploument_qty from td_stock_emis where id=#rep.asset_id)*.STOCK_QTY_MULT(#rep.asset_id)) as deploument_qty from #rep order by #rep.sam, #rep.uk_id, #rep.cnt, #rep.asset_type_id, #rep.asset_name drop table #rep --.TRANSACTION_RESTORE .END $ENDTEXT(16084310) $ENDFORM $FORM(SD_ASSET_ENUM_REP) name=Просмотр отчета class=5 filter=null target_state= uo=uo_print dw=d_sd_asset_enum_rep procedure=ap_60860000000305252 patterns=GENERIC_VIEW_ITEM user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .GET_PROPS .NAME_VAR(@fond_name) .NAME_VAR(@fond_code) .NAME_VAR(@control_name) .NAME_VAR(@fond_lic) .NAME_VAR(@control_lic) select @fond_name=f.partner_name, @fond_code=f.partner_code, @control_name=p.partner_name from td_pay_fond, t_partners p, t_partners f where td_pay_fond.id=@owner_id and f.id=@owner_id and p.id=*td_pay_fond.ctrl_comp_id if upper(.ITEM_TYPE_CODE(@owner_id))='NPF_FUND' select @fond_lic='Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from t_licence l, td_pay_fond where td_pay_fond.id=@owner_id and .ITEMS_EXISTS(l.id) and l.partner_id=td_pay_fond.id and l.activity_id=6 else select @control_lic='Лицензия № '+max(l.lic_no)+' от '+convert(varchar,max(l.lic_date),104)+', выдана '+max(l.lic_autor) from t_licence l, td_pay_fond where td_pay_fond.id=@owner_id and .ITEMS_EXISTS(l.id) and l.partner_id=td_pay_fond.ctrl_comp_id and l.activity_id=4 declare @show_err varchar(255) select @show_err=isnull(max(v.code),'YES') from t_item2class i, t_classvalues v, t_classes c where i.item_id=@owner_id and i.value_id=v.id and v.class_id=c.id and c.code='SD_SHOW_ERR' and .ITEMS_EXISTS(i.id) select @sid, @fond_name as fond_name, @fond_code as fond_code, @control_name as control_name, /* 'на '+*/ convert(varchar,@doc_date,104) as date_str, @fond_lic as fond_lic, @control_lic as contol_lic, convert(decimal(36,4),(select activ_sum from tp_pif_srez where id=@srezdoc_id)) as activ_sum, --(18,4) @date_b as date_b, (case @show_err when 'NO' then 0 else 1 end) as is_show_div, convert(varchar(30),@owner_id) as owner_id_s .END $ENDTEXT(16084310) $ENDFORM $FORM(SD_ASSET_ENUM_VIOL) name=Перечень нарушений class=5 filter=null target_state= uo=uo_list_rep dw=d_sd_asset_enum_viol procedure=ap_sd_asset_enum_viol patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .GET_PROPS if not exists(select 1 from ts_asset_structure_div where ts_asset_structure_div.report_id=@srezdoc_id and .ITEMS_EXISTS(ts_asset_structure_div.id)) select 'Нарушений по составу и структуре активов Фонда не выявлено', null, null, null, null else select lim_name, lim_code, convert(decimal(18,4),min_lim_value) as min_lim_value, convert(decimal(18,4),max_lim_value) as max_lim_value, convert(decimal(18,4),round(calc_lim_value,2)) as calc_lim_value from ts_asset_structure_div where ts_asset_structure_div.report_id=@srezdoc_id and .ITEMS_EXISTS(ts_asset_structure_div.id) order by lim_code .END $ENDTEXT(16084310) $ENDFORM $FORM(SD_ASSET_STRUCT) name=Перечень приложения по структуре class=5 filter=null target_state= uo=uo_list_rep dw=d_sd_asset_enum_struct procedure=ap_sd_asset_enum_struct patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .GET_PROPS declare @fund_type varchar(30) select @fund_type=upper(.ITEM_TYPE_CODE(@owner_id)) create table #str ( code varchar(255) not null, name varchar(255) not null, minv money not null, maxv money not null, fact money not null, asset_id numeric(18,0) null, asset_name varchar(255) null, viol money null ) if @fund_type='NPF_FUND' insert into #str (code,name,asset_id,minv,maxv,fact) select t.lim_code_eff, t.lim_name, null, v.min_lim_value, v.max_lim_value, (select round(sum(isnull(rep.fact_percent,0)),2) from ts_asset_structure_report rep where rep.srez_id=@srezdoc_id and rep.line_id=t.id) from ts_restrict_types t, ts_restrict_values v where v.organization_id=@owner_id and v.lim_id=t.id and .ITEMS_EXISTS(v.id) and .ITEMS_EXISTS(t.id) and not (t.lim_code_eff like '3.%') and v.min_lim_value is not null and v.max_lim_value is not null union select t.lim_code_eff, t.lim_name, rep.asset_id, v.min_lim_value, v.max_lim_value, round(isnull(rep.fact_percent,0),2) from ts_restrict_types t, ts_restrict_values v, ts_asset_structure_report rep where v.organization_id=@owner_id and v.lim_id=t.id and rep.srez_id=@srezdoc_id and rep.line_id=t.id and .ITEMS_EXISTS(v.id) and .ITEMS_EXISTS(t.id) and t.lim_code_eff like '3.%' and v.min_lim_value is not null and v.max_lim_value is not null if @fund_type='PIF_FUND' insert into #str (code,name,asset_id,minv,maxv,fact) select t.lim_code_eff, t.lim_name, null, v.min_lim_value, v.max_lim_value, (select round(sum(isnull(rep.fact_percent,0)),2) from ts_investment_report rep where rep.srez_id=@srezdoc_id and rep.line_id=t.id) from ts_restrict_types t, ts_restrict_values v where v.organization_id=@owner_id and v.lim_id=t.id and .ITEMS_EXISTS(v.id) and .ITEMS_EXISTS(t.id) and t.calk_type_id not in (6,7) and v.min_lim_value is not null and v.max_lim_value is not null union select t.lim_code_eff, t.lim_name, rep.object_id, v.min_lim_value, v.max_lim_value, round(isnull(rep.fact_percent,0),2) from ts_restrict_types t, ts_restrict_values v, ts_investment_report rep where v.organization_id=@owner_id and v.lim_id=t.id and rep.srez_id=@srezdoc_id and rep.line_id=t.id and .ITEMS_EXISTS(v.id) and .ITEMS_EXISTS(t.id) and t.lim_code in ('EMITENT','GOS','BANK') and v.min_lim_value is not null and v.max_lim_value is not null update #str set asset_name=t.partner_name from t_partners t where t.id=#str.asset_id update #str set asset_name=t.bank_name from t_banks t where t.id=#str.asset_id update #str set asset_name=t.emi_name from td_emitent_info t where t.id=#str.asset_id update #str set asset_name=t.stock_name from td_stock_emis t where t.id=#str.asset_id update #str set asset_name=t.item_name from t_items t where t.id=#str.asset_id and isnull(#str.asset_name,'')='' and #str.asset_id is not null select name as lim_name, code as lim_code, convert(decimal(18,4),minv) as min_lim_value, convert(decimal(18,4),maxv) as max_lim_value, convert(decimal(18,4),fact) as calc_lim_value, asset_name from #str order by code, asset_name drop table #str .END $ENDTEXT(16084310) $ENDFORM $ACTION(ACTION1) name=Удалить class=3 form=FORM1 target_state=null procedure=ap_60785000000050416 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .CHECK_UPDATE begin tran .TYPE_DELETE commit tran .END $ENDTEXT(16084310) $ENDACTION $ACTION(ACTION2) name=Изменить class=2 form=FORM1 target_state=null procedure=ap_60785000000050417 patterns=GENERIC_UPDATE_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2194 height=1348 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL,1) as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL,1) .TEST_UNIQUE(ALL,1) begin tran .UPDATE(ALL,1) commit tran select sid = convert(varchar, @id) .END $ENDTEXT(16084310) $BIND(BIND1) type=SD_ASSET_ENUM action=ACTION4 class=1 order=2 idname=null $ENDBIND $ENDACTION $ACTION(ACTION3) name=Добавить class=1 form=FORM1 target_state=CRT procedure=ap_60785000000050420 patterns=GENERIC_INSERT_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2199 height=1372 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL,1) as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL,1) .DEPO_GEN_NO(@in_no,@depo_doc_type) .INIT_VARS(AFTER,ALL,1) .TEST_UNIQUE(ALL,1) begin tran .UPDATE(ALL,1) .RELGEN .UPDATE_STATE commit tran select sid = convert(varchar,@id) .END $ENDTEXT(16084310) $BIND(BIND1) type=SD_ASSET_ENUM action=ACTION4 class=1 order=10 idname=null $ENDBIND $ENDACTION $ACTION(ACTION4) name=Данные (изм) class=2 form=FORM2 target_state=null procedure=ap_60785000000050418 patterns=GENERIC_UPDATE_P2 user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(16084310) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL, 2) as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL, 2) .TEST_UNIQUE(ALL, 2) .GET_PROPS(ALL,1) begin tran if exists(select 1 from td_queries where td_queries.srezdoc_id=@srezdoc_id and td_queries.id<>@id and .ITEMS_EXISTS_BY_TYPE(td_queries.id,'SD_ASSET_ENUM')) .EXIT_MESSAGE('Для данного среза уже существует перечень имущества') if @date_b is null select @date_b = (dateadd(hh,datepart(hh,getdate()),dateadd(mi,datepart(mi,getdate()),dateadd(ss,datepart(ss,getdate()),(@doc_date))))) .UPDATE_ITEMS .UPDATE(ALL,2) update td_depo_docs set foundation_id=@srezdoc_id where id=@id update td_depo_docs set owner_id=(select fond_id from tp_pif_srez where id=@srezdoc_id) where id=@id .RELGEN .UPDATE_STATE commit tran .END $ENDTEXT(16084310) $ENDACTION $STATE2ACTION(CRT.ACTION1) state=CRT action=ACTION1 $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION2) state=CRT action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION4) state=CRT action=ACTION4 $ENDSTATE2ACTION $STATE2ACTION(CRT.FORM1) state=CRT action=FORM1 $ENDSTATE2ACTION $STATE2ACTION(CRT.FORM2) state=CRT action=FORM2 $ENDSTATE2ACTION $STATE2ACTION(CRT.FORM3) state=CRT action=FORM3 $ENDSTATE2ACTION $STATE2ACTION(CRT.FORM4) state=CRT action=FORM4 $ENDSTATE2ACTION $STATE2ACTION(CRT.OLD_SD_ASSET_ENUM_REP) state=CRT action=OLD_SD_ASSET_ENUM_REP $ENDSTATE2ACTION $STATE2ACTION(CRT.SD_ASSET_ENUM_ADD) state=CRT action=SD_ASSET_ENUM_ADD $ENDSTATE2ACTION $STATE2ACTION(CRT.SD_ASSET_ENUM_REP) state=CRT action=SD_ASSET_ENUM_REP $ENDSTATE2ACTION $STATE2ACTION(NEW.ACTION3) state=NEW action=ACTION3 $ENDSTATE2ACTION $STATE2PROP(CRT.CORRESPONDENT_ID) state=CRT prop=CORRESPONDENT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.DATE_B) state=CRT prop=DATE_B enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.DEPO_DOC_TYPE) state=CRT prop=DEPO_DOC_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.DOCUMENT_FORM_ID) state=CRT prop=DOCUMENT_FORM_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.DOC_COMMENT) state=CRT prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.DOC_DATE) state=CRT prop=DOC_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.FOLDER_ID) state=CRT prop=FOLDER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.INITIATOR_ID) state=CRT prop=INITIATOR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.IN_DATE) state=CRT prop=IN_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.IN_NO) state=CRT prop=IN_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.OUT_DATE) state=CRT prop=OUT_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.OUT_NO) state=CRT prop=OUT_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.OWNER_ID) state=CRT prop=OWNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.PAYER_ID) state=CRT prop=PAYER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.PAY_SUM) state=CRT prop=PAY_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.SREZDOC_ID) state=CRT prop=SREZDOC_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.SUM_CUR_ID) state=CRT prop=SUM_CUR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.WHO_GET) state=CRT prop=WHO_GET enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.WHO_PUT) state=CRT prop=WHO_PUT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.CORRESPONDENT_ID) state=NEW prop=CORRESPONDENT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.DATE_B) state=NEW prop=DATE_B enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.DEPO_DOC_TYPE) state=NEW prop=DEPO_DOC_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.DOCUMENT_FORM_ID) state=NEW prop=DOCUMENT_FORM_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.DOC_COMMENT) state=NEW prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.DOC_DATE) state=NEW prop=DOC_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.FOLDER_ID) state=NEW prop=FOLDER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.INITIATOR_ID) state=NEW prop=INITIATOR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.IN_DATE) state=NEW prop=IN_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.IN_NO) state=NEW prop=IN_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.OUT_DATE) state=NEW prop=OUT_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.OUT_NO) state=NEW prop=OUT_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.OWNER_ID) state=NEW prop=OWNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.PAYER_ID) state=NEW prop=PAYER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.PAY_SUM) state=NEW prop=PAY_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.SREZDOC_ID) state=NEW prop=SREZDOC_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.SUM_CUR_ID) state=NEW prop=SUM_CUR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.WHO_GET) state=NEW prop=WHO_GET enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.WHO_PUT) state=NEW prop=WHO_PUT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $ENDDOC