# Date: 04/09/06 # Version: 105 $PATTERN(.BACK_GEN_TICKET_NO_DWS) name=Генератор номеро тикетов DWS class=2 product=ALD_SECUR pattern_text=$TEXT(14044953) declare @tmp_id_back2 numeric(18,0) if not exists (select 1 from t_gen2date where t_gen2date.type_code=2 and t_gen2date.organization_id =%OWNER_ID% ) begin exec ap_getid @tmp_id_back2 out insert t_gen2date (id, date_day, doc_counter_in, doc_counter_out, doc_counter_home,partion_gen_no,organization_id,investor_id,type_code) values (@tmp_id_back2,%DATE%,1,1,1,0,%OWNER_ID%, null,2) end else if isnull(datepart(yy, %DATE%),0)>isnull(datepart(yy,(select date_day from t_gen2date where t_gen2date.type_code=2 and t_gen2date.organization_id =%OWNER_ID% )),0) update t_gen2date set doc_counter_in=1, date_day=%DATE% where organization_id=%OWNER_ID% and type_code=2 else update t_gen2date set doc_counter_in=doc_counter_in+1 where organization_id=%OWNER_ID% and type_code=2 select %OUT_NO%= replicate('0',4 - datalength(convert(varchar,(select doc_counter_in from t_gen2date where t_gen2date.type_code=2 and t_gen2date.organization_id = %OWNER_ID% ))) ) +convert(varchar,(select doc_counter_in from t_gen2date where t_gen2date.type_code=2 and t_gen2date.organization_id = %OWNER_ID% ))+'/'+ (select partner_code from t_partners where t_partners.id=%PARTNER_ID%) $ENDTEXT(14044953) $PATTERNARG(%OWNER_ID%) name=Организация order=1 comment=Организация mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%DATE%) name=Дата order=2 comment=Дата mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%PARTNER_ID%) name=Клиент order=3 comment=Клиент mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%OUT_NO%) name=Получаемый номер order=4 comment=Получаемый номер mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $ENDPATTERN $PATTERN(.BACK_GEN_DOG_NO_DWS) name=Генератор номеров договоров к/п ЦБ ВБР class=2 product=ALD_SECUR pattern_text=$TEXT(14044953) declare @tmp_id_back1 numeric(18,0) -----------генерация порядкового номера if not exists (select 1 from t_gen2date where t_gen2date.type_code=1 and t_gen2date.organization_id =%OWNER_ID%) begin exec ap_getid @tmp_id_back1 out insert t_gen2date (id, date_day, doc_counter_in, doc_counter_out, doc_counter_home,partion_gen_no,organization_id,investor_id,type_code) values (@tmp_id_back1,%DATE%,1,1,1,0,%OWNER_ID%, null,1) end else if isnull(datepart(yy, %DATE%),0)>isnull(datepart(yy,(select date_day from t_gen2date where t_gen2date.type_code=1 and t_gen2date.organization_id =%OWNER_ID%)),0) update t_gen2date set doc_counter_in=1, date_day=%DATE% where organization_id=%OWNER_ID% and type_code=1 else update t_gen2date set doc_counter_in=doc_counter_in+1 where organization_id=%OWNER_ID% and type_code=1 select %OUT_NO%= (case %DOG_TYPE% when 0 then 'П' else 'К' end) +'/'+ left(%CONTR%,4)+'/'+ left((select partner_code from t_partners where t_partners.id=%PARTNER_ID%),5) +'/'+ replicate('0',4 - datalength(convert(varchar,(select doc_counter_in from t_gen2date where t_gen2date.type_code=1 and t_gen2date.organization_id = %OWNER_ID%))) ) +convert(varchar,(select doc_counter_in from t_gen2date where t_gen2date.type_code=1 and t_gen2date.organization_id = %OWNER_ID%)) $ENDTEXT(14044953) $PATTERNARG(%OWNER_ID%) name=Организация order=1 comment=Организация mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%DOG_TYPE%) name=Тип договора order=2 comment=Тип договора mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%DATE%) name=Дата order=3 comment=Дата mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%PARTNER_ID%) name=Клиент order=4 comment=Клиент mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%CONTR%) name=контрагент order=5 comment=null mandatory=null default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $PATTERNARG(%OUT_NO%) name=Получаемый номер order=6 comment=Получаемый номер mandatory=1 default=null choose_type=null choose_action=null choose_field=null $ENDPATTERNARG $ENDPATTERN