# Date: 16/10/06 # Version: 107 $DOC(BILL_OUT) name=Исходящий счет class=1 product=ALD_DEPO_BILLS name_formula=$TEXT(13542198) 'Счет N ' + @doc_number + ' от ' + .DATE_TO_STR(@doc_date) + ' плательщик ' + .ITEM_NAME(@to_partner_id) + ' ' + convert(varchar,@sum_total) + .CUR_CODE(@cur_id) $ENDTEXT(13542198) remark_formula=$TEXT(13542198) @doc_number + ' ' + .DATE_TO_STR(@doc_date) + ' ' + .ITEM_NAME(@to_partner_id) $ENDTEXT(13542198) $STATE(BEG) name=Начальный class=1 $ENDSTATE $STATE(CRT) name=На оплате class=0 $ENDSTATE $STATE(DEL) name=Удален class=2 $ENDSTATE $STATE(ED) name=В обработке class=0 $ENDSTATE $STATE(KILL) name=Анулирован class=0 $ENDSTATE $STATE(PART) name=Оплачен частично class=0 $ENDSTATE $STATE(PAYED) name=Оплачен class=0 $ENDSTATE $PROP(DOC_NUMBER) name=Номер счета- фактуры field_name=doc_number table_name=t_schfact field_type=varchar field_length=30 field_scale=null field_prec=30 page=1 order=1 init_class=0 init_formula=null unique_index=2 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=t_schfact field_type=datetime field_length=8 field_scale=3 field_prec=23 page=1 order=2 init_class=null init_formula=null unique_index=2 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_TOTAL) name=Общая сумма field_name=sum_total table_name=t_schfact field_type=money field_length=8 field_scale=4 field_prec=19 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(CUR_ID) name=Валюта field_name=cur_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=5 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(FROM_PARTNER_ID) name=Плательщик field_name=from_partner_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=6 init_class=null 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(EXEC_DATE) name=Дата оплаты field_name=exec_date table_name=t_schfact field_type=datetime field_length=8 field_scale=3 field_prec=23 page=1 order=9 init_class=null 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(SUM_TAX) name=НДС field_name=sum_tax table_name=t_schfact field_type=money field_length=8 field_scale=4 field_prec=19 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(TO_PARTNER_ID) name=Получатель платежа field_name=to_partner_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=7 init_class=1 init_formula=$TEXT(13542198) (select p.id from t_partners p where p.partner_code='DEPO' and .ITEMS_EXISTS_BY_TYPE(p.id,'partners_jur')) $ENDTEXT(13542198) 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_DESCRIPTION) name=Описание документа field_name=doc_description table_name=t_schfact field_type=varchar field_length=100 field_scale=null field_prec=100 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(FROM_PARTNER_ACC_ID) name=Расчетный счет плательщика field_name=from_partner_acc_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=10 init_class=null 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(TO_PARTNER_ACC_ID) name=Расчетный счет получателя платежа field_name=to_partner_acc_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=11 init_class=1 init_formula=$TEXT(13542199) (select min(a.id) from t_partners p, t_bank_accounts a where p.partner_code='DEPO' and .ITEMS_EXISTS_BY_TYPE(p.id,'partners_jur') and a.partner_id=p.id and .ITEMS_EXISTS_BY_TYPE(a.id,'bank_accounts')) $ENDTEXT(13542199) 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(CLEAR_SUM_TOTAL) name=Сумма без налога field_name=clear_sum_total table_name=t_schfact field_type=money field_length=8 field_scale=4 field_prec=19 page=1 order=12 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(BILL_TYPE_DESCRIPTION) name=Описание назначения платежа field_name=bill_type_description table_name=t_schfact field_type=varchar field_length=255 field_scale=null field_prec=255 page=1 order=13 init_class=0 init_formula=$TEXT(13542199) 'Депозитарные услуги за период с ' + .DATE_TO_STR(@date_b) + ' по ' + .DATE_TO_STR(@date_e) $ENDTEXT(13542199) 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=t_schfact field_type=datetime field_length=8 field_scale=3 field_prec=23 page=1 order=14 init_class=null 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(DATE_E) name=Дата окончания периода field_name=date_e table_name=t_schfact field_type=datetime field_length=8 field_scale=3 field_prec=23 page=1 order=15 init_class=null 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(DEPO_ACC_ID) name=Счет ДЕПО field_name=depo_acc_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=16 init_class=null 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(PRICE_LIST_ID) name=Прайс-лист field_name=price_list_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=17 init_class=null 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_CUR_ID) name=Валюта курса field_name=rate_cur_id table_name=t_schfact field_type=numeric field_length=9 field_scale=0 field_prec=18 page=1 order=18 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(SUM_RATE) name=Курс счета field_name=sum_rate table_name=t_schfact field_type=money field_length=8 field_scale=4 field_prec=19 page=1 order=19 init_class=null 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(CHIEF_SIGN) name=Подпись руководителя field_name=chief_sign table_name=t_schfact field_type=varchar field_length=255 field_scale=null field_prec=255 page=2 order=33 init_class=null 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(BOOKKEEPER_SIGN) name=Подпись бухгалтера field_name=bookkeeper_sign table_name=t_schfact field_type=varchar field_length=255 field_scale=null field_prec=255 page=2 order=34 init_class=null 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_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=20 init_class=null 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=21 init_class=1 init_formula=.OPERDAY unique_index=1 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=22 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=23 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=24 init_class=null 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=25 init_class=0 init_formula=null unique_index=1 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=26 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=27 init_class=2 init_formula=$TEXT(13542201) (select p.id from t_partners p , t_items i, t_states s, t_types t where p.partner_code="NIKOILD" and i.id=p.id and s.id=i.state_id and s.class_id=0 and i.type_id=t.id and t.type_code="partners_jur") $ENDTEXT(13542201) 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=28 init_class=1 init_formula=1 unique_index=null numerator=null import_type=null import_table=null import_field= 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=29 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=30 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(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=31 init_class=null 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=32 init_class=null 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(REL9) class=1 type=T_OPERATIONS form=ITEM_OPERS_LIST prop=null idname=item_id_s order=999 $ENDRELATION $RELATION(REL3) class=0 type=PARTNERS form=null prop=FROM_PARTNER_ID idname=null order=null $ENDRELATION $RELATION(REL4) class=0 type=PARTNERS form=null prop=TO_PARTNER_ID idname=null order=null $ENDRELATION $RELATION(REL2) class=0 type=PARTNERS form=null prop=CORRESPONDENT_ID idname=null order=null $ENDRELATION $RELATION(REL1) class=0 type=PARTNERS form=null prop=INITIATOR_ID idname=null order=null $ENDRELATION $RELATION(REL6) class=0 type=ITEMS form=null prop=FOUNDATION_ID idname=null order=10 $ENDRELATION $RELATION(REL10) class=1 type=ACTIONS_HISTORY form=UO_ACTIONS_HISTORY_LIST prop=null idname=null order=998 $ENDRELATION $RELATION(REL7) class=1 type=ACTIVDOCS form=null prop=null idname=null order=1000 $ENDRELATION $RELATION(REL8) class=0 type=D_DEPO_ACCOUNTS form=null prop=DEPO_ACC_ID idname=null order=20 $ENDRELATION $RELATION(REL5) class=0 type=PRICE_LISTS form=null prop=PRICE_LIST_ID idname=null order=30 $ENDRELATION $RELATION(REL11) class=1 type=BILL_OUT_PAYS form=LST prop=null idname=bill_id_s order=997 $ENDRELATION $FORM(D_BILL_QUERY_BILL_PORTFOLIO) name=Счет (RUS) - Портфель class=5 filter=null target_state= uo=uo_list dw=d_bill_query_bill_portfolio procedure=ap_11535000007810065 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542201) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .GET_PROPS select tr_query4bills_portfolio.day, td_depo_accounts.depo_acc_name, td_stock_emis.stock_name, sum(tr_query4bills_portfolio.qty) as qty, max(tr_query4bills_portfolio.rate_value) as rate, sum(convert(decimal(18,8), round(tr_query4bills_portfolio.qty * tr_query4bills_portfolio.rate_value, 8))) as total from tr_query4bills_portfolio, td_stock_emis, td_depo_subacc, td_depo_accounts where tr_query4bills_portfolio.id = @foundation_id AND td_depo_subacc.depo_acc_id = @depo_acc_id and tr_query4bills_portfolio.stock_id = td_stock_emis.id and tr_query4bills_portfolio.subacc_id = td_depo_subacc.id and td_depo_subacc.depo_acc_id = td_depo_accounts.id GROUP BY td_depo_accounts.depo_acc_name, tr_query4bills_portfolio.day, td_stock_emis.stock_name ORDER BY td_depo_accounts.depo_acc_name, tr_query4bills_portfolio.day, td_stock_emis.stock_name .END $ENDTEXT(13542201) $ENDFORM $FORM(D_DEPO_BILL_OUT) name=Просмотр class=5 filter=null target_state= uo=uo_edit dw=d_depo_bill_out procedure=ap_10000000000051966 patterns=GENERIC_VIEW_ITEM_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=3337 height=2004 proc_text=$TEXT(13542201) 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(13542201) $ACTION2RELATION(REL1.PARTNER_CODE) relation=REL1 where=null prop=PARTNER_CODE order=1 alias=initiator_code $ENDACTION2RELATION $ACTION2RELATION(REL1.PARTNER_SHORT_NAME) relation=REL1 where=null prop=PARTNER_SHORT_NAME order=4 alias=initiator_short_name $ENDACTION2RELATION $ACTION2RELATION(REL2.PARTNER_CODE) relation=REL2 where=null prop=PARTNER_CODE order=1 alias=corr_code $ENDACTION2RELATION $ACTION2RELATION(REL2.PARTNER_SHORT_NAME) relation=REL2 where=null prop=PARTNER_SHORT_NAME order=4 alias=corr_short_name $ENDACTION2RELATION $ACTION2RELATION(REL4.PARTNER_CODE) relation=REL4 where=null prop=PARTNER_CODE order=1 alias=reseiver_code $ENDACTION2RELATION $ACTION2RELATION(REL4.PARTNER_SHORT_NAME) relation=REL4 where=null prop=PARTNER_SHORT_NAME order=4 alias=reseiver_short_name $ENDACTION2RELATION $ACTION2RELATION(REL3.PARTNER_CODE) relation=REL3 where=null prop=PARTNER_CODE order=1 alias=payer_code $ENDACTION2RELATION $ACTION2RELATION(REL3.PARTNER_SHORT_NAME) relation=REL3 where=null prop=PARTNER_SHORT_NAME order=4 alias=payer_short_name $ENDACTION2RELATION $ACTION2RELATION(REL5.PRICE_NAME) relation=REL5 where=null prop=PRICE_NAME order=2 alias=price_name $ENDACTION2RELATION $ACTION2RELATION(REL8.DEPO_ACC_NUMBER) relation=REL8 where=null prop=DEPO_ACC_NUMBER order=2 alias=depo_acc_no $ENDACTION2RELATION $ACTION2RELATION(REL8.DEPO_ACC_NAME) relation=REL8 where=null prop=DEPO_ACC_NAME order=4 alias=depo_acc_name $ENDACTION2RELATION $ACTION2RELATION(REL6.ITEM_NAME) relation=REL6 where=null prop=ITEM_NAME order=2 alias=foundation_name $ENDACTION2RELATION $BIND(BIND1) type=BILL_OUT_LIST_GRP action=FORM1 class=1 order=10 idname=bill_id_s $ENDBIND $BIND(BIND2) type=BILL_OUT action=D_DEPO_BILL_OUT_SIGN_ED class=1 order=2 idname=null $ENDBIND $ENDFORM $FORM(D_DEPO_BILL_OUT_ADD) name=Счет (RUS) - приложение ММБ class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_add procedure=ap_11535000006832778 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric begin select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select td_depo_doc2bill.doc_description, td_depo_doc2bill.doc_sum, (select cur_code from t_currencies where t_currencies.id = td_depo_doc2bill.cur_id) as cur_code, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_ADDON_DETAIL) name=Счет (RUS) - приложение - перечень class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_addon_detail procedure=ap_depobill_out_addon_detail patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) 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 .GET_PROPS declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select convert(varchar,td_depo_doc2bill.id) as sid, bill_type, (select simple_name from t_simples where id=td_depo_doc2bill.bill_type and type_id=1006) bill_type_name, bill_type_description, doc_description, doc_comment, doc_sum, (select cur_sign from t_currencies where id=td_depo_doc2bill.cur_id) cur_code, bill_list_sum, (select cur_sign from t_currencies where id=td_depo_doc2bill.rate_cur_id) as rate_cur_code, (select td_price_lists.max_sum /*@vat*/ from td_price_lists, t_schfact where td_price_lists.id=t_schfact.price_list_id and t_schfact.id=@id) max_sum, (select sum_rate from t_schfact where t_schfact.id=@id) sum_rate, substring(t_types.type_code,1,12) type_code from td_depo_doc2bill, t_items, t_types, t_states /*, td_depo_docs*/ where td_depo_doc2bill.bill_id=@id and t_items.id=td_depo_doc2bill.id and t_types.id=t_items.type_id and t_states.id=t_items.state_id and t_states.class_id=0 /* and td_depo_docs.id=*td_depo_doc2bill.doc_id order by td_depo_docs.in_date */ end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_ADDON_HEADER) name=Счет (RUS) - приложение class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_addon_header procedure=ap_depo_bill_addon_header patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) 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 .GET_PROPS declare @date varchar(255) declare @from_partner_short_name varchar(255) declare @to_partner_short_name varchar(255) declare @depo_account varchar(255), @vat varchar(255) select @date='С '+.DATE_TO_STR(@date_b)+' ПО '+.DATE_TO_STR(@date_e) select @from_partner_short_name = (select t_partners.partner_name from t_partners,td_depo_accounts where t_partners.id=td_depo_accounts.partner_id and td_depo_accounts.id=@depo_acc_id) select @depo_account = (select depo_acc_number from td_depo_accounts where td_depo_accounts.id=@depo_acc_id) select @to_partner_short_name = (select t_partners.partner_short_name from t_partners where t_partners.id=@to_partner_id) /* if @cur_id <> @rate_cur_id*/ select @vat = 'Расчет призведен по курсу Банка России на ' + .DATE_TO_STR(@doc_date) + ' : ' + convert(varchar,@sum_rate) + (select cur_sign from t_currencies where id=@rate_cur_id) + char(13) + char(10) + 'Суммы указаны c учетом НДС' /* else select @vat = 'Суммы указаны c учетом НДС'*/ declare @com_sum money,@ret_sum money,@max_sum money,@fact_sum money declare @save_min_sum money declare @save_max_sum money declare @save_sum money declare @sum_rate_vat money --select @sum_rate_vat=1+@sum_rate*convert(money,.GET_CONST('VAT'))/100 select @sum_rate_vat=1 select @max_sum =@sum_rate_vat * (select max_sum from td_price_lists where id=@price_list_id) select @save_max_sum=@sum_rate_vat*(select save_max_sum from td_price_lists where id=@price_list_id) select @save_min_sum=@sum_rate_vat*(select save_min_sum from td_price_lists where id=@price_list_id) select @com_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_COM' and upper(t_types.type_code)<>'BILL_OUT_COM_SAVE') select @save_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill,t_items,t_states,t_types where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and upper(t_types.type_code)='BILL_OUT_COM_SAVE') if @save_max_sum > 0 and @save_sum > @save_max_sum and @save_sum > 0 select @save_sum=@save_max_sum if @save_min_sum > 0 and @save_sum < @save_min_sum and @save_sum > 0 select @save_sum=@save_min_sum --if @com_sum>@max_sum and @max_sum>0 select @com_sum=@max_sum select @ret_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_RET') if @max_sum > 0 and (@save_sum+@com_sum) > @max_sum and (@save_sum+@com_sum) >0 select @fact_sum=round((@max_sum+@ret_sum),2) else select @fact_sum=round(((@com_sum+@ret_sum+@save_sum)),2) --select @fact_sum=(@com_sum+@save_sum+@ret_sum) select convert(varchar,@id) as sid, @doc_number as doc_number, @doc_date as doc_date, @in_date as in_date_d, @in_no as in_no, @date as date, @from_partner_short_name as from_partner_name, @depo_account as depo_account, @to_partner_short_name as company_name, (select user_name from t_users where login_name=suser_name()) as user_name, @vat as vat, @fact_sum sum_total, (select cur_sign from t_currencies where id = @cur_id) cur_code end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_BILL) name=Счет (RUS) class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_bill procedure=ap_depo_bill_out_bill patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) 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 .GET_PROPS declare @bill_type_name varchar(255), @from_partner varchar(255), @from_address varchar(255), @from_inn varchar(20), @from_account varchar(255), @from_chief varchar(255), @from_bookkeeper varchar(255), @to_partner varchar(255), @to_address varchar(255), @to_inn varchar(20), @vat money, @account varchar(255), @pay_sum_s varchar(36), @pay_sum_t varchar(255), @vat_sum_s varchar(36), @vat_sum_t varchar(255), @from_partner_cpp varchar(255), @to_partner_cpp varchar(255) select @bill_type_name=@bill_type_description select @from_partner=/*isnull(t_simples.simple_name + ' ', '') + */isnull(partner_name,''), @from_address = isnull(jur_code,'') + ' ' + isnull(juraddress, partner_address), --+ isnull(' т.' + partner_phone,''), @from_inn = isnull(j_inn,''), @from_chief = isnull(j_head_last_name,''), @from_bookkeeper = isnull(j_bookkeeper_name,''), @from_partner_cpp = isnull(partner_cpp,'') from t_partners, t_partners_jur, t_simples where t_partners.id=@to_partner_id and t_partners_jur.id = t_partners.id and t_simples.type_id = 1001 and t_partners_jur.organisation_form_id = t_simples.id select @from_account = 'р/с ' + isnull(t_bank_accounts.bank_account_no,'') + ' в ' + isnull(t_bank_accounts.bank_name,'') + + char(13) + char(10) +'к/с ' + isnull(t_bank_accounts.corr_account,'') + ' в ОПЕРУ Московского ГТУ Банка России по г. Москве ' + ', БИК ' + + isnull(t_bank_accounts.bik,'') from t_bank_accounts,t_banks where t_bank_accounts.id=@to_partner_acc_id and t_banks.id = t_bank_accounts.bank_id select @to_partner=isnull(partner_name,''), @to_address = isnull(jur_code,'') + ' ' + isnull(partner_address,isnull(juraddress,'')), -- + isnull(' т.' + partner_phone,''), @to_inn = isnull(j_inn,''), @to_partner_cpp = isnull(partner_cpp,'') from t_partners where t_partners.id=@from_partner_id --select @vat=convert(money,.GET_CONST('VAT')) -- John 02.02.05 -- Получаем НДС из перечня -- Сумму из перечня select @sum_total = isnull(sum(isnull(doc_sum,0)),0), @vat = isnull(max(isnull(vat,0)),0) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) .TYPE_GET('cur',@rate_cur_id) select @pay_sum_s=convert(varchar,@sum_total) exec ap_dig2txt @dig=@pay_sum_s, @whole_mode=@cur_name_mode1, @whole_1=@cur_name_11, @whole_2_4=@cur_name_2_41, @whole_5_=@cur_name_5_01, @hund_mode=@cur_hund_mode1, @hund_1=@cur_hund_11, @hund_2_4=@cur_hund_2_41, @hund_5_=@cur_hund_5_01, @with_hund=0, @txt=@pay_sum_t out select @pay_sum_t = upper(substring(@pay_sum_t,1,1)) + substring(@pay_sum_t,2,254) select @sum_tax = round((@sum_total / (1+@vat) * @vat) , 2) select @vat_sum_s=convert(varchar,@sum_tax) exec ap_dig2txt @dig=@vat_sum_s, @whole_mode=@cur_name_mode1, @whole_1=@cur_name_11, @whole_2_4=@cur_name_2_41, @whole_5_=@cur_name_5_01, @hund_mode=@cur_hund_mode1, @hund_1=@cur_hund_11, @hund_2_4=@cur_hund_2_41, @hund_5_=@cur_hund_5_01, @with_hund=0, @txt=@vat_sum_t out -- John 08.02.05 -- MASTER CODE declare @class_value_id numeric declare @master_code varchar(100) .GET_CLASS_VALUE('PARTNER_CODE','MASTER',1,@class_value_id) select @master_code = t_item2class.code from t_item2class where t_item2class.item_id = @from_partner_id and t_item2class.value_id = @class_value_id and .ITEMS_EXISTS(t_item2class.id) select convert(varchar,@id) as sid, @in_no as in_no, @in_date as in_date_d, @doc_number as doc_no, @doc_date as dock_date_d, convert(varchar(30),null) as foundation_no, convert(datetime,null) as foundation_date_d, @from_partner as sale_partner, @from_address as sale_address, @from_inn as sale_inn, @from_account as sale_account, @to_partner as buy_partner, @to_address as buy_address, @to_inn as buy_inn, @doc_description as addon, @bill_type_name as bill_type, @clear_sum_total as clear_sum, @vat as vat, @sum_tax as vat_sum, @vat_sum_t as vat_sum_t, @sum_total as pay_sum, @pay_sum_t as pay_sum_t, @from_chief as sale_chief, @from_bookkeeper as sale_bookkeeper, @from_partner_cpp as sale_partner_cpp, @to_partner_cpp as buy_partner_cpp, @master_code -- ADD John 08.02.05 end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_ENG_OPER_DET) name=Счет (ENG) - операции class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_eng_oper_det procedure=ap_depo_bill_out_eng_oper_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select (select isnull(t_classvalues.remark,t_classvalues.name) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, doc.out_no client_ref, doc.in_date our_date_d, doc.in_no our_ref, isnull(stock.stock_rate_code,'n/a') stock_isin, stock.stock_name_eng stock_name, (select stock_type_name_eng from t_stock_types where id=stock.stock_type_id) stock_type, move.stock_qty_in, (select (case upper(type_code) when 'D_STOCK_IN' then 'Receipt' when 'D_STOCK_OUT' then 'Delivery' when 'STOCK_MOVE' then 'Internal' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_TRANSFER' then 'Change safekeeping' else 'n/a' end) from t_items, t_types where t_items.id=doc.id and t_types.id=t_items.type_id) oper_type, isnull((select t_partners.partner_name_eng from t_partners where t_partners.id=move.deliver_agent_id),'n/a') counterpart, isnull((select t_partners.partner_name_eng from t_partners where t_partners.id=move.keep_traject_end_id),'n/a') sett_place, /*2004-07-19 btdvprik isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.deliver_agent_id),'n/a') counterpart, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.keep_traject_end_id),'n/a') sett_place, btdvprik 2004-07-19*/ doc.settlement_date sett_date, doc.arch_date, bill.doc_sum sum_total, round(bill.doc_sum*(@vat - 1.0)/@vat,2) sum_tax, @vat vat, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_depo_docs doc, td_stock_moves move, td_prices price, td_stock_emis stock where bill.bill_id=@id and bill_type=2 and price.id=bill.stock_type and doc.id=bill.doc_id and move.id=doc.id and stock.id=move.stock_id $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_ENG_RETO_DET) name=Счет (ENG) - возмещение операций class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_eng_reto_det procedure=ap_depo_bill_out_eng_reto_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select DISTINCT (select isnull(t_classvalues.remark,t_classvalues.name) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, doc.out_no client_ref, doc.in_date our_date_d, doc.in_no our_ref, isnull(stock.stock_rate_code,'n/a') stock_isin, stock.stock_name_eng stock_name, (select stock_type_name_eng from t_stock_types where id=stock.stock_type_id) stock_type, move.stock_qty_in, (select (case upper(type_code) when 'D_STOCK_IN' then 'Receipt' when 'D_STOCK_OUT' then 'Delivery' when 'STOCK_MOVE' then 'Internal' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_TRANSFER' then 'Change safekeeping' else 'n/a' end) from t_items, t_types where t_items.id=doc.id and t_types.id=t_items.type_id) oper_type, -- VVS,17.12.2004 : partner_short_name -> partner_short_name isnull((select t_partners.partner_name_eng from t_partners where t_partners.id=move.deliver_agent_id),'n/a') counterpart, -- VVS,17.12.2004 : partner_short_name -> partner_short_name isnull((select t_partners.partner_name_eng from t_partners where t_partners.id=move.keep_traject_end_id),'n/a') sett_place, doc.settlement_date sett_date, doc.arch_date, ret.doc_sum sum_total, isnull((select doc_number from t_schfact where id=ret.bill_in_id),'n/a') invoice_no, -- convert(decimal(18,4), round(ret.doc_sum*(@vat - 1.0)/@vat,2)) sum_tax, @vat vat, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_depo_docs doc, td_stock_moves move, td_prices price, td_stock_emis stock, td_depo_doc2bill ret where bill.bill_id=@id and bill.bill_type=4 -- ADD John 28.02.05 and price.id=*bill.stock_type and doc.id=bill.doc_id and move.id=doc.id and stock.id=move.stock_id and ret.doc_id=bill.doc_id and ret.bill_type=4 and ret.bill_id = @id AND .ITEMS_EXISTS(bill.id) ORDER BY doc.in_date, doc.in_no /* AND .ITEMS_EXISTS(bill.id) AND .ITEMS_EXISTS(ret.id) AND .ITEMS_EXISTS(price.id) AND .ITEMS_EXISTS(doc.id) */ $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_ENG_SAVE_DET) name=Счет (ENG) - хранение class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_eng_save_det procedure=ap_depo_bill_out_eng_save_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select @days_num=datediff(dd,@date_b,@date_e) + 1, @days_year=360 /* datediff(dd,convert(datetime,('01/01/'+convert(varchar,datepart(yy,getdate())))), convert(datetime,('01/01/'+convert(varchar,datepart(yy,getdate())+1)))) */ select (select isnull(t_classvalues.remark,t_classvalues.name) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, day, isnull(stock.stock_rate_code,'n/a') stock_isin, stock.stock_name_eng stock_name, (select stock_type_name_eng from t_stock_types where id=stock.stock_type_id) stock_type, bill.stock_qty, round(bill.rate_value,4) stock_rate_value, convert(varchar(50),'n/a') stock_rate_source_name, bill.rate_date stock_rate_date, convert(decimal(18,4), round(bill.stock_qty*round(bill.rate_value,4),2)) stock_portfolio, price.tax_percent tariff, convert(decimal(18,4), round(price.tax_percent/@days_year,8)) as eff_tariff, bill.doc_sum sum_total, --04/08/2004 round(bill.doc_sum*(@vat - 1.0)/@vat,8) sum_tax, bill.doc_tax sum_tax, @vat vat, @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_price_taxs price, td_stock_emis stock where bill.bill_id=@id and bill_type=3 and price.id=bill.stock_type and stock.id=bill.stock_id $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_FACT) name=Счет (RUS) - счет фактура class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_fact procedure=ap_depo_bill_out_fact patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) 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 .GET_PROPS declare @bill_type_name varchar(255), @from_partner varchar(255), @from_address varchar(255), @from_inn varchar(20), @from_account varchar(255), @from_chief varchar(255), @from_bookkeeper varchar(255), @to_partner varchar(255), @to_address varchar(255), @to_inn varchar(20), @vat money, @account varchar(255), @pay_sum_s varchar(36), @pay_sum_t varchar(255), @vat_sum_s varchar(36), @vat_sum_t varchar(255), @to_partner_cpp varchar(255), @from_partner_cpp varchar(255) select @bill_type_name=@bill_type_description -- John 14.02.05 if (@foundation_id is not null) AND (@chief_sign is null) select @chief_sign = chief_sign, @bookkeeper_sign = bookkeeper_sign from td_query4bills where id=@foundation_id select @from_partner=isnull(partner_name,''), @from_address = isnull(jur_code,'') + ' ' + isnull(juraddress, partner_address), --+ isnull(' т.' + partner_phone,''), @from_inn = isnull(j_inn,''), @from_chief = isnull(@chief_sign, isnull(j_head_last_name,'')), @from_bookkeeper = isnull(@bookkeeper_sign, isnull(j_bookkeeper_name,'')), @from_partner_cpp = isnull(partner_cpp,'') from t_partners, t_partners_jur, t_simples where t_partners.id=@to_partner_id and t_partners_jur.id = t_partners.id and t_simples.type_id = 1001 and t_partners_jur.organisation_form_id = t_simples.id select @from_account = 'р/с ' + isnull(t_bank_accounts.bank_account_no,'') + ' в ' + isnull(t_bank_accounts.bank_name,'') + + char(13) + char(10) +'к/с ' + isnull(t_bank_accounts.corr_account,'') + ', БИК ' + + isnull(t_bank_accounts.bik,'') from t_bank_accounts,t_banks where t_bank_accounts.id=@to_partner_acc_id and t_banks.id = t_bank_accounts.bank_id select @to_partner=isnull(partner_name,''), @to_address = isnull(jur_code,'') + ' ' + isnull(partner_address,isnull(juraddress,'')), @to_inn = isnull(j_inn,''), @to_partner_cpp = isnull(partner_cpp,'') from t_partners where t_partners.id=@from_partner_id -- John 14.03.05 -- обработка адреса у Атон IF @to_partner='Общество с ограниченной ответственностью "Атон"' SELECT @to_address = REPLACE(@to_address, 'Российская Федерация, ', '') select @vat=convert(money,.GET_CONST('VAT')) .TYPE_GET('cur',@rate_cur_id) declare @com_sum money,@ret_sum money,@max_sum money,@fact_sum money declare @save_min_sum money declare @save_max_sum money declare @save_sum money select @max_sum = @sum_rate /*@vat*/ *(select max_sum from td_price_lists where id=@price_list_id) select @save_max_sum=@sum_rate /*@vat*/ *(select save_max_sum from td_price_lists where id=@price_list_id) select @save_min_sum=@sum_rate /*@vat*/ *(select save_min_sum from td_price_lists where id=@price_list_id) select @com_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_COM' and upper(t_types.type_code)<>'BILL_OUT_COM_SAVE') select @save_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill,t_items,t_states,t_types where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and upper(t_types.type_code)='BILL_OUT_COM_SAVE') if @save_max_sum > 0 and @save_sum > @save_max_sum and @save_sum > 0 select @save_sum=@save_max_sum if @save_min_sum > 0 and @save_sum < @save_min_sum and @save_sum > 0 select @save_sum=@save_min_sum --if @com_sum>@max_sum and @max_sum>0 select @com_sum=@max_sum select @ret_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_RET') if @max_sum > 0 and (@save_sum+@com_sum) > @max_sum and (@save_sum+@com_sum) >0 select @fact_sum=round((@max_sum+@ret_sum),2) else select @fact_sum=round(((@com_sum+@ret_sum+@save_sum)),2) --select @fact_sum=(@com_sum+@save_sum+@ret_sum) /* select @sum_total = @fact_sum, @sum_tax = @fact_sum*@vat/100, @clear_sum_total = @fact_sum*(1-@vat/100) */ select @pay_sum_s=convert(varchar,@sum_total) exec ap_dig2txt @dig=@pay_sum_s, @whole_mode=@cur_name_mode1, @whole_1=@cur_name_11, @whole_2_4=@cur_name_2_41, @whole_5_=@cur_name_5_01, @hund_mode=@cur_hund_mode1, @hund_1=@cur_hund_11, @hund_2_4=@cur_hund_2_41, @hund_5_=@cur_hund_5_01, @with_hund=0, @txt=@pay_sum_t out select @pay_sum_t = upper(substring(@pay_sum_t,1,1)) + substring(@pay_sum_t,2,254) select @vat_sum_s=convert(varchar,@sum_tax) exec ap_dig2txt @dig=@vat_sum_s, @whole_mode=@cur_name_mode1, @whole_1=@cur_name_11, @whole_2_4=@cur_name_2_41, @whole_5_=@cur_name_5_01, @hund_mode=@cur_hund_mode1, @hund_1=@cur_hund_11, @hund_2_4=@cur_hund_2_41, @hund_5_=@cur_hund_5_01, @with_hund=0, @txt=@vat_sum_t out -- John 08.02.05 -- MASTER CODE declare @class_value_id numeric declare @master_code varchar(100) .GET_CLASS_VALUE('PARTNER_CODE','MASTER',1,@class_value_id) select @master_code = t_item2class.code from t_item2class where t_item2class.item_id = @from_partner_id and t_item2class.value_id = @class_value_id and .ITEMS_EXISTS(t_item2class.id) select convert(varchar,@id) as sid, @in_no as in_no, @in_date as in_date_d, @doc_number as doc_no, @doc_date as dock_date_d, convert(varchar(30),null) as foundation_no, convert(datetime,null) as foundation_date_d, @from_partner as sale_partner, @from_address as sale_address, @from_inn as sale_inn, @from_account as sale_account, @to_partner as buy_partner, @to_address as buy_address, @to_inn as buy_inn, @doc_description as addon, @bill_type_name as bill_type, @clear_sum_total as clear_sum, @vat as vat, @sum_tax as vat_sum, @vat_sum_t as vat_sum_t, @sum_total as pay_sum, @pay_sum_t as pay_sum_t, @from_chief as sale_chief, @from_bookkeeper as sale_bookkeeper, @to_partner_cpp as buy_partner_cpp, @from_partner_cpp as sale_partner_cpp, @master_code as master_code -- ADD John end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_FACT_DETAIL) name=Счет (RUS) - перечень class=5 filter=null target_state= uo=null dw=d_depo_bill_out_fact_detail procedure=ap_bill_out_fact_detail patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) 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) .NAME_VAR(@cur_name) begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% select @type_id_s = NULL select @state_name_id_s = NULL .CHECK_USER .GET_PROPS declare @vat decimal(18,4) --select @vat = convert(decimal(18,4),.GET_CONST('VAT')) -- John 08.02.05 select @vat = isnull(max(isnull(vat,0)),0) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) .TYPE_GET('cur',@rate_cur_id) select @cur_name = @cur_sign1 declare @com_sum decimal(18,4), @clear_com_sum decimal(18,4), @com_sum_tax decimal(18,4), @ret_sum decimal(18,4), @clear_ret_sum decimal(18,4), @ret_sum_tax decimal(18,4) select @com_sum = isnull(sum(isnull(doc_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_COM' select @com_sum = round(@com_sum, 2) -- Расчет НДС select @com_sum_tax = round(@com_sum * @vat/(1.0 + @vat), 2) select @clear_com_sum = @com_sum - @com_sum_tax select @ret_sum = isnull(sum(isnull(doc_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_RET' select @ret_sum = round(@ret_sum, 2) -- Расчет НДС select @ret_sum_tax = round(@ret_sum * @vat/(1.0 + @vat), 2) select @clear_ret_sum = @ret_sum - @ret_sum_tax select convert(varchar,@id) as sid, 1 as ord, @bill_type_description as bill_type, @clear_com_sum as clear_sum, @vat as vat, @com_sum_tax as vat_sum, @com_sum as pay_sum, @cur_name as cur_name where @com_sum > 0 union select convert(varchar,@id) as sid, 2 as ord, 'Возмещение затрат по депозитарным услугам' as bill_type, @clear_ret_sum as clear_sum, @vat as vat, @ret_sum_tax as vat_sum, @ret_sum as pay_sum, @cur_name as cur_name where @ret_sum>0 end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_RUS_OPER_DET) name=Счет (RUS) - операции class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_rus_oper_det procedure=ap_depo_bill_out_rus_oper_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select (select isnull(t_classvalues.name,t_classvalues.remark) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, doc.out_no client_ref, doc.in_date our_date_d, doc.in_no our_ref, isnull(stock.stock_rate_code,'н/д') stock_isin, stock.stock_name stock_name, (select stock_type_name from t_stock_types where id=stock.stock_type_id) stock_type, move.stock_qty_in, (select (case upper(type_code) when 'D_STOCK_IN' then 'Получение' when 'D_STOCK_OUT' then 'Поставка' when 'STOCK_MOVE' then 'Перевод' when 'CANCEL_MISSION' then 'Отмена инстр.' when 'STOCK_TRANSFER' then 'Перемещение' else 'н/д' end) from t_items, t_types where t_items.id=doc.id and t_types.id=t_items.type_id) oper_type, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.deliver_agent_id),'н/д') counterpart, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.keep_traject_end_id),'н/д') sett_place, doc.settlement_date sett_date, doc.arch_date, bill.doc_sum sum_total, convert(decimal(18,4), round(bill.doc_sum*(@vat - 1.0)/@vat,2)) sum_tax, @vat vat, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_depo_docs doc, td_stock_moves move, td_prices price, td_stock_emis stock where bill.bill_id=@id and bill_type=2 and price.id=bill.stock_type and doc.id=bill.doc_id and move.id=doc.id and stock.id=move.stock_id $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_RUS_RETO_DET) name=Счет (RUS) - возмещение операций class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_rus_reto_det procedure=ap_depo_bill_out_rus_reto_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select DISTINCT (select isnull(t_classvalues.name,t_classvalues.remark) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, doc.out_no client_ref, doc.in_date our_date_d, doc.in_no our_ref, isnull(stock.stock_rate_code,'н/д') stock_isin, stock.stock_name stock_name, (select stock_type_name from t_stock_types where id=stock.stock_type_id) stock_type, move.stock_qty_in, (select (case upper(type_code) when 'D_STOCK_IN' then 'Получение' when 'D_STOCK_OUT' then 'Поставка' when 'STOCK_MOVE' then 'Перевод' when 'CANCEL_MISSION' then 'Отмена инстр.' when 'STOCK_TRANSFER' then 'Перемещение' else 'n/a' end) from t_items, t_types where t_items.id=doc.id and t_types.id=t_items.type_id) oper_type, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.deliver_agent_id),'н/д') counterpart, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.keep_traject_end_id),'н/д') sett_place, doc.settlement_date sett_date, doc.arch_date, ret.doc_sum sum_total, isnull((select doc_number from t_schfact where id=ret.bill_in_id),'н/д') invoice_no, -- convert(decimal(18,4), round(ret.doc_sum*(@vat - 1.0)/@vat,2)) sum_tax, @vat vat, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_depo_docs doc, td_stock_moves move, td_prices price, td_stock_emis stock, td_depo_doc2bill ret where bill.bill_id=@id and bill.bill_type=4 -- and bill.bill_type=2 -- Change John 28.02.05 and price.id=*bill.stock_type and doc.id=bill.doc_id and move.id=doc.id and stock.id=move.stock_id and ret.doc_id=bill.doc_id and ret.bill_type=4 and ret.bill_id = @id AND .ITEMS_EXISTS(bill.id) $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_RUS_SAVE_DET) name=Счет (RUS) - хранение class=5 filter=null target_state= uo=uo_list_rep dw=d_depo_bill_out_rus_save_det procedure=ap_depo_bill_out_rus_save_det patterns=GENERIC_VIEW_ITEM user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id select @days_num=datediff(dd,@date_b,@date_e) + 1, @days_year=360 /* datediff(dd,convert(datetime,('01/01/'+convert(varchar,datepart(yy,getdate())))), convert(datetime,('01/01/'+convert(varchar,datepart(yy,getdate())+1)))) */ select (select isnull(t_classvalues.name,t_classvalues.remark) from t_classvalues where t_classvalues.id=price.stock_value_id) stock_class, day, isnull(stock.stock_rate_code,'н/д') stock_isin, stock.stock_name stock_name, (select stock_type_name from t_stock_types where id=stock.stock_type_id) stock_type, bill.stock_qty, round(bill.rate_value,4) stock_rate_value, convert(varchar(50),'н/д') stock_rate_source_name, bill.rate_date stock_rate_date, convert(decimal(18,4), round(bill.stock_qty*round(bill.rate_value,4),2)) stock_portfolio, price.tax_percent tariff, convert(decimal(18,8), round(price.tax_percent/@days_year,8)) eff_tariff, bill.doc_sum sum_total, --04/08/2004 round(bill.doc_sum*(@vat - 1.0)/@vat,8) sum_tax, bill.doc_tax sum_tax, @vat vat, @date_b date_b, @date_e date_e, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from td_depo_doc2bill bill, td_price_taxs price, td_stock_emis stock where bill.bill_id=@id and bill_type=3 and price.id=bill.stock_type and stock.id=bill.stock_id $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_BILL_OUT_SIGN) name=Подписи class=5 filter=null target_state= uo=uo_edit dw=d_depo_bill_out_sign procedure=ap_11535000007007669 patterns=GENERIC_VIEW_ITEM_P2 user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER --.CHECK_VIEW_ITEM .VIEW_ITEM(ALL,2) .END $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_INVOICE_ENG_EUR) name=Счет (ENG-EUR) class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_bill_eng_e procedure=ap_depo_bill_out_bill_eng patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $ENDFORM $FORM(D_DEPO_INVOICE_ENG_RUR) name=Счет (ENG-РУБ) class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_bill_eng_r procedure=ap_depo_bill_out_bill_eng patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $ENDFORM $FORM(D_DEPO_INVOICE_FOR_FOREIGNS) name=Счет (ENG) class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_bill_eng procedure=ap_depo_bill_out_bill_eng patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542202) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric begin select @id = convert(numeric, @sid) .GET_PROPS declare @from_partner_name varchar(255) declare @from_partner_addres varchar(255) declare @depo_account varchar(255) declare @depo_dog_no varchar(50) declare @depo_dog_date datetime declare @vat decimal(18,4) --select @vat=1 + convert(decimal(18,4),.GET_CONST('VAT'))/100 -- John 02.02.05 -- Получаем НДС из перечня select @sum_total = isnull(sum(isnull(doc_sum,0)),0), @vat = isnull(max(isnull(vat,0)),0) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) select @sum_tax = round((@sum_total / (1+@vat) * @vat) , 2) select @from_partner_name=t_partners.partner_name_eng, @from_partner_addres=t_partners.juraddress from t_partners where t_partners.id=@from_partner_id select @depo_account=depo_acc_number, @depo_dog_no=depo_doc_no, @depo_dog_date = operator_doc_date from td_depo_accounts where td_depo_accounts.id=@depo_acc_id select convert(varchar,@id) as sid, @doc_number as doc_number, @doc_date as doc_date, @date_b as date_b, @date_e as date_e, @from_partner_name as from_partner_name, @from_partner_addres as from_partner_addres, @depo_dog_no as depo_dog_no, @depo_dog_date as depo_dog_date_d, @depo_account as depo_account, @vat as vat, @sum_tax as sum_tax, @sum_total sum_total end $ENDTEXT(13542202) $ENDFORM $FORM(D_DEPO_INVOICE_SAFEKEEPING) name=Счет (ENG) - перечень class=5 filter=null target_state= uo=uo_print dw=d_depo_bill_out_bill_eng_det procedure=ap_depo_bill_out_bill_eng_det patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric begin select @id = convert(numeric, @sid) .GET_PROPS declare @days_cnt int declare @vat money select @days_cnt = datediff(day,@date_b,@date_e) + 1 --select @vat=1 + convert(money,.GET_CONST('VAT'))/100 -- John 04.02.05 -- Получаем НДС из перечня select @vat = isnull(max(isnull(vat,0)),0) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) create table #report ( -- 1 - хранение, 2 - операции, 3 - корпоративные действия, 4 - прочие услуги, 5 - возмещение mode int not null, -- 1 - ведение счета, 2 - хранение, -- 3 - операции, 4 - корпоративные действия, 5 - прочие услуги, 6 - возмещение submode int not null, stock_class varchar(255) not null, cnt varchar(10) null, sum_fee money null, sum_tax money null, sum_total money null ) -- -- Абонентская плата -- insert #report select 1, 1, 'Account maintenance', convert(varchar,@days_cnt) + ' days', bill.doc_sum sum_fee, round((bill.doc_sum / (1+ @vat) * @vat), 2) as sum_tax, bill.doc_sum sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=1 and .ITEMS_EXISTS(bill.id) -- -- Довесок до минимальной суммы за хранение -- insert #report select 1, 1, 'Up to minimum administrative fee', convert(varchar,@days_cnt) + ' days', bill.doc_sum sum_fee, round((bill.doc_sum / (1+ @vat) * @vat), 2) as sum_tax, bill.doc_sum sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=13 and .ITEMS_EXISTS(bill.id) -- -- Хранение -- insert #report select 1, 2, isnull(t_classvalues.remark,t_classvalues.name) stock_class, convert(varchar,@days_cnt) + ' days', null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill, td_price_taxs price, td_stock_emis stock, t_classvalues where bill.bill_id=@id and bill_type=3 and price.id=bill.stock_type and stock.id=bill.stock_id and t_classvalues.id=price.stock_value_id and .ITEMS_EXISTS(bill.id) group by isnull(t_classvalues.remark,t_classvalues.name) -- -- Операции без квитовки -- insert #report select 2, 3, (case upper(t_types.type_code) when 'D_STOCK_IN' then 'External receipt' when 'D_STOCK_OUT' then 'External delivery' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_MOVE' then 'Internal book transfer' when 'STOCK_TRANSFER' then 'Change place of safekeeping' end) + ' of ' + isnull(t_classvalues.remark,t_classvalues.name) stock_class, convert(varchar,count(*)), -- min(price.oper_price), price.oper_price, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill, td_prices price, t_types, t_classvalues where bill.bill_id=@id and bill_type=2 and price.id=bill.stock_type and t_types.id=price.doc_type_id and t_classvalues.id=*price.stock_value_id AND ((price.cross_ref is null) OR (price.cross_ref = 0)) and .ITEMS_EXISTS(bill.id) group by (case upper(t_types.type_code) when 'D_STOCK_IN' then 'External receipt' when 'D_STOCK_OUT' then 'External delivery' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_MOVE' then 'Internal book transfer' when 'STOCK_TRANSFER' then 'Change place of safekeeping' end) + ' of ' + isnull(t_classvalues.remark,t_classvalues.name), price.oper_price -- с квитовкой -- John 06.09.05 insert #report select 2, 3, (case upper(t_types.type_code) when 'D_STOCK_IN' then 'Internal receipt' when 'D_STOCK_OUT' then 'Internal delivery' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_MOVE' then 'Internal book transfer' when 'STOCK_TRANSFER' then 'Change place of safekeeping' end) + ' of ' + isnull(t_classvalues.remark,t_classvalues.name) stock_class, convert(varchar,count(*)), price.oper_price, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill, td_prices price, t_types, t_classvalues where bill.bill_id=@id and bill_type=2 and price.id=bill.stock_type and t_types.id=price.doc_type_id and t_classvalues.id=*price.stock_value_id AND price.cross_ref is not null AND price.cross_ref = 1 and .ITEMS_EXISTS(bill.id) group by (case upper(t_types.type_code) when 'D_STOCK_IN' then 'Internal receipt' when 'D_STOCK_OUT' then 'Internal delivery' when 'CANCEL_MISSION' then 'Cancellation of instruction' when 'STOCK_MOVE' then 'Internal book transfer' when 'STOCK_TRANSFER' then 'Change place of safekeeping' end) + ' of ' + isnull(t_classvalues.remark,t_classvalues.name), price.oper_price -- -- Корпоративные действия -- insert #report select 3, 4, 'Participaton in shareholders meeting, proxy voting by physical presence on GM in Moscow', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=21 and .ITEMS_EXISTS(bill.id) insert #report select 3, 4, 'Participaton in shareholders meeting, proxy voting by physical presence on GM outside Moscow', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=22 and .ITEMS_EXISTS(bill.id) insert #report select 3, 4, 'Participaton in shareholders meeting, proxy voting by correspondence', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=23 and .ITEMS_EXISTS(bill.id) -- -- Прочие услуги -- insert #report select 4, 5, 'Checking the authenticity of physical securities', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=31 and .ITEMS_EXISTS(bill.id) insert #report select 4, 5, 'Pledge registration including pledge registration stipulated by terms of credit or other agreements with IMB', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=41 and .ITEMS_EXISTS(bill.id) -- -- Возмещение -- insert #report select 5, 6, 'Third party fees for transactions', convert(varchar,count(*)) cnt, null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=4 and .ITEMS_EXISTS(bill.id) -- John 06.10.05 -- ADD bill_type = 7 insert #report select 5, 6, 'Third party fees for other services (translation, notarize, etc)', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type in (6, 7) and .ITEMS_EXISTS(bill.id) insert #report select 5, 6, 'Third party fees for safekeeping', convert(varchar,count(*)), null, round((sum(bill.doc_sum) / (1+ @vat) * @vat), 2) as sum_tax, sum(bill.doc_sum) sum_total from td_depo_doc2bill bill where bill.bill_id=@id and bill_type=5 select *, @vat as vat from #report end $ENDTEXT(13542204) $ENDFORM $FORM(D_DEPO_MIDAS_LIST_EXP) name=Список экспорта в МИДАС class=5 filter=null target_state= uo=uo_format_export dw=d_depo_bill_out_midas procedure=ap_11535000003459712 patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 .GET_PROPS declare @master_code char(6) declare @branch_code char(3) declare @set_class_type_id numeric declare @set_class_value_id numeric -- MasterCode select @set_class_type_id = t_classes.id from t_classes where upper(t_classes.code) = upper('PARTNER_CODE') and exists(select 1 from t_items, t_states where t_items.id=t_classes.id and t_states.id=t_items.state_id and t_states.class_id=0) select @set_class_value_id = t_classvalues.id from t_classvalues where upper(t_classvalues.code) = upper('MASTER') and t_classvalues.class_id = @set_class_type_id and exists(select 1 from t_items, t_states where t_items.id=t_classvalues.id and t_states.id=t_items.state_id and t_states.class_id=0) select @master_code = t_item2class.code from t_item2class where t_item2class.item_id = @from_partner_id and t_item2class.value_id = @set_class_value_id and exists(select 1 from t_items, t_states where t_items.id=t_item2class.id and t_states.id=t_items.state_id and t_states.class_id=0) if @master_code is null .EXIT_MESSAGE('У партнера не задан классификатор с MASTER кодом') -- BRANCH select @set_class_type_id = null select @set_class_type_id = t_classes.id from t_classes where upper(t_classes.code) = upper('BRANCH') and exists(select 1 from t_items, t_states where t_items.id=t_classes.id and t_states.id=t_items.state_id and t_states.class_id=0) select @branch_code = t_classvalues.code from t_item2class, t_classvalues where t_item2class.item_id = @from_partner_id and t_classvalues.id = t_item2class.value_id and t_classvalues.class_id = @set_class_type_id and exists(select 1 from t_items, t_states where t_items.id=t_item2class.id and t_states.id=t_items.state_id and t_states.class_id=0) if @branch_code is null .EXIT_MESSAGE('У партнера не задан классификатор с кодом Филиала') declare @curr_code char(3) declare @amount varchar(20) declare @narrative varchar(30) declare @list_sum money select @curr_code = (select cur_code from t_currencies where id=@rate_cur_id) create table #rep( brca char(3) null, cnum char(6) null, ccy char(3) null, acod char(4) null, acsq char(2) null, curr_code char(3) null, amount char(20) null, narrative char(30) null) -- -- В валюте счета -- declare cstock cursor for select sum(bill_list_sum) from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id AND .ITEMS_EXISTS(td_depo_doc2bill.id) open cstock begin tran fetch cstock into @list_sum while .CURSOR_STATE=0 begin select @amount = convert(varchar(20), round(@list_sum, 2)) select @amount = isnull(REPLICATE('0', (20 - LEN(@amount))), '') + @amount select @narrative = @master_code + ' DEPO SERV ' + convert(varchar(4), datepart(year, @doc_date)) + '/' + isnull(rtrim(@doc_number), '') + ' ' + '1' insert into #rep( brca, cnum, ccy, acod, acsq, curr_code, amount, narrative) select @branch_code, @master_code, ' ', ' ', ' ', @curr_code, @amount, @narrative fetch cstock into @list_sum end -- End LOOP commit tran close cstock .DEALLOCATE cstock select brca, cnum, ccy, acod, acsq, curr_code, amount, narrative from #rep end $ENDTEXT(13542204) $ENDFORM $FORM(D_DEPO_MIDAS_LIST_IMP) name=Список импорта из МИДАС class=5 filter=null target_state= uo=uo_format_import dw=d_depo_bill_midas_imp procedure=null patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $ENDFORM $FORM(MMB_DEPO_BILL_OUT_RUS_OPER) name=Счет (RUS) - операции ММБ class=5 filter=null target_state= uo=uo_list_rep dw=d_mmb_depo_bill_out_rus_oper procedure=ap_11535000007284484 patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric select @id = convert(numeric,@sid) declare @days_num decimal(18,8), @days_year decimal(18,8), @date_b datetime, @date_e datetime, @doc_no varchar(50), @doc_date datetime, @partner_name varchar(255), @partner_address varchar(255), @depo_acc_no varchar(50) DECLARE @depo_acc_id numeric declare @vat money select @vat=1 + convert(money,.GET_CONST('VAT'))/100 select @date_b=date_b, @date_e=date_e, @doc_no=doc_number, @doc_date=doc_date, @partner_name=t_partners.partner_name, @partner_address=t_partners.juraddress, @depo_acc_no=td_depo_accounts.depo_acc_number, @depo_acc_id = td_depo_accounts.id from t_schfact, t_partners, td_depo_accounts where t_schfact.id=@id and t_partners.id=t_schfact.from_partner_id and td_depo_accounts.id=t_schfact.depo_acc_id CREATE TABLE #rep( doc_sum money null, stock_value_id numeric null, -- Тип ЦБ doc_id numeric null, -- OPERATION stock_id numeric null -- ЦБ ) INSERT INTO #rep( doc_id, -- OPERATION doc_sum, -- SUM stock_value_id, -- Тип ЦБ stock_id ) SELECT td_depo_doc2bill.doc_id, td_depo_doc2bill.doc_sum, td_prices.stock_value_id, td_stock_moves.stock_id FROM td_depo_doc2bill, td_prices, td_stock_moves WHERE td_depo_doc2bill.stock_type = td_prices.id AND td_depo_doc2bill.bill_id=@id AND td_depo_doc2bill.bill_type=2 AND td_depo_doc2bill.doc_id *= td_stock_moves.id --select * from #rep INSERT INTO #rep( doc_id, -- OPERATION doc_sum, -- SUM stock_value_id, -- Тип ЦБ stock_id ) SELECT td_depo_docs.id, 0, null, td_stock_moves.stock_id FROM td_depo_docs, td_stock_moves, td_depo_subacc WHERE td_depo_docs.in_date >= @date_b AND td_depo_docs.in_date <= @date_e AND td_depo_docs.id = td_stock_moves.id AND NOT EXISTS(SELECT 1 FROM #rep WHERE #rep.doc_id = td_depo_docs.id) AND td_stock_moves.s_subacc_id = td_depo_subacc.id AND td_depo_subacc.depo_acc_id = @depo_acc_id AND .ITEMS_EXISTS(td_depo_docs.id) INSERT INTO #rep( doc_id, -- OPERATION doc_sum, -- SUM stock_value_id, -- Тип ЦБ stock_id ) SELECT td_depo_docs.id, 0, null, td_stock_moves.stock_id FROM td_depo_docs, td_stock_moves, td_depo_subacc WHERE td_depo_docs.in_date >= @date_b AND td_depo_docs.in_date <= @date_e AND td_depo_docs.id = td_stock_moves.id AND NOT EXISTS(SELECT 1 FROM #rep WHERE #rep.doc_id = td_depo_docs.id) AND td_stock_moves.t_subacc_id = td_depo_subacc.id AND td_depo_subacc.depo_acc_id = @depo_acc_id AND .ITEMS_EXISTS(td_depo_docs.id) --select * from #rep select /*(select isnull(t_classvalues.name,t_classvalues.remark) from t_classvalues where t_classvalues.id=bill.stock_value_id) stock_class,*/ null as stock_class, --!!! doc.out_no client_ref, doc.in_date our_date_d, doc.in_no our_ref, isnull(td_stock_emis.stock_rate_code,'н/д') stock_isin, td_stock_emis.stock_name stock_name, /* (select stock_type_name from t_stock_types where id=stock.stock_type_id) stock_type, */ null as stock_type, --!!! move.stock_qty_in, (select (case upper(type_code) when 'D_STOCK_IN' then 'Получение' when 'D_STOCK_OUT' then 'Поставка' when 'STOCK_MOVE' then 'Перевод' when 'CANCEL_MISSION' then 'Отмена инстр.' when 'STOCK_TRANSFER' then 'Перемещение' else 'н/д' end) from t_items, t_types where t_items.id=doc.id and t_types.id=t_items.type_id) oper_type, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.deliver_agent_id),'н/д') counterpart, isnull((select t_partners.partner_short_name from t_partners where t_partners.id=move.keep_traject_end_id),'н/д') sett_place, doc.settlement_date sett_date, doc.arch_date, bill.doc_sum sum_total, convert(decimal(18,4), round(bill.doc_sum*(@vat - 1.0)/@vat,2)) sum_tax, @vat vat, -- Заголовок @date_b date_b_d, @date_e date_e_d, @doc_no doc_no, @doc_date doc_date, @partner_name partner_name, @partner_address partner_address, @depo_acc_no depo_acc_no from #rep bill, td_depo_docs doc, td_stock_moves move, td_stock_emis where bill.doc_id = doc.id and bill.doc_id *= move.id and bill.stock_id *= td_stock_emis.id order by doc.in_date, doc.in_no $ENDTEXT(13542204) $ENDFORM $ACTION(ACTION_CANCEL_OPER2BILL_OUT) name=На уточнение бэком class=9 form=null target_state=null procedure=ap_11535000001066294 patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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) ---.UPDATE_STATE .ACTION_HISTORY .GET_PROPS .OPERS_ROLL(ALL) declare @pos_id numeric /*-------Проводки ----------*/ declare cur1 cursor for select tb_baysale_docitems.id from tb_baysale_docitems,td_depo_docs,t_types t,t_items i,t_states s where in_date>=@date_b and in_date<=@date_e and td_depo_docs.id=tb_baysale_docitems.id and i.id=td_depo_docs.id and i.state_id=s.id and s.class_id=0 and t.id=i.type_id and t.type_code in ('DEALINGS_VIA_BROKER','DEALINGS_VIA_BROKER_SALE','DOG_DEALINGS_BAY_VBR','DOG_DEALINGS_SALE_VBR') order by in_date,in_no open cur1 fetch cur1 into @pos_id while .CURSOR_STATE=0 begin delete t_items from td_comis2oper where td_comis2oper.id=t_items.id and td_comis2oper.item_id=@pos_id and .ITEMS_EXISTS_BY_TYPE_STATE(td_comis2oper.id,'TD_COMIS2OPER','PODT_LAST') delete td_comis2oper where td_comis2oper.item_id=@pos_id and .ITEMS_EXISTS_BY_TYPE_STATE(td_comis2oper.id,'TD_COMIS2OPER','PODT_LAST') fetch cur1 into @pos_id end close cur1 .DEALLOCATE cur1 declare cur2 cursor for select id from td_depo_doc2bill where bill_id=@id open cur2 fetch cur2 into @pos_id while .CURSOR_STATE=0 begin exec ap_can_exec_com_calc null,@pos_id fetch cur2 into @pos_id end close cur2 .DEALLOCATE cur2 commit tran $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION_END_OPER2BILL_OUT) name=Подтвердить бэком class=9 form=null target_state=null procedure=ap_11535000001066295 patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 -- #define PRINT_DEBUG_INFO select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) /* .CHECK_USER .CHECK_UPDATE */ begin tran .GET_PROPS /* update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, cur_id=@cur_id, bill_list_sum=doc_sum*@sum_rate where bill_id=@id */ declare @vat money select @vat = 1+convert(money,(.GET_NDS_RATE))/100.0 /* select @sum_total=sum(isnull(doc_sum,0)) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) select @clear_sum_total = round(@sum_total/@vat,2) select @sum_tax = @sum_total - @clear_sum_total .UPDATE(ALL) */ .UPDATE_STATE .ACTION_HISTORY commit tran create table #inv2obor(investor_id numeric,s_sum money,qty money,com money null) declare @pos_id numeric, @full_qty money, @full_sum money, @investor_id numeric, @sum money, @qty money, @s money, @com money declare cur cursor for select id from td_depo_doc2bill where bill_id=@id and type_exec_id in (1,2,3) and .ITEMS_EXISTS_BY_TYPE(td_depo_doc2bill.id,'BILL_OUT_COM_OPER') open cur fetch cur into @pos_id while .CURSOR_STATE=0 begin .TYPE_GET('BILL_OUT_COM_OPER',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_partition2investor_id1',@type_partition2investor_id1) /*if @type_bill_display_id1=1 begin insert #inv2obor(investor_id,s_sum,qty,com) select investor_id,deal_sum,stock_qty,@doc_sum1 from tb_bill2dealings where pos2bill_id=@pos_id end else*/ if @type_bill_display_id1 in (2,1) begin if @type_partition2investor_id1=1 begin insert #inv2obor(investor_id,s_sum,qty) select investor_id,sum(deal_sum*bay_or_sale),sum(stock_qty*bay_or_sale) from tb_bill2dealings where pos2bill_id=@pos_id group by investor_id select @full_qty=(select sum(qty) from #inv2obor) select @full_sum=(select sum(s_sum) from #inv2obor) end else if @type_partition2investor_id1=2 begin insert #inv2obor(investor_id,s_sum,qty) select investor_id,sum(deal_sum),sum(stock_qty) from tb_bill2dealings where pos2bill_id=@pos_id group by investor_id select @full_qty=(select sum(qty) from #inv2obor) select @full_sum=(select sum(s_sum) from #inv2obor) end else if @type_partition2investor_id1=3 begin insert #inv2obor(investor_id,s_sum,qty) select investor_id,deal_sum,stock_qty from tb_bill2dealings where pos2bill_id=@pos_id select @full_qty=(select sum(qty) from #inv2obor) select @full_sum=(select sum(s_sum) from #inv2obor) end if @part_sum_id1=1 begin update #inv2obor set com=round(convert(money,(convert(double precision,@doc_sum1)*convert(double precision,abs(s_sum))/convert(double precision,@full_sum,2))),2) end else if @part_sum_id1=2 begin update #inv2obor set com=round(convert(money,(convert(double precision,@doc_sum1)*convert(double precision,abs(qty))/convert(double precision,@full_qty,2))),2) end end declare curcur cursor for select investor_id,s_sum,qty,abs(com) from #inv2obor open curcur fetch curcur into @investor_id,@sum,@qty,@com while .CURSOR_STATE=0 begin if @part_sum_id1=1 select @s=@sum else select @s=@qty if @type_bill_display_id1 in (2,1) begin ---.EXIT_MESSAGE_PARM('!!!',@type_exec_id1) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_partition2investor_id1',@type_partition2investor_id1) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_exec_id1', @type_exec_id1) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @s',@s) if @type_partition2investor_id1 in (1,2,3) begin if @type_exec_id1=1 begin if @s<0 /*Продаж больше*/ begin ---- Ok! Writed .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: ap_profit2loss',null) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @investor_id',@investor_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @pos_id',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @com',@com) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) exec ap_profit2loss @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id -- exec ap_other2sale @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id end else if @s>0 /*Покупок больше*/ begin ---- Ok! Writed .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: ap_getbay',null) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @investor_id',@investor_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @pos_id',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @com',@com) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) exec ap_getbay @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id -- exec ap_other2sale @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id end end else begin ---- Ok! Writed .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: ap_other2sale',null) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @investor_id',@investor_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @pos_id',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @com',@com) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) exec ap_other2sale @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id end end else begin ---.EXIT_MESSAGE_PARM('!!!',@type_exec_id1) ---- Ok! Writed .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: ap_other2sale',null) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @investor_id',@investor_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @pos_id',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @com',@com) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) exec ap_other2sale @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id end end else begin ---- Ok! Writed .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: ap_ab2pay',null) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @investor_id',@investor_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @pos_id',@pos_id) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @com',@com) .DEBUG_INFO('ivan','ACTION_END_OPER2BILL_OUT: @type_bill_display_id1',@type_bill_display_id1) exec ap_ab2pay @sid,@investor_id,@pos_id,@com,@type_bill_display_id1,@action_history_id,@action_id end fetch curcur into @investor_id,@sum,@qty,@com end close curcur .DEALLOCATE curcur delete #inv2obor fetch cur into @pos_id end close cur .DEALLOCATE cur .EXEC_ACTION(@sid,'BILL_OUT','OPER_BILL_OUT_BACK') end $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION_INSERT) name=Импорт МИДАС class=1 form=D_DEPO_MIDAS_LIST_IMP target_state=null procedure=ap_11535000003459714 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) create procedure dbo.%PROC% @brc varchar(255), @cnum varchar(255), @ccy varchar(255), @acod varchar(255), @sq varchar(255), @d varchar(255), @pstdt varchar(255), @valdt varchar(255), @amount varchar(255), @narrative varchar(255) as declare @sid varchar(30) .BEGIN('N') .CHECK_USER if @brc not in ('001', '002', '006') -- Отсекаем комментарии по филиалу return declare @set_class_type_id numeric declare @set_class_value_id numeric declare @partner_id numeric declare @pay_cur_id numeric declare @pay_sum decimal(18,4) declare @mess varchar(255) declare @doc_year int declare @doc_number varchar(255) declare @bill_id numeric declare @doc2bill_id numeric declare @bill_pos_no int declare @li_pos int -- -- Код партнера -- select @set_class_type_id = t_classes.id from t_classes where upper(t_classes.code) = upper('PARTNER_CODE') and exists(select 1 from t_items, t_states where t_items.id=t_classes.id and t_states.id=t_items.state_id and t_states.class_id=0) select @set_class_value_id = t_classvalues.id from t_classvalues where upper(t_classvalues.code) = upper('MASTER') and t_classvalues.class_id = @set_class_type_id and exists(select 1 from t_items, t_states where t_items.id=t_classvalues.id and t_states.id=t_items.state_id and t_states.class_id=0) select @partner_id = t_item2class.item_id from t_item2class where upper(t_item2class.code) = upper(@cnum) and t_item2class.value_id = @set_class_value_id and exists(select 1 from t_items, t_states where t_items.id=t_item2class.id and t_states.id=t_items.state_id and t_states.class_id=0) if @partner_id is null begin select @mess = 'Партнер с Мастер-кодом ' + upper(@cnum) + ' не найден' .EXIT_MESSAGE(@mess) end -- -- Валюта -- select @pay_cur_id = .CUR((upper(@ccy))) if @pay_cur_id is null begin select @mess = 'Валюта с кодом ' + upper(@ccy) + ' не найдена' .EXIT_MESSAGE(@mess) end -- -- Сумма -- select @amount = replace(@amount, ',', '') select @pay_sum = convert(decimal(18,4), @amount) -- -- Парсинг комментария -- if substring(@narrative, 8, 9) <> 'DEPO SERV' .EXIT_MESSAGE('Неверный формат narrative') select @narrative = ltrim(substring(@narrative, 17, len(@narrative) - 16)) -- Год select @doc_year = convert(int, substring(@narrative, 1, 4)) select @narrative = ltrim(substring(@narrative, 6, len(@narrative) - 5)) -- Номер select @li_pos = charindex(' ', @narrative) select @doc_number = substring(@narrative, 1, @li_pos - 1) select @narrative = ltrim(substring(@narrative, @li_pos + 1, len(@narrative) - @li_pos)) -- Позиция select @bill_pos_no = convert(int, @narrative) -- -- Поиск исходящего счета -- select @bill_id = t_schfact.id from t_schfact where upper(t_schfact.doc_number) = upper(@doc_number) and datepart(year, t_schfact.doc_date) = @doc_year and t_schfact.from_partner_id = @partner_id and .ITEMS_EXISTS_BY_TYPE(t_schfact.id, 'BILL_OUT') if @bill_id is null begin select @mess = 'Исходящий счет с номером ' + @doc_number + ' за ' + convert(varchar(4), @doc_year) + ' год не найден' .EXIT_MESSAGE(@mess) end -- -- Проводка оплаты -- .TYPE_INIT('BILL_OUT_PAYS', 1) .TYPE_ASSIGN(bill_id, @bill_id, 1) .TYPE_ASSIGN(pay_sum, @pay_sum, 1) .TYPE_ASSIGN(pay_cur_id, @pay_cur_id, 1) .TYPE_INSERT('BILL_OUT_PAYS', 'CRT', 1) declare @bill_id_s varchar(30) select @bill_id_s = convert(varchar, @bill_id) .EXEC_ACTION(@bill_id_s, 'BILL_OUT', 'ACTION8') .END $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION11) name=На оплату class=9 form=null target_state=CRT procedure=ap_10000000000052262 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 /*-------Проводки ----------*/ .GET_PROPS update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, bill_list_sum=round(doc_sum * @sum_rate, 2) where bill_id=@id select @sum_total = isnull(sum(td_depo_doc2bill.doc_sum), 0), @sum_tax = isnull(sum(td_depo_doc2bill.doc_tax), 0), @clear_sum_total = isnull(sum(td_depo_doc2bill.clear_doc_sum), 0) from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) .UPDATE(ALL) .UPDATE_STATE .ACTION_HISTORY /* declare @doc_name varchar(255),@rate_sum money select @doc_name = "Задолженность по " + .ITEM_NAME(@id) select @rate_sum = @sum_total*@sum_rate .OPERATION('DEPO','ACCOUNT',OPERDAY,'76.1','46',@rate_sum,@rate_cur_id,OPERDAY,0,0,@doc_name) .UPDATE_SUBC('D','partners',@from_partner_id) .SUBC_CHECK */ -- -- Номера позиций -- declare cpos cursor for select id, bill_pos_no from td_depo_doc2bill where bill_id=@id for update of bill_pos_no declare @pos_id numeric, @pos_no int, @i int open cpos select @i=1 fetch cpos into @pos_id, @pos_no while .cursor_state=0 begin update td_depo_doc2bill set bill_pos_no = @i where current of cpos fetch cpos into @pos_id, @pos_no select @i=@i+1 end close cpos .deallocate cpos /* по запросу # NT00002132 #ifdef ALD_SECUR .EXEC_ACTION(@sid,'BILL_OUT','ACTION_END_OPER2BILL_OUT') #endif */ commit tran $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION12) name=Расчет процента за депозитарные услуги class=9 form=null target_state=null procedure=ap_11535000003006744 patterns=GENERIC_MOVE user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) create procedure dbo.%PROC% @sid varchar(30) = null as .BEGIN('N') .CHECK_USER .MONEY_VAR(@vat1) .MONEY_VAR(@vat2) .MONEY_VAR(@ret_sum) .MONEY_VAR(@sum_total) .MONEY_VAR(@bill_rate) .ID_VAR(@bill_cur_id) declare @date_b datetime, @date_e datetime begin tran .UPDATE_STATE .ACTION_HISTORY select @id = convert(numeric,@sid) select @vat1=convert(money,.GET_CONST('RET_PERSEN')) select @vat2=1 + convert(money,.GET_CONST('VAT'))/100 select @ret_sum = (select isnull(sum(isnull(bill_list_sum,0)),0) from td_depo_doc2bill, t_items, t_types, t_states where bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 and t_types.id=t_items.type_id and substring(upper(t_types.type_code),1,12)='BILL_OUT_RET') select @bill_cur_id = td_query4bills.bill_cur_id, @bill_rate = td_query4bills.bill_rate, @date_b = td_query4bills.date_b, @date_e = td_query4bills.date_e from td_depo_docs,td_query4bills where td_depo_docs.id = @id and td_query4bills.id = td_depo_docs.foundation_id if @vat1 is not null and @vat1 > 0 begin select @sum_total = (@ret_sum / 100) * @vat1 if @sum_total != 0 begin .TYPE_INIT('BILL_OUT_COM_ANY',1) .TYPE_ASSIGN(bill_id,@id,1,1) .TYPE_ASSIGN(bill_type,1,1,1) .TYPE_ASSIGN(rate_cur_id,@bill_cur_id,1,1) .TYPE_ASSIGN(doc_sum,(@sum_total*@vat2),1,1) .TYPE_ASSIGN(doc_description,('за период с ' + .DATE_TO_STR(@date_b) + ' по ' + .DATE_TO_STR(@date_e)),1,1) .TYPE_ASSIGN(rate,@bill_rate,1,1) .TYPE_ASSIGN(bill_type_description,'Привлечение депозитария - доминициата',1,1) .TYPE_ASSIGN(bill_list_sum,(@sum_total*@vat2*@bill_rate),1,1) .TYPE_INSERT('BILL_OUT_COM_ANY','CRT',1) end end commit tran .END $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION2) name=На уточнение class=9 form=null target_state=ED procedure=ap_10000000000052263 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 /*-------Проводки ----------*/ .OPERS_ROLL .ARH_FLAG_CLEAR #ifdef ALD_SECUR .EXEC_ACTION(@sid,'BILL_OUT','ACTION_CANCEL_OPER2BILL_OUT') #endif commit tran $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION3) name=Добавить class=1 form=D_DEPO_BILL_OUT target_state=ED procedure=ap_10000000000052264 patterns=GENERIC_INSERT_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=2469 height=2072 proc_text=$TEXT(13542204) 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) if @doc_number is null select @doc_number = (select max(convert(int,doc_number)) from t_schfact where YEAR(doc_date) = YEAR(@doc_date) and isnumeric(doc_number)=1 -- John Yashin 20/01/05 and .ITEMS_EXISTS_BY_TYPE(t_schfact.id,'BILL_OUT')) + 1 -- John Yashin 20.01.05 -- ADD John Yashin 26.01.05 if exists(select 1 from t_schfact,t_items,t_states where rtrim(ltrim(UPPER(t_schfact.doc_number))) = rtrim(ltrim(UPPER(@doc_number))) and YEAR(t_schfact.doc_date) = YEAR(@doc_date) and t_schfact.id=t_items.id and t_items.type_id = @type_id and t_items.id != @id and t_items.state_id=t_states.id and t_states.class_id !=2) begin rollback tran raiserror 40000 'Документ с таким значением "Номер счета", уже существует в этом году' return end -------------- update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, bill_list_sum=round(doc_sum * @sum_rate, 2) where bill_id=@id select @sum_total = isnull(sum(td_depo_doc2bill.doc_sum), 0), @sum_tax = isnull(sum(td_depo_doc2bill.doc_tax), 0), @clear_sum_total = isnull(sum(td_depo_doc2bill.clear_doc_sum), 0) from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) begin tran .UPDATE(ALL,1) .UPDATE_ITEMS .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select @sid = convert(varchar,@id) select @sid end $ENDTEXT(13542204) $BIND(BIND1) type=BILL_OUT_LIST_GRP action=FORM1 class=1 order=null idname=bill_id_s $ENDBIND $ENDACTION $ACTION(ACTION4) name=Изменить class=2 form=D_DEPO_BILL_OUT target_state=null procedure=ap_10000000000052266 patterns=GENERIC_UPDATE_P1 user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=3497 height=1820 proc_text=$TEXT(13542204) 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) .INIT_VARS(AFTER,ALL,1) .DEPO_CHK_NO(@id,@in_no,@depo_doc_type) if @doc_number is null select @doc_number = (select max(convert(int,doc_number)) from t_schfact where YEAR(doc_date) = YEAR(@doc_date) and isnumeric(doc_number)=1 -- John Yashin 26/01/05 and .ITEMS_EXISTS_BY_TYPE(t_schfact.id,'BILL_OUT')) + 1 -- John Yashin 26.01.05 -- ADD John Yashin 26.01.05 if exists(select 1 from t_schfact,t_items,t_states where rtrim(ltrim(UPPER(t_schfact.doc_number))) = rtrim(ltrim(UPPER(@doc_number))) and YEAR(t_schfact.doc_date) = YEAR(@doc_date) and t_schfact.id=t_items.id and t_items.type_id = @type_id and t_items.id != @id and t_items.state_id=t_states.id and t_states.class_id !=2) begin rollback tran raiserror 40000 'Документ с таким значением "Номер счета", уже существует в этом году' return end -------------- update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, bill_list_sum=round(doc_sum * @sum_rate, 2) where bill_id=@id select @sum_total = isnull(sum(td_depo_doc2bill.doc_sum), 0), @sum_tax = isnull(sum(td_depo_doc2bill.doc_tax), 0), @clear_sum_total = isnull(sum(td_depo_doc2bill.clear_doc_sum), 0) from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) .UPDATE(ALL,1) .UPDATE_ITEMS .RELGEN .UPDATE_STATE .ACTION_HISTORY commit tran select sid = convert(varchar, @id) $ENDTEXT(13542204) $BIND(BIND1) type=BILL_OUT_LIST_GRP action=FORM1 class=1 order=10 idname=bill_id_s $ENDBIND $BIND(BIND2) type=BILL_OUT action=D_DEPO_BILL_OUT_SIGN_ED class=1 order=2 idname=null $ENDBIND $ENDACTION $ACTION(ACTION5) name=Удалить class=3 form=D_DEPO_BILL_OUT target_state=DEL procedure=ap_10000000000052268 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 declare @doc_id numeric declare doc_cur cursor for select id from td_depo_doc2bill where bill_id=@id for read only open doc_cur fetch doc_cur into @doc_id while .CURSOR_STATE=0 begin .TYPE_DELETE(@doc_id,'BILL_OUT_LIST_GRP') if @@error!=0 begin rollback tran return end fetch doc_cur into @doc_id end close doc_cur .DEALLOCATE doc_cur .UPDATE_STATE .ACTION_HISTORY commit tran $ENDTEXT(13542204) $ENDACTION $ACTION(ACTION8) name=Подтвердить оплату class=9 form=null target_state=null procedure=ap_10000000000052271 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2395 height=1992 proc_text=$TEXT(13542204) 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 .GET_PROPS /*-------Проводки ----------*/ declare @bill_sum decimal(18,4) declare @pay_sum decimal(18,4) select @bill_sum = isnull((select sum(bill_list_sum) from td_depo_doc2bill where td_depo_doc2bill.bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id)),0) select @pay_sum = isnull((select sum(pay_sum) from td_bill_out_pays where td_bill_out_pays.bill_id=@id and .ITEMS_EXISTS(td_bill_out_pays.id)),0) --if @bill_sum>0 and @pay_sum>0 begin if @bill_sum>0 begin -- Change John 28.01.05 if @pay_sum = 0 begin -- Переводим счет в статус НА ОПЛАТЕ John 28.01.05 select @exec_date=null -- ADD select @new_state_id = (select t_states.id from t_states, t_types where t_states.type_id=t_types.id and upper(t_types.type_code)='BILL_OUT' and upper(t_states.state_code)='CRT') --.item_move_state(@id,'PART') end else if @bill_sum>@pay_sum begin -- Переводим счет в статус оплачен частично select @exec_date=null -- ADD select @new_state_id = (select t_states.id from t_states, t_types where t_states.type_id=t_types.id and upper(t_types.type_code)='BILL_OUT' and upper(t_states.state_code)='PART') --.item_move_state(@id,'PART') end else begin -- Переводим счет в статус оплачен select @exec_date=null -- ADD select @new_state_id = (select t_states.id from t_states, t_types where t_states.type_id=t_types.id and upper(t_types.type_code)='BILL_OUT' and upper(t_states.state_code)='PAYED') --.item_move_state(@id,'PAYED') -- select @exec_date=.OPERDAY() -- Comment John 28.01.05 -- ADD John 28.01.05 select @exec_date=(select max(td_bill_out_pays.pay_date) from td_bill_out_pays where td_bill_out_pays.bill_id=@id and .ITEMS_EXISTS(td_bill_out_pays.id)) end end .UPDATE .UPDATE_STATE .ACTION_HISTORY commit tran $ENDTEXT(13542204) $ENDACTION $ACTION(BILL_OUT_RECALC) name=Пересчитать сумму счета class=9 form=null target_state=null procedure=ap_10000000000052273 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 */ .GET_PROPS update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, bill_list_sum=doc_sum*@sum_rate where bill_id=@id /* select @sum_total = isnull(sum(td_depo_doc2bill.doc_sum),0), @sum_tax = isnull(sum(td_depo_doc2bill.doc_tax),0), @clear_sum_total = isnull(sum(td_depo_doc2bill.clear_doc_sum),0) from td_depo_doc2bill, t_items, t_states where td_depo_doc2bill.bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 */ -- John 01.02.05 declare @vat decimal(18,4) select @sum_total = isnull(sum(isnull(doc_sum,0)),0), @vat = isnull(max(isnull(vat,0)),0) from td_depo_doc2bill, t_items, t_states where td_depo_doc2bill.bill_id=@id and t_items.id=td_depo_doc2bill.id and t_states.id=t_items.state_id and t_states.class_id=0 select @sum_total = round(@sum_total, 2) -- Расчет НДС select @sum_tax = round(@sum_total * @vat/(1.0 + @vat), 0) select @clear_sum_total = @sum_total - @sum_tax /* доработка по письму ММБ от 07/2004 declare @withvat int declare @vat decimal(18,8) select @withvat = (select withvat from td_price_lists where id=@price_list_id) select @vat = convert(decimal(18,8), (.GET_CONST('VAT')))/100 if @withvat=0 begin select @sum_tax = round(@clear_sum_total * @vat, 2) select @sum_total = @clear_sum_total + @sum_tax end else begin select @sum_tax = round((@sum_total * @vat) / (1.0 + @vat), 2) select @clear_sum_total = @sum_total - @sum_tax end */ .UPDATE_ITEMS .UPDATE .UPDATE_STATE .ACTION_HISTORY /*-------Проводки ----------*/ $ENDTEXT(13542204) $ENDACTION $ACTION(D_DEPO_BILL_MIDAS_EXP) name=Экспорт МИДАС class=2 form=D_DEPO_MIDAS_LIST_EXP target_state=null procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=3058 height=1732 proc_text=null $ENDACTION $ACTION(D_DEPO_BILL_OUT_SIGN_ED) name=Подписи (изм) class=2 form=D_DEPO_BILL_OUT_SIGN target_state=null procedure=ap_11535000007007671 patterns=GENERIC_UPDATE_P2 user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542204) 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 .UPDATE(ALL,2) commit tran .END $ENDTEXT(13542204) $ENDACTION $ACTION(KILL) name=Аннулировать class=9 form=null target_state=KILL procedure=ap_11535000007814927 patterns=GENERIC_MOVE user_define=0 isvisible=0 istab=0 posx=null posy=null width=null height=null proc_text=$TEXT(13542204) 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(13542204) $ENDACTION $ACTION(OPER_BILL_OUT_BACK) name=Провести на задолженность class=9 form=null target_state=null procedure=ap_11535000001066296 patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(13542205) 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 .GET_PROPS /* update td_depo_doc2bill set rate_cur_id=@rate_cur_id, rate=@sum_rate, cur_id=@cur_id, bill_list_sum=doc_sum*@sum_rate where bill_id=@id */ declare @vat money select @vat = 1+convert(money,(.GET_NDS_RATE))/100.0 /* select @sum_total=sum(isnull(doc_sum,0)) from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS(td_depo_doc2bill.id) select @clear_sum_total = round(@sum_total/@vat,2) select @sum_tax = @sum_total - @clear_sum_total .UPDATE(ALL) */ .UPDATE_STATE .ACTION_HISTORY declare @pos_id numeric, @com_acc_id numeric, @cred_acc_id numeric, @deb_acc_id numeric, @com_brok_acc_id numeric declare @is_realiz int, @is_p2l_comis int, @is_com_in int, @is_allow_short4own int, @asset4pereoc_type_id numeric, @out_method_id numeric, @plan_money numeric, @plan_secur numeric, @broker_id numeric, @res_mess varchar(255), @portfolio_brok_id numeric, @portfolio_sub_brok_id numeric, @value_id numeric, @client_id numeric, @comment varchar(255) .BACK_GET_ORG_PARMS(@to_partner_id,@broker_id,@plan_money,@plan_secur,@out_method_id,@is_realiz,@is_p2l_comis,@is_com_in,@is_allow_short4own,@asset4pereoc_type_id) .ACCID_FROM_CONST2PLAN(@com_acc_id,'BACK_ACC_COMISSIONS',@plan_money,1,1,'Счет комиссии',@res_mess) .ACCID_FROM_CONST2PLAN(@cred_acc_id,'BACK_ACC_OBLIG_COMIS',@plan_money,3,1,'Счет кредиторской задолженности клиента',@res_mess) .ACCID_FROM_CONST2PLAN(@deb_acc_id,'BACK_ACC_OBLIG_COMIS',@plan_money,2,1,'Счет дебиторской задолженности перед клиентом',@res_mess) .ACCID_FROM_CONST2PLAN(@com_brok_acc_id,'BACK_ACC_BROK_COMISS_IN',@plan_money,1,3,'Счет полученной брокером комиссии',@res_mess) select @value_id=t_classvalues.id from t_classvalues, t_classes where t_classes.code='COMMON' and t_classvalues.class_id=t_classes.id and t_classvalues.code='YES' select @portfolio_brok_id = min(tb_portfolio.id) from tb_portfolio, tb_portfolio2investor where tb_portfolio2investor.investor_id = @broker_id and tb_portfolio2investor.portfolio_id = tb_portfolio.id and tb_portfolio.charge_flag = 1 and .ITEMS_EXISTS_BY_TYPE(tb_portfolio.id,'portfolio') if @portfolio_brok_id is null select @portfolio_brok_id = min(tb_portfolio.id) from tb_portfolio where tb_portfolio.charge_flag = 1 and .ITEMS_EXISTS_BY_TYPE(tb_portfolio.id,'portfolio') and .ITEMS_EXISTS_BY_CLASS_VALUE(tb_portfolio.id,@value_id) if @portfolio_brok_id is null .EXIT_MESSAGE('Портфель, используемый для начисления комиссий, не найден') select @portfolio_sub_brok_id=min(tb_portfolio_section.id) from tb_portfolio_section where tb_portfolio_section.investor_id = @broker_id and tb_portfolio_section.charge_flag = 1 and .ITEMS_EXISTS_BY_TYPE(tb_portfolio_section.id,'portfolio_section') if @portfolio_sub_brok_id is null .EXIT_MESSAGE('Раздел учета, используемый для начисления комиссий, не найден') declare cur cursor for select id from td_depo_doc2bill where bill_id=@id and .ITEMS_EXISTS_BY_TYPE(td_depo_doc2bill.id,'BILL_OUT_COM_OPER') and type_exec_id=4 open cur fetch cur into @pos_id while .CURSOR_STATE=0 begin .TYPE_GET('BILL_OUT_COM_OPER',@pos_id) select @client_id=client_id from tb_contracts where id=@contract_id1 select @comment='Задолженность клиента по вознаграждению' .OPERATION(@to_partner_id,@plan_money,@in_date,@com_acc_id,@cred_acc_id,@doc_sum1,@cur_id1,@in_date,null,null,@comment,N,@oper_id,@id,@action_id,@action_history_id) .UPDATE_SUBC(D,'investors',@contract_id1) .UPDATE_SUBC(D,'portfolio',@portfolio_id1) .UPDATE_SUBC(D,'investor2portfolio',@portfolio_sub_id1) .UPDATE_SUBC(D,'price_position',@price_position_id1) .UPDATE_SUBC(D,'contragents',@contragent_id1) .UPDATE_SUBC(D,'doc_sec',@id) .UPDATE_SUBC(K,'portfolio',@portfolio_id1) .UPDATE_SUBC(K,'investor2portfolio',@portfolio_sub_id1) .UPDATE_SUBC(K,'investors',@contract_id1) .UPDATE_SUBC(K,'contragents',@contragent_id1) .SUBC_CHECK .OPERATION(@to_partner_id,@plan_money,@in_date,@com_brok_acc_id,@com_acc_id,@doc_sum1,@cur_id1,@in_date,null,null,@comment,N,@oper_id,@id,@action_id,@action_history_id) .UPDATE_SUBC(K,'investors',@contract_id1) .UPDATE_SUBC(K,'portfolio',@portfolio_id1) .UPDATE_SUBC(K,'investor2portfolio',@portfolio_sub_id1) .UPDATE_SUBC(K,'price_position',@price_position_id1) .UPDATE_SUBC(K,'contragents',@contragent_id1) .UPDATE_SUBC(K,'doc_sec',@id) .UPDATE_SUBC(D,'investor2portfolio',@portfolio_sub_id1) .UPDATE_SUBC(D,'investors',@contract_id1) .SUBC_CHECK .OPERATION(@to_partner_id,@plan_money,@in_date,@deb_acc_id,@com_brok_acc_id,@doc_sum1,@cur_id1,@in_date,null,null,@comment,N,@oper_id,@id,@action_id,@action_history_id) .UPDATE_SUBC(D,'portfolio',@portfolio_brok_id) .UPDATE_SUBC(D,'investor2portfolio',@portfolio_sub_brok_id) .UPDATE_SUBC(D,'investors',@broker_id) .UPDATE_SUBC(D,'contragents',@client_id) .UPDATE_SUBC(K,'investor2portfolio',@portfolio_sub_id1) .UPDATE_SUBC(K,'investors',@contract_id1) .SUBC_CHECK fetch cur into @pos_id end close cur .DEALLOCATE cur commit tran $ENDTEXT(13542205) $ENDACTION $STATE2ACTION(BEG.ACTION_INSERT) state=BEG action=ACTION_INSERT $ENDSTATE2ACTION $STATE2ACTION(BEG.ACTION3) state=BEG action=ACTION3 $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION_CANCEL_OPER2BILL_OUT) state=CRT action=ACTION_CANCEL_OPER2BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION2) state=CRT action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(CRT.ACTION8) state=CRT action=ACTION8 $ENDSTATE2ACTION $STATE2ACTION(CRT.D_BILL_QUERY_BILL_PORTFOLIO) state=CRT action=D_BILL_QUERY_BILL_PORTFOLIO $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_MIDAS_EXP) state=CRT action=D_DEPO_BILL_MIDAS_EXP $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT) state=CRT action=D_DEPO_BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ADD) state=CRT action=D_DEPO_BILL_OUT_ADD $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ADDON_DETAIL) state=CRT action=D_DEPO_BILL_OUT_ADDON_DETAIL $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ADDON_HEADER) state=CRT action=D_DEPO_BILL_OUT_ADDON_HEADER $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_BILL) state=CRT action=D_DEPO_BILL_OUT_BILL $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ENG_OPER_DET) state=CRT action=D_DEPO_BILL_OUT_ENG_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ENG_RETO_DET) state=CRT action=D_DEPO_BILL_OUT_ENG_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_ENG_SAVE_DET) state=CRT action=D_DEPO_BILL_OUT_ENG_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_FACT) state=CRT action=D_DEPO_BILL_OUT_FACT $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_RUS_OPER_DET) state=CRT action=D_DEPO_BILL_OUT_RUS_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_RUS_RETO_DET) state=CRT action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_RUS_SAVE_DET) state=CRT action=D_DEPO_BILL_OUT_RUS_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_SIGN) state=CRT action=D_DEPO_BILL_OUT_SIGN $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_BILL_OUT_SIGN_ED) state=CRT action=D_DEPO_BILL_OUT_SIGN_ED $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_INVOICE_ENG_EUR) state=CRT action=D_DEPO_INVOICE_ENG_EUR $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_INVOICE_ENG_RUR) state=CRT action=D_DEPO_INVOICE_ENG_RUR $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_INVOICE_FOR_FOREIGNS) state=CRT action=D_DEPO_INVOICE_FOR_FOREIGNS $ENDSTATE2ACTION $STATE2ACTION(CRT.D_DEPO_INVOICE_SAFEKEEPING) state=CRT action=D_DEPO_INVOICE_SAFEKEEPING $ENDSTATE2ACTION $STATE2ACTION(CRT.KILL) state=CRT action=KILL $ENDSTATE2ACTION $STATE2ACTION(CRT.MMB_DEPO_BILL_OUT_RUS_OPER) state=CRT action=MMB_DEPO_BILL_OUT_RUS_OPER $ENDSTATE2ACTION $STATE2ACTION(CRT.OPER_BILL_OUT_BACK) state=CRT action=OPER_BILL_OUT_BACK $ENDSTATE2ACTION $STATE2ACTION(DEL.D_DEPO_BILL_OUT_RUS_RETO_DET) state=DEL action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION_CANCEL_OPER2BILL_OUT) state=ED action=ACTION_CANCEL_OPER2BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION_END_OPER2BILL_OUT) state=ED action=ACTION_END_OPER2BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION11) state=ED action=ACTION11 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION4) state=ED action=ACTION4 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION5) state=ED action=ACTION5 $ENDSTATE2ACTION $STATE2ACTION(ED.ACTION8) state=ED action=ACTION8 $ENDSTATE2ACTION $STATE2ACTION(ED.D_BILL_QUERY_BILL_PORTFOLIO) state=ED action=D_BILL_QUERY_BILL_PORTFOLIO $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT) state=ED action=D_DEPO_BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ADD) state=ED action=D_DEPO_BILL_OUT_ADD $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ADDON_DETAIL) state=ED action=D_DEPO_BILL_OUT_ADDON_DETAIL $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ADDON_HEADER) state=ED action=D_DEPO_BILL_OUT_ADDON_HEADER $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_BILL) state=ED action=D_DEPO_BILL_OUT_BILL $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ENG_OPER_DET) state=ED action=D_DEPO_BILL_OUT_ENG_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ENG_RETO_DET) state=ED action=D_DEPO_BILL_OUT_ENG_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_ENG_SAVE_DET) state=ED action=D_DEPO_BILL_OUT_ENG_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_FACT) state=ED action=D_DEPO_BILL_OUT_FACT $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_RUS_OPER_DET) state=ED action=D_DEPO_BILL_OUT_RUS_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_RUS_RETO_DET) state=ED action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_RUS_SAVE_DET) state=ED action=D_DEPO_BILL_OUT_RUS_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_SIGN) state=ED action=D_DEPO_BILL_OUT_SIGN $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_BILL_OUT_SIGN_ED) state=ED action=D_DEPO_BILL_OUT_SIGN_ED $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_INVOICE_ENG_EUR) state=ED action=D_DEPO_INVOICE_ENG_EUR $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_INVOICE_ENG_RUR) state=ED action=D_DEPO_INVOICE_ENG_RUR $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_INVOICE_FOR_FOREIGNS) state=ED action=D_DEPO_INVOICE_FOR_FOREIGNS $ENDSTATE2ACTION $STATE2ACTION(ED.D_DEPO_INVOICE_SAFEKEEPING) state=ED action=D_DEPO_INVOICE_SAFEKEEPING $ENDSTATE2ACTION $STATE2ACTION(ED.MMB_DEPO_BILL_OUT_RUS_OPER) state=ED action=MMB_DEPO_BILL_OUT_RUS_OPER $ENDSTATE2ACTION $STATE2ACTION(ED.OPER_BILL_OUT_BACK) state=ED action=OPER_BILL_OUT_BACK $ENDSTATE2ACTION $STATE2ACTION(KILL.ACTION2) state=KILL action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(KILL.D_BILL_QUERY_BILL_PORTFOLIO) state=KILL action=D_BILL_QUERY_BILL_PORTFOLIO $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT) state=KILL action=D_DEPO_BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ADD) state=KILL action=D_DEPO_BILL_OUT_ADD $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ADDON_DETAIL) state=KILL action=D_DEPO_BILL_OUT_ADDON_DETAIL $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ADDON_HEADER) state=KILL action=D_DEPO_BILL_OUT_ADDON_HEADER $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_BILL) state=KILL action=D_DEPO_BILL_OUT_BILL $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ENG_OPER_DET) state=KILL action=D_DEPO_BILL_OUT_ENG_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ENG_RETO_DET) state=KILL action=D_DEPO_BILL_OUT_ENG_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_ENG_SAVE_DET) state=KILL action=D_DEPO_BILL_OUT_ENG_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_FACT) state=KILL action=D_DEPO_BILL_OUT_FACT $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_FACT_DETAIL) state=KILL action=D_DEPO_BILL_OUT_FACT_DETAIL $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_RUS_OPER_DET) state=KILL action=D_DEPO_BILL_OUT_RUS_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_RUS_RETO_DET) state=KILL action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_BILL_OUT_RUS_SAVE_DET) state=KILL action=D_DEPO_BILL_OUT_RUS_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_INVOICE_ENG_EUR) state=KILL action=D_DEPO_INVOICE_ENG_EUR $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_INVOICE_ENG_RUR) state=KILL action=D_DEPO_INVOICE_ENG_RUR $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_INVOICE_FOR_FOREIGNS) state=KILL action=D_DEPO_INVOICE_FOR_FOREIGNS $ENDSTATE2ACTION $STATE2ACTION(KILL.D_DEPO_INVOICE_SAFEKEEPING) state=KILL action=D_DEPO_INVOICE_SAFEKEEPING $ENDSTATE2ACTION $STATE2ACTION(KILL.MMB_DEPO_BILL_OUT_RUS_OPER) state=KILL action=MMB_DEPO_BILL_OUT_RUS_OPER $ENDSTATE2ACTION $STATE2ACTION(PART.ACTION2) state=PART action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(PART.ACTION8) state=PART action=ACTION8 $ENDSTATE2ACTION $STATE2ACTION(PART.D_BILL_QUERY_BILL_PORTFOLIO) state=PART action=D_BILL_QUERY_BILL_PORTFOLIO $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT) state=PART action=D_DEPO_BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ADD) state=PART action=D_DEPO_BILL_OUT_ADD $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ADDON_DETAIL) state=PART action=D_DEPO_BILL_OUT_ADDON_DETAIL $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ADDON_HEADER) state=PART action=D_DEPO_BILL_OUT_ADDON_HEADER $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_BILL) state=PART action=D_DEPO_BILL_OUT_BILL $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ENG_OPER_DET) state=PART action=D_DEPO_BILL_OUT_ENG_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ENG_RETO_DET) state=PART action=D_DEPO_BILL_OUT_ENG_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_ENG_SAVE_DET) state=PART action=D_DEPO_BILL_OUT_ENG_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_FACT) state=PART action=D_DEPO_BILL_OUT_FACT $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_FACT_DETAIL) state=PART action=D_DEPO_BILL_OUT_FACT_DETAIL $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_RUS_OPER_DET) state=PART action=D_DEPO_BILL_OUT_RUS_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_RUS_RETO_DET) state=PART action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_RUS_SAVE_DET) state=PART action=D_DEPO_BILL_OUT_RUS_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_SIGN) state=PART action=D_DEPO_BILL_OUT_SIGN $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_BILL_OUT_SIGN_ED) state=PART action=D_DEPO_BILL_OUT_SIGN_ED $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_INVOICE_ENG_EUR) state=PART action=D_DEPO_INVOICE_ENG_EUR $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_INVOICE_ENG_RUR) state=PART action=D_DEPO_INVOICE_ENG_RUR $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_INVOICE_FOR_FOREIGNS) state=PART action=D_DEPO_INVOICE_FOR_FOREIGNS $ENDSTATE2ACTION $STATE2ACTION(PART.D_DEPO_INVOICE_SAFEKEEPING) state=PART action=D_DEPO_INVOICE_SAFEKEEPING $ENDSTATE2ACTION $STATE2ACTION(PART.KILL) state=PART action=KILL $ENDSTATE2ACTION $STATE2ACTION(PART.MMB_DEPO_BILL_OUT_RUS_OPER) state=PART action=MMB_DEPO_BILL_OUT_RUS_OPER $ENDSTATE2ACTION $STATE2ACTION(PAYED.ACTION2) state=PAYED action=ACTION2 $ENDSTATE2ACTION $STATE2ACTION(PAYED.ACTION8) state=PAYED action=ACTION8 $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_BILL_QUERY_BILL_PORTFOLIO) state=PAYED action=D_BILL_QUERY_BILL_PORTFOLIO $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_MIDAS_EXP) state=PAYED action=D_DEPO_BILL_MIDAS_EXP $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT) state=PAYED action=D_DEPO_BILL_OUT $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ADD) state=PAYED action=D_DEPO_BILL_OUT_ADD $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ADDON_DETAIL) state=PAYED action=D_DEPO_BILL_OUT_ADDON_DETAIL $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ADDON_HEADER) state=PAYED action=D_DEPO_BILL_OUT_ADDON_HEADER $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_BILL) state=PAYED action=D_DEPO_BILL_OUT_BILL $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ENG_OPER_DET) state=PAYED action=D_DEPO_BILL_OUT_ENG_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ENG_RETO_DET) state=PAYED action=D_DEPO_BILL_OUT_ENG_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_ENG_SAVE_DET) state=PAYED action=D_DEPO_BILL_OUT_ENG_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_FACT) state=PAYED action=D_DEPO_BILL_OUT_FACT $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_RUS_OPER_DET) state=PAYED action=D_DEPO_BILL_OUT_RUS_OPER_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_RUS_RETO_DET) state=PAYED action=D_DEPO_BILL_OUT_RUS_RETO_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_RUS_SAVE_DET) state=PAYED action=D_DEPO_BILL_OUT_RUS_SAVE_DET $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_SIGN) state=PAYED action=D_DEPO_BILL_OUT_SIGN $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_BILL_OUT_SIGN_ED) state=PAYED action=D_DEPO_BILL_OUT_SIGN_ED $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_INVOICE_ENG_EUR) state=PAYED action=D_DEPO_INVOICE_ENG_EUR $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_INVOICE_ENG_RUR) state=PAYED action=D_DEPO_INVOICE_ENG_RUR $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_INVOICE_FOR_FOREIGNS) state=PAYED action=D_DEPO_INVOICE_FOR_FOREIGNS $ENDSTATE2ACTION $STATE2ACTION(PAYED.D_DEPO_INVOICE_SAFEKEEPING) state=PAYED action=D_DEPO_INVOICE_SAFEKEEPING $ENDSTATE2ACTION $STATE2ACTION(PAYED.KILL) state=PAYED action=KILL $ENDSTATE2ACTION $STATE2ACTION(PAYED.MMB_DEPO_BILL_OUT_RUS_OPER) state=PAYED action=MMB_DEPO_BILL_OUT_RUS_OPER $ENDSTATE2ACTION $STATE2PROP(BEG.BILL_TYPE_DESCRIPTION) state=BEG prop=BILL_TYPE_DESCRIPTION enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.BOOKKEEPER_SIGN) state=BEG prop=BOOKKEEPER_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.CHIEF_SIGN) state=BEG prop=CHIEF_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.CORRESPONDENT_ID) state=BEG prop=CORRESPONDENT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.CUR_ID) state=BEG prop=CUR_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DATE_B) state=BEG prop=DATE_B enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DATE_E) state=BEG prop=DATE_E enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DEPO_ACC_ID) state=BEG prop=DEPO_ACC_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOC_COMMENT) state=BEG prop=DOC_COMMENT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOC_DATE) state=BEG prop=DOC_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOC_DESCRIPTION) state=BEG prop=DOC_DESCRIPTION enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOC_NUMBER) state=BEG prop=DOC_NUMBER enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.DOCUMENT_FORM_ID) state=BEG prop=DOCUMENT_FORM_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.EXEC_DATE) state=BEG prop=EXEC_DATE 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.FROM_PARTNER_ACC_ID) state=BEG prop=FROM_PARTNER_ACC_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.FROM_PARTNER_ID) state=BEG prop=FROM_PARTNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.IN_DATE) state=BEG prop=IN_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.IN_NO) state=BEG prop=IN_NO 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.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.PRICE_LIST_ID) state=BEG prop=PRICE_LIST_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.RATE_CUR_ID) state=BEG prop=RATE_CUR_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SUM_RATE) state=BEG prop=SUM_RATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SUM_TAX) state=BEG prop=SUM_TAX enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.SUM_TOTAL) state=BEG prop=SUM_TOTAL enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.TO_PARTNER_ACC_ID) state=BEG prop=TO_PARTNER_ACC_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(BEG.TO_PARTNER_ID) state=BEG prop=TO_PARTNER_ID enable=1 mandatory=1 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(CRT.BOOKKEEPER_SIGN) state=CRT prop=BOOKKEEPER_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(CRT.CHIEF_SIGN) state=CRT prop=CHIEF_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.BILL_TYPE_DESCRIPTION) state=ED prop=BILL_TYPE_DESCRIPTION enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.BOOKKEEPER_SIGN) state=ED prop=BOOKKEEPER_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.CHIEF_SIGN) state=ED prop=CHIEF_SIGN 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.CUR_ID) state=ED prop=CUR_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DATE_B) state=ED prop=DATE_B enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DATE_E) state=ED prop=DATE_E enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DEPO_ACC_ID) state=ED prop=DEPO_ACC_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $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=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOC_DESCRIPTION) state=ED prop=DOC_DESCRIPTION enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOC_NUMBER) state=ED prop=DOC_NUMBER enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.DOCUMENT_FORM_ID) state=ED prop=DOCUMENT_FORM_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.EXEC_DATE) state=ED prop=EXEC_DATE 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.FOUNDATION_ID) state=ED prop=FOUNDATION_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.FROM_PARTNER_ACC_ID) state=ED prop=FROM_PARTNER_ACC_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.FROM_PARTNER_ID) state=ED prop=FROM_PARTNER_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.IN_DATE) state=ED prop=IN_DATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.IN_NO) state=ED prop=IN_NO enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.INITIATOR_ID) state=ED prop=INITIATOR_ID enable=1 mandatory=0 visible=1 $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.PRICE_LIST_ID) state=ED prop=PRICE_LIST_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.RATE_CUR_ID) state=ED prop=RATE_CUR_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SUM_RATE) state=ED prop=SUM_RATE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SUM_TAX) state=ED prop=SUM_TAX enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.SUM_TOTAL) state=ED prop=SUM_TOTAL enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.TO_PARTNER_ACC_ID) state=ED prop=TO_PARTNER_ACC_ID enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(ED.TO_PARTNER_ID) state=ED prop=TO_PARTNER_ID enable=1 mandatory=1 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(PART.BOOKKEEPER_SIGN) state=PART prop=BOOKKEEPER_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(PART.CHIEF_SIGN) state=PART prop=CHIEF_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(PAYED.BOOKKEEPER_SIGN) state=PAYED prop=BOOKKEEPER_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(PAYED.CHIEF_SIGN) state=PAYED prop=CHIEF_SIGN enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $ENDDOC