20240522@222012.2330 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@222012.2440 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.2570 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222012.2630 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e629964664e618c05',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222012.2670 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.2790 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222012.2850 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e629964664e618c05','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222012.2900 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.3020 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222012.3080 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e629964664e618c05','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222012.9300 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222012.9330 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@222012.9470 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@222012.9580 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.9740 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@222012.9840 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.9960 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222012.1001 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@222012.1011 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222012.1022 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222012.1028 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e638202664e618c18','aut664e629964664e618c05',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e629964664e618c05'
20240522@222315.4745 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@222315.4758 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@222315.4771 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='15';
20240522@222315.4806 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='15';
20240522@222315.4819 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='15';
20240522@222315.4829 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='15';
20240522@222315.4838 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.4841 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@222315.4855 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@222315.4865 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@222315.4879 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@222315.4891 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.4894 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@222315.4905 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.4908 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@222315.4926 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@222315.4942 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.4945 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@222315.4959 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.4962 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@222315.4972 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.4987 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222315.4993 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5005 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222315.5011 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5022 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222315.5028 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@222315.5041 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222315.5057 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222315.5072 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.5075 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@222315.5086 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5115 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222315.5122 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e642664664e62437b',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222315.5126 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5139 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222315.5145 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e642664664e62437b','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222315.5150 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5162 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222315.5168 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e642664664e62437b','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222315.5641 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222315.5645 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@222315.5660 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@222315.5672 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5687 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@222315.5699 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5711 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222315.5718 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@222315.5728 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222315.5739 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222315.5746 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e676404664e62438b','aut664e642664664e62437b',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e642664664e62437b'
20240522@222512.1905 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@222512.1919 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@222512.1931 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='16';
20240522@222512.1968 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='16';
20240522@222512.1980 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='16';
20240522@222512.1990 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='16';
20240522@222512.1999 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2003 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@222512.2017 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@222512.2027 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@222512.2039 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@222512.2051 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2054 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@222512.2065 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2068 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@222512.2094 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@222512.2111 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2114 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@222512.2138 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2141 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@222512.2151 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2174 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222512.2181 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2193 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222512.2199 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2211 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222512.2217 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@222512.2230 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222512.2246 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222512.2263 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2266 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@222512.2278 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2292 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222512.2299 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e602660664e62b837',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222512.2303 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2318 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222512.2325 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e602660664e62b837','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222512.2330 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2346 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222512.2352 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e602660664e62b837','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222512.2810 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222512.2813 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@222512.2825 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@222512.2836 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2851 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@222512.2860 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2874 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222512.2880 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@222512.2890 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222512.2903 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222512.2909 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e679430664e62b846','aut664e602660664e62b837',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e602660664e62b837'
20240522@222810.5400 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@222810.5414 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@222810.5429 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='17';
20240522@222810.5480 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='17';
20240522@222810.5492 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='17';
20240522@222810.5502 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='17';
20240522@222810.5513 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5515 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@222810.5529 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@222810.5539 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@222810.5551 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@222810.5563 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5566 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@222810.5576 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5578 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@222810.5596 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@222810.5611 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5613 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@222810.5625 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5628 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@222810.5637 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5651 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222810.5657 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5668 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222810.5674 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5685 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222810.5691 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@222810.5703 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222810.5718 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222810.5732 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.5736 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@222810.5746 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5758 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222810.5764 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e665455664e636a8b',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222810.5768 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5780 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222810.5786 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e665455664e636a8b','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222810.5790 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.5802 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222810.5808 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e665455664e636a8b','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222810.6254 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222810.6257 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@222810.6269 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@222810.6280 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.6294 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@222810.6322 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.6334 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222810.6340 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@222810.6351 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222810.6363 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222810.6369 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e610361664e636a9b','aut664e665455664e636a8b',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e665455664e636a8b'
20240522@222925.9359 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@222925.9378 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@222925.9390 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='18';
20240522@222925.9426 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='18';
20240522@222925.9437 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='18';
20240522@222925.9447 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='18';
20240522@222925.9463 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9466 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@222925.9479 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@222925.9489 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@222925.9501 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@222925.9513 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9516 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@222925.9527 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9529 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@222925.9547 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@222925.9563 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9566 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@222925.9579 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9582 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@222925.9591 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9606 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222925.9612 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9624 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222925.9630 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9642 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222925.9648 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@222925.9660 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222925.9676 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@222925.9693 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222925.9696 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@222925.9707 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9719 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@222925.9726 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e603061664e63b5ec',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222925.9730 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9742 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@222925.9748 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e603061664e63b5ec','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222925.9753 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222925.9764 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@222925.9784 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e603061664e63b5ec','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@222926.4740 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@222926.4790 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@222926.6560 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@222926.8130 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222926.1011 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@222926.1150 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222926.1164 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222926.1170 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@222926.1180 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@222926.1192 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@222926.1199 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e622268664e63b61c','aut664e603061664e63b5ec',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e603061664e63b5ec'
20240522@223220.4137 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@223220.4796 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@223220.6848 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='608';
20240522@223220.7081 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='608';
20240522@223220.7178 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='608';
20240522@223220.7387 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='608';
20240522@223220.7474 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223220.7515 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@223220.7797 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='608';
20240522@223220.8003 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='608';
20240522@223307.9956 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@223308.3000 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@223308.2400 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='609';
20240522@223308.4750 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='609';
20240522@223308.5600 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='609';
20240522@223308.7680 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='609';
20240522@223308.8520 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223308.8940 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@223308.1019 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='609';
20240522@223308.1227 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='609';

20240522@223613.7147 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='19';
20240522@223613.7159 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='19';
20240522@223613.7171 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='19';
20240522@223613.7182 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7184 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@223613.7200 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@223613.7212 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@223613.7226 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@223613.7242 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7245 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@223613.7257 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7260 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@223613.7280 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@223613.7297 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7300 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@223613.7314 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7317 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@223613.7328 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7343 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@223613.7350 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7362 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@223613.7369 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7381 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@223613.7388 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@223613.7401 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@223613.7418 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@223613.7436 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7439 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@223613.7452 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7465 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@223613.7474 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e608148664e654db5',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223613.7480 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7493 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@223613.7500 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e608148664e654db5','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223613.7505 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.7518 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@223613.7524 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e608148664e654db5','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223613.7970 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223613.7974 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@223613.7987 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@223613.7999 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.8013 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@223613.8024 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.8037 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@223613.8044 pk1lg35pdb5af35l8s7mgoqvjb Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240522@223613.8056 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@223613.8067 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223613.8080 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@223613.8087 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e630011664e654dc4','aut664e608148664e654db5',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e608148664e654db5'
20240522@223918.2568 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@223918.2582 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@223918.2594 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='20';
20240522@223918.2633 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='20';
20240522@223918.2645 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='20';
20240522@223918.2654 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='20';
20240522@223918.2664 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2667 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@223918.2680 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@223918.2689 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@223918.2702 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@223918.2714 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2716 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@223918.2726 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2729 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@223918.2746 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@223918.2765 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2768 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@223918.2781 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2783 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@223918.2794 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2809 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@223918.2815 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2827 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@223918.2832 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2844 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@223918.2849 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@223918.2862 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@223918.2877 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@223918.2894 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.2897 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@223918.2907 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2919 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@223918.2925 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e671778664e660646',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223918.2930 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2942 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@223918.2951 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e671778664e660646','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223918.2956 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.2968 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@223918.2974 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e671778664e660646','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@223918.3419 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223918.3422 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@223918.3434 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@223918.3445 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.3459 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@223918.3469 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.3480 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@223918.3486 pk1lg35pdb5af35l8s7mgoqvjb Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240522@223918.3495 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@223918.3505 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.3516 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@223918.3522 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e609154664e660655','aut664e671778664e660646',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e671778664e660646'
20240522@223918.3689 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@223918.3704 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@223918.3717 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664e609154664e660655',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.253000,9.253000*200.48 ,9.253000,9.253000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664e671778664e660646'
20240522@223931.3441 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223931.3462 pk1lg35pdb5af35l8s7mgoqvjb Query : declare @bostamp varchar(25) = 'aut664e671778664e660646' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240522@223943.7530 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223943.7534 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from bo where bo.bostamp = 'aut664e671778664e660646'
20240522@223943.7641 pk1lg35pdb5af35l8s7mgoqvjb Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664e671778664e660646' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240522@223943.9698 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@223943.9702 pk1lg35pdb5af35l8s7mgoqvjb Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240522@223943.9719 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='20';
20240522@223943.9730 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='20';
20240522@224044.7588 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240522@224044.7604 pk1lg35pdb5af35l8s7mgoqvjb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240522@224044.7618 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='21';
20240522@224044.7656 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='21';
20240522@224044.7668 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='21';
20240522@224044.7679 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='21';
20240522@224044.7692 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7695 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240522@224044.7711 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240522@224044.7722 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240522@224044.7736 pk1lg35pdb5af35l8s7mgoqvjb Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240522@224044.7748 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7752 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 1 valor from ts where ts.ndos = 61
20240522@224044.7763 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7766 pk1lg35pdb5af35l8s7mgoqvjb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240522@224044.7785 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240522@224044.7802 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7805 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240522@224044.7821 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7825 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from ts where ndos = 61
20240522@224044.7836 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.7851 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@224044.7858 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.7870 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@224044.7877 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.7890 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@224044.7897 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240522@224044.7910 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@224044.7926 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240522@224044.7942 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.7946 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240522@224044.7957 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.7970 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240522@224044.7978 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e684149664e665cc1',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@224044.7982 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.7997 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240522@224044.8005 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e684149664e665cc1','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@224044.8011 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.8026 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240522@224044.8033 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664e684149664e665cc1','guia r. fornecedor','2024-05-17',61,2401462,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240522@224044.8521 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.8525 pk1lg35pdb5af35l8s7mgoqvjb Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240522@224044.8540 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240522@224044.8552 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.8568 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@224044.8578 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.8748 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@224044.8769 pk1lg35pdb5af35l8s7mgoqvjb Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240522@224044.8784 pk1lg35pdb5af35l8s7mgoqvjb Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240522@224044.8794 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.8808 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240522@224044.8814 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664e644551664e665cd6','aut664e684149664e665cc1',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664e684149664e665cc1'
20240522@224044.8983 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240522@224044.8997 pk1lg35pdb5af35l8s7mgoqvjb Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240522@224044.9008 pk1lg35pdb5af35l8s7mgoqvjb Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664e644551664e665cd6',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.254000,9.254000*200.48 ,9.254000,9.254000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664e684149664e665cc1'
20240522@224044.9664 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224044.9668 pk1lg35pdb5af35l8s7mgoqvjb Query : declare @bostamp varchar(25) = 'aut664e684149664e665cc1' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240522@224045.1184 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224045.1189 pk1lg35pdb5af35l8s7mgoqvjb Query : select 1 valor from bo where bo.bostamp = 'aut664e684149664e665cc1'
20240522@224045.1203 pk1lg35pdb5af35l8s7mgoqvjb Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664e684149664e665cc1' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240522@224045.3225 pk1lg35pdb5af35l8s7mgoqvjb Query : use flama_phc
20240522@224045.3229 pk1lg35pdb5af35l8s7mgoqvjb Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240522@224045.3242 pk1lg35pdb5af35l8s7mgoqvjb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='21';
20240522@224045.3253 pk1lg35pdb5af35l8s7mgoqvjb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='21';

