# Date: 24/01/06 # Version: 105 $DOC(PIF_RESERVE) name=Начисление резервов для ПИФ class=1 product=ALD_PIF name_formula=.TYPE_NAME(@type_id) + ' № ' + @in_no+' от '+.DATE_TO_STR(@in_date) remark_formula=null $STATE(BEG) name=Начальный class=1 $ENDSTATE $STATE(DEL) name=Удален class=2 $ENDSTATE $STATE(ED) name=В обработке class=0 $ENDSTATE $STATE(ED_END) name=В операции class=0 $ENDSTATE $STATE(OP_END) name=Исполнен class=0 $ENDSTATE $PROP(OUT_DATE) name=Исходящая дата корреспондента field_name=out_date table_name=td_depo_docs field_type=datetime field_length=8 field_scale=3 field_prec=23 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=3 field_prec=23 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=100 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=100 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=50 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=50 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=4 field_prec=19 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=0 field_prec=10 page=1 order=12 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(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=2 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=1 init_formula=.CUR('RUR') 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=255 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(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=16 init_class=1 init_formula=.ORGANIZATION_PIF 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(SREZ_ID) name=Срез ПИФ field_name=srez_id table_name=tp_pif_reserve field_type=numeric field_length=9 field_scale=0 field_prec=18 page=2 order=17 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(SCHA_SUM) name=Сумма СЧА для расчета field_name=scha_sum table_name=tp_pif_reserve field_type=money field_length=8 field_scale=4 field_prec=19 page=2 order=18 init_class=1 init_formula=0 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(MANAGER_SUM) name=Резерв на вознаграждение УК field_name=manager_sum table_name=tp_pif_reserve field_type=money field_length=8 field_scale=4 field_prec=19 page=2 order=19 init_class=1 init_formula=0 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(OTHER_SUM) name=Резерв на прочие расходы field_name=other_sum table_name=tp_pif_reserve field_type=money field_length=8 field_scale=4 field_prec=19 page=2 order=20 init_class=1 init_formula=0 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(OP_RESERVE) name=Начислить резервы field_name=op_reserve table_name=tp_pif_reserve field_type=int field_length=4 field_scale=0 field_prec=10 page=2 order=21 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(OP_DEBTS) name=Начислить задолженности field_name=op_debts table_name=tp_pif_reserve field_type=int field_length=4 field_scale=0 field_prec=10 page=2 order=22 init_class=1 init_formula=0 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(SD_SUM) name=Резерв на СД, СР, аудитора, оценщика field_name=sd_sum table_name=tp_pif_reserve field_type=money field_length=8 field_scale=4 field_prec=19 page=2 order=23 init_class=1 init_formula=0 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(QTY_DAY) name=Количество дней для расчета field_name=qty_day table_name=tp_pif_reserve field_type=int field_length=4 field_scale=0 field_prec=10 page=2 order=24 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 $RELATION(REL8) class=0 type=FUND_GROUP form=null prop=OWNER_ID idname=null order=6 $ENDRELATION $RELATION(REL3) class=1 type=T_OPERATIONS form=ITEM_OPERS_LIST prop=null idname=item_id_s order=120 $ENDRELATION $RELATION(REL9) class=0 type=D_DEPO_FOLDERS form=null prop=FOLDER_ID idname=null order=5 $ENDRELATION $RELATION(REL1) class=4 type=D_DEPO_FOLDERS form=null prop=FOLDER_ID idname=null order=null $ENDRELATION $RELATION(REL5) class=0 type=PARTNERS form=null prop=CORRESPONDENT_ID idname=null order=1 $ENDRELATION $RELATION(REL6) class=0 type=PARTNERS form=null prop=PAYER_ID idname=null order=2 $ENDRELATION $RELATION(REL7) class=0 type=PARTNERS form=null prop=INITIATOR_ID idname=null order=3 $ENDRELATION $RELATION(REL2) class=1 type=ACTIONS_HISTORY form=UO_ACTIONS_HISTORY_LIST prop=null idname=null order=110 $ENDRELATION $RELATION(REL4) class=1 type=ACTIVDOCS form=ACTION2 prop=null idname=null order=130 $ENDRELATION $RELATION(REL11) class=1 type=PIF_RESERVE_DEBTS form=FORM1 prop=null idname=doc_id_s order=100 $ENDRELATION $RELATION(REL10) class=0 type=PIF_SREZ form=null prop=SREZ_ID idname=null order=10 $ENDRELATION $FORM(FORM1) name=Просмотр class=5 filter=null target_state= uo=uo_edit dw=d_sdepo_oper_p1 procedure=ap_10000000000088932 patterns=GENERIC_VIEW_ITEM_P1 user_define=1 isvisible=0 istab=1 posx=0 posy=0 width=3141 height=1800 proc_text=$TEXT(12172209) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @type_id_s varchar(30), @new_state_id numeric, @state_name_id_s varchar(30) begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% select @type_id_s = NULL select @state_name_id_s = NULL .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(12172209) $ACTION2RELATION(REL7.PARTNER_CODE) relation=REL7 where=null prop=PARTNER_CODE order=20 alias=initiator_code $ENDACTION2RELATION $ACTION2RELATION(REL7.PARTNER_SHORT_NAME) relation=REL7 where=null prop=PARTNER_SHORT_NAME order=21 alias=initiator_short_name $ENDACTION2RELATION $ACTION2RELATION(REL5.PARTNER_CODE) relation=REL5 where=null prop=PARTNER_CODE order=20 alias=corr_code $ENDACTION2RELATION $ACTION2RELATION(REL5.PARTNER_SHORT_NAME) relation=REL5 where=null prop=PARTNER_SHORT_NAME order=21 alias=corr_short_name $ENDACTION2RELATION $ACTION2RELATION(REL6.PARTNER_CODE) relation=REL6 where=null prop=PARTNER_CODE order=20 alias=payer_code $ENDACTION2RELATION $ACTION2RELATION(REL6.PARTNER_SHORT_NAME) relation=REL6 where=null prop=PARTNER_SHORT_NAME order=21 alias=payer_short_name $ENDACTION2RELATION $ACTION2RELATION(REL8.PARTNER_CODE) relation=REL8 where=null prop=PARTNER_CODE order=2 alias=fond_code $ENDACTION2RELATION $ACTION2RELATION(REL8.CTRL_COMP_ID) relation=REL8 where=null prop=CTRL_COMP_ID order=4 alias=ctrl_comp_id_s $ENDACTION2RELATION $ACTION2RELATION(REL8.PARTNER_NAME) relation=REL8 where=null prop=PARTNER_NAME order=3 alias=fond_name $ENDACTION2RELATION $BIND(BIND1) type=PIF_RESERVE action=FORM2 class=1 order=1 idname=null $ENDBIND $ENDFORM $FORM(FORM2) name=Данные class=5 filter=null target_state= uo=uo_edit dw=d_pif_reserve_edit procedure=ap_10000000000088937 patterns=GENERIC_VIEW_ITEM_P2 user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172210) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @new_state_id numeric begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% .CHECK_USER .CHECK_VIEW_ITEM .VIEW_ITEM(ALL,2) end $ENDTEXT(12172210) $ACTION2RELATION(REL10.SREZ_DATE) relation=REL10 where=null prop=SREZ_DATE order=10 alias=srez_date $ENDACTION2RELATION $ACTION2RELATION(REL10.REMARK) relation=REL10 where=null prop=REMARK order=9 alias=remark $ENDACTION2RELATION $ENDFORM $FORM(FORM3) name=Список class=4 filter=FORM4 target_state= uo=uo_list dw=d_pif_reserve_list procedure=ap_10000000000088940 patterns=GENERIC_VIEW_LIST_P1 user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2894 height=1012 proc_text=$TEXT(12172210) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @new_state_id numeric begin select @action_id = %ACTION_ID% .CHECK_USER .CHECK_VIEW .ARGCONVERT_FILTER .VIEW_LIST(ALL,1) and td_depo_docs.owner_id=.ORGANIZATION end $ENDTEXT(12172210) $ACTION2RELATION(REL9.DEPO_FOLDER_CODE) relation=REL9 where=null prop=DEPO_FOLDER_CODE order=3 alias=depo_folder_code $ENDACTION2RELATION $ACTION2RELATION(REL8.PARTNER_SHORT_NAME) relation=REL8 where=null prop=PARTNER_SHORT_NAME order=1 alias=organization_name $ENDACTION2RELATION $ENDFORM $FORM(FORM4) name=Фильтр class=6 filter=null target_state= uo=uo_filter dw=d_pif_reserve_filter procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=1449 height=384 proc_text=null $FILTER(IN_DATE) type=2 label=Дата документа prop=IN_DATE arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $ENDFORM $ACTION(ACTION1) name=Добавить class=1 form=FORM1 target_state=ED procedure=ap_10000000000088945 patterns=GENERIC_INSERT_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2199 height=1844 proc_text=$TEXT(12172212) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL,1) as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric begin select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL,1) .INIT_VARS(AFTER,ALL,1) .DEPO_GEN_NO(@in_no,@depo_doc_type) --.TEST_UNIQUE(ALL,1) .TEST_ORGANIZATION_PIF(@owner_id) begin tran .UPDATE(ALL,1) .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select @sid = convert(varchar,@id) select @sid end $ENDTEXT(12172212) $BIND(BIND1) type=PIF_RESERVE action=ACTION3 class=1 order=2 idname=null $ENDBIND $ENDACTION $ACTION(ACTION2) name=Изменить class=2 form=FORM1 target_state=null procedure=ap_10000000000088948 patterns=GENERIC_UPDATE_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2382 height=1888 proc_text=$TEXT(12172212) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL,1) as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL,1) .DEPO_CHK_NO(@id,@in_no,@depo_doc_type) --.TEST_UNIQUE(ALL,1) .UPDATE(ALL,1) .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select sid = convert(varchar, @id) $ENDTEXT(12172212) $BIND(BIND1) type=PIF_RESERVE action=ACTION3 class=1 order=2 idname=null $ENDBIND $ENDACTION $ACTION(ACTION3) name=Данные (изм.) class=2 form=FORM2 target_state=null procedure=ap_10000000000088946 patterns=GENERIC_UPDATE_P2 user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172212) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST(ALL, 2) as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .ARGCONVERT(ALL, 2) .TEST_UNIQUE(ALL, 2) .GET_PROPS(ALL,1) .UPDATE_ITEMS .UPDATE(ALL,2) .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran $ENDTEXT(12172212) $ENDACTION $ACTION(ACTION4) name=В операцию class=9 form=null target_state=ED_END procedure=ap_10000000000088950 patterns=GENERIC_MOVE user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172212) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .UPDATE_STATE .ACTION_HISTORY .GET_PROPS declare @uk_reserve_proc money, @other_reserve_proc money, @sd_reserve_proc money, @debt_sum money, @fond_interval money .ID_VAR(@dog_id) .ID_VAR(@dog_type_id) .ID_VAR(@client_id) .ID_VAR(@comission_period_id) .INT_VAR(@fond_type) select @uk_reserve_proc=uk_reserve, @other_reserve_proc=other_reserve, @sd_reserve_proc=sd_reserve from td_pay_fond where id=@owner_id if @uk_reserve_proc is null .EXIT_MESSAGE('Задайте размер резерва на вознаграждение УК для фонда') if @other_reserve_proc is null .EXIT_MESSAGE('Задайте размер резерва на прочие расходы для фонда') if @sd_reserve_proc is null .EXIT_MESSAGE('Задайте размер резерва на вознаграждение СД, СР, аудитора, оценщика') if @qty_day <= 0 .EXIT_MESSAGE('Количество дней должно быть больше нуля') select @manager_sum = @scha_sum*@uk_reserve_proc/100.0 select @other_sum = @scha_sum*@other_reserve_proc/100.0 select @sd_sum = @scha_sum*@sd_reserve_proc/100.0 select @fond_interval=convert(money,fond_interval) from td_pay_fond where id=@owner_id if isnull(@fond_interval,0)=0 .EXIT_MESSAGE('Для фонда не задан период начисления резервов') select @manager_sum = round(@manager_sum/@fond_interval,2) select @other_sum = round(@other_sum/@fond_interval,2) select @sd_sum = round(@sd_sum/@fond_interval,2) select @manager_sum = @manager_sum * @qty_day select @other_sum = @other_sum * @qty_day select @sd_sum = @sd_sum * @qty_day .UPDATE(ALL,2) declare dogs cursor for select c.id, c.dog_type_id, c.client_id, c.comission_period_id from tb_contracts c, td_depo_docs d,.ACTUAL_TABLES where d.id=c.id and d.owner_id=@owner_id and c.dog_type_id in (3,4,5,7,8) -- c УК,СД,СР,оценщиком и аудитором .ACTUAL_WHERE(c.id) open dogs fetch dogs into @dog_id, @dog_type_id, @client_id, @comission_period_id while .CURSOR_STATE = 0 begin .CALC_AGENT_COMIS(@scha_sum,@debt_sum,@dog_id,'RUR',@in_date,@owner_id,3) select @debt_sum=round(@debt_sum,2) select @debt_sum=(case @comission_period_id when 1 then @debt_sum/52 when 2 then @debt_sum/4 when 3 then @debt_sum/2 when 4 then @debt_sum/1 when 5 then @debt_sum/360 when 6 then @debt_sum/365 when 7 then @debt_sum/12 end) select @debt_sum=round(@debt_sum,2) select @debt_sum=@debt_sum * @qty_day if @debt_sum >= 0 and not(@debt_sum=0 and @dog_type_id=3) begin .TYPE_INIT('pif_reserve_debts') .TYPE_ASSIGN(doc_id,@id) .TYPE_ASSIGN(perpose_id,@dog_type_id) .TYPE_ASSIGN(debt_sum,@debt_sum) .TYPE_ASSIGN(contrag_id,@client_id) .TYPE_INSERT('pif_reserve_debts','CRT') end fetch dogs into @dog_id, @dog_type_id, @client_id, @comission_period_id end close dogs .DEALLOCATE dogs if not exists(select 1 from tp_pif_reserve_debts where doc_id=@id and perpose_id=3) begin select @client_id=ctrl_comp_id from td_pay_fond where id=@owner_id .TYPE_INIT('pif_reserve_debts',2) .TYPE_ASSIGN(doc_id,@id,2) .TYPE_ASSIGN(perpose_id,3,2) .TYPE_ASSIGN(debt_sum,@manager_sum,2) .TYPE_ASSIGN(contrag_id,@client_id,2) .TYPE_INSERT('pif_reserve_debts','CRT',2) end commit tran $ENDTEXT(12172212) $ENDACTION $ACTION(ACTION5) name=На уточнение class=9 form=null target_state=ED procedure=ap_10000000000088951 patterns=GENERIC_MOVE user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172213) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .UPDATE_STATE .ACTION_HISTORY delete t_items from tp_pif_reserve_debts where t_items.id=tp_pif_reserve_debts.id and tp_pif_reserve_debts.doc_id=@id delete tp_pif_reserve_debts where tp_pif_reserve_debts.doc_id=@id update tp_pif_reserve set manager_sum=null, other_sum=null, sd_sum=null where id=@id commit tran $ENDTEXT(12172213) $ENDACTION $ACTION(ACTION6) name=Удалить class=9 form=null target_state=DEL procedure=ap_10000000000088952 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172213) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .UPDATE_STATE .ACTION_HISTORY /*-------Проводки ----------*/ commit tran $ENDTEXT(12172213) $ENDACTION $ACTION(ACTION7) name=Исполнить class=9 form=null target_state=OP_END procedure=ap_10000000000088953 patterns=GENERIC_MOVE user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172213) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .UPDATE_STATE .ACTION_HISTORY .GET_PROPS declare @operday datetime select @operday = .OPERDAY .NAME_VAR(@remark) .MONEY_VAR(@uk_sum) .MONEY_VAR(@all_other_sum) .MONEY_VAR(@debt_sum) .ID_VAR(@perpose_id) .ID_VAR(@contrag_id) .ID_VAR(@deb_acc_id) .ID_VAR(@cred_acc_id) .ID_VAR(@uk_rez_acc_id) .ID_VAR(@other_rez_acc_id) .ID_VAR(@sd_rez_acc_id) .ID_VAR(@uk_acc_id) .ID_VAR(@sd_acc_id) .ID_VAR(@sr_acc_id) .ID_VAR(@aud_acc_id) .ID_VAR(@ocen_acc_id) .ID_VAR(@other_acc_id) .ID_VAR(@acc_96_id) .ID_VAR(@fund_plan_id) if @owner_id is null .EXIT_MESSAGE('Задайте фонд') select @uk_sum=sum(debt_sum) from tp_pif_reserve_debts where perpose_id=3 and doc_id=@id --if @uk_sum > @manager_sum --EXIT_MESSAGE('Сумма задолженности УК не должна превышать сумму резерва на вознаграждение УК') select @all_other_sum=sum(debt_sum) from tp_pif_reserve_debts where perpose_id != 3 and doc_id=@id --if @all_other_sum > @other_sum --EXIT_MESSAGE('Суммарная задолженность(кроме УК) не должна превышать сумму резерва на прочие расходы') select @fund_plan_id = .ARG_PLAN('PIF_ACCOUNT') select @uk_rez_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'89.1') select @other_rez_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'89.2') select @sd_rez_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'89.3') select @uk_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.1') select @sd_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.2') select @sr_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.3') select @aud_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.18') select @ocen_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.17') select @other_acc_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'76.8') select @acc_96_id = .SD_ACCID_FROM_EFFNO(@fund_plan_id,'96.2') select @manager_sum=.ROUND_MONEY(@manager_sum,2) select @other_sum=.ROUND_MONEY(@other_sum,2) select @sd_sum=.ROUND_MONEY(@sd_sum,2) if @op_reserve=1 begin .OPERATION(@owner_id,@fund_plan_id,@operday,@acc_96_id,@uk_rez_acc_id,@manager_sum,'RUR',@operday,null,null,'Начисление резерва на выплату вознаграждения УК',N) .SUBC_CHECK .OPERATION(@owner_id,@fund_plan_id,@operday,@acc_96_id,@other_rez_acc_id,@other_sum,'RUR',@operday,null,null,'Начисление резерва на прочие расходы, выплачиваемые из имущества фонда',N) .SUBC_CHECK .OPERATION(@owner_id,@fund_plan_id,@operday,@acc_96_id,@sd_rez_acc_id,@sd_sum,'RUR',@operday,null,null,'Начисление резерва на выплату вознаграждения СД, СР, аудитора, оценщика',N) .SUBC_CHECK end if @op_debts=1 begin declare debts cursor for select perpose_id, contrag_id, debt_sum, remark from tp_pif_reserve_debts where doc_id=@id and isnull(debt_sum,0) > 0 open debts fetch debts into @perpose_id, @contrag_id, @debt_sum, @remark while .CURSOR_STATE = 0 begin select @remark = 'Начисление кредиторской задолженности:'+.SIMPLE_NAME(5013,@perpose_id) +':'+ @remark if @perpose_id=3 -- УК begin select @deb_acc_id=@uk_rez_acc_id select @cred_acc_id=@uk_acc_id end else begin -- прочие if @perpose_id in (4,5,7,8) select @deb_acc_id=@sd_rez_acc_id else begin select @deb_acc_id=@other_rez_acc_id select @cred_acc_id=@other_acc_id end if @perpose_id=4 -- СД select @cred_acc_id=@sd_acc_id if @perpose_id=5 -- СР select @cred_acc_id=@sr_acc_id if @perpose_id=7 -- аудитор select @cred_acc_id=@aud_acc_id if @perpose_id=8 -- оценщик select @cred_acc_id=@ocen_acc_id end select @debt_sum=.ROUND_MONEY(@debt_sum,2) .OPERATION(@owner_id,@fund_plan_id,@operday,@deb_acc_id,@cred_acc_id,@debt_sum,'RUR',@operday,null,null,@remark,N) .UPDATE_SUBC(K,'partners',@contrag_id) .SUBC_CHECK fetch debts into @perpose_id, @contrag_id, @debt_sum, @remark end close debts .DEALLOCATE debts update t_items set state_id=.STATE_ID_FROM_CODE((.TYPE_ID('PIF_RESERVE_DEBTS')),'END') from tp_pif_reserve_debts where t_items.id=tp_pif_reserve_debts.id and tp_pif_reserve_debts.doc_id=@id end else begin delete t_items from tp_pif_reserve_debts where t_items.id=tp_pif_reserve_debts.id and tp_pif_reserve_debts.doc_id=@id delete tp_pif_reserve_debts where tp_pif_reserve_debts.doc_id=@id end commit tran $ENDTEXT(12172213) $ENDACTION $ACTION(ACTION8) name=На уточнение class=9 form=null target_state=ED_END procedure=ap_10000000000088954 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(12172213) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .UPDATE_STATE .ACTION_HISTORY update t_items set state_id=.STATE_ID_FROM_CODE((.TYPE_ID('PIF_RESERVE_DEBTS')),'CRT') from tp_pif_reserve_debts where t_items.id=tp_pif_reserve_debts.id and tp_pif_reserve_debts.doc_id=@id .OPERS_ROLL commit tran $ENDTEXT(12172213) $ENDACTION $STATE2ACTION(BEG.ACTION1) state=BEG action=ACTION1 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION2) state=ED action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION3) state=ED action=ACTION3 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION4) state=ED action=ACTION4 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION6) state=ED action=ACTION6 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM1) state=ED action=FORM1 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM2) state=ED action=FORM2 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM3) state=ED action=FORM3 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM4) state=ED action=FORM4 $ENDSTATE2ACTION $STATE2ACTION(ED_END.ACTION2) state=ED_END action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(ED_END.ACTION3) state=ED_END action=ACTION3 $ENDSTATE2ACTION $STATE2ACTION(ED_END.ACTION5) state=ED_END action=ACTION5 $ENDSTATE2ACTION $STATE2ACTION(ED_END.ACTION7) state=ED_END action=ACTION7 $ENDSTATE2ACTION $STATE2ACTION(ED_END.FORM1) state=ED_END action=FORM1 $ENDSTATE2ACTION $STATE2ACTION(ED_END.FORM2) state=ED_END action=FORM2 $ENDSTATE2ACTION $STATE2ACTION(ED_END.FORM3) state=ED_END action=FORM3 $ENDSTATE2ACTION $STATE2ACTION(ED_END.FORM4) state=ED_END action=FORM4 $ENDSTATE2ACTION $STATE2ACTION(OP_END.ACTION8) state=OP_END action=ACTION8 $ENDSTATE2ACTION $STATE2ACTION(OP_END.FORM1) state=OP_END action=FORM1 $ENDSTATE2ACTION $STATE2ACTION(OP_END.FORM2) state=OP_END action=FORM2 $ENDSTATE2ACTION $STATE2ACTION(OP_END.FORM3) state=OP_END action=FORM3 $ENDSTATE2ACTION $STATE2ACTION(OP_END.FORM4) state=OP_END action=FORM4 $ENDSTATE2ACTION $STATE2PROP(BEG.CORRESPONDENT_ID) state=BEG prop=CORRESPONDENT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DEPO_DOC_TYPE) state=BEG prop=DEPO_DOC_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOCUMENT_FORM_ID) state=BEG prop=DOCUMENT_FORM_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOC_COMMENT) state=BEG prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.FOLDER_ID) state=BEG prop=FOLDER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.INITIATOR_ID) state=BEG prop=INITIATOR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.IN_DATE) state=BEG prop=IN_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.IN_NO) state=BEG prop=IN_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.OP_DEBTS) state=BEG prop=OP_DEBTS enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(BEG.OP_RESERVE) state=BEG prop=OP_RESERVE enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(BEG.OUT_DATE) state=BEG prop=OUT_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.OUT_NO) state=BEG prop=OUT_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.PAYER_ID) state=BEG prop=PAYER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.PAY_SUM) state=BEG prop=PAY_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.QTY_DAY) state=BEG prop=QTY_DAY enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SCHA_SUM) state=BEG prop=SCHA_SUM enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SREZ_ID) state=BEG prop=SREZ_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SUM_CUR_ID) state=BEG prop=SUM_CUR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.WHO_GET) state=BEG prop=WHO_GET enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.WHO_PUT) state=BEG prop=WHO_PUT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.CORRESPONDENT_ID) state=ED prop=CORRESPONDENT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DEPO_DOC_TYPE) state=ED prop=DEPO_DOC_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOCUMENT_FORM_ID) state=ED prop=DOCUMENT_FORM_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOC_COMMENT) state=ED prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.FOLDER_ID) state=ED prop=FOLDER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.INITIATOR_ID) state=ED prop=INITIATOR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.IN_DATE) state=ED prop=IN_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.IN_NO) state=ED prop=IN_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.OP_DEBTS) state=ED prop=OP_DEBTS enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(ED.OP_RESERVE) state=ED prop=OP_RESERVE enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(ED.OUT_DATE) state=ED prop=OUT_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.OUT_NO) state=ED prop=OUT_NO enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.PAYER_ID) state=ED prop=PAYER_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.PAY_SUM) state=ED prop=PAY_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.QTY_DAY) state=ED prop=QTY_DAY enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SCHA_SUM) state=ED prop=SCHA_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SREZ_ID) state=ED prop=SREZ_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SUM_CUR_ID) state=ED prop=SUM_CUR_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.WHO_GET) state=ED prop=WHO_GET enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.WHO_PUT) state=ED prop=WHO_PUT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.DOC_COMMENT) state=ED_END prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.MANAGER_SUM) state=ED_END prop=MANAGER_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.OP_DEBTS) state=ED_END prop=OP_DEBTS enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.OP_RESERVE) state=ED_END prop=OP_RESERVE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.OTHER_SUM) state=ED_END prop=OTHER_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED_END.SD_SUM) state=ED_END prop=SD_SUM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(OP_END.DOC_COMMENT) state=OP_END prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $ENDDOC