# Date: 19/06/06 # Version: 105 $DOC(STOCK_VALUATION) name=Оценка ЦБ class=1 product=ALD_FUND name_formula=null remark_formula=null $STATE(CRT) name=Создан class=0 $ENDSTATE $STATE(DEL) name=Удален class=2 $ENDSTATE $STATE(NEW) name=Начальный class=1 $ENDSTATE $PROP(FUND_ID) name=Фонд field_name=fund_id table_name=t_stock_val field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=1 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(STOCK_ID) name=ЦБ field_name=stock_id table_name=t_stock_val 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(RATE_TYPE) name=Тип оценки (1 - оценка ЦБ, 2 - оценка пакета) field_name=rate_type table_name=t_stock_val field_type=int field_length=4 field_scale=null field_prec=null 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 $PROP(RATE_SUM) name=Оцен.стоимость (ЦБ или пакета) field_name=rate_sum table_name=t_stock_val field_type=money field_length=8 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(RATE_DATE) name=Дата field_name=rate_date table_name=t_stock_val field_type=datetime field_length=8 field_scale=null field_prec=null page=1 order=4 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(STOCK_QTY) name=Количество ЦБ (в пакете) field_name=stock_qty table_name=t_stock_val 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 $PROP(END_DATE) name=Дата окончания field_name=end_date table_name=t_stock_val field_type=datetime field_length=8 field_scale=null field_prec=null 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 $RELATION(REL1) class=0 type=FUND_GROUP form=null prop=FUND_ID idname=null order=10 $ENDRELATION $RELATION(REL2) class=0 type=td_stock_emis form=null prop=STOCK_ID idname=null order=20 $ENDRELATION $FORM(FORM1) name=Список class=4 filter=FORM3 target_state= uo=uo_list dw=d_stock_valuation_list procedure=ap_60270000001821118 patterns=GENERIC_VIEW_LIST user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=3950 height=1012 proc_text=$TEXT(14395131) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as .BEGIN('N') .CHECK_USER .CHECK_VIEW_LIST .ARGCONVERT_FILTER .VIEW_LIST .END $ENDTEXT(14395131) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=null alias=fund_code $ENDACTION2RELATION $ACTION2RELATION(REL2.STOCK_NAME) relation=REL2 where=null prop=STOCK_NAME order=18 alias=stock_name $ENDACTION2RELATION $ENDFORM $FORM(FORM2) name=Редактор class=5 filter=null target_state= uo=uo_edit dw=d_stock_valuation_edit procedure=ap_60270000001821121 patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(14395131) 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(14395131) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=null alias=fund_code $ENDACTION2RELATION $ACTION2RELATION(REL2.STOCK_NAME) relation=REL2 where=null prop=STOCK_NAME order=18 alias=stock_name $ENDACTION2RELATION $ENDFORM $FORM(FORM3) name=Фильтр class=6 filter=null target_state= uo=uo_filter dw=d_stock_valuation_filter procedure=ap_60270000001821124 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2153 height=508 proc_text=$TEXT(14395131) create procedure dbo.%PROC% as begin declare @fund_id numeric declare @fund_code varchar(255) declare @rate_date_db datetime declare @rate_date_de datetime select @fund_id = .ORGANIZATION select @rate_date_de=.OPERDAY select @rate_date_db=@rate_date_de select @fund_code = (select partner_code from t_partners where id=@fund_id) select convert(varchar(30), null) as sid, convert(varchar(30), @fund_id) as fund_id_s, convert(varchar(255), @fund_code) as fund_code, convert(varchar(30), null) as stock_id_s, convert(varchar(255), null) as stock_name, @rate_date_db as rate_date_db, @rate_date_de as rate_date_de end $ENDTEXT(14395131) $FILTER(FUND_ID) type=1 label=Фонд prop=FUND_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $FILTER(STOCK_ID) type=1 label=ЦБ prop=STOCK_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $FILTER(RATE_DATE) type=2 label=Дата prop=RATE_DATE arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $ENDFORM $ACTION(#AP_GET_STOCK_VALUATION) name=Получить оцен.стоимость class=9 form=null target_state=null procedure=ap_get_stock_valuation patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(14395131) create procedure dbo.%PROC% @stock_id numeric, @fund_id numeric, @check_date datetime, @stock_qty decimal(18,8), @check_type int, -- 0 - без проверки, 1 - с проверкой @stock_sum money out as declare @rate_sum money, @rate_id numeric, @rate_type int, @rate_stock_qty decimal(18,8), @ms varchar(255) select @rate_id=(select t.id from t_stock_val t where t.stock_id=@stock_id and t.fund_id=@fund_id and .ITEMS_EXISTS(t.id) and t.rate_date=(select max(rate_date) from t_stock_val t1 where t1.stock_id=@stock_id and t1.fund_id=@fund_id and .ITEMS_EXISTS(t1.id) and t1.rate_date<=@check_date and ((t1.end_date>=@check_date and t1.end_date is not null) or t1.end_date is null) and isnull(t1.rate_sum,0)>0)) if @rate_id is null return select @rate_sum=rate_sum, @rate_type=rate_type, @rate_stock_qty=stock_qty from t_stock_val where id=@rate_id if @check_type=1 and @rate_type=2 and @rate_stock_qty<>@stock_qty and @rate_stock_qty is not null and @stock_qty is not null begin select @ms='Указанное кол-во ЦБ ' + (select stock_name from td_stock_emis where id=@stock_id) + ' в пакете для оценки ('+convert(varchar,@rate_stock_qty)+' шт.)' + ' не соответствует кол-ву ЦБ в портфеле ('+convert(varchar,@stock_qty)+' шт.)' .EXIT_MESSAGE(@ms) end if @rate_type=1 select @stock_sum=round((@rate_sum*@stock_qty*convert(float,1.0)),2) if @rate_type=2 select @stock_sum=@rate_sum $ENDTEXT(14395131) $ENDACTION $ACTION(ACTION1) name=Добавить class=1 form=FORM2 target_state=CRT procedure=ap_60270000001821129 patterns=GENERIC_INSERT user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2149 height=920 proc_text=$TEXT(14395131) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT .INIT_VARS .TEST_UNIQUE if exists(select 1 from t_stock_val d where d.rate_date=@rate_date and d.fund_id=@fund_id and d.stock_id=@stock_id and d.id<>@id and .ITEMS_EXISTS(d.id)) .EXIT_MESSAGE('Оценка указанной ЦБ для фонда на указанную дату уже существует') if @rate_type=2 select @rate_sum=round(@rate_sum,2) begin tran .UPDATE_ITEMS .UPDATE .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select sid = convert(varchar, @id) .END $ENDTEXT(14395131) $ENDACTION $ACTION(ACTION2) name=Изменить class=2 form=FORM2 target_state=null procedure=ap_60270000001821130 patterns=GENERIC_UPDATE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2153 height=936 proc_text=$TEXT(14395131) create procedure dbo.%PROC% @sid varchar(30) = null, .ARGLIST as .BEGIN('N') .CHECK_USER .CHECK_UPDATE .ARGCONVERT .TEST_UNIQUE if exists(select 1 from t_stock_val d where d.rate_date=@rate_date and d.fund_id=@fund_id and d.stock_id=@stock_id and d.id<>@id and .ITEMS_EXISTS(d.id)) .EXIT_MESSAGE('Оценка указанной ЦБ для фонда на указанную дату уже существует') if @rate_type=2 select @rate_sum=round(@rate_sum,2) begin tran .UPDATE_ITEMS .UPDATE .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran .END $ENDTEXT(14395131) $ENDACTION $ACTION(ACTION3) name=Удалить class=3 form=FORM2 target_state=DEL procedure=ap_60270000001821131 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2153 height=860 proc_text=$TEXT(14395131) 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(14395131) $ENDACTION $STATE2ACTION(CRT.ACTION2) state=CRT action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION3) state=CRT action=ACTION3 $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(NEW.ACTION1) state=NEW action=ACTION1 $ENDSTATE2ACTION $STATE2ACTION(NEW.FORM3) state=NEW action=FORM3 $ENDSTATE2ACTION $STATE2PROP(CRT.END_DATE) state=CRT prop=END_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.FUND_ID) state=CRT prop=FUND_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.RATE_DATE) state=CRT prop=RATE_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.RATE_SUM) state=CRT prop=RATE_SUM enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.RATE_TYPE) state=CRT prop=RATE_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.STOCK_ID) state=CRT prop=STOCK_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.STOCK_QTY) state=CRT prop=STOCK_QTY enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.END_DATE) state=NEW prop=END_DATE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.FUND_ID) state=NEW prop=FUND_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.RATE_DATE) state=NEW prop=RATE_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.RATE_SUM) state=NEW prop=RATE_SUM enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.RATE_TYPE) state=NEW prop=RATE_TYPE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.STOCK_ID) state=NEW prop=STOCK_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(NEW.STOCK_QTY) state=NEW prop=STOCK_QTY enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $ENDDOC