20240523@074552.5665 so171h2a31mns672926u2oemfb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='22';
20240523@074552.5686 so171h2a31mns672926u2oemfb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='22';
20240523@074552.5705 so171h2a31mns672926u2oemfb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='22';
20240523@074552.5716 so171h2a31mns672926u2oemfb Query : use flama_phc
20240523@074552.5719 so171h2a31mns672926u2oemfb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@074552.5943 so171h2a31mns672926u2oemfb Query : use flama_phc
20240523@074552.5946 so171h2a31mns672926u2oemfb Query : select no, estab,szadrsdesc from szadrs where u_coddest=2138
20240523@074552.6138 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1256.00.1'
20240523@074552.6317 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1879.00.1'
20240523@074552.6483 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4965.00.1'
20240523@074552.6754 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4967.00.1'
20240523@074552.6956 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1805.00.1'
20240523@074552.7111 so171h2a31mns672926u2oemfb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1805.00.1'
20240523@074552.7125 so171h2a31mns672926u2oemfb Query : use flama_phc
20240523@074552.7128 so171h2a31mns672926u2oemfb Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@074552.7392 so171h2a31mns672926u2oemfb Query : use flama_phc
20240523@074552.7396 so171h2a31mns672926u2oemfb Query : select top 1 1 valor from td where td.ndoc = 39
20240523@074552.7485 so171h2a31mns672926u2oemfb Query : use flama_phc
20240523@074552.7488 so171h2a31mns672926u2oemfb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080253.9396 0ph5tri0ii9p4mimel25ps9htc Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080253.9614 0ph5tri0ii9p4mimel25ps9htc Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080254.4000 0ph5tri0ii9p4mimel25ps9htc Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='23';
20240523@080254.6800 0ph5tri0ii9p4mimel25ps9htc Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='23';
20240523@080254.1480 0ph5tri0ii9p4mimel25ps9htc Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='23';
20240523@080254.3700 0ph5tri0ii9p4mimel25ps9htc Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='23';
20240523@080254.4450 0ph5tri0ii9p4mimel25ps9htc Query : use flama_phc
20240523@080254.5390 0ph5tri0ii9p4mimel25ps9htc Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080254.8260 0ph5tri0ii9p4mimel25ps9htc Query : use flama_phc
20240523@080254.8670 0ph5tri0ii9p4mimel25ps9htc Query : select no, estab,szadrsdesc from szadrs where u_coddest=4783
20240523@080254.1104 0ph5tri0ii9p4mimel25ps9htc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080254.1381 0ph5tri0ii9p4mimel25ps9htc Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403646 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080254.2108 0ph5tri0ii9p4mimel25ps9htc Query : use flama_phc
20240523@080254.2154 0ph5tri0ii9p4mimel25ps9htc Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080254.2670 0ph5tri0ii9p4mimel25ps9htc Query : use flama_phc
20240523@080254.2713 0ph5tri0ii9p4mimel25ps9htc Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080254.3044 0ph5tri0ii9p4mimel25ps9htc Query : use flama_phc
20240523@080254.3087 0ph5tri0ii9p4mimel25ps9htc Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080254.4672 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080254.4684 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080254.4703 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='24';
20240523@080254.4737 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='24';
20240523@080254.4749 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='24';
20240523@080254.4760 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='24';
20240523@080254.4770 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : use flama_phc
20240523@080254.4773 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080254.4787 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : use flama_phc
20240523@080254.4790 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4783
20240523@080254.4822 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080254.4967 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403647 and bi.ref ='304.4860.00.1' and bi.lordem =1
20240523@080254.5276 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4902.00.1'
20240523@080254.5426 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403647 and bi.ref ='324.4902.00.1' and bi.lordem =2
20240523@080254.5742 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : use flama_phc
20240523@080254.5746 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080254.5759 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : use flama_phc
20240523@080254.5762 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080254.5772 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : use flama_phc
20240523@080254.5775 bk2g2mqbb5ogm1hdmh2mk5qrs0 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080254.6296 gbqbmgkunq8ha4t8v3si7mrnot Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080254.6374 gbqbmgkunq8ha4t8v3si7mrnot Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080254.6625 gbqbmgkunq8ha4t8v3si7mrnot Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='25';
20240523@080254.7120 gbqbmgkunq8ha4t8v3si7mrnot Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='25';
20240523@080254.7560 gbqbmgkunq8ha4t8v3si7mrnot Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='25';
20240523@080254.8067 gbqbmgkunq8ha4t8v3si7mrnot Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='25';
20240523@080254.8177 gbqbmgkunq8ha4t8v3si7mrnot Query : use flama_phc
20240523@080254.8181 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080254.8378 gbqbmgkunq8ha4t8v3si7mrnot Query : use flama_phc
20240523@080254.8417 gbqbmgkunq8ha4t8v3si7mrnot Query : select no, estab,szadrsdesc from szadrs where u_coddest=4743
20240523@080254.8765 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4751.00.1'
20240523@080254.9169 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4751.00.1' and bi.lordem =1
20240523@080254.9754 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4751.00.1'
20240523@080254.9904 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4751.00.1' and bi.lordem =1
20240523@080254.9913 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080255.3440 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4320.00.1' and bi.lordem =2
20240523@080255.1098 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080255.1159 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4320.00.1' and bi.lordem =2
20240523@080255.1217 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080255.1344 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4320.00.1' and bi.lordem =2
20240523@080255.1354 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080255.1376 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4320.00.1' and bi.lordem =2
20240523@080255.1385 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080255.1630 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4320.00.1' and bi.lordem =3
20240523@080255.2386 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4006.00.2'
20240523@080255.2877 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4006.00.2' and bi.lordem =4
20240523@080255.3543 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4006.00.2'
20240523@080255.3715 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4006.00.2' and bi.lordem =4
20240523@080255.3856 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4006.00.2'
20240523@080255.3867 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4006.00.2' and bi.lordem =4
20240523@080255.4049 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4007.00.2'
20240523@080255.4469 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4007.00.2' and bi.lordem =5
20240523@080255.5164 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4007.00.2'
20240523@080255.5300 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4007.00.2' and bi.lordem =5
20240523@080255.5314 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4007.00.2'
20240523@080255.5324 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4007.00.2' and bi.lordem =5
20240523@080255.5334 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.422.00.07'
20240523@080255.5744 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.422.00.07' and bi.lordem =6
20240523@080255.6442 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.422.00.07'
20240523@080255.6648 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.422.00.07' and bi.lordem =6
20240523@080255.6797 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080255.6911 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4860.00.1' and bi.lordem =7
20240523@080255.7516 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080255.7629 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4860.00.1' and bi.lordem =7
20240523@080255.7638 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080255.7798 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='304.4860.00.1' and bi.lordem =7
20240523@080255.7923 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4840.00.1'
20240523@080255.8343 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4840.00.1' and bi.lordem =8
20240523@080255.9024 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4840.00.1'
20240523@080255.9036 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4840.00.1' and bi.lordem =8
20240523@080255.9044 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4840.00.1'
20240523@080255.9059 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4840.00.1' and bi.lordem =8
20240523@080255.9067 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080255.9479 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =9
20240523@080256.2150 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080256.4240 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =9
20240523@080256.5480 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080256.5860 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =9
20240523@080256.6740 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080256.7280 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =9
20240523@080256.7350 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080256.7590 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =9
20240523@080256.7670 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4421.00.1'
20240523@080256.8440 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4421.00.1' and bi.lordem =10
20240523@080256.2144 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4585.00.1'
20240523@080256.2845 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403648 and bi.ref ='324.4585.00.1' and bi.lordem =11
20240523@080256.3566 gbqbmgkunq8ha4t8v3si7mrnot Query : use flama_phc
20240523@080256.3570 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080256.3585 gbqbmgkunq8ha4t8v3si7mrnot Query : use flama_phc
20240523@080256.3588 gbqbmgkunq8ha4t8v3si7mrnot Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080256.3604 gbqbmgkunq8ha4t8v3si7mrnot Query : use flama_phc
20240523@080256.3608 gbqbmgkunq8ha4t8v3si7mrnot Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080256.4361 u037q0tte24e7r8qktnlbcboso Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080256.4375 u037q0tte24e7r8qktnlbcboso Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080256.4388 u037q0tte24e7r8qktnlbcboso Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='26';
20240523@080256.4424 u037q0tte24e7r8qktnlbcboso Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='26';
20240523@080256.4435 u037q0tte24e7r8qktnlbcboso Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='26';
20240523@080256.4446 u037q0tte24e7r8qktnlbcboso Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='26';
20240523@080256.4456 u037q0tte24e7r8qktnlbcboso Query : use flama_phc
20240523@080256.4460 u037q0tte24e7r8qktnlbcboso Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080256.4474 u037q0tte24e7r8qktnlbcboso Query : use flama_phc
20240523@080256.4478 u037q0tte24e7r8qktnlbcboso Query : select no, estab,szadrsdesc from szadrs where u_coddest=4743
20240523@080256.4508 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080256.4520 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240523@080256.4862 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080256.4874 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='304.4860.00.1' and bi.lordem =2
20240523@080256.5174 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080256.5186 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='304.4860.00.1' and bi.lordem =2
20240523@080256.5195 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080256.5206 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='304.4860.00.1' and bi.lordem =2
20240523@080256.5213 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080256.5224 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.691.00.01' and bi.lordem =3
20240523@080256.5544 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080256.5557 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.691.00.01' and bi.lordem =3
20240523@080256.5565 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4963.00.1'
20240523@080256.5707 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4963.00.1' and bi.lordem =4
20240523@080256.6030 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4963.00.1'
20240523@080256.6044 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4963.00.1' and bi.lordem =4
20240523@080256.6054 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4963.00.1'
20240523@080256.6069 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4963.00.1' and bi.lordem =4
20240523@080256.6077 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4964.00.1'
20240523@080256.6236 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4964.00.1' and bi.lordem =5
20240523@080256.6561 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4964.00.1'
20240523@080256.6572 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4964.00.1' and bi.lordem =5
20240523@080256.6579 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4961.00.1'
20240523@080256.6719 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4961.00.1' and bi.lordem =6
20240523@080256.7031 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4962.00.1'
20240523@080256.7169 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4962.00.1' and bi.lordem =7
20240523@080256.7505 u037q0tte24e7r8qktnlbcboso Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4962.00.1'
20240523@080256.7516 u037q0tte24e7r8qktnlbcboso Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403649 and bi.ref ='324.4962.00.1' and bi.lordem =7
20240523@080256.7523 u037q0tte24e7r8qktnlbcboso Query : use flama_phc
20240523@080256.7525 u037q0tte24e7r8qktnlbcboso Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080256.7537 u037q0tte24e7r8qktnlbcboso Query : use flama_phc
20240523@080256.7540 u037q0tte24e7r8qktnlbcboso Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080256.7559 u037q0tte24e7r8qktnlbcboso Query : use flama_phc
20240523@080256.7562 u037q0tte24e7r8qktnlbcboso Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080256.8096 t0kk1qcun4ue3bhp8n26rfjc3s Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080256.8109 t0kk1qcun4ue3bhp8n26rfjc3s Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080256.8123 t0kk1qcun4ue3bhp8n26rfjc3s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='27';
20240523@080256.8159 t0kk1qcun4ue3bhp8n26rfjc3s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='27';
20240523@080256.8170 t0kk1qcun4ue3bhp8n26rfjc3s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='27';
20240523@080256.8180 t0kk1qcun4ue3bhp8n26rfjc3s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='27';
20240523@080256.8191 t0kk1qcun4ue3bhp8n26rfjc3s Query : use flama_phc
20240523@080256.8194 t0kk1qcun4ue3bhp8n26rfjc3s Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080256.8213 t0kk1qcun4ue3bhp8n26rfjc3s Query : use flama_phc
20240523@080256.8217 t0kk1qcun4ue3bhp8n26rfjc3s Query : select no, estab,szadrsdesc from szadrs where u_coddest=4783
20240523@080256.8250 t0kk1qcun4ue3bhp8n26rfjc3s Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080256.8398 t0kk1qcun4ue3bhp8n26rfjc3s Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403672 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240523@080256.8725 t0kk1qcun4ue3bhp8n26rfjc3s Query : use flama_phc
20240523@080256.8729 t0kk1qcun4ue3bhp8n26rfjc3s Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080256.8743 t0kk1qcun4ue3bhp8n26rfjc3s Query : use flama_phc
20240523@080256.8746 t0kk1qcun4ue3bhp8n26rfjc3s Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080256.8757 t0kk1qcun4ue3bhp8n26rfjc3s Query : use flama_phc
20240523@080256.8760 t0kk1qcun4ue3bhp8n26rfjc3s Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080256.9238 83b034n0pkg1iaqvv9hoig4hpb Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080256.9263 83b034n0pkg1iaqvv9hoig4hpb Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080256.9293 83b034n0pkg1iaqvv9hoig4hpb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='28';
20240523@080256.9326 83b034n0pkg1iaqvv9hoig4hpb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='28';
20240523@080256.9336 83b034n0pkg1iaqvv9hoig4hpb Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='28';
20240523@080256.9346 83b034n0pkg1iaqvv9hoig4hpb Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='28';
20240523@080256.9356 83b034n0pkg1iaqvv9hoig4hpb Query : use flama_phc
20240523@080256.9362 83b034n0pkg1iaqvv9hoig4hpb Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080256.9375 83b034n0pkg1iaqvv9hoig4hpb Query : use flama_phc
20240523@080256.9378 83b034n0pkg1iaqvv9hoig4hpb Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240523@080256.9458 83b034n0pkg1iaqvv9hoig4hpb Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '326.595.00.01'
20240523@080256.9604 83b034n0pkg1iaqvv9hoig4hpb Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403673 and bi.ref ='326.595.00.01' and bi.lordem =1
20240523@080256.9898 83b034n0pkg1iaqvv9hoig4hpb Query : use flama_phc
20240523@080256.9901 83b034n0pkg1iaqvv9hoig4hpb Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080256.9913 83b034n0pkg1iaqvv9hoig4hpb Query : use flama_phc
20240523@080256.9916 83b034n0pkg1iaqvv9hoig4hpb Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080256.9926 83b034n0pkg1iaqvv9hoig4hpb Query : use flama_phc
20240523@080256.9928 83b034n0pkg1iaqvv9hoig4hpb Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080257.3680 8u3fv7r4nmbt0ldick5au0l45j Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080257.3810 8u3fv7r4nmbt0ldick5au0l45j Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080257.3930 8u3fv7r4nmbt0ldick5au0l45j Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='29';
20240523@080257.4800 8u3fv7r4nmbt0ldick5au0l45j Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='29';
20240523@080257.4910 8u3fv7r4nmbt0ldick5au0l45j Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='29';
20240523@080257.5010 8u3fv7r4nmbt0ldick5au0l45j Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='29';
20240523@080257.5120 8u3fv7r4nmbt0ldick5au0l45j Query : use flama_phc
20240523@080257.5150 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080257.5280 8u3fv7r4nmbt0ldick5au0l45j Query : use flama_phc
20240523@080257.5320 8u3fv7r4nmbt0ldick5au0l45j Query : select no, estab,szadrsdesc from szadrs where u_coddest=4781
20240523@080257.6150 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1879.00.1'
20240523@080257.8170 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403676 and bi.ref ='324.1879.00.1' and bi.lordem =1
20240523@080257.1121 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1879.00.1'
20240523@080257.1132 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403676 and bi.ref ='324.1879.00.1' and bi.lordem =2
20240523@080257.1507 8u3fv7r4nmbt0ldick5au0l45j Query : use flama_phc
20240523@080257.1511 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080257.1524 8u3fv7r4nmbt0ldick5au0l45j Query : use flama_phc
20240523@080257.1527 8u3fv7r4nmbt0ldick5au0l45j Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080257.1538 8u3fv7r4nmbt0ldick5au0l45j Query : use flama_phc
20240523@080257.1541 8u3fv7r4nmbt0ldick5au0l45j Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080257.2121 lbhnq5ki7ripmipnjidfdaejo0 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080257.2139 lbhnq5ki7ripmipnjidfdaejo0 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080257.2258 lbhnq5ki7ripmipnjidfdaejo0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='30';
20240523@080257.2417 lbhnq5ki7ripmipnjidfdaejo0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='30';
20240523@080257.2428 lbhnq5ki7ripmipnjidfdaejo0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='30';
20240523@080257.2579 lbhnq5ki7ripmipnjidfdaejo0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='30';
20240523@080257.2661 lbhnq5ki7ripmipnjidfdaejo0 Query : use flama_phc
20240523@080257.2702 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080257.2918 lbhnq5ki7ripmipnjidfdaejo0 Query : use flama_phc
20240523@080257.2957 lbhnq5ki7ripmipnjidfdaejo0 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4787
20240523@080257.3232 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4860.00.1'
20240523@080257.3244 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403677 and bi.ref ='304.4860.00.1' and bi.lordem =1
20240523@080257.4059 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4751.00.1'
20240523@080257.4364 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403677 and bi.ref ='324.4751.00.1' and bi.lordem =2
20240523@080257.5358 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.727.00.01'
20240523@080257.5776 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403677 and bi.ref ='324.727.00.01' and bi.lordem =3
20240523@080257.6344 lbhnq5ki7ripmipnjidfdaejo0 Query : use flama_phc
20240523@080257.6414 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080257.6610 lbhnq5ki7ripmipnjidfdaejo0 Query : use flama_phc
20240523@080257.6614 lbhnq5ki7ripmipnjidfdaejo0 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080257.6627 lbhnq5ki7ripmipnjidfdaejo0 Query : use flama_phc
20240523@080257.6694 lbhnq5ki7ripmipnjidfdaejo0 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080257.7900 b58ofi4utea12e44k3tj3b2oo7 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080257.7971 b58ofi4utea12e44k3tj3b2oo7 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080257.8180 b58ofi4utea12e44k3tj3b2oo7 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='31';
20240523@080257.8410 b58ofi4utea12e44k3tj3b2oo7 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='31';
20240523@080257.8491 b58ofi4utea12e44k3tj3b2oo7 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='31';
20240523@080257.8700 b58ofi4utea12e44k3tj3b2oo7 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='31';
20240523@080257.8711 b58ofi4utea12e44k3tj3b2oo7 Query : use flama_phc
20240523@080257.8714 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080257.8850 b58ofi4utea12e44k3tj3b2oo7 Query : use flama_phc
20240523@080257.8854 b58ofi4utea12e44k3tj3b2oo7 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4787
20240523@080257.8888 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080257.9045 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403678 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240523@080257.9663 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080257.9902 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403678 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240523@080258.2600 b58ofi4utea12e44k3tj3b2oo7 Query : use flama_phc
20240523@080258.6700 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.2350 b58ofi4utea12e44k3tj3b2oo7 Query : use flama_phc
20240523@080258.2390 b58ofi4utea12e44k3tj3b2oo7 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.3310 b58ofi4utea12e44k3tj3b2oo7 Query : use flama_phc
20240523@080258.3720 b58ofi4utea12e44k3tj3b2oo7 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.1229 517jovoqmgap0jah2lehn1937d Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.1244 517jovoqmgap0jah2lehn1937d Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.1263 517jovoqmgap0jah2lehn1937d Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='32';
20240523@080258.1303 517jovoqmgap0jah2lehn1937d Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='32';
20240523@080258.1314 517jovoqmgap0jah2lehn1937d Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='32';
20240523@080258.1325 517jovoqmgap0jah2lehn1937d Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='32';
20240523@080258.1339 517jovoqmgap0jah2lehn1937d Query : use flama_phc
20240523@080258.1342 517jovoqmgap0jah2lehn1937d Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.1357 517jovoqmgap0jah2lehn1937d Query : use flama_phc
20240523@080258.1359 517jovoqmgap0jah2lehn1937d Query : select no, estab,szadrsdesc from szadrs where u_coddest=4787
20240523@080258.1388 517jovoqmgap0jah2lehn1937d Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080258.1398 517jovoqmgap0jah2lehn1937d Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403679 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080258.1710 517jovoqmgap0jah2lehn1937d Query : use flama_phc
20240523@080258.1713 517jovoqmgap0jah2lehn1937d Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.1726 517jovoqmgap0jah2lehn1937d Query : use flama_phc
20240523@080258.1728 517jovoqmgap0jah2lehn1937d Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.1739 517jovoqmgap0jah2lehn1937d Query : use flama_phc
20240523@080258.1742 517jovoqmgap0jah2lehn1937d Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.2197 0m62in0fclbatpimsc9lmecu0o Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.2209 0m62in0fclbatpimsc9lmecu0o Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.2221 0m62in0fclbatpimsc9lmecu0o Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='33';
20240523@080258.2256 0m62in0fclbatpimsc9lmecu0o Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='33';
20240523@080258.2268 0m62in0fclbatpimsc9lmecu0o Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='33';
20240523@080258.2278 0m62in0fclbatpimsc9lmecu0o Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='33';
20240523@080258.2287 0m62in0fclbatpimsc9lmecu0o Query : use flama_phc
20240523@080258.2290 0m62in0fclbatpimsc9lmecu0o Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.2303 0m62in0fclbatpimsc9lmecu0o Query : use flama_phc
20240523@080258.2306 0m62in0fclbatpimsc9lmecu0o Query : select no, estab,szadrsdesc from szadrs where u_coddest=4789
20240523@080258.2372 0m62in0fclbatpimsc9lmecu0o Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080258.2382 0m62in0fclbatpimsc9lmecu0o Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403682 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240523@080258.2694 0m62in0fclbatpimsc9lmecu0o Query : use flama_phc
20240523@080258.2697 0m62in0fclbatpimsc9lmecu0o Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.2710 0m62in0fclbatpimsc9lmecu0o Query : use flama_phc
20240523@080258.2712 0m62in0fclbatpimsc9lmecu0o Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.2723 0m62in0fclbatpimsc9lmecu0o Query : use flama_phc
20240523@080258.2725 0m62in0fclbatpimsc9lmecu0o Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.3680 2uhoba6rsl7sq8reuo6p8rvr05 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.4396 2uhoba6rsl7sq8reuo6p8rvr05 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.4807 2uhoba6rsl7sq8reuo6p8rvr05 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='34';
20240523@080258.5057 2uhoba6rsl7sq8reuo6p8rvr05 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='34';
20240523@080258.5070 2uhoba6rsl7sq8reuo6p8rvr05 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='34';
20240523@080258.5081 2uhoba6rsl7sq8reuo6p8rvr05 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='34';
20240523@080258.5091 2uhoba6rsl7sq8reuo6p8rvr05 Query : use flama_phc
20240523@080258.5095 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.5110 2uhoba6rsl7sq8reuo6p8rvr05 Query : use flama_phc
20240523@080258.5113 2uhoba6rsl7sq8reuo6p8rvr05 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4789
20240523@080258.5143 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080258.5157 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403683 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240523@080258.5482 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080258.5494 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403683 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240523@080258.5503 2uhoba6rsl7sq8reuo6p8rvr05 Query : use flama_phc
20240523@080258.5507 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.5520 2uhoba6rsl7sq8reuo6p8rvr05 Query : use flama_phc
20240523@080258.5523 2uhoba6rsl7sq8reuo6p8rvr05 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.5534 2uhoba6rsl7sq8reuo6p8rvr05 Query : use flama_phc
20240523@080258.5546 2uhoba6rsl7sq8reuo6p8rvr05 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.6010 4rnvbt7taq949i0qf16tib43r0 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.6025 4rnvbt7taq949i0qf16tib43r0 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.6037 4rnvbt7taq949i0qf16tib43r0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='35';
20240523@080258.6075 4rnvbt7taq949i0qf16tib43r0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='35';
20240523@080258.6087 4rnvbt7taq949i0qf16tib43r0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='35';
20240523@080258.6100 4rnvbt7taq949i0qf16tib43r0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='35';
20240523@080258.6111 4rnvbt7taq949i0qf16tib43r0 Query : use flama_phc
20240523@080258.6114 4rnvbt7taq949i0qf16tib43r0 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.6128 4rnvbt7taq949i0qf16tib43r0 Query : use flama_phc
20240523@080258.6130 4rnvbt7taq949i0qf16tib43r0 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4789
20240523@080258.6160 4rnvbt7taq949i0qf16tib43r0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1834.00.1'
20240523@080258.6307 4rnvbt7taq949i0qf16tib43r0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403684 and bi.ref ='324.1834.00.1' and bi.lordem =1
20240523@080258.6792 4rnvbt7taq949i0qf16tib43r0 Query : use flama_phc
20240523@080258.6796 4rnvbt7taq949i0qf16tib43r0 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.6810 4rnvbt7taq949i0qf16tib43r0 Query : use flama_phc
20240523@080258.6814 4rnvbt7taq949i0qf16tib43r0 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.6825 4rnvbt7taq949i0qf16tib43r0 Query : use flama_phc
20240523@080258.6828 4rnvbt7taq949i0qf16tib43r0 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.7271 eigi4i94fuo5ob9fs57vkhhk6j Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.7283 eigi4i94fuo5ob9fs57vkhhk6j Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.7296 eigi4i94fuo5ob9fs57vkhhk6j Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='36';
20240523@080258.7331 eigi4i94fuo5ob9fs57vkhhk6j Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='36';
20240523@080258.7341 eigi4i94fuo5ob9fs57vkhhk6j Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='36';
20240523@080258.7351 eigi4i94fuo5ob9fs57vkhhk6j Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='36';
20240523@080258.7361 eigi4i94fuo5ob9fs57vkhhk6j Query : use flama_phc
20240523@080258.7364 eigi4i94fuo5ob9fs57vkhhk6j Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.7378 eigi4i94fuo5ob9fs57vkhhk6j Query : use flama_phc
20240523@080258.7381 eigi4i94fuo5ob9fs57vkhhk6j Query : select no, estab,szadrsdesc from szadrs where u_coddest=4789
20240523@080258.7427 eigi4i94fuo5ob9fs57vkhhk6j Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080258.7438 eigi4i94fuo5ob9fs57vkhhk6j Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403685 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080258.7761 eigi4i94fuo5ob9fs57vkhhk6j Query : use flama_phc
20240523@080258.7764 eigi4i94fuo5ob9fs57vkhhk6j Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080258.7778 eigi4i94fuo5ob9fs57vkhhk6j Query : use flama_phc
20240523@080258.7781 eigi4i94fuo5ob9fs57vkhhk6j Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080258.7792 eigi4i94fuo5ob9fs57vkhhk6j Query : use flama_phc
20240523@080258.7795 eigi4i94fuo5ob9fs57vkhhk6j Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080258.8244 ca2jgbi63mfkc05om2stdv7jct Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080258.8320 ca2jgbi63mfkc05om2stdv7jct Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080258.8530 ca2jgbi63mfkc05om2stdv7jct Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='37';
20240523@080258.8668 ca2jgbi63mfkc05om2stdv7jct Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='37';
20240523@080258.8716 ca2jgbi63mfkc05om2stdv7jct Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='37';
20240523@080258.8882 ca2jgbi63mfkc05om2stdv7jct Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='37';
20240523@080258.8895 ca2jgbi63mfkc05om2stdv7jct Query : use flama_phc
20240523@080258.8925 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080258.9019 ca2jgbi63mfkc05om2stdv7jct Query : use flama_phc
20240523@080258.9022 ca2jgbi63mfkc05om2stdv7jct Query : select no, estab,szadrsdesc from szadrs where u_coddest=4790
20240523@080258.9324 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080258.9334 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.1720 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.3820 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.5060 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.5420 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.6310 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.6810 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.6880 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.6980 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.7110 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.8270 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.9540 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.9660 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.9730 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.1124 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403687 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080259.1250 ca2jgbi63mfkc05om2stdv7jct Query : use flama_phc
20240523@080259.1290 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080259.1501 ca2jgbi63mfkc05om2stdv7jct Query : use flama_phc
20240523@080259.1541 ca2jgbi63mfkc05om2stdv7jct Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080259.1711 ca2jgbi63mfkc05om2stdv7jct Query : use flama_phc
20240523@080259.1714 ca2jgbi63mfkc05om2stdv7jct Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080259.3891 4abq16c569m576ib2r9p4o7lgo Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080259.3978 4abq16c569m576ib2r9p4o7lgo Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080259.4098 4abq16c569m576ib2r9p4o7lgo Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='38';
20240523@080259.4138 4abq16c569m576ib2r9p4o7lgo Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='38';
20240523@080259.4207 4abq16c569m576ib2r9p4o7lgo Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='38';
20240523@080259.4389 4abq16c569m576ib2r9p4o7lgo Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='38';
20240523@080259.4400 4abq16c569m576ib2r9p4o7lgo Query : use flama_phc
20240523@080259.4403 4abq16c569m576ib2r9p4o7lgo Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080259.4599 4abq16c569m576ib2r9p4o7lgo Query : use flama_phc
20240523@080259.4637 4abq16c569m576ib2r9p4o7lgo Query : select no, estab,szadrsdesc from szadrs where u_coddest=2155
20240523@080259.4983 4abq16c569m576ib2r9p4o7lgo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1837.00.1'
20240523@080259.5354 4abq16c569m576ib2r9p4o7lgo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403688 and bi.ref ='324.1837.00.1' and bi.lordem =1
20240523@080259.5938 4abq16c569m576ib2r9p4o7lgo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1837.00.1'
20240523@080259.6070 4abq16c569m576ib2r9p4o7lgo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403688 and bi.ref ='324.1837.00.1' and bi.lordem =2
20240523@080259.6699 4abq16c569m576ib2r9p4o7lgo Query : use flama_phc
20240523@080259.6738 4abq16c569m576ib2r9p4o7lgo Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080259.6948 4abq16c569m576ib2r9p4o7lgo Query : use flama_phc
20240523@080259.6988 4abq16c569m576ib2r9p4o7lgo Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080259.7157 4abq16c569m576ib2r9p4o7lgo Query : use flama_phc
20240523@080259.7197 4abq16c569m576ib2r9p4o7lgo Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080259.7809 6nvthcqrjpvi6s46ncg1s2n0in Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080259.7822 6nvthcqrjpvi6s46ncg1s2n0in Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080259.7834 6nvthcqrjpvi6s46ncg1s2n0in Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='39';
20240523@080259.7868 6nvthcqrjpvi6s46ncg1s2n0in Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='39';
20240523@080259.7878 6nvthcqrjpvi6s46ncg1s2n0in Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='39';
20240523@080259.7887 6nvthcqrjpvi6s46ncg1s2n0in Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='39';
20240523@080259.7897 6nvthcqrjpvi6s46ncg1s2n0in Query : use flama_phc
20240523@080259.7901 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080259.7916 6nvthcqrjpvi6s46ncg1s2n0in Query : use flama_phc
20240523@080259.7918 6nvthcqrjpvi6s46ncg1s2n0in Query : select no, estab,szadrsdesc from szadrs where u_coddest=912
20240523@080259.7985 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.5540.00.1'
20240523@080259.8122 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403689 and bi.ref ='324.5540.00.1' and bi.lordem =1
20240523@080259.8429 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080259.8440 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403689 and bi.ref ='324.691.00.01' and bi.lordem =2
20240523@080259.8744 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.692.00.01'
20240523@080259.8891 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403689 and bi.ref ='324.692.00.01' and bi.lordem =3
20240523@080259.9211 6nvthcqrjpvi6s46ncg1s2n0in Query : use flama_phc
20240523@080259.9215 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080259.9227 6nvthcqrjpvi6s46ncg1s2n0in Query : use flama_phc
20240523@080259.9230 6nvthcqrjpvi6s46ncg1s2n0in Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080259.9240 6nvthcqrjpvi6s46ncg1s2n0in Query : use flama_phc
20240523@080259.9243 6nvthcqrjpvi6s46ncg1s2n0in Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080259.9687 732dq18oq1ol0jl9h1k869lfej Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080259.9705 732dq18oq1ol0jl9h1k869lfej Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080259.9964 732dq18oq1ol0jl9h1k869lfej Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='40';
20240523@080300.5520 732dq18oq1ol0jl9h1k869lfej Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='40';
20240523@080300.1051 732dq18oq1ol0jl9h1k869lfej Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='40';
20240523@080300.1171 732dq18oq1ol0jl9h1k869lfej Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='40';
20240523@080300.1254 732dq18oq1ol0jl9h1k869lfej Query : use flama_phc
20240523@080300.1294 732dq18oq1ol0jl9h1k869lfej Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080300.1506 732dq18oq1ol0jl9h1k869lfej Query : use flama_phc
20240523@080300.1544 732dq18oq1ol0jl9h1k869lfej Query : select no, estab,szadrsdesc from szadrs where u_coddest=1967
20240523@080300.1873 732dq18oq1ol0jl9h1k869lfej Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '323.318.09.00'
20240523@080300.2139 732dq18oq1ol0jl9h1k869lfej Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403690 and bi.ref ='323.318.09.00' and bi.lordem =1
20240523@080300.2776 732dq18oq1ol0jl9h1k869lfej Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1462.00.1'
20240523@080300.3197 732dq18oq1ol0jl9h1k869lfej Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403690 and bi.ref ='324.1462.00.1' and bi.lordem =2
20240523@080300.3922 732dq18oq1ol0jl9h1k869lfej Query : use flama_phc
20240523@080300.3964 732dq18oq1ol0jl9h1k869lfej Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080300.4046 732dq18oq1ol0jl9h1k869lfej Query : use flama_phc
20240523@080300.4050 732dq18oq1ol0jl9h1k869lfej Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080300.4187 732dq18oq1ol0jl9h1k869lfej Query : use flama_phc
20240523@080300.4190 732dq18oq1ol0jl9h1k869lfej Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080300.4640 2l9ar6j85hd36jmg6ilbracppo Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080300.4653 2l9ar6j85hd36jmg6ilbracppo Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080300.4665 2l9ar6j85hd36jmg6ilbracppo Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='41';
20240523@080300.4699 2l9ar6j85hd36jmg6ilbracppo Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='41';
20240523@080300.4710 2l9ar6j85hd36jmg6ilbracppo Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='41';
20240523@080300.4719 2l9ar6j85hd36jmg6ilbracppo Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='41';
20240523@080300.4728 2l9ar6j85hd36jmg6ilbracppo Query : use flama_phc
20240523@080300.4731 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080300.4744 2l9ar6j85hd36jmg6ilbracppo Query : use flama_phc
20240523@080300.4747 2l9ar6j85hd36jmg6ilbracppo Query : select no, estab,szadrsdesc from szadrs where u_coddest=1124
20240523@080300.4828 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4723.00.2'
20240523@080300.4971 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403691 and bi.ref ='324.4723.00.2' and bi.lordem =1
20240523@080300.5292 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.421.00.04'
20240523@080300.5520 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403691 and bi.ref ='304.421.00.04' and bi.lordem =2
20240523@080300.5863 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.681.00.01'
20240523@080300.6005 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403691 and bi.ref ='324.681.00.01' and bi.lordem =4
20240523@080300.6325 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.681.00.01'
20240523@080300.6335 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403691 and bi.ref ='324.681.00.01' and bi.lordem =5
20240523@080300.6645 2l9ar6j85hd36jmg6ilbracppo Query : use flama_phc
20240523@080300.6679 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080300.6705 2l9ar6j85hd36jmg6ilbracppo Query : use flama_phc
20240523@080300.6709 2l9ar6j85hd36jmg6ilbracppo Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080300.6720 2l9ar6j85hd36jmg6ilbracppo Query : use flama_phc
20240523@080300.6723 2l9ar6j85hd36jmg6ilbracppo Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080300.7163 1cgqg4ffv9chb1pgf6q356jrd0 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080300.7175 1cgqg4ffv9chb1pgf6q356jrd0 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080300.7187 1cgqg4ffv9chb1pgf6q356jrd0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='42';
20240523@080300.7221 1cgqg4ffv9chb1pgf6q356jrd0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='42';
20240523@080300.7231 1cgqg4ffv9chb1pgf6q356jrd0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='42';
20240523@080300.7241 1cgqg4ffv9chb1pgf6q356jrd0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='42';
20240523@080300.7251 1cgqg4ffv9chb1pgf6q356jrd0 Query : use flama_phc
20240523@080300.7254 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080300.7267 1cgqg4ffv9chb1pgf6q356jrd0 Query : use flama_phc
20240523@080300.7270 1cgqg4ffv9chb1pgf6q356jrd0 Query : select no, estab,szadrsdesc from szadrs where u_coddest=2794
20240523@080300.7337 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '323.367.09.00'
20240523@080300.7476 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403696 and bi.ref ='323.367.09.00' and bi.lordem =1
20240523@080300.7785 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1837.00.1'
20240523@080300.7797 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403696 and bi.ref ='324.1837.00.1' and bi.lordem =2
20240523@080300.8128 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1833.00.2'
20240523@080300.8270 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403696 and bi.ref ='324.1833.00.2' and bi.lordem =3
20240523@080300.8579 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1889.00.1'
20240523@080300.8743 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403696 and bi.ref ='324.1889.00.1' and bi.lordem =4
20240523@080300.9052 1cgqg4ffv9chb1pgf6q356jrd0 Query : use flama_phc
20240523@080300.9055 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080300.9068 1cgqg4ffv9chb1pgf6q356jrd0 Query : use flama_phc
20240523@080300.9071 1cgqg4ffv9chb1pgf6q356jrd0 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080300.9081 1cgqg4ffv9chb1pgf6q356jrd0 Query : use flama_phc
20240523@080300.9084 1cgqg4ffv9chb1pgf6q356jrd0 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080300.9520 492dafucipnieg02lla5vlgvea Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080300.9533 492dafucipnieg02lla5vlgvea Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080300.9546 492dafucipnieg02lla5vlgvea Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='43';
20240523@080300.9593 492dafucipnieg02lla5vlgvea Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='43';
20240523@080300.9605 492dafucipnieg02lla5vlgvea Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='43';
20240523@080300.9616 492dafucipnieg02lla5vlgvea Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='43';
20240523@080300.9626 492dafucipnieg02lla5vlgvea Query : use flama_phc
20240523@080300.9629 492dafucipnieg02lla5vlgvea Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080300.9642 492dafucipnieg02lla5vlgvea Query : use flama_phc
20240523@080300.9645 492dafucipnieg02lla5vlgvea Query : select no, estab,szadrsdesc from szadrs where u_coddest=1260
20240523@080300.9731 492dafucipnieg02lla5vlgvea Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '323.318.09.00'
20240523@080300.9741 492dafucipnieg02lla5vlgvea Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403697 and bi.ref ='323.318.09.00' and bi.lordem =1
20240523@080301.9500 492dafucipnieg02lla5vlgvea Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080301.1060 492dafucipnieg02lla5vlgvea Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403697 and bi.ref ='304.4320.00.1' and bi.lordem =2
20240523@080301.4140 492dafucipnieg02lla5vlgvea Query : use flama_phc
20240523@080301.4170 492dafucipnieg02lla5vlgvea Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080301.4300 492dafucipnieg02lla5vlgvea Query : use flama_phc
20240523@080301.4330 492dafucipnieg02lla5vlgvea Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080301.4430 492dafucipnieg02lla5vlgvea Query : use flama_phc
20240523@080301.4450 492dafucipnieg02lla5vlgvea Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080301.8970 oup916bkd6v7pv42lickf0cgh6 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080301.9090 oup916bkd6v7pv42lickf0cgh6 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080301.9430 oup916bkd6v7pv42lickf0cgh6 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='44';
20240523@080301.9780 oup916bkd6v7pv42lickf0cgh6 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='44';
20240523@080301.9890 oup916bkd6v7pv42lickf0cgh6 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='44';
20240523@080301.9990 oup916bkd6v7pv42lickf0cgh6 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='44';
20240523@080301.1008 oup916bkd6v7pv42lickf0cgh6 Query : use flama_phc
20240523@080301.1011 oup916bkd6v7pv42lickf0cgh6 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080301.1024 oup916bkd6v7pv42lickf0cgh6 Query : use flama_phc
20240523@080301.1030 oup916bkd6v7pv42lickf0cgh6 Query : select no, estab,szadrsdesc from szadrs where u_coddest=1124
20240523@080301.1060 oup916bkd6v7pv42lickf0cgh6 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4211.00.1'
20240523@080301.1203 oup916bkd6v7pv42lickf0cgh6 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2036 and bo.obrano = 2403698 and bi.ref ='304.4211.00.1' and bi.lordem =1
20240523@080301.1518 oup916bkd6v7pv42lickf0cgh6 Query : use flama_phc
20240523@080301.1522 oup916bkd6v7pv42lickf0cgh6 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080301.1534 oup916bkd6v7pv42lickf0cgh6 Query : use flama_phc
20240523@080301.1537 oup916bkd6v7pv42lickf0cgh6 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080301.1547 oup916bkd6v7pv42lickf0cgh6 Query : use flama_phc
20240523@080301.1550 oup916bkd6v7pv42lickf0cgh6 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080301.1995 q2k9trsfpv0d10bpr3f1p7u4lk Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080301.2010 q2k9trsfpv0d10bpr3f1p7u4lk Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080301.2021 q2k9trsfpv0d10bpr3f1p7u4lk Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='45';
20240523@080301.2056 q2k9trsfpv0d10bpr3f1p7u4lk Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='45';
20240523@080301.2066 q2k9trsfpv0d10bpr3f1p7u4lk Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='45';
20240523@080301.2076 q2k9trsfpv0d10bpr3f1p7u4lk Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='45';
20240523@080301.2085 q2k9trsfpv0d10bpr3f1p7u4lk Query : use flama_phc
20240523@080301.2088 q2k9trsfpv0d10bpr3f1p7u4lk Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080301.2100 q2k9trsfpv0d10bpr3f1p7u4lk Query : use flama_phc
20240523@080301.2107 q2k9trsfpv0d10bpr3f1p7u4lk Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240523@080301.2135 q2k9trsfpv0d10bpr3f1p7u4lk Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.642.00.01'
20240523@080301.2281 q2k9trsfpv0d10bpr3f1p7u4lk Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403703 and bi.ref ='324.642.00.01' and bi.lordem =1
20240523@080301.2591 q2k9trsfpv0d10bpr3f1p7u4lk Query : use flama_phc
20240523@080301.2594 q2k9trsfpv0d10bpr3f1p7u4lk Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080301.2607 q2k9trsfpv0d10bpr3f1p7u4lk Query : use flama_phc
20240523@080301.2610 q2k9trsfpv0d10bpr3f1p7u4lk Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080301.2620 q2k9trsfpv0d10bpr3f1p7u4lk Query : use flama_phc
20240523@080301.2623 q2k9trsfpv0d10bpr3f1p7u4lk Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080301.3092 q2us7mr6s65d2ts53iecprh0b2 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080301.3105 q2us7mr6s65d2ts53iecprh0b2 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080301.3118 q2us7mr6s65d2ts53iecprh0b2 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='46';
20240523@080301.3154 q2us7mr6s65d2ts53iecprh0b2 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='46';
20240523@080301.3165 q2us7mr6s65d2ts53iecprh0b2 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='46';
20240523@080301.3177 q2us7mr6s65d2ts53iecprh0b2 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='46';
20240523@080301.3197 q2us7mr6s65d2ts53iecprh0b2 Query : use flama_phc
20240523@080301.3200 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080301.3614 q2us7mr6s65d2ts53iecprh0b2 Query : use flama_phc
20240523@080301.3693 q2us7mr6s65d2ts53iecprh0b2 Query : select no, estab,szadrsdesc from szadrs where u_coddest=557
20240523@080301.4370 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080301.4380 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080301.4765 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080301.4791 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.691.00.01' and bi.lordem =1
20240523@080301.4798 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080301.4807 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.691.00.01' and bi.lordem =2
20240523@080301.5241 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080301.5254 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.691.00.01' and bi.lordem =2
20240523@080301.5261 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.698.00.01'
20240523@080301.5402 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.698.00.01' and bi.lordem =3
20240523@080301.5713 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.698.00.01'
20240523@080301.5723 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.698.00.01' and bi.lordem =3
20240523@080301.5729 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.698.00.01'
20240523@080301.5738 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.698.00.01' and bi.lordem =3
20240523@080301.5745 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.698.00.01'
20240523@080301.5755 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.698.00.01' and bi.lordem =3
20240523@080301.5762 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.645.00.01'
20240523@080301.5903 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.645.00.01' and bi.lordem =4
20240523@080301.6275 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1646.00.1'
20240523@080301.6417 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1646.00.1' and bi.lordem =5
20240523@080301.6724 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1646.00.1'
20240523@080301.6734 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1646.00.1' and bi.lordem =5
20240523@080301.6741 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1646.00.1'
20240523@080301.6752 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1646.00.1' and bi.lordem =6
20240523@080301.7065 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2221.00.1'
20240523@080301.7204 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.2221.00.1' and bi.lordem =7
20240523@080301.7509 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2222.00.1'
20240523@080301.7650 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.2222.00.1' and bi.lordem =9
20240523@080301.7956 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2223.00.1'
20240523@080301.8095 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.2223.00.1' and bi.lordem =11
20240523@080301.8417 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2224.00.1'
20240523@080301.8555 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.2224.00.1' and bi.lordem =13
20240523@080301.8870 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4961.00.1'
20240523@080301.8883 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4961.00.1' and bi.lordem =15
20240523@080301.9211 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4962.00.1'
20240523@080301.9227 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4962.00.1' and bi.lordem =17
20240523@080301.9561 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4963.00.1'
20240523@080301.9574 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4963.00.1' and bi.lordem =19
20240523@080301.9893 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4964.00.1'
20240523@080301.9906 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4964.00.1' and bi.lordem =21
20240523@080302.2360 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1706.00.1'
20240523@080302.3890 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1706.00.1' and bi.lordem =23
20240523@080302.8310 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4320.00.1'
20240523@080302.8450 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='304.4320.00.1' and bi.lordem =25
20240523@080302.1196 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4211.00.1'
20240523@080302.1209 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='304.4211.00.1' and bi.lordem =27
20240523@080302.1561 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.4211.00.1'
20240523@080302.1572 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='304.4211.00.1' and bi.lordem =27
20240523@080302.1578 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '304.422.00.07'
20240523@080302.1588 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='304.422.00.07' and bi.lordem =29
20240523@080302.1906 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4751.00.1'
20240523@080302.1918 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4751.00.1' and bi.lordem =31
20240523@080302.2259 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4751.00.1'
20240523@080302.2270 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4751.00.1' and bi.lordem =31
20240523@080302.2276 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4723.00.2'
20240523@080302.2286 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4723.00.2' and bi.lordem =33
20240523@080302.2595 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4840.00.1'
20240523@080302.2606 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.4840.00.1' and bi.lordem =35
20240523@080302.2929 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080302.2940 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1824.00.1' and bi.lordem =37
20240523@080302.3266 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080302.3278 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1824.00.1' and bi.lordem =37
20240523@080302.3284 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080302.3293 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1824.00.1' and bi.lordem =37
20240523@080302.3301 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080302.3311 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1824.00.1' and bi.lordem =37
20240523@080302.3318 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1824.00.1'
20240523@080302.3328 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1824.00.1' and bi.lordem =37
20240523@080302.3335 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1884.00.1'
20240523@080302.3476 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1884.00.1' and bi.lordem =38
20240523@080302.3850 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1884.00.1'
20240523@080302.3862 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1884.00.1' and bi.lordem =39
20240523@080302.4177 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1837.00.1'
20240523@080302.4188 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1837.00.1' and bi.lordem =40
20240523@080302.4521 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1837.00.1'
20240523@080302.4536 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1837.00.1' and bi.lordem =41
20240523@080302.4861 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1832.00.2'
20240523@080302.5005 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1832.00.2' and bi.lordem =42
20240523@080302.5343 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1832.00.2'
20240523@080302.5360 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1832.00.2' and bi.lordem =42
20240523@080302.5370 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1832.00.2'
20240523@080302.5384 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1832.00.2' and bi.lordem =43
20240523@080302.5713 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1833.00.2'
20240523@080302.5725 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1833.00.2' and bi.lordem =44
20240523@080302.6040 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1833.00.2'
20240523@080302.6051 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1833.00.2' and bi.lordem =44
20240523@080302.6058 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1833.00.2'
20240523@080302.6067 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403708 and bi.ref ='324.1833.00.2' and bi.lordem =45
20240523@080302.6467 q2us7mr6s65d2ts53iecprh0b2 Query : use flama_phc
20240523@080302.6470 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080302.6483 q2us7mr6s65d2ts53iecprh0b2 Query : use flama_phc
20240523@080302.6485 q2us7mr6s65d2ts53iecprh0b2 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080302.6497 q2us7mr6s65d2ts53iecprh0b2 Query : use flama_phc
20240523@080302.6501 q2us7mr6s65d2ts53iecprh0b2 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080302.7933 jaan1dl6kop5u2umvvccpp3te4 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080302.7945 jaan1dl6kop5u2umvvccpp3te4 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080302.7957 jaan1dl6kop5u2umvvccpp3te4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='47';
20240523@080302.7993 jaan1dl6kop5u2umvvccpp3te4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='47';
20240523@080302.8003 jaan1dl6kop5u2umvvccpp3te4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='47';
20240523@080302.8013 jaan1dl6kop5u2umvvccpp3te4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='47';
20240523@080302.8023 jaan1dl6kop5u2umvvccpp3te4 Query : use flama_phc
20240523@080302.8026 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@080302.8040 jaan1dl6kop5u2umvvccpp3te4 Query : use flama_phc
20240523@080302.8043 jaan1dl6kop5u2umvvccpp3te4 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4799
20240523@080302.8146 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4910.00.1'
20240523@080302.8304 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403710 and bi.ref ='324.4910.00.1' and bi.lordem =1
20240523@080302.8666 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.719.00.01'
20240523@080302.8809 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403710 and bi.ref ='324.719.00.01' and bi.lordem =2
20240523@080302.9140 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.727.00.01'
20240523@080302.9153 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403710 and bi.ref ='324.727.00.01' and bi.lordem =3
20240523@080302.9711 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4521.00.1'
20240523@080303.2410 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403710 and bi.ref ='324.4521.00.1' and bi.lordem =4
20240523@080303.9220 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.691.00.01'
20240523@080303.1213 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =240 and bo.boano =2037 and bo.obrano = 2403710 and bi.ref ='324.691.00.01' and bi.lordem =5
20240523@080303.1630 jaan1dl6kop5u2umvvccpp3te4 Query : use flama_phc
20240523@080303.1635 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240523@080303.1652 jaan1dl6kop5u2umvvccpp3te4 Query : use flama_phc
20240523@080303.1655 jaan1dl6kop5u2umvvccpp3te4 Query : select top 1 1 valor from td where td.ndoc = 39
20240523@080303.1675 jaan1dl6kop5u2umvvccpp3te4 Query : use flama_phc
20240523@080303.1678 jaan1dl6kop5u2umvvccpp3te4 Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@080303.2839 5c3eljlq01mpn1855fr6s8t8l9 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@080303.2918 5c3eljlq01mpn1855fr6s8t8l9 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@080303.3138 5c3eljlq01mpn1855fr6s8t8l9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='48';
20240523@080303.3259 5c3eljlq01mpn1855fr6s8t8l9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='48';
20240523@080303.3354 5c3eljlq01mpn1855fr6s8t8l9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='48';
20240523@080303.3410 5c3eljlq01mpn1855fr6s8t8l9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='48';

20240523@112111.5748 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='49';
20240523@112111.5771 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='49';
20240523@112111.5783 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='49';
20240523@112111.5804 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.5810 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@112111.5870 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@112111.5986 43742rj9r88k8ep1pbna67g28b Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240523@112111.6440 43742rj9r88k8ep1pbna67g28b Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240523@112111.6839 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.6843 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@112111.6939 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.6943 43742rj9r88k8ep1pbna67g28b Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@112111.7033 43742rj9r88k8ep1pbna67g28b Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240523@112111.7189 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.7192 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@112111.7289 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.7294 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@112111.7406 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.7722 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112111.7780 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.7797 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112111.7807 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.7822 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112111.7831 43742rj9r88k8ep1pbna67g28b Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240523@112111.7967 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112111.8086 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112111.8107 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.8115 43742rj9r88k8ep1pbna67g28b Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240523@112111.8226 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.8246 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112111.8288 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f160623664f1897c5',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112111.8358 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.8392 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112111.8403 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f160623664f1897c5','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112111.8630 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.8648 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112111.8661 43742rj9r88k8ep1pbna67g28b Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f160623664f1897c5','guia r. fornecedor','2024-05-17',61,2401465,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112111.9186 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112111.9192 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@112111.9368 43742rj9r88k8ep1pbna67g28b Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240523@112111.9525 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.9544 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112111.9561 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.9588 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112111.9596 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@112111.9698 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@112111.9743 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.9771 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112111.9779 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f161143664f1897ed','aut664f160623664f1897c5',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664f160623664f1897c5'
20240523@112111.9955 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112111.9973 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112111.9992 43742rj9r88k8ep1pbna67g28b Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664f161143664f1897ed',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.254000,9.254000*200.48 ,9.254000,9.254000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f160623664f1897c5'
20240523@112120.3425 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112120.3463 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f160623664f1897c5' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240523@112135.3796 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112135.3800 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f160623664f1897c5'
20240523@112135.3919 43742rj9r88k8ep1pbna67g28b Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664f160623664f1897c5' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240523@112135.7234 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112135.7239 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@112135.7253 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='49';
20240523@112135.7268 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='49';
20240523@112628.2284 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@112628.2300 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@112628.2317 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='50';
20240523@112628.2360 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='50';
20240523@112628.2371 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='50';
20240523@112628.2384 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='50';
20240523@112628.2436 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2448 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@112628.2468 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@112628.2504 43742rj9r88k8ep1pbna67g28b Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240523@112628.2520 43742rj9r88k8ep1pbna67g28b Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240523@112628.2537 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2540 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@112628.2553 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2556 43742rj9r88k8ep1pbna67g28b Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@112628.2578 43742rj9r88k8ep1pbna67g28b Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240523@112628.2596 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2599 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@112628.2615 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2618 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@112628.2630 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2647 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112628.2654 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2667 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112628.2674 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2688 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112628.2696 43742rj9r88k8ep1pbna67g28b Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240523@112628.2711 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112628.2729 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112628.2746 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.2750 43742rj9r88k8ep1pbna67g28b Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240523@112628.2764 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2781 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112628.2789 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f176389664f19d443',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112628.2795 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2810 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112628.2818 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f176389664f19d443','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112628.2824 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.2838 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112628.2846 43742rj9r88k8ep1pbna67g28b Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f176389664f19d443','guia r. fornecedor','2024-05-17',61,2401465,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112628.4535 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.5306 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@112628.5325 43742rj9r88k8ep1pbna67g28b Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240523@112628.5340 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.5358 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112628.5371 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.5386 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112628.5394 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@112628.5406 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@112628.5420 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.5435 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112628.5442 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f175337664f19d484','aut664f176389664f19d443',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664f176389664f19d443'
20240523@112628.5792 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112628.5844 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112628.5858 43742rj9r88k8ep1pbna67g28b Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664f175337664f19d484',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.254000,9.254000*200.48 ,9.254000,9.254000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f176389664f19d443'
20240523@112628.6647 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.6651 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f176389664f19d443' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240523@112628.9021 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112628.9104 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f176389664f19d443'
20240523@112628.9414 43742rj9r88k8ep1pbna67g28b Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664f176389664f19d443' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240523@112629.1659 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112629.2099 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@112629.2805 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='50';
20240523@112629.2904 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='50';
20240523@112705.7849 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@112705.7864 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@112705.7878 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='51';
20240523@112705.7918 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='51';
20240523@112705.7929 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='51';
20240523@112705.7942 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='51';
20240523@112705.7958 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.7961 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@112705.7980 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@112705.7994 43742rj9r88k8ep1pbna67g28b Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240523@112705.8010 43742rj9r88k8ep1pbna67g28b Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240523@112705.8028 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8032 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@112705.8047 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8050 43742rj9r88k8ep1pbna67g28b Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@112705.8072 43742rj9r88k8ep1pbna67g28b Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240523@112705.8092 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8095 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@112705.8116 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8119 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@112705.8131 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8150 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112705.8158 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8173 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112705.8182 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8196 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112705.8203 43742rj9r88k8ep1pbna67g28b Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240523@112705.8218 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112705.8236 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@112705.8255 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8258 43742rj9r88k8ep1pbna67g28b Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240523@112705.8274 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8293 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@112705.8301 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f141100664f19f9c9',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112705.8312 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8326 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@112705.8334 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f141100664f19f9c9','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112705.8339 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8357 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@112705.8364 43742rj9r88k8ep1pbna67g28b Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f141100664f19f9c9','guia r. fornecedor','2024-05-17',61,2401465,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@112705.8835 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.8839 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@112705.8857 43742rj9r88k8ep1pbna67g28b Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240523@112705.8870 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8888 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112705.8899 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8913 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112705.8920 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@112705.8931 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@112705.8942 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.8961 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@112705.8970 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f132440664f19f9da','aut664f141100664f19f9c9',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664f141100664f19f9c9'
20240523@112705.9144 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@112705.9161 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@112705.9173 43742rj9r88k8ep1pbna67g28b Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664f132440664f19f9da',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.254000,9.254000*200.48 ,9.254000,9.254000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f141100664f19f9c9'
20240523@112705.9755 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112705.9761 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f141100664f19f9c9' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240523@112706.2580 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112706.2585 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f141100664f19f9c9'
20240523@112706.2600 43742rj9r88k8ep1pbna67g28b Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664f141100664f19f9c9' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240523@112706.4846 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@112706.4850 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@112706.4865 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='51';
20240523@112706.4878 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='51';
20240523@113057.3222 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@113057.3244 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@113057.3261 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='52';
20240523@113057.3303 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='52';
20240523@113057.3315 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='52';
20240523@113057.3328 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='52';
20240523@113057.3341 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3354 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@113057.3372 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@113057.3384 43742rj9r88k8ep1pbna67g28b Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240523@113057.3399 43742rj9r88k8ep1pbna67g28b Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240523@113057.3413 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3417 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@113057.3430 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3433 43742rj9r88k8ep1pbna67g28b Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@113057.3467 43742rj9r88k8ep1pbna67g28b Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240523@113057.3484 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3504 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@113057.3522 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3525 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@113057.3537 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3552 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@113057.3573 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3587 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@113057.3594 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3610 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@113057.3616 43742rj9r88k8ep1pbna67g28b Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240523@113057.3632 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@113057.3653 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@113057.3681 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.3686 43742rj9r88k8ep1pbna67g28b Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240523@113057.3700 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3717 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@113057.3726 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f128830664f1ae159',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@113057.3732 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3747 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@113057.3755 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f128830664f1ae159','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@113057.3761 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.3788 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@113057.3795 43742rj9r88k8ep1pbna67g28b Query : insert into bo (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f128830664f1ae159','guia r. fornecedor','2024-05-17',61,2401465,?,?,?,?,?,?,?,?,2024, (select valor from para1 where descricao = 'ge_euro') ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@113057.4988 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.5109 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@113057.5460 43742rj9r88k8ep1pbna67g28b Query : select top 1 st.tabiva ,st.ivaincl ,st.stns ,st.uni2 ,st.familia ,isnull(tx.taxa, 0) txiva ,unidade ,usalote ,epcpond ,noserie ,conversao ,st.texteis from st left join taxasiva tx on st.tabiva = tx.codigo where st.ref = '2211.075.0001'
20240523@113057.5475 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.5491 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@113057.5503 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.5518 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@113057.5538 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@113057.5551 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@113057.5563 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.5577 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@113057.5584 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f133616664f1ae187','aut664f128830664f1ae159',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from bo bo where bo.bostamp = 'aut664f128830664f1ae159'
20240523@113057.5772 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113057.5802 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@113057.5814 43742rj9r88k8ep1pbna67g28b Query : insert into bi (bistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,obrano, qtt,uni2qtt ,no, estab,nmdos ,ndos, obranome,fechada, dataobra ,rdata ,dataopen, datafecho,local, morada ,codpost, nome,bostamp,lordem ,edebito,debito, epu,pu ,ivaincl,stns,unidade, unidad2 ,marcada,usalote ,ettdeb,ttdeb,epcusto, pcusto ,ecustoind,custoind ,vendedor,vendnm, ccusto,ncusto ,noserie,tabiva,iva ,ref,design,familia,desconto,desc2,desc3,desc4,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664f133616664f1ae187',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1428, 1428*.0000000 ,bo.no, bo.estab,bo.nmdos ,bo.ndos, bo.obranome,bo.fechada, bo.dataobra ,bo.dataobra ,bo.dataopen,bo.datafecho,bo.local, bo.morada ,bo.codpost, bo.nome,bo.bostamp,10000 ,9.2892,9.2892*200.48,9.2892,9.2892*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,9.2892*1428,9.2892*1428*200.48 ,9.254000,9.254000*200.48 ,9.254000,9.254000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,9.2892,9.2892*200.48,9.2892*1428,9.2892*1428*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1428,9.2892,9.2892*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f128830664f1ae159'
20240523@113057.6646 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.6651 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f128830664f1ae159' ,@bistamp varchar(25) = '' update bi set tecoval = qtt * ecoval ,etecoval = qtt * eecoval ,tecoval2 = qtt * ecoval2 ,etecoval2 = qtt * eecoval2 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end -- se tiver classificação e não for normal, não calcula nada update bi set ttdeb = 0 ,ettdeb = 0 ,ttmoeda = 0 where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and bi.classifc <> '' and bi.classifc <> 'normal' -- no caso normal com moeda euro if exists ( select 1 from bo cross apply ( select valor moeda from para1 where descricao = 'ge_pteoueuro' ) par where bo.bostamp = @bostamp and bo.moeda = par.moeda ) begin -- sem ecovalores update bi set ettdeb = round(bi.qtt * ((bi.edebito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttdeb = round(bi.qtt * ((bi.debito * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100))), 6) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 1 -- com ecovalores update bi set ettdeb = round(bi.qtt * ( ( bi.edebito + ( iif(p.st_econotdesc = 1, - bi.eecoval2, bi.eecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.eecoval + bi.eecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttdeb = round(bi.qtt * ( ( bi.debito + ( iif(p.st_econotdesc = 1, - bi.ecoval2, bi.ecoval) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ) ) ) * (1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) ), 6) + ( bi.qtt * iif(p.st_econotdesc = 1, (bi.ecoval + bi.ecoval2) * ( 1 + iif(bi.ivaincl = 1 and tiva.taxa <> 0, tiva.taxa / 100, 0) ), 0) ) ,ttmoeda = 0 from bi inner join bo on bi.bostamp = bo.bostamp left join st on bi.ref = st.ref left join taxasiva tiva on bi.tabiva = tiva.codigo cross apply ( select max(valor) st_econotdesc from ( select case when valor = 's' then 1 else 0 end valor from para1 where descricao = 'st_econotdesc' union all select 0 ) a ) p where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.econotcalc = 0 --acrescenta os descontos em valor, caso existam: update bi set ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 2) ,ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ttmoeda = 0 from bi where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end else begin update bi set ttmoeda = round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2) ,ettdeb = case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ,edebito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end ,debito = case when bi.qtt = 0 then 0 else round(abs(( case when bo2.cambio <> 0 then round((round((1 - bi.desconto / 100) * (1 - bi.desc2 / 100) * (1 - bi.desc3 / 100) * (1 - bi.desc4 / 100) * (1 - bi.desc5 / 100) * (1 - bi.desc6 / 100) * bi.qtt * bi.vumoeda, 2)) / bo2.cambio, 2) else 0 end ) / (1 - bi.desconto / 100) / (1 - bi.desc2 / 100) / (1 - bi.desc3 / 100) / (1 - bi.desc4 / 100) / (1 - bi.desc5 / 100) / (1 - bi.desc6 / 100) / bi.qtt), 2) end * 200.482 from bi inner join bo2 on bi.bostamp = bo2.bo2stamp where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) update bi set ttdeb = round(bi.ttdeb - (bi.qtt * bi.valdesc), 2) ,ettdeb = round(bi.ettdeb - (bi.qtt * bi.evaldesc), 0) ,debito = round(bi.debito - (bi.qtt * bi.valdesc), 2) ,edebito = round(bi.edebito - (bi.qtt * bi.evaldesc), 2) where bi.bostamp = @bostamp and bi.bistamp = case when @bistamp <> '' then @bistamp else bi.bistamp end and ( bi.classifc = '' or bi.classifc = 'normal' ) and bi.valdesc <> 0 end 
20240523@113057.9081 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113057.9133 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f128830664f1ae159'
20240523@113057.9164 43742rj9r88k8ep1pbna67g28b Query : declare @errno int ,@errmsg varchar(255) ,@prod bit ,@nrdec numeric(10, 0) ,@totaldeb numeric(18, 5) ,@etotaldeb numeric(19, 6) ,@total numeric(18, 5) ,@etotal numeric(19, 6) ,@custo numeric(18, 5) ,@ecusto numeric(19, 6) ,@bo_1iliq numeric(19, 6) ,@bo_2iliq numeric(19, 6) ,@base1 numeric(19, 6) ,@base2 numeric(19, 6) ,@moetotal numeric(13, 3) ,@smoe1 numeric(13, 3) ,@smoe2 numeric(13, 3) ,@smoe3 numeric(13, 3) ,@smoe4 numeric(13, 3) ,@bo11_bins numeric(18, 5) ,@bo21_bins numeric(18, 5) ,@bo31_bins numeric(18, 5) ,@bo41_bins numeric(18, 5) ,@bo51_bins numeric(18, 5) ,@bo61_bins numeric(18, 5) ,@bo71_bins numeric(18, 5) ,@bo81_bins numeric(18, 5) ,@bo91_bins numeric(18, 5) ,@bo12_bins numeric(18, 5) ,@bo22_bins numeric(18, 5) ,@bo32_bins numeric(18, 5) ,@bo42_bins numeric(18, 5) ,@bo52_bins numeric(18, 5) ,@bo62_bins numeric(18, 5) ,@bo72_bins numeric(18, 5) ,@bo82_bins numeric(18, 5) ,@bo92_bins numeric(18, 5) ,@ebo11_bins numeric(19, 6) ,@ebo21_bins numeric(19, 6) ,@ebo31_bins numeric(19, 6) ,@ebo41_bins numeric(19, 6) ,@ebo51_bins numeric(19, 6) ,@ebo61_bins numeric(19, 6) ,@ebo71_bins numeric(18, 5) ,@ebo81_bins numeric(18, 5) ,@ebo91_bins numeric(18, 5) ,@ebo12_bins numeric(19, 6) ,@ebo22_bins numeric(19, 6) ,@ebo32_bins numeric(19, 6) ,@ebo42_bins numeric(19, 6) ,@ebo52_bins numeric(19, 6) ,@ebo62_bins numeric(19, 6) ,@ebo72_bins numeric(18, 5) ,@ebo82_bins numeric(18, 5) ,@ebo92_bins numeric(18, 5) ,@bo11_iva numeric(18, 5) ,@bo21_iva numeric(18, 5) ,@bo31_iva numeric(18, 5) ,@bo41_iva numeric(18, 5) ,@bo51_iva numeric(18, 5) ,@bo61_iva numeric(18, 5) ,@bo71_iva numeric(18, 5) ,@bo81_iva numeric(18, 5) ,@bo91_iva numeric(18, 5) ,@bo12_iva numeric(18, 5) ,@bo22_iva numeric(18, 5) ,@bo32_iva numeric(18, 5) ,@bo42_iva numeric(18, 5) ,@bo52_iva numeric(18, 5) ,@bo62_iva numeric(18, 5) ,@bo72_iva numeric(18, 5) ,@bo82_iva numeric(18, 5) ,@bo92_iva numeric(18, 5) ,@ebo11_iva numeric(19, 6) ,@ebo21_iva numeric(19, 6) ,@ebo31_iva numeric(19, 6) ,@ebo41_iva numeric(19, 6) ,@ebo51_iva numeric(19, 6) ,@ebo61_iva numeric(19, 6) ,@ebo71_iva numeric(18, 5) ,@ebo81_iva numeric(18, 5) ,@ebo91_iva numeric(18, 5) ,@ebo12_iva numeric(19, 6) ,@ebo22_iva numeric(19, 6) ,@ebo32_iva numeric(19, 6) ,@ebo42_iva numeric(19, 6) ,@ebo52_iva numeric(19, 6) ,@ebo62_iva numeric(19, 6) ,@ebo72_iva numeric(18, 5) ,@ebo82_iva numeric(18, 5) ,@ebo92_iva numeric(18, 5) ,@esdeb1 numeric(19, 6) ,@esdeb2 numeric(19, 6) ,@esdeb3 numeric(19, 6) ,@esdeb4 numeric(19, 6) ,@sdeb1 numeric(18, 5) ,@sdeb2 numeric(18, 5) ,@sdeb3 numeric(18, 5) ,@sdeb4 numeric(18, 5) ,@estot1 numeric(19, 6) ,@estot2 numeric(19, 6) ,@estot3 numeric(19, 6) ,@estot4 numeric(19, 6) ,@stot1 numeric(18, 5) ,@stot2 numeric(18, 5) ,@stot3 numeric(18, 5) ,@stot4 numeric(18, 5) ,@ebo_1tvall numeric(19, 6) ,@ebo_2tvall numeric(19, 6) ,@bo_1tvall numeric(18, 5) ,@bo_2tvall numeric(18, 5) ,@ebo_totp1 numeric(19, 6) ,@ebo_totp2 numeric(19, 6) ,@bo_totp1 numeric(18, 5) ,@bo_totp2 numeric(18, 5) ,@sqtt11 numeric(13, 3) ,@sqtt21 numeric(13, 3) ,@sqtt12 numeric(13, 3) ,@sqtt22 numeric(13, 3) ,@sqtt13 numeric(13, 3) ,@sqtt23 numeric(13, 3) ,@sqtt14 numeric(13, 3) ,@sqtt24 numeric(13, 3) ,@userinis varchar (30) ,@mybostamp char(25) = 'aut664f128830664f1ae159' declare @totaisiva table ( bostamp varchar (25), codigo numeric(1), taxa numeric (5,2), ebaseinc numeric (19,6), baseinc numeric (18,5), evalor numeric (19,6), valor numeric (18,5) ) set @prod = ( select ts.producao from bo(nolock) inner join ts(nolock) on bo.ndos = ts.ndos and bo.bostamp = @mybostamp ) set @nrdec = ( select convert(numeric(10, 0), valor) from para1(nolock) where descricao = 'de_euro' ) --set @prod = 0 --set @nrdec = 2 select @ecusto = sum(bi.epcusto * bi.qtt) ,@custo = sum(bi.pcusto * bi.qtt) ,@bo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.qtt * bi.pu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo11_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo21_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo31_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo41_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo51_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo61_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo71_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo81_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo91_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo12_bins = sum(case when bi.tabiva = 1 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo22_bins = sum(case when bi.tabiva = 2 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo32_bins = sum(case when bi.tabiva = 3 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo42_bins = sum(case when bi.tabiva = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo52_bins = sum(case when bi.tabiva = 5 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo62_bins = sum(case when bi.tabiva = 6 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo72_bins = sum(case when bi.tabiva = 7 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo82_bins = sum(case when bi.tabiva = 8 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@ebo92_bins = sum(case when bi.tabiva = 9 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@bo_1iliq = round(sum(bi.qtt * bi.epu), @nrdec) ,@bo_2iliq = round(sum(bi.ettdeb), @nrdec) ,@bo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.pu) * (bi.iva / 100) else (bi.qtt * bi.pu) - ((bi.qtt * bi.pu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@bo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ttdeb * (bi.iva / 100) else bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo11_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo12_iva = sum(case when bi.tabiva = 1 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo21_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo22_iva = sum(case when bi.tabiva = 2 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo31_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo32_iva = sum(case when bi.tabiva = 3 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo41_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo42_iva = sum(case when bi.tabiva = 4 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo51_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo52_iva = sum(case when bi.tabiva = 5 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo61_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo62_iva = sum(case when bi.tabiva = 6 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo71_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo72_iva = sum(case when bi.tabiva = 7 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo81_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else (bi.qtt * bi.epu) - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo82_iva = sum(case when bi.tabiva = 8 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo91_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then (bi.qtt * bi.epu) * (bi.iva / 100) else bi.ettdeb - ((bi.qtt * bi.epu) / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@ebo92_iva = sum(case when bi.tabiva = 9 then round(case when bi.ivaincl = 0 then bi.ettdeb * (bi.iva / 100) else bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) end, @nrdec) else 0 end) ,@esdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ettdeb else bi.ettdeb - round(bi.ettdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@esdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ettdeb else round(bi.ettdeb - (bi.ettdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@sdeb1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttdeb else bi.ttdeb - round(bi.ttdeb / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@sdeb4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttdeb else round(bi.ttdeb - (bi.ttdeb / (1 + bi.iva / 100)) * bi.iva / 100, @nrdec) end else 0 end) ,@smoe1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@smoe4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.ttmoeda else round(bi.ttmoeda / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@estot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.epu else round((bi.qtt * bi.epu) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot1 = sum(case when bi.stipo <= 1 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot2 = sum(case when bi.stipo = 2 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot3 = sum(case when bi.stipo = 3 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@stot4 = sum(case when bi.stipo = 4 then case when bi.ivaincl = 0 then bi.qtt * bi.pu else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end else 0 end) ,@total = @stot1 + @stot2 + @stot3 + @stot4 ,@etotal = @estot1 + @estot2 + @estot3 + @estot4 ,@totaldeb = @sdeb1 + @sdeb2 + @sdeb3 + @sdeb4 ,@etotaldeb = @esdeb1 + @esdeb2 + @esdeb3 + @esdeb4 ,@moetotal = @smoe1 + @smoe2 + @smoe3 + @smoe4 ,@ebo_1tvall = @ebo11_bins + @ebo21_bins + @ebo31_bins + @ebo41_bins + @ebo51_bins + @ebo61_bins + @ebo71_bins + @ebo81_bins + @ebo91_bins ,@ebo_2tvall = @ebo12_bins + @ebo22_bins + @ebo32_bins + @ebo42_bins + @ebo52_bins + @ebo62_bins + @ebo72_bins + @ebo82_bins + @ebo92_bins ,@bo_1tvall = @bo11_bins + @bo21_bins + @bo31_bins + @bo41_bins + @bo51_bins + @bo61_bins + @bo71_bins + @bo81_bins + @bo91_bins ,@bo_2tvall = @bo12_bins + @bo22_bins + @bo32_bins + @bo42_bins + @bo52_bins + @bo62_bins + @bo72_bins + @bo82_bins + @bo92_bins ,@ebo_totp1 = sum(case when bi.ivaincl = 0 then (bi.epu * bi.qtt) else round((bi.epu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@ebo_totp2 = sum(case when bi.ivaincl = 0 then (bi.edebito * bi.qtt) else round((bi.edebito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp1 = sum(case when bi.ivaincl = 0 then (bi.pu * bi.qtt) else round((bi.pu * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@bo_totp2 = sum(case when bi.ivaincl = 0 then (bi.debito * bi.qtt) else round((bi.debito * bi.qtt) / (1 + bi.iva / 100), @nrdec) end) ,@sqtt11 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt21 = sum(case when bi.stipo = 1 then bi.qtt else 0 end) ,@sqtt12 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt22 = sum(case when bi.stipo = 2 then bi.qtt else 0 end) ,@sqtt13 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt23 = sum(case when bi.stipo = 3 then bi.qtt else 0 end) ,@sqtt14 = sum(case when bi.stipo = 4 then bi.qtt else 0 end) ,@sqtt24 = sum(case when bi.stipo = 5 then bi.qtt else 0 end) from bi(nolock) where bi.bostamp = @mybostamp and bi.producao = case when @prod = 1 then 1 else bi.producao end and bi.composto = 0 and bi.qtt <> 0 update bo set bo.totaldeb = isnull(@totaldeb, 0) ,bo.total = isnull(@total, 0) ,bo.etotaldeb = isnull(@etotaldeb, 0) ,bo.moetotal = isnull(@moetotal, 0) ,bo.etotal = isnull(@etotal, 0) ,bo.ecusto = isnull(@ecusto, 0) ,bo.custo = isnull(@custo, 0) ,bo.bo11_bins = isnull(@bo11_bins, 0) ,bo.bo12_bins = isnull(@bo12_bins, 0) ,bo.bo21_bins = isnull(@bo21_bins, 0) ,bo.bo22_bins = isnull(@bo22_bins, 0) ,bo.bo31_bins = isnull(@bo31_bins, 0) ,bo.bo32_bins = isnull(@bo32_bins, 0) ,bo.bo41_bins = isnull(@bo41_bins, 0) ,bo.bo42_bins = isnull(@bo42_bins, 0) ,bo.bo51_bins = isnull(@bo51_bins, 0) ,bo.bo52_bins = isnull(@bo52_bins, 0) ,bo.bo61_bins = isnull(@bo61_bins, 0) ,bo.bo62_bins = isnull(@bo62_bins, 0) ,bo.ebo11_bins = isnull(@ebo11_bins, 0) ,bo.ebo12_bins = isnull(@ebo12_bins, 0) ,bo.ebo21_bins = isnull(@ebo21_bins, 0) ,bo.ebo22_bins = isnull(@ebo22_bins, 0) ,bo.ebo31_bins = isnull(@ebo31_bins, 0) ,bo.ebo32_bins = isnull(@ebo32_bins, 0) ,bo.ebo41_bins = isnull(@ebo41_bins, 0) ,bo.ebo42_bins = isnull(@ebo42_bins, 0) ,bo.ebo51_bins = isnull(@ebo51_bins, 0) ,bo.ebo52_bins = isnull(@ebo52_bins, 0) ,bo.ebo61_bins = isnull(@ebo61_bins, 0) ,bo.ebo62_bins = isnull(@ebo62_bins, 0) ,bo.bo11_iva = isnull(@bo11_iva, 0) ,bo.bo12_iva = isnull(@bo12_iva, 0) ,bo.bo21_iva = isnull(@bo21_iva, 0) ,bo.bo22_iva = isnull(@bo22_iva, 0) ,bo.bo31_iva = isnull(@bo31_iva, 0) ,bo.bo32_iva = isnull(@bo32_iva, 0) ,bo.bo41_iva = isnull(@bo41_iva, 0) ,bo.bo42_iva = isnull(@bo42_iva, 0) ,bo.bo51_iva = isnull(@bo51_iva, 0) ,bo.bo52_iva = isnull(@bo52_iva, 0) ,bo.bo61_iva = isnull(@bo61_iva, 0) ,bo.bo62_iva = isnull(@bo62_iva, 0) ,bo.ebo11_iva = isnull(@ebo11_iva, 0) ,bo.ebo12_iva = isnull(@ebo12_iva, 0) ,bo.ebo21_iva = isnull(@ebo21_iva, 0) ,bo.ebo22_iva = isnull(@ebo22_iva, 0) ,bo.ebo31_iva = isnull(@ebo31_iva, 0) ,bo.ebo32_iva = isnull(@ebo32_iva, 0) ,bo.ebo41_iva = isnull(@ebo41_iva, 0) ,bo.ebo42_iva = isnull(@ebo42_iva, 0) ,bo.ebo51_iva = isnull(@ebo51_iva, 0) ,bo.ebo52_iva = isnull(@ebo52_iva, 0) ,bo.ebo61_iva = isnull(@ebo61_iva, 0) ,bo.ebo62_iva = isnull(@ebo62_iva, 0) ,bo.esdeb1 = isnull(@esdeb1, 0) ,bo.esdeb2 = isnull(@esdeb2, 0) ,bo.esdeb3 = isnull(@esdeb3, 0) ,bo.esdeb4 = isnull(@esdeb4, 0) ,bo.sdeb1 = isnull(@sdeb1, 0) ,bo.sdeb2 = isnull(@sdeb2, 0) ,bo.sdeb3 = isnull(@sdeb3, 0) ,bo.sdeb4 = isnull(@sdeb4, 0) ,bo.smoe1 = isnull(@smoe1, 0) ,bo.smoe2 = isnull(@smoe2, 0) ,bo.smoe3 = isnull(@smoe3, 0) ,bo.smoe4 = isnull(@smoe4, 0) ,bo.estot1 = isnull(@estot1, 0) ,bo.estot2 = isnull(@estot2, 0) ,bo.estot3 = isnull(@estot3, 0) ,bo.estot4 = isnull(@estot4, 0) ,bo.stot1 = isnull(@stot1, 0) ,bo.stot2 = isnull(@stot2, 0) ,bo.stot3 = isnull(@stot3, 0) ,bo.stot4 = isnull(@stot4, 0) ,bo.ebo_1tvall = isnull(@ebo_1tvall, 0) ,bo.ebo_2tvall = isnull(@ebo_2tvall, 0) ,bo.bo_1tvall = isnull(@bo_1tvall, 0) ,bo.bo_2tvall = isnull(@bo_2tvall, 0) ,bo.ebo_totp1 = isnull(@ebo_totp1, 0) ,bo.ebo_totp2 = isnull(@ebo_totp2, 0) ,bo.bo_totp1 = isnull(@bo_totp1, 0) ,bo.bo_totp2 = isnull(@bo_totp2, 0) ,bo.sqtt11 = isnull(@sqtt11, 0) ,bo.sqtt21 = isnull(@sqtt21, 0) ,bo.sqtt12 = isnull(@sqtt12, 0) ,bo.sqtt22 = isnull(@sqtt22, 0) ,bo.sqtt13 = isnull(@sqtt13, 0) ,bo.sqtt23 = isnull(@sqtt23, 0) ,bo.sqtt14 = isnull(@sqtt14, 0) ,bo.sqtt24 = isnull(@sqtt24, 0) where bostamp = @mybostamp update bo2 set bo2.bo71_bins = isnull(@bo71_bins, 0) ,bo2.bo72_bins = isnull(@bo72_bins, 0) ,bo2.bo81_bins = isnull(@bo81_bins, 0) ,bo2.bo82_bins = isnull(@bo82_bins, 0) ,bo2.bo91_bins = isnull(@bo91_bins, 0) ,bo2.bo92_bins = isnull(@bo92_bins, 0) ,bo2.ebo71_bins = isnull(@ebo71_bins, 0) ,bo2.ebo72_bins = isnull(@ebo72_bins, 0) ,bo2.ebo81_bins = isnull(@ebo81_bins, 0) ,bo2.ebo82_bins = isnull(@ebo82_bins, 0) ,bo2.ebo91_bins = isnull(@ebo91_bins, 0) ,bo2.ebo92_bins = isnull(@ebo92_bins, 0) ,bo2.bo71_iva = isnull(@bo71_iva, 0) ,bo2.bo72_iva = isnull(@bo72_iva, 0) ,bo2.bo81_iva = isnull(@bo81_iva, 0) ,bo2.bo82_iva = isnull(@bo82_iva, 0) ,bo2.bo91_iva = isnull(@bo91_iva, 0) ,bo2.bo92_iva = isnull(@bo92_iva, 0) ,bo2.ebo71_iva = isnull(@ebo71_iva, 0) ,bo2.ebo72_iva = isnull(@ebo72_iva, 0) ,bo2.ebo81_iva = isnull(@ebo81_iva, 0) ,bo2.ebo82_iva = isnull(@ebo82_iva, 0) ,bo2.ebo91_iva = isnull(@ebo91_iva, 0) ,bo2.ebo92_iva = isnull(@ebo92_iva, 0) ,bo2.etotalciva = isnull(@etotaldeb, 0) + isnull(@ebo12_iva, 0) +isnull(@ebo22_iva, 0) +isnull(@ebo32_iva, 0) +isnull(@ebo42_iva, 0) +isnull(@ebo52_iva, 0) +isnull(@ebo62_iva, 0) +isnull(@ebo72_iva, 0) +isnull(@ebo82_iva, 0) +isnull(@ebo92_iva, 0) --,bo2.mtotalciva =isnull(@moetotal, 0) where bo2stamp = @mybostamp -- trata os bot select @userinis = usrinis from bo where bo.bostamp=@mybostamp insert into @totaisiva ( bostamp, codigo, taxa, ebaseinc, baseinc, evalor, valor ) select @mybostamp,codigo,taxa ,case when (@ebo11_bins <>0) then @ebo11_bins else @ebo12_bins end ,case when (@ebo11_bins <>0) then @bo11_bins else @bo12_bins end ,case when (@ebo11_bins <>0) then @ebo11_iva else @ebo12_iva end ,case when (@ebo11_bins <>0) then @bo11_iva else @bo12_iva end from taxasiva where codigo = 1 union all select @mybostamp,codigo,taxa ,case when (@ebo21_bins <>0) then @ebo21_bins else @ebo22_bins end ,case when (@ebo21_bins <>0) then @bo21_bins else @bo22_bins end ,case when (@ebo21_bins <>0) then @ebo21_iva else @ebo22_iva end ,case when (@ebo21_bins <>0) then @bo21_iva else @bo22_iva end from taxasiva where codigo = 2 union all select @mybostamp,codigo,taxa ,case when (@ebo31_bins <>0) then @ebo31_bins else @ebo32_bins end ,case when (@ebo31_bins <>0) then @bo31_bins else @bo32_bins end ,case when (@ebo31_bins <>0) then @ebo31_iva else @ebo32_iva end ,case when (@ebo31_bins <>0) then @bo31_iva else @bo32_iva end from taxasiva where codigo = 3 union all select @mybostamp,codigo,taxa ,case when (@ebo41_bins <>0) then @ebo41_bins else @ebo42_bins end ,case when (@ebo41_bins <>0) then @bo41_bins else @bo42_bins end ,case when (@ebo41_bins <>0) then @ebo41_iva else @ebo42_iva end ,case when (@ebo41_bins <>0) then @bo41_iva else @bo42_iva end from taxasiva where codigo = 4 union all select @mybostamp,codigo,taxa ,case when (@ebo51_bins <>0) then @ebo51_bins else @ebo52_bins end ,case when (@ebo51_bins <>0) then @bo51_bins else @bo52_bins end ,case when (@ebo51_bins <>0) then @ebo51_iva else @ebo52_iva end ,case when (@ebo51_bins <>0) then @bo51_iva else @bo52_iva end from taxasiva where codigo = 5 union all select @mybostamp,codigo,taxa ,case when (@ebo61_bins <>0) then @ebo61_bins else @ebo62_bins end ,case when (@ebo61_bins <>0) then @bo61_bins else @bo62_bins end ,case when (@ebo61_bins <>0) then @ebo61_iva else @ebo62_iva end ,case when (@ebo61_bins <>0) then @bo61_iva else @bo62_iva end from taxasiva where codigo = 6 union all select @mybostamp,codigo,taxa ,case when (@ebo71_bins <>0) then @ebo71_bins else @ebo72_bins end ,case when (@ebo71_bins <>0) then @bo71_bins else @bo72_bins end ,case when (@ebo71_bins <>0) then @ebo71_iva else @ebo72_iva end ,case when (@ebo71_bins <>0) then @bo71_iva else @bo72_iva end from taxasiva where codigo = 7 union all select @mybostamp,codigo,taxa ,case when (@ebo81_bins <>0) then @ebo81_bins else @ebo82_bins end ,case when (@ebo81_bins <>0) then @bo81_bins else @bo82_bins end ,case when (@ebo81_bins <>0) then @ebo81_iva else @ebo82_iva end ,case when (@ebo81_bins <>0) then @bo81_iva else @bo82_iva end from taxasiva where codigo = 8 union all select @mybostamp,codigo,taxa ,case when (@ebo91_bins <>0) then @ebo91_bins else @ebo92_bins end ,case when (@ebo91_bins <>0) then @bo91_bins else @bo92_bins end ,case when (@ebo91_bins <>0) then @ebo91_iva else @ebo92_iva end ,case when (@ebo91_bins <>0) then @bo91_iva else @bo92_iva end from taxasiva where codigo = 9 update bot set ebaseinc = totiva.ebaseinc, baseinc = totiva.baseinc, evalor = totiva.evalor, valor = totiva.valor, usrinis = @userinis, usrdata = convert (date,getdate()), usrhora = convert (time,getdate()) from @totaisiva totiva inner join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo insert into bot ( botstamp ,bostamp ,codigo ,taxa ,ebaseinc ,baseinc ,evalor ,valor ,ousrinis ,ousrdata ,ousrhora ,usrinis ,usrdata ,usrhora ) select ( left(@userinis,3) + 'tt' + left(newid(),5) + right(newid(),5) + left(newid(),5) + right(newid(),5)) stamp ,@mybostamp stampbo ,totiva.codigo ,totiva.taxa ,totiva.ebaseinc ,totiva.baseinc ,totiva.evalor ,totiva.valor ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) ,@userinis ,convert (date,getdate()) ,convert (time,getdate()) from @totaisiva totiva left join bot on totiva.bostamp = bot.bostamp and totiva.codigo = bot.codigo where bot.botstamp is null -- atualiza os campo bi.series e bi.series2, caso tenha equipamentos update bi set series = s1, series2=s2 from bi inner join ( select distinct bistamp,ser.s1, ser.s2 from boma cross apply (select stuff ( ( select ',' + rtrim(serie) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s1 , stuff ( ( select ',' + rtrim(serie2) from boma myboma where myboma.bistamp = boma.bistamp order by serie for xml path('') ), 1, 1, '' ) s2 ) ser where boma.bostamp = @mybostamp ) myboma on bi.bistamp = myboma.bistamp where bi.bostamp = @mybostamp 
20240523@113058.2164 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113058.2168 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@113058.2185 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='52';
20240523@113058.2201 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='52';
20240523@113214.5686 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@113214.5703 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@113214.5719 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='53';
20240523@113214.5758 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='53';
20240523@113214.5770 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='53';
20240523@113214.5782 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='53';
20240523@113214.5793 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113214.5797 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@113500.1961 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@113500.1988 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@113500.2005 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='54';
20240523@113500.2205 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='54';
20240523@113500.2251 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='54';
20240523@113500.2264 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='54';
20240523@113500.2281 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2288 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@113500.2306 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@113500.2327 43742rj9r88k8ep1pbna67g28b Query : select top 1 bistamp valor from bi inner join bo on bo.bostamp=bi.bostamp where bo.ndos =002 and bo.boano =2024 and bo.obrano = 2400601 and bi.ref ='2211.075.0001' and bi.lordem =20000
20240523@113500.2406 43742rj9r88k8ep1pbna67g28b Query : select bi.edebito ,bi.desconto ,bi.desc2 ,bi.desc3 ,bi.desc4 ,bi.obranome ,bi.bostamp ,bo.moeda ,bi.vumoeda ,isnull(bi.vumoeda/nullif(bi.edebito,0),1) cambio ,bi.tabiva from bi inner join bo on bi.bostamp = bo.bostamp where bi.bistamp = 'ags24052144762,631000002 ' 
20240523@113500.2421 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2426 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@113500.2439 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2442 43742rj9r88k8ep1pbna67g28b Query : select lower(descricao) descricao ,case when valor='s' then 1 else 0 end valor from para1 where descricao in ('st_lote','st_usalogifunc', 'st_grelha')
20240523@113500.2473 43742rj9r88k8ep1pbna67g28b Query : select top 1 assinadoc issigned ,ts.stocks ,ts.bdempresas origin ,case when (cmstocks between 1 and 50 or cm2stocks between 1 and 50 ) then 1 else 0 end entrada ,case when cmstocks>50 or (cm2stocks>50 and trfa =1) then 1 else 0 end saida ,stneg validatestock ,tiposaft ,veserie useserialnumber ,foserie assetin ,ftserie assetout ,veserie assets ,trfarm assetstransfer ,grelha usegridfields from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos =61
20240523@113500.2540 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2544 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@113500.2565 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2569 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@113500.2580 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113500.2596 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@113500.2603 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113500.2618 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@113500.2641 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113500.2654 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@113500.2660 43742rj9r88k8ep1pbna67g28b Query : select top 1 ts2.manternumero, ts.tiposaft, ts.idserie,ts.nmdos,ts.bdempresas from ts inner join ts2 on ts.tsstamp=ts2.ts2stamp where ts.ndos = 61
20240523@113500.2676 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@113500.2700 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@113500.2729 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113500.2733 43742rj9r88k8ep1pbna67g28b Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202090' and estab=00
20240523@113500.2745 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113500.2759 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@113500.2766 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f195469664f1bd442',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@113500.2771 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@113500.2786 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@113500.2793 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f195469664f1bd442','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@113500.2798 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
