# Date: 07/06/06 # Version: 105 $DOC(PIF_PAY_SPLIT_PARTS) name=Дробление-консолидация паев - партии к операции class=1 product=ALD_PIF name_formula=null remark_formula=null $STATE(CRT) name=Создан class=0 $ENDSTATE $PROP(JOUR_ID) name=Операция field_name=jour_id table_name=t_pif_pay_split_parts field_type=numeric field_length=9 field_scale=0 field_prec=18 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(PAYS_SUM) name=Балансовая стоимость паев field_name=pays_sum table_name=t_pif_pay_split_parts field_type=money field_length=8 field_scale=4 field_prec=19 page=1 order=2 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(PARTNER_ID) name=Пайщик field_name=partner_id table_name=t_pif_pay_split_parts field_type=numeric field_length=9 field_scale=0 field_prec=18 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(PART_ID) name=Партия field_name=part_id table_name=t_pif_pay_split_parts field_type=numeric field_length=9 field_scale=0 field_prec=18 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(IN_QTY) name=Остаток до операции field_name=in_qty table_name=t_pif_pay_split_parts field_type=decimal field_length=9 field_scale=8 field_prec=18 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(OUT_QTY) name=Остаток после операции field_name=out_qty table_name=t_pif_pay_split_parts field_type=decimal field_length=9 field_scale=8 field_prec=18 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 $RELATION(REL1) class=0 type=PARTNERS form=null prop=PARTNER_ID idname=null order=1 $ENDRELATION $RELATION(REL2) class=0 type=ITEMS form=null prop=PART_ID idname=null order=2 $ENDRELATION $FORM(FORM1) name=Партии паев class=4 filter=null target_state= uo=uo_list dw=d_pif_pay_split_parts_list procedure=ap_30000000000019002 patterns=GENERIC_VIEW_LIST user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(17374508) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as .BEGIN('N') .CHECK_USER .CHECK_VIEW .ARGCONVERT_FILTER .VIEW_LIST .END $ENDTEXT(17374508) $ACTION2RELATION(REL1.PARTNER_SHORT_NAME) relation=REL1 where=null prop=PARTNER_SHORT_NAME order=null alias=partner_short_name $ENDACTION2RELATION $ACTION2RELATION(REL2.ITEM_NAME) relation=REL2 where=null prop=ITEM_NAME order=3 alias=part_name $ENDACTION2RELATION $FILTER(JOUR_ID) type=11 label=Операция prop=JOUR_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $ENDFORM $STATE2ACTION(CRT.FORM1) state=CRT action=FORM1 $ENDSTATE2ACTION $ENDDOC $DOC(PIF_PAY_SPLIT) name=Дробление-консолидация паев class=1 product=ALD_PIF name_formula=$TEXT(17374508) 'Дробление-консолидация паев ПИФ ' + (select partner_code from t_partners where id=@owner_id) + ' от ' + convert(varchar, @doc_date, 3) $ENDTEXT(17374508) remark_formula=@doc_comment $STATE(CRT) name=Исполнен class=0 $ENDSTATE $STATE(DEL) name=Удален class=2 $ENDSTATE $STATE(ED) name=Редактируется class=0 $ENDSTATE $STATE(NEW) name=Начальный class=1 $ENDSTATE $PROP(DOC_DATE) name=Дата операции field_name=doc_date table_name=t_pif_pay_split 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(DOC_COMMENT) name=Комментарий field_name=doc_comment table_name=t_pif_pay_split field_type=varchar field_length=255 field_scale=null field_prec=255 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(OWNER_ID) name=Фонд field_name=owner_id table_name=t_pif_pay_split field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=2 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(QTY_IN) name=Исходное количество field_name=qty_in table_name=t_pif_pay_split field_type=decimal field_length=9 field_scale=8 field_prec=18 page=1 order=4 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(QTY_OUT) name=Целевое количество field_name=qty_out table_name=t_pif_pay_split field_type=decimal field_length=9 field_scale=8 field_prec=18 page=1 order=5 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(REL1) class=0 type=FUND_GROUP form=null prop=OWNER_ID idname=null order=1 $ENDRELATION $RELATION(REL2) class=1 type=T_OPERATIONS form=ITEM_OPERS_LIST prop=null idname=item_id_s order=200 $ENDRELATION $RELATION(REL3) class=1 type=ACTIONS_HISTORY form=UO_ACTIONS_HISTORY_LIST prop=null idname=doc_id_s order=120 $ENDRELATION $RELATION(REL4) class=1 type=PIF_PAY_SPLIT_PARTS form=FORM1 prop=null idname=jour_id_s order=100 $ENDRELATION $FORM(FORM1) name=Просмотр class=5 filter=null target_state= uo=uo_edit dw=d_pif_pay_split_edit procedure=ap_30000000000019020 patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=3872 height=1280 proc_text=$TEXT(17374511) 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 .END $ENDTEXT(17374511) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=null alias=partner_code $ENDACTION2RELATION $ENDFORM $FORM(FORM2) name=Список class=4 filter=FORM3 target_state= uo=uo_list dw=d_pif_pay_split_list procedure=ap_30000000000019022 patterns=GENERIC_VIEW_LIST user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=3826 height=1012 proc_text=$TEXT(17374511) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as .BEGIN('N') .CHECK_USER .CHECK_VIEW .ARGCONVERT_FILTER .VIEW_LIST .END $ENDTEXT(17374511) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=null alias=partner_code $ENDACTION2RELATION $ENDFORM $FORM(FORM3) name=Фильтр class=6 filter=null target_state= uo=uo_filter dw=d_pif_pay_split_filter procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2158 height=528 proc_text=null $FILTER(DOC_COMMENT) type=3 label=Комментарий prop=DOC_COMMENT 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 $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 $ENDFORM $ACTION(ACTION1) name=Добавить class=1 form=FORM1 target_state=ED procedure=ap_30000000000019028 patterns=GENERIC_INSERT user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2217 height=904 proc_text=$TEXT(17374513) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT .INIT_VARS .TEST_ORGANIZATION_PIF(@owner_id) begin tran .UPDATE_ITEMS .UPDATE .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select sid = convert(varchar, @id) .END $ENDTEXT(17374513) $ENDACTION $ACTION(ACTION2) name=Изменить class=2 form=FORM1 target_state=null procedure=ap_30000000000019029 patterns=GENERIC_UPDATE user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2217 height=884 proc_text=$TEXT(17374513) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT .TEST_ORGANIZATION_PIF(@owner_id) begin tran .UPDATE_ITEMS .UPDATE .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran .END $ENDTEXT(17374513) $ENDACTION $ACTION(ACTION3) name=Исполнить class=9 form=null target_state=CRT procedure=ap_30000000000019030 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(17374513) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .GET_PROPS declare @pif_plan_id numeric, @pp_id numeric, @acc861_id numeric, @acc00_id numeric, @pays_sum money, @partner_id numeric, @part_id numeric, @part_in_qty .PIF_PAY_TYPE, @part_out_qty .PIF_PAY_TYPE, @op_qty .PIF_PAY_TYPE, @subc_part_type_id numeric, @subc_partner_type_id numeric, @oper_name varchar(255) select @pif_plan_id=.ARG_PLAN('PIF_ACCOUNT') select @acc00_id=.SD_ACCID_FROM_EFFNO(@pif_plan_id,'00') select @acc861_id=.SD_ACCID_FROM_EFFNO(@pif_plan_id,'86.1') select @subc_part_type_id=.SUBCTYPE_FROM_CODE('doc_item') select @subc_partner_type_id=.SUBCTYPE_FROM_CODE('partners') select @pp_id=pp.id from t_plans2partner pp where pp.partner_id=@owner_id and pp.plan_id=@pif_plan_id and .ITEMS_EXISTS(pp.id) select @oper_name='Дробление-консолидация паев' .TRANSACTION_SAVE create table #parts ( pays_sum money not null, in_qty .PIF_PAY_TYPE not null, part_id numeric not null, partner_id numeric not null ) insert into #parts (part_id, partner_id, pays_sum, in_qty) select os_part.item_id, os_partner.item_id, sum(isnull(ol.sum_bal*ol.deb_or_cred*(-1),0)), .PAYS_QTY_CALC((sum(isnull(ol.qty_sum*ol.deb_or_cred*(-1),0))),@owner_id) from t_oper_subconto os_part, t_oper_subconto os_partner, t_oper_list ol, t_operations o where o.partner2plan_id=@pp_id and ol.head_id=o.id and ol.acc_id=@acc861_id and os_part.id=ol.id and os_part.subconto_type_id=@subc_part_type_id and os_partner.id=ol.id and os_partner.subconto_type_id=@subc_partner_type_id and o.op_date<@doc_date group by os_part.item_id, os_partner.item_id having sum(isnull(ol.qty_sum*ol.deb_or_cred*(-1),0))>0 and sum(isnull(ol.qty_sum*ol.deb_or_cred*(-1),0))>0 begin tran .UPDATE_STATE .ACTION_HISTORY declare opscur cursor for select pays_sum, in_qty, part_id, partner_id from #parts for read only open opscur fetch opscur into @pays_sum, @part_in_qty, @part_id, @partner_id while .CURSOR_STATE = 0 begin if isnull(@qty_in,0)<>0 select @part_out_qty=convert(float,1)*@part_in_qty/@qty_in select @part_out_qty=convert(float,1)*@part_out_qty*@qty_out .PIF_ROUND_PAYS(@owner_id,@part_out_qty,@part_out_qty) if isnull(@part_out_qty,0)>0 and isnull(@pays_sum,0)>0 and @part_id is not null and @partner_id is not null begin select @op_qty=.PAYS_QTY_BAL(@part_in_qty,@owner_id) .OPERATION(@owner_id,@pif_plan_id,@doc_date,@acc861_id,@acc00_id,@pays_sum,'RUR',@doc_date,@op_qty,@op_qty,@oper_name,N) .UPDATE_SUBC(D,'partners',@partner_id) .UPDATE_SUBC(D,'doc_item',@part_id) .SUBC_CHECK select @op_qty=.PAYS_QTY_BAL(@part_out_qty,@owner_id) .OPERATION(@owner_id,@pif_plan_id,@doc_date,@acc00_id,@acc861_id,@pays_sum,'RUR',@doc_date,@op_qty,@op_qty,@oper_name,N) .UPDATE_SUBC(K,'partners',@partner_id) .UPDATE_SUBC(K,'doc_item',@part_id) .SUBC_CHECK .TYPE_INIT('PIF_PAY_SPLIT_PARTS',1) .TYPE_ASSIGN(jour_id,@id,1) .TYPE_ASSIGN(pays_sum,@pays_sum,1) .TYPE_ASSIGN(in_qty,@part_in_qty,1) .TYPE_ASSIGN(out_qty,@part_out_qty,1) .TYPE_ASSIGN(part_id,@part_id,1) .TYPE_ASSIGN(partner_id,@partner_id,1) .TYPE_INSERT('PIF_PAY_SPLIT_PARTS','CRT',1) end fetch opscur into @pays_sum, @part_in_qty, @part_id, @partner_id end close opscur .DEALLOCATE opscur commit tran drop table #parts .TRANSACTION_RESTORE .END $ENDTEXT(17374513) $ENDACTION $ACTION(ACTION4) name=На редактирование class=9 form=null target_state=ED procedure=ap_30000000000019031 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(17374513) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .CHECK_UPDATE begin tran .UPDATE_STATE .ACTION_HISTORY delete t_items from t_pif_pay_split_parts where t_pif_pay_split_parts.id=t_items.id and t_pif_pay_split_parts.jour_id=@id delete t_pif_pay_split_parts where t_pif_pay_split_parts.jour_id=@id .OPERS_ROLL commit tran .END $ENDTEXT(17374513) $ENDACTION $ACTION(ACTION5) name=Удалить class=3 form=FORM1 target_state=DEL procedure=ap_30000000000019032 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(17374513) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .CHECK_UPDATE begin tran .UPDATE_STATE .ACTION_HISTORY commit tran .END $ENDTEXT(17374513) $ENDACTION $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(ED.ACTION2) state=ED action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION3) state=ED action=ACTION3 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION5) state=ED action=ACTION5 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM1) state=ED action=FORM1 $ENDSTATE2ACTION $STATE2ACTION(ED.FORM2) state=ED action=FORM2 $ENDSTATE2ACTION $STATE2ACTION(NEW.ACTION1) state=NEW action=ACTION1 $ENDSTATE2ACTION $STATE2PROP(ED.DOC_COMMENT) state=ED prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOC_DATE) state=ED prop=DOC_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.OWNER_ID) state=ED prop=OWNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.QTY_IN) state=ED prop=QTY_IN enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.QTY_OUT) state=ED prop=QTY_OUT 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.OWNER_ID) state=NEW prop=OWNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.QTY_IN) state=NEW prop=QTY_IN enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.QTY_OUT) state=NEW prop=QTY_OUT enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $ENDDOC