20240523@113908.4282 43742rj9r88k8ep1pbna67g28b INICIO DE FICHEIRO DE LOG :: /var/www/webservices/logs/website.sql.log
20240523@113908.4278 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@113908.4290 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@113908.4307 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='55';
20240523@113908.4326 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='55';
20240523@114142.3895 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@114142.3909 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@114142.3937 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='56';
20240523@114142.3978 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='56';
20240523@114142.3990 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='56';
20240523@114142.4003 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='56';
20240523@114142.4016 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4021 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@114142.4038 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@114142.4050 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@114142.4065 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@114142.4081 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4085 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@114142.4097 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4100 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@114142.4121 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@114142.4139 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4142 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@114142.4159 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4162 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@114142.4172 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4187 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114142.4194 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4208 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114142.4215 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4230 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114142.4237 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@114142.4253 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114142.4276 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114142.4295 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4299 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@114142.4313 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4328 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114142.4336 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f119130664f1d6668',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114142.4347 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4361 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114142.4370 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f119130664f1d6668','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114142.4380 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4396 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114142.4403 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 ('aut664f119130664f1d6668','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@114142.4850 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.4853 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@114142.4872 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@114142.4887 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4904 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114142.4916 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4930 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114142.4938 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@114142.4950 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@114142.4962 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.4975 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114142.4982 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f136392664f1d6679','aut664f119130664f1d6668',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 = 'aut664f119130664f1d6668'
20240523@114142.5379 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114142.5837 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114142.5850 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 'aut664f136392664f1d6679',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1680, 1680*.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*1680,9.2892*1680*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*1680,9.2892*1680*200.48,'ags24052144762,631000002 ',9.2892,9.2892*1680,9.2892,9.2892*1680,?,?,?,4 from bo bo where bo.bostamp = 'aut664f119130664f1d6668'
20240523@114142.6401 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.6405 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f119130664f1d6668' ,@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@114142.8116 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114142.8120 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f119130664f1d6668'
20240523@114142.8136 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) = 'aut664f119130664f1d6668' 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@114143.9320 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114143.9370 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@114143.9510 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='56';
20240523@114143.9660 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='56';
20240523@114357.5825 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@114357.5843 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@114357.5858 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='57';
20240523@114357.5899 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='57';
20240523@114357.5911 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='57';
20240523@114357.5923 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='57';
20240523@114357.5934 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.5937 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@114357.5953 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '2211.075.0001'
20240523@114357.5965 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 = 2400054 and bi.ref ='2211.075.0001' and bi.lordem =10000
20240523@114357.6318 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.6322 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@114357.6334 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.6337 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@114357.6361 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@114357.6379 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.6382 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@114357.6411 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.6414 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@114357.6426 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6443 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114357.6451 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6465 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114357.6471 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6484 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114357.6491 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@114357.6520 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114357.6540 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114357.6557 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.6560 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@114357.6583 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6598 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114357.6606 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f194310664f1deda0',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114357.6612 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6626 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114357.6633 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f194310664f1deda0','--','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114357.6638 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.6652 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114357.6659 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 ('aut664f194310664f1deda0','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@114357.7202 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.7206 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '2211.075.0001'
20240523@114357.7225 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@114357.7239 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.7254 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114357.7267 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.7281 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114357.7287 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='2211.075.0001' and lote = 'r1900585200a'
20240523@114357.7300 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@114357.7311 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.7328 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114357.7336 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f119551664f1dedb2','aut664f194310664f1deda0',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 = 'aut664f194310664f1deda0'
20240523@114357.7507 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114357.7525 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114357.7538 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,eslvu,slvu,esltt,sltt,oobistamp,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,obistamp ,stipo) select 'aut664f119551664f1dedb2',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1680, 1680*.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 ,0,0*200.48,0,0*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,0*1680,0*1680*200.48 ,9.255000,9.255000*200.48 ,9.255000,9.255000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0*200.48,0*1680,0*1680*200.48,'',0,0*1680,0,0*1680,?,?,?,4 from bo bo where bo.bostamp = 'aut664f194310664f1deda0'
20240523@114357.8974 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114357.8983 43742rj9r88k8ep1pbna67g28b Query : select top 1 errorresult result ,errornumber errornumber ,descriptionpt description ,isnull(descriptionen,'') descriptionen ,isnull(descriptionfr,'') descriptionfr from wserrorcodes where errornumber = -110
20240523@114357.9043 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='57';
20240523@114357.9057 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='57';
20240523@114421.2024 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@114421.2040 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@114421.2056 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='58';
20240523@114421.2096 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='58';
20240523@114421.2107 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='58';
20240523@114421.2121 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='58';
20240523@114421.2133 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.2136 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@114421.2152 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@114421.2265 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@114421.2595 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 = 'cps24011554815,886000003 ' 
20240523@114421.2905 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.2909 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@114421.2923 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.2927 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@114421.2950 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@114421.2971 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.2975 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@114421.2993 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.2997 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@114421.3010 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3025 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114421.3032 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3045 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114421.3051 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3065 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114421.3071 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@114421.3084 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114421.3101 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114421.3121 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.3125 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@114421.3140 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3154 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114421.3161 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f119944664f1e054c',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114421.3177 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3192 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114421.3200 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f119944664f1e054c','--','bo',7.4184636118598382749 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114421.3397 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.3413 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114421.3420 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 ('aut664f119944664f1e054c','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@114421.3857 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.3862 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '324.646.00.01'
20240523@114421.3880 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 = '324.646.00.01'
20240523@114421.4028 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.4044 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114421.4056 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.4069 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114421.4076 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='324.646.00.01' and lote = 'r2400054100a'
20240523@114421.4090 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@114421.4101 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.4115 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114421.4123 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f155548664f1e0564','aut664f119944664f1e054c',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 = 'aut664f119944664f1e054c'
20240523@114421.4284 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114421.4305 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114421.4321 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 'aut664f155548664f1e0564',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 ,14.84,14.84*200.48,14.84,14.84*200.48 ,0,0,'un ',' ' ,bo.marcada,1 ,14.84*1428,14.84*1428*200.48 ,18.322000,18.322000*200.48 ,18.322000,18.322000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,14.84,14.84*200.48,14.84*1428,14.84*1428*200.48,'cps24011554815,886000003 ',110.09,110.09*1428,110.09,110.09*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f119944664f1e054c'
20240523@114421.5100 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.5105 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f119944664f1e054c' ,@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@114421.6793 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.6798 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f119944664f1e054c'
20240523@114421.6816 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) = 'aut664f119944664f1e054c' 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@114421.9118 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114421.9122 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@114421.9138 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='58';
20240523@114421.9157 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='58';
20240523@114558.6067 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@114558.6084 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@114558.6099 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='59';
20240523@114558.6266 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='59';
20240523@114558.7371 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='59';
20240523@114558.7388 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='59';
20240523@114558.7402 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7405 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@114558.7425 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@114558.7438 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@114558.7453 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 = 'cps24011554815,886000003 ' 
20240523@114558.7468 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7472 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@114558.7485 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7489 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@114558.7509 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@114558.7527 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7530 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@114558.7548 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7552 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@114558.7567 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7585 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114558.7593 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7608 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114558.7616 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7630 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114558.7636 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@114558.7650 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114558.7669 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114558.7690 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.7695 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@114558.7723 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7740 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114558.7751 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f128358664f1e66bb',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114558.7756 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7772 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114558.7781 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f128358664f1e66bb','--','bo',7.4184636118598382749 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114558.7786 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.7801 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114558.7809 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 ('aut664f128358664f1e66bb','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@114558.8323 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.8327 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '324.646.00.01'
20240523@114558.8349 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 = '324.646.00.01'
20240523@114558.8364 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.8381 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114558.8393 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.8410 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114558.8418 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='324.646.00.01' and lote = 'r2400054100a'
20240523@114558.8431 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@114558.8445 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.8465 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114558.8474 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f146903664f1e66ce','aut664f128358664f1e66bb',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 = 'aut664f128358664f1e66bb'
20240523@114558.8651 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114558.8671 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114558.8686 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 'aut664f146903664f1e66ce',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 ,14.84,14.84*200.48,14.84,14.84*200.48 ,0,0,'un ',' ' ,bo.marcada,1 ,14.84*1428,14.84*1428*200.48 ,18.323000,18.323000*200.48 ,18.323000,18.323000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,14.84,14.84*200.48,14.84*1428,14.84*1428*200.48,'cps24011554815,886000003 ',110.09,110.09*1428,110.09,110.09*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f128358664f1e66bb'
20240523@114558.9258 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114558.9264 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f128358664f1e66bb' ,@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@114559.1151 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114559.1167 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f128358664f1e66bb'
20240523@114559.1184 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) = 'aut664f128358664f1e66bb' 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@114559.3223 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114559.3227 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@114559.3240 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='59';
20240523@114559.3254 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='59';
20240523@114755.6862 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@114755.6879 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@114755.6895 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='60';
20240523@114755.6934 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='60';
20240523@114755.6946 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='60';
20240523@114755.6957 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='60';
20240523@114755.6969 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.6973 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@114755.6989 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@114755.6999 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@114755.7013 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 = 'cps24011554815,886000003 ' 
20240523@114755.7026 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7029 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@114755.7040 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7043 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@114755.7064 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@114755.7082 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7085 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@114755.7100 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7103 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@114755.7114 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7132 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114755.7140 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7154 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114755.7160 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7174 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114755.7180 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@114755.7194 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114755.7284 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@114755.7303 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7307 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@114755.7322 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7340 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@114755.7347 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f101533664f1edbb2',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114755.7358 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7374 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@114755.7383 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f101533664f1edbb2','--','bo',7.4184636118598382749 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@114755.7388 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7402 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@114755.7409 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 ('aut664f101533664f1edbb2','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@114755.7904 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.7909 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '324.646.00.01'
20240523@114755.7927 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 = '324.646.00.01'
20240523@114755.7941 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7957 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114755.7968 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.7982 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114755.7991 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='324.646.00.01' and lote = 'rxxa'
20240523@114755.8001 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.8015 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'se' and documentnumber = 0
20240523@114755.8023 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.8038 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'se' and documentnumber = 0
20240523@114755.8048 43742rj9r88k8ep1pbna67g28b Query : insert into se (sestamp,ref, lote, data,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f165036664f1edbc3',?,?,'20240523',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut;','aut;')
20240523@114755.8160 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@114755.8175 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.8191 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@114755.8198 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f129410664f1edbc7','aut664f101533664f1edbb2',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 = 'aut664f101533664f1edbb2'
20240523@114755.8397 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@114755.8414 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@114755.8428 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 'aut664f129410664f1edbc7',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 ,14.84,14.84*200.48,14.84,14.84*200.48 ,0,0,'un ',' ' ,bo.marcada,1 ,14.84*1428,14.84*1428*200.48 ,18.323000,18.323000*200.48 ,18.323000,18.323000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,14.84,14.84*200.48,14.84*1428,14.84*1428*200.48,'cps24011554815,886000003 ',110.09,110.09*1428,110.09,110.09*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f101533664f1edbb2'
20240523@114755.9117 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114755.9137 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f101533664f1edbb2' ,@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@114756.9620 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114756.9660 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f101533664f1edbb2'
20240523@114756.9830 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) = 'aut664f101533664f1edbb2' 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@114756.3931 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@114756.3937 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@114756.3951 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='60';
20240523@114756.3965 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='60';
20240523@115057.3485 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@115057.3499 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@115057.3518 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='61';
20240523@115057.3558 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='61';
20240523@115057.3569 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='61';
20240523@115057.3584 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='61';
20240523@115057.3594 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115057.3598 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@115057.3618 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@115057.3634 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@115057.3651 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 = 'cps24011554815,886000003 ' 
20240523@115329.8037 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@115329.8061 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@115329.8078 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='62';
20240523@115329.8118 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='62';
20240523@115329.8129 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='62';
20240523@115329.8142 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='62';
20240523@115329.8175 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115329.8179 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@115329.8199 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@115329.8224 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@115329.8292 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 = 'cps24011554815,886000003 ' 
20240523@115701.5449 43742rj9r88k8ep1pbna67g28b Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240523@115701.5500 43742rj9r88k8ep1pbna67g28b Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240523@115701.5517 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='63';
20240523@115701.5553 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='63';
20240523@115701.5565 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='63';
20240523@115701.5577 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='63';
20240523@115701.5588 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.5592 43742rj9r88k8ep1pbna67g28b Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240523@115701.5611 43742rj9r88k8ep1pbna67g28b Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.646.00.01'
20240523@115701.5622 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 = 2400054 and bi.ref ='324.646.00.01' and bi.lordem =10000
20240523@115701.5636 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 = 'cps24011554815,886000003 ' 
20240523@115701.5649 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.5652 43742rj9r88k8ep1pbna67g28b Query : select top 1 1 valor from ts where ts.ndos = 61
20240523@115701.5664 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.5667 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@115701.5753 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@115701.5771 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.5774 43742rj9r88k8ep1pbna67g28b Query : select top 1 ~inactivo valor from fl where no = '202090' and estab = 00 order by inactivo desc
20240523@115701.5853 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.5856 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from ts where ndos = 61
20240523@115701.5867 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.5925 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@115701.5954 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.5969 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@115701.5976 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.6050 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@115701.6058 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@115701.6073 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@115701.6157 43742rj9r88k8ep1pbna67g28b Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240523@115701.6176 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.6179 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@115701.6232 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.6272 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240523@115701.6279 43742rj9r88k8ep1pbna67g28b Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f245184664f20fd96',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@115701.6327 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.6366 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240523@115701.6374 43742rj9r88k8ep1pbna67g28b Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f245184664f20fd96','--','bo',7.4184636118598382749 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240523@115701.6380 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.6395 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240523@115701.6459 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 ('aut664f245184664f20fd96','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@115701.7305 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115701.7346 43742rj9r88k8ep1pbna67g28b Query : select st.usalote valor from st where st.ref = '324.646.00.01'
20240523@115701.7363 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 = '324.646.00.01'
20240523@115701.7386 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.7565 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@115701.7576 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.7591 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@115701.7598 43742rj9r88k8ep1pbna67g28b Query : select sestamp valor from se where ref ='324.646.00.01' and lote = 'rxxa'
20240523@115701.7691 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.8573 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'se' and documentnumber = 0
20240523@115701.8964 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115701.9335 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'se' and documentnumber = 0
20240523@115701.9614 43742rj9r88k8ep1pbna67g28b Query : insert into se (sestamp,ref, lote, data,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut664f228246664f20fdda',?,?,'20240523',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut;','aut;')
20240523@115701.9943 43742rj9r88k8ep1pbna67g28b Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240523@115702.4470 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115702.8560 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240523@115702.9830 43742rj9r88k8ep1pbna67g28b Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut664f299573664f20fe0a','aut664f245184664f20fd96',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 = 'aut664f245184664f20fd96'
20240523@115702.1372 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240523@115702.2045 43742rj9r88k8ep1pbna67g28b Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240523@115702.3212 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 'aut664f299573664f20fe0a',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 ,14.84,14.84*200.48,14.84,14.84*200.48 ,0,0,'un ',' ' ,bo.marcada,1 ,14.84*1428,14.84*1428*200.48 ,18.323000,18.323000*200.48 ,18.323000,18.323000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,14.84,14.84*200.48,14.84*1428,14.84*1428*200.48,'cps24011554815,886000003 ',110.09,110.09*1428,110.09,110.09*1428,?,?,?,4 from bo bo where bo.bostamp = 'aut664f245184664f20fd96'
20240523@115702.4648 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115702.4667 43742rj9r88k8ep1pbna67g28b Query : declare @bostamp varchar(25) = 'aut664f245184664f20fd96' ,@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@115702.9627 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115702.9855 43742rj9r88k8ep1pbna67g28b Query : select 1 valor from bo where bo.bostamp = 'aut664f245184664f20fd96'
20240523@115703.4430 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) = 'aut664f245184664f20fd96' 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@115703.7828 43742rj9r88k8ep1pbna67g28b Query : use flama_phc
20240523@115703.7874 43742rj9r88k8ep1pbna67g28b Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240523@115703.7952 43742rj9r88k8ep1pbna67g28b Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='63';
20240523@115703.8392 43742rj9r88k8ep1pbna67g28b Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='63';

20240523@153656.7072 kfbtc5mqs84l4q9kgoiofb7cra Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='64';
20240523@153656.7083 kfbtc5mqs84l4q9kgoiofb7cra Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='64';
20240523@153656.7095 kfbtc5mqs84l4q9kgoiofb7cra Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='64';

20240524@081843.7092 n9m9jakfo2mh3sadspi9f423ud Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='65';
20240524@081843.7115 n9m9jakfo2mh3sadspi9f423ud Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='65';
20240524@081843.7126 n9m9jakfo2mh3sadspi9f423ud Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='65';
20240524@081843.7136 n9m9jakfo2mh3sadspi9f423ud Query : use flama_phc
20240524@081843.7139 n9m9jakfo2mh3sadspi9f423ud Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081843.7183 n9m9jakfo2mh3sadspi9f423ud Query : use flama_phc
20240524@081843.7187 n9m9jakfo2mh3sadspi9f423ud Query : select no, estab,szadrsdesc from szadrs where u_coddest=4785
20240524@081843.7268 n9m9jakfo2mh3sadspi9f423ud 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'
20240524@081843.7407 n9m9jakfo2mh3sadspi9f423ud 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 = 2403680 and bi.ref ='324.1879.00.1' and bi.lordem =1
20240524@081843.8040 n9m9jakfo2mh3sadspi9f423ud 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'
20240524@081843.8250 n9m9jakfo2mh3sadspi9f423ud 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 = 2403680 and bi.ref ='324.1879.00.1' and bi.lordem =1
20240524@081843.8265 n9m9jakfo2mh3sadspi9f423ud 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'
20240524@081843.8497 n9m9jakfo2mh3sadspi9f423ud 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 = 2403680 and bi.ref ='324.1879.00.1' and bi.lordem =2
20240524@081843.8836 n9m9jakfo2mh3sadspi9f423ud Query : use flama_phc
20240524@081843.8839 n9m9jakfo2mh3sadspi9f423ud Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081843.9014 n9m9jakfo2mh3sadspi9f423ud Query : use flama_phc
20240524@081843.9017 n9m9jakfo2mh3sadspi9f423ud Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081843.9094 n9m9jakfo2mh3sadspi9f423ud Query : use flama_phc
20240524@081843.9097 n9m9jakfo2mh3sadspi9f423ud 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')
20240524@081843.9645 7r6f01pla7a5l44btuk5i3o1o0 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081843.9657 7r6f01pla7a5l44btuk5i3o1o0 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081843.9670 7r6f01pla7a5l44btuk5i3o1o0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='66';
20240524@081843.9704 7r6f01pla7a5l44btuk5i3o1o0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='66';
20240524@081843.9716 7r6f01pla7a5l44btuk5i3o1o0 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='66';
20240524@081843.9727 7r6f01pla7a5l44btuk5i3o1o0 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='66';
20240524@081843.9737 7r6f01pla7a5l44btuk5i3o1o0 Query : use flama_phc
20240524@081843.9740 7r6f01pla7a5l44btuk5i3o1o0 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081843.9754 7r6f01pla7a5l44btuk5i3o1o0 Query : use flama_phc
20240524@081843.9756 7r6f01pla7a5l44btuk5i3o1o0 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4801
20240524@081843.9826 7r6f01pla7a5l44btuk5i3o1o0 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'
20240524@081843.9967 7r6f01pla7a5l44btuk5i3o1o0 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 = 2403686 and bi.ref ='324.1824.00.1' and bi.lordem =1
20240524@081844.7530 7r6f01pla7a5l44btuk5i3o1o0 Query : use flama_phc
20240524@081844.9140 7r6f01pla7a5l44btuk5i3o1o0 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081844.1478 7r6f01pla7a5l44btuk5i3o1o0 Query : use flama_phc
20240524@081844.1482 7r6f01pla7a5l44btuk5i3o1o0 Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081844.1528 7r6f01pla7a5l44btuk5i3o1o0 Query : use flama_phc
20240524@081844.1530 7r6f01pla7a5l44btuk5i3o1o0 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')
20240524@081844.2016 abo940vpsi9qrju8qv5c7i40nv Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081844.2028 abo940vpsi9qrju8qv5c7i40nv Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081844.2041 abo940vpsi9qrju8qv5c7i40nv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='67';
20240524@081844.2074 abo940vpsi9qrju8qv5c7i40nv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='67';
20240524@081844.2084 abo940vpsi9qrju8qv5c7i40nv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='67';
20240524@081844.2094 abo940vpsi9qrju8qv5c7i40nv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='67';
20240524@081844.2104 abo940vpsi9qrju8qv5c7i40nv Query : use flama_phc
20240524@081844.2107 abo940vpsi9qrju8qv5c7i40nv Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081844.2121 abo940vpsi9qrju8qv5c7i40nv Query : use flama_phc
20240524@081844.2124 abo940vpsi9qrju8qv5c7i40nv Query : select no, estab,szadrsdesc from szadrs where u_coddest=743
20240524@081844.2196 abo940vpsi9qrju8qv5c7i40nv 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'
20240524@081844.2338 abo940vpsi9qrju8qv5c7i40nv 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 = 2403707 and bi.ref ='323.367.09.00' and bi.lordem =1
20240524@081844.2656 abo940vpsi9qrju8qv5c7i40nv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1675.00.2'
20240524@081844.2804 abo940vpsi9qrju8qv5c7i40nv 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 = 2403707 and bi.ref ='324.1675.00.2' and bi.lordem =2
20240524@081844.3120 abo940vpsi9qrju8qv5c7i40nv 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'
20240524@081844.3256 abo940vpsi9qrju8qv5c7i40nv 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 = 2403707 and bi.ref ='324.691.00.01' and bi.lordem =3
20240524@081844.3575 abo940vpsi9qrju8qv5c7i40nv 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'
20240524@081844.3718 abo940vpsi9qrju8qv5c7i40nv 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 = 2403707 and bi.ref ='324.692.00.01' and bi.lordem =4
20240524@081844.4040 abo940vpsi9qrju8qv5c7i40nv Query : use flama_phc
20240524@081844.4043 abo940vpsi9qrju8qv5c7i40nv Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081844.4058 abo940vpsi9qrju8qv5c7i40nv Query : use flama_phc
20240524@081844.4061 abo940vpsi9qrju8qv5c7i40nv Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081844.4072 abo940vpsi9qrju8qv5c7i40nv Query : use flama_phc
20240524@081844.4075 abo940vpsi9qrju8qv5c7i40nv 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')
20240524@081844.4800 p2t4b2f2mad5852spcim3f78qp Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081844.4814 p2t4b2f2mad5852spcim3f78qp Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081844.4826 p2t4b2f2mad5852spcim3f78qp Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='68';
20240524@081844.4861 p2t4b2f2mad5852spcim3f78qp Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='68';
20240524@081844.4871 p2t4b2f2mad5852spcim3f78qp Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='68';
20240524@081844.4883 p2t4b2f2mad5852spcim3f78qp Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='68';
20240524@081844.4894 p2t4b2f2mad5852spcim3f78qp Query : use flama_phc
20240524@081844.4896 p2t4b2f2mad5852spcim3f78qp Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081844.4910 p2t4b2f2mad5852spcim3f78qp Query : use flama_phc
20240524@081844.4912 p2t4b2f2mad5852spcim3f78qp Query : select no, estab,szadrsdesc from szadrs where u_coddest=1334
20240524@081844.4990 p2t4b2f2mad5852spcim3f78qp 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'
20240524@081844.5000 p2t4b2f2mad5852spcim3f78qp 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 = 2403714 and bi.ref ='324.691.00.01' and bi.lordem =1
20240524@081844.5315 p2t4b2f2mad5852spcim3f78qp 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'
20240524@081844.5327 p2t4b2f2mad5852spcim3f78qp 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 = 2403714 and bi.ref ='324.692.00.01' and bi.lordem =2
20240524@081844.5666 p2t4b2f2mad5852spcim3f78qp Query : use flama_phc
20240524@081844.5669 p2t4b2f2mad5852spcim3f78qp Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081844.5682 p2t4b2f2mad5852spcim3f78qp Query : use flama_phc
20240524@081844.5685 p2t4b2f2mad5852spcim3f78qp Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081844.5696 p2t4b2f2mad5852spcim3f78qp Query : use flama_phc
20240524@081844.5699 p2t4b2f2mad5852spcim3f78qp 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')
20240524@081844.6592 nhbh26i3c0vf1udqgh1d6d1t5c Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081844.6605 nhbh26i3c0vf1udqgh1d6d1t5c Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081844.6618 nhbh26i3c0vf1udqgh1d6d1t5c Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='69';
20240524@081844.6654 nhbh26i3c0vf1udqgh1d6d1t5c Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='69';
20240524@081844.6665 nhbh26i3c0vf1udqgh1d6d1t5c Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='69';
20240524@081844.6675 nhbh26i3c0vf1udqgh1d6d1t5c Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='69';
20240524@081844.6685 nhbh26i3c0vf1udqgh1d6d1t5c Query : use flama_phc
20240524@081844.6688 nhbh26i3c0vf1udqgh1d6d1t5c Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081844.6700 nhbh26i3c0vf1udqgh1d6d1t5c Query : use flama_phc
20240524@081844.6703 nhbh26i3c0vf1udqgh1d6d1t5c Query : select no, estab,szadrsdesc from szadrs where u_coddest=6625
20240524@081844.6779 nhbh26i3c0vf1udqgh1d6d1t5c 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'
20240524@081844.6914 nhbh26i3c0vf1udqgh1d6d1t5c 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 = 2403715 and bi.ref ='324.2223.00.1' and bi.lordem =1
20240524@081844.7223 nhbh26i3c0vf1udqgh1d6d1t5c 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'
20240524@081844.7369 nhbh26i3c0vf1udqgh1d6d1t5c 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 = 2403715 and bi.ref ='324.681.00.01' and bi.lordem =2
20240524@081844.7693 nhbh26i3c0vf1udqgh1d6d1t5c 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'
20240524@081844.7841 nhbh26i3c0vf1udqgh1d6d1t5c 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 = 2403715 and bi.ref ='324.4521.00.1' and bi.lordem =3
20240524@081844.8160 nhbh26i3c0vf1udqgh1d6d1t5c 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'
20240524@081844.8170 nhbh26i3c0vf1udqgh1d6d1t5c 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 = 2403715 and bi.ref ='324.4521.00.1' and bi.lordem =3
20240524@081844.8177 nhbh26i3c0vf1udqgh1d6d1t5c Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.5342.00.1'
20240524@081844.8320 nhbh26i3c0vf1udqgh1d6d1t5c 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 = 2403715 and bi.ref ='324.5342.00.1' and bi.lordem =4
20240524@081844.8648 nhbh26i3c0vf1udqgh1d6d1t5c Query : use flama_phc
20240524@081844.8651 nhbh26i3c0vf1udqgh1d6d1t5c Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081844.8664 nhbh26i3c0vf1udqgh1d6d1t5c Query : use flama_phc
20240524@081844.8667 nhbh26i3c0vf1udqgh1d6d1t5c Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081844.8677 nhbh26i3c0vf1udqgh1d6d1t5c Query : use flama_phc
20240524@081844.8680 nhbh26i3c0vf1udqgh1d6d1t5c 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')
20240524@081844.9157 4656t8iguu3mqt8eimlvp721sa Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081844.9169 4656t8iguu3mqt8eimlvp721sa Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081844.9182 4656t8iguu3mqt8eimlvp721sa Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='70';
20240524@081844.9217 4656t8iguu3mqt8eimlvp721sa Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='70';
20240524@081844.9227 4656t8iguu3mqt8eimlvp721sa Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='70';
20240524@081844.9237 4656t8iguu3mqt8eimlvp721sa Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='70';
20240524@081844.9247 4656t8iguu3mqt8eimlvp721sa Query : use flama_phc
20240524@081844.9250 4656t8iguu3mqt8eimlvp721sa Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081844.9273 4656t8iguu3mqt8eimlvp721sa Query : use flama_phc
20240524@081844.9276 4656t8iguu3mqt8eimlvp721sa Query : select no, estab,szadrsdesc from szadrs where u_coddest=5187
20240524@081845.4660 4656t8iguu3mqt8eimlvp721sa 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'
20240524@081845.6130 4656t8iguu3mqt8eimlvp721sa 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 = 2403716 and bi.ref ='324.2221.00.1' and bi.lordem =1
20240524@081845.9410 4656t8iguu3mqt8eimlvp721sa 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'
20240524@081845.1085 4656t8iguu3mqt8eimlvp721sa 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 = 2403716 and bi.ref ='324.645.00.01' and bi.lordem =2
20240524@081845.1418 4656t8iguu3mqt8eimlvp721sa Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240524@081845.1558 4656t8iguu3mqt8eimlvp721sa 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 = 2403716 and bi.ref ='324.646.00.01' and bi.lordem =3
20240524@081845.1907 4656t8iguu3mqt8eimlvp721sa 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'
20240524@081845.2063 4656t8iguu3mqt8eimlvp721sa 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 = 2403716 and bi.ref ='324.642.00.01' and bi.lordem =4
20240524@081845.2540 4656t8iguu3mqt8eimlvp721sa Query : use flama_phc
20240524@081845.2544 4656t8iguu3mqt8eimlvp721sa Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081845.2559 4656t8iguu3mqt8eimlvp721sa Query : use flama_phc
20240524@081845.2561 4656t8iguu3mqt8eimlvp721sa Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081845.2572 4656t8iguu3mqt8eimlvp721sa Query : use flama_phc
20240524@081845.2575 4656t8iguu3mqt8eimlvp721sa 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')
20240524@081845.3069 eooehklv8ltqciqkls39ia6169 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081845.3081 eooehklv8ltqciqkls39ia6169 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081845.3094 eooehklv8ltqciqkls39ia6169 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='71';
20240524@081845.3129 eooehklv8ltqciqkls39ia6169 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='71';
20240524@081845.3140 eooehklv8ltqciqkls39ia6169 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='71';
20240524@081845.3149 eooehklv8ltqciqkls39ia6169 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='71';
20240524@081845.3159 eooehklv8ltqciqkls39ia6169 Query : use flama_phc
20240524@081845.3162 eooehklv8ltqciqkls39ia6169 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240524@081845.3175 eooehklv8ltqciqkls39ia6169 Query : use flama_phc
20240524@081845.3178 eooehklv8ltqciqkls39ia6169 Query : select no, estab,szadrsdesc from szadrs where u_coddest=1124
20240524@081845.3254 eooehklv8ltqciqkls39ia6169 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1461.00.1'
20240524@081845.3397 eooehklv8ltqciqkls39ia6169 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 = 2403720 and bi.ref ='324.1461.00.1' and bi.lordem =1
20240524@081845.3739 eooehklv8ltqciqkls39ia6169 Query : use flama_phc
20240524@081845.3742 eooehklv8ltqciqkls39ia6169 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240524@081845.3755 eooehklv8ltqciqkls39ia6169 Query : use flama_phc
20240524@081845.3758 eooehklv8ltqciqkls39ia6169 Query : select top 1 1 valor from td where td.ndoc = 39
20240524@081845.3769 eooehklv8ltqciqkls39ia6169 Query : use flama_phc
20240524@081845.3772 eooehklv8ltqciqkls39ia6169 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')
20240524@081845.4350 cfoglsai7cde6vo6c17lhl6buv Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240524@081845.4363 cfoglsai7cde6vo6c17lhl6buv Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240524@081845.4376 cfoglsai7cde6vo6c17lhl6buv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='72';
20240524@081845.4412 cfoglsai7cde6vo6c17lhl6buv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='72';
20240524@081845.4422 cfoglsai7cde6vo6c17lhl6buv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='72';
20240524@081845.4433 cfoglsai7cde6vo6c17lhl6buv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='72';

20240524@163548.4449 lgji1he9unf4iufn27sufj8eee Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='73';
20240524@163548.4474 lgji1he9unf4iufn27sufj8eee Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='73';
20240524@163548.4488 lgji1he9unf4iufn27sufj8eee Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='73';

20240524@165048.4195 oabokcs6qk9kh82q52dn62u0mi Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='74';
20240524@165048.4205 oabokcs6qk9kh82q52dn62u0mi Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='74';
20240524@165048.4215 oabokcs6qk9kh82q52dn62u0mi Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='74';

20240527@074545.3416 ld5dsvd9to4fq3j3o3ektaiih1 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='75';
20240527@074545.3454 ld5dsvd9to4fq3j3o3ektaiih1 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='75';
20240527@074545.3465 ld5dsvd9to4fq3j3o3ektaiih1 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='75';
20240527@074545.3477 ld5dsvd9to4fq3j3o3ektaiih1 Query : use flama_phc
20240527@074545.3480 ld5dsvd9to4fq3j3o3ektaiih1 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074545.3529 ld5dsvd9to4fq3j3o3ektaiih1 Query : use flama_phc
20240527@074545.3532 ld5dsvd9to4fq3j3o3ektaiih1 Query : select no, estab,szadrsdesc from szadrs where u_coddest=6737
20240527@074545.3616 ld5dsvd9to4fq3j3o3ektaiih1 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '328.9106.00.1'
20240527@074545.3772 ld5dsvd9to4fq3j3o3ektaiih1 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 = 2403704 and bi.ref ='328.9106.00.1' and bi.lordem =1
20240527@074545.4146 ld5dsvd9to4fq3j3o3ektaiih1 Query : use flama_phc
20240527@074545.4166 ld5dsvd9to4fq3j3o3ektaiih1 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074545.4343 ld5dsvd9to4fq3j3o3ektaiih1 Query : use flama_phc
20240527@074545.4346 ld5dsvd9to4fq3j3o3ektaiih1 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074545.4419 ld5dsvd9to4fq3j3o3ektaiih1 Query : use flama_phc
20240527@074545.4422 ld5dsvd9to4fq3j3o3ektaiih1 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')
20240527@074545.5008 tk5k4o2gjdeitk7p9mbuo4l8op Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074545.5021 tk5k4o2gjdeitk7p9mbuo4l8op Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074545.5035 tk5k4o2gjdeitk7p9mbuo4l8op Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='76';
20240527@074545.5070 tk5k4o2gjdeitk7p9mbuo4l8op Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='76';
20240527@074545.5085 tk5k4o2gjdeitk7p9mbuo4l8op Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='76';
20240527@074545.5095 tk5k4o2gjdeitk7p9mbuo4l8op Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='76';
20240527@074545.5106 tk5k4o2gjdeitk7p9mbuo4l8op Query : use flama_phc
20240527@074545.5109 tk5k4o2gjdeitk7p9mbuo4l8op Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074545.5125 tk5k4o2gjdeitk7p9mbuo4l8op Query : use flama_phc
20240527@074545.5128 tk5k4o2gjdeitk7p9mbuo4l8op Query : select no, estab,szadrsdesc from szadrs where u_coddest=4779
20240527@074545.5206 tk5k4o2gjdeitk7p9mbuo4l8op 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'
20240527@074545.5386 tk5k4o2gjdeitk7p9mbuo4l8op 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 = 2403705 and bi.ref ='304.421.00.04' and bi.lordem =1
20240527@074545.5789 tk5k4o2gjdeitk7p9mbuo4l8op 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'
20240527@074545.5970 tk5k4o2gjdeitk7p9mbuo4l8op 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 = 2403705 and bi.ref ='324.4521.00.1' and bi.lordem =2
20240527@074545.6324 tk5k4o2gjdeitk7p9mbuo4l8op Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4960.00.1'
20240527@074545.6468 tk5k4o2gjdeitk7p9mbuo4l8op 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 = 2403705 and bi.ref ='324.4960.00.1' and bi.lordem =3
20240527@074545.7835 tk5k4o2gjdeitk7p9mbuo4l8op Query : use flama_phc
20240527@074545.7839 tk5k4o2gjdeitk7p9mbuo4l8op Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074545.7854 tk5k4o2gjdeitk7p9mbuo4l8op Query : use flama_phc
20240527@074545.7857 tk5k4o2gjdeitk7p9mbuo4l8op Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074545.7867 tk5k4o2gjdeitk7p9mbuo4l8op Query : use flama_phc
20240527@074545.7870 tk5k4o2gjdeitk7p9mbuo4l8op 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')
20240527@074545.8316 o8880hg74ih8sqv2p79mnqturv Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074545.8329 o8880hg74ih8sqv2p79mnqturv Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074545.8343 o8880hg74ih8sqv2p79mnqturv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='77';
20240527@074545.8991 o8880hg74ih8sqv2p79mnqturv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='77';
20240527@074545.9006 o8880hg74ih8sqv2p79mnqturv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='77';
20240527@074545.9018 o8880hg74ih8sqv2p79mnqturv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='77';
20240527@074545.9030 o8880hg74ih8sqv2p79mnqturv Query : use flama_phc
20240527@074545.9033 o8880hg74ih8sqv2p79mnqturv Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074545.9048 o8880hg74ih8sqv2p79mnqturv Query : use flama_phc
20240527@074545.9050 o8880hg74ih8sqv2p79mnqturv Query : select no, estab,szadrsdesc from szadrs where u_coddest=6917
20240527@074545.9123 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2000.94.1'
20240527@074545.9270 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.2000.94.1' and bi.lordem =1
20240527@074545.9630 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2000.94.1'
20240527@074545.9641 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.2000.94.1' and bi.lordem =1
20240527@074545.9647 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.900.94.02'
20240527@074545.9847 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.900.94.02' and bi.lordem =2
20240527@074546.1660 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.900.94.02'
20240527@074546.1730 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.900.94.02' and bi.lordem =2
20240527@074546.1800 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.700.94.01'
20240527@074546.3290 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.700.94.01' and bi.lordem =3
20240527@074546.7590 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2200.94.1'
20240527@074546.9030 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.2200.94.1' and bi.lordem =4
20240527@074546.1214 o8880hg74ih8sqv2p79mnqturv Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2200.94.1'
20240527@074546.1226 o8880hg74ih8sqv2p79mnqturv 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 = 2403718 and bi.ref ='324.2200.94.1' and bi.lordem =4
20240527@074546.1235 o8880hg74ih8sqv2p79mnqturv Query : use flama_phc
20240527@074546.1238 o8880hg74ih8sqv2p79mnqturv Query : select szadrsstamp valor from szadrs where szadrsdesc='espaÇotrans,lda'
20240527@074546.1285 o8880hg74ih8sqv2p79mnqturv Query : use flama_phc
20240527@074546.1288 o8880hg74ih8sqv2p79mnqturv Query : select top 1 errorresult result ,errornumber errornumber ,descriptionpt description ,isnull(descriptionen,'') descriptionen ,isnull(descriptionfr,'') descriptionfr from wserrorcodes where errornumber = -65
20240527@074546.1339 o8880hg74ih8sqv2p79mnqturv Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='77';
20240527@074546.1350 o8880hg74ih8sqv2p79mnqturv Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='77';
20240527@074546.1809 mn89g6nupvfmd2c3mlb5vmtc56 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074546.1821 mn89g6nupvfmd2c3mlb5vmtc56 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074546.1835 mn89g6nupvfmd2c3mlb5vmtc56 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='78';
20240527@074546.1882 mn89g6nupvfmd2c3mlb5vmtc56 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='78';
20240527@074546.1893 mn89g6nupvfmd2c3mlb5vmtc56 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='78';
20240527@074546.1904 mn89g6nupvfmd2c3mlb5vmtc56 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='78';
20240527@074546.1914 mn89g6nupvfmd2c3mlb5vmtc56 Query : use flama_phc
20240527@074546.1917 mn89g6nupvfmd2c3mlb5vmtc56 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074546.1930 mn89g6nupvfmd2c3mlb5vmtc56 Query : use flama_phc
20240527@074546.1933 mn89g6nupvfmd2c3mlb5vmtc56 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4774
20240527@074546.2008 mn89g6nupvfmd2c3mlb5vmtc56 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1461.00.1'
20240527@074546.2254 mn89g6nupvfmd2c3mlb5vmtc56 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 = 2403719 and bi.ref ='324.1461.00.1' and bi.lordem =1
20240527@074546.2721 mn89g6nupvfmd2c3mlb5vmtc56 Query : use flama_phc
20240527@074546.2725 mn89g6nupvfmd2c3mlb5vmtc56 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074546.2738 mn89g6nupvfmd2c3mlb5vmtc56 Query : use flama_phc
20240527@074546.2741 mn89g6nupvfmd2c3mlb5vmtc56 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074546.2752 mn89g6nupvfmd2c3mlb5vmtc56 Query : use flama_phc
20240527@074546.2755 mn89g6nupvfmd2c3mlb5vmtc56 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')
20240527@074546.4040 e55m1j0ft0qh3o2cnrjola2ff4 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074546.4054 e55m1j0ft0qh3o2cnrjola2ff4 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074546.4068 e55m1j0ft0qh3o2cnrjola2ff4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='79';
20240527@074546.4397 e55m1j0ft0qh3o2cnrjola2ff4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='79';
20240527@074546.4749 e55m1j0ft0qh3o2cnrjola2ff4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='79';
20240527@074546.4763 e55m1j0ft0qh3o2cnrjola2ff4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='79';
20240527@074546.4777 e55m1j0ft0qh3o2cnrjola2ff4 Query : use flama_phc
20240527@074546.4780 e55m1j0ft0qh3o2cnrjola2ff4 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074546.4795 e55m1j0ft0qh3o2cnrjola2ff4 Query : use flama_phc
20240527@074546.4798 e55m1j0ft0qh3o2cnrjola2ff4 Query : select no, estab,szadrsdesc from szadrs where u_coddest=6737
20240527@074546.4830 e55m1j0ft0qh3o2cnrjola2ff4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '328.9902.00.1'
20240527@074546.4979 e55m1j0ft0qh3o2cnrjola2ff4 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 = 2403729 and bi.ref ='328.9902.00.1' and bi.lordem =1
20240527@074546.5300 e55m1j0ft0qh3o2cnrjola2ff4 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '328.9902.00.1'
20240527@074546.5312 e55m1j0ft0qh3o2cnrjola2ff4 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 = 2403729 and bi.ref ='328.9902.00.1' and bi.lordem =1
20240527@074546.5320 e55m1j0ft0qh3o2cnrjola2ff4 Query : use flama_phc
20240527@074546.5323 e55m1j0ft0qh3o2cnrjola2ff4 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074546.5337 e55m1j0ft0qh3o2cnrjola2ff4 Query : use flama_phc
20240527@074546.5339 e55m1j0ft0qh3o2cnrjola2ff4 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074546.5351 e55m1j0ft0qh3o2cnrjola2ff4 Query : use flama_phc
20240527@074546.5353 e55m1j0ft0qh3o2cnrjola2ff4 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')
20240527@074546.6926 n3harbp4ba54u0a2av9qprji7c Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074546.6939 n3harbp4ba54u0a2av9qprji7c Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074546.6953 n3harbp4ba54u0a2av9qprji7c Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='80';
20240527@074546.6993 n3harbp4ba54u0a2av9qprji7c Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='80';
20240527@074546.7004 n3harbp4ba54u0a2av9qprji7c Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='80';
20240527@074546.7016 n3harbp4ba54u0a2av9qprji7c Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='80';
20240527@074546.7026 n3harbp4ba54u0a2av9qprji7c Query : use flama_phc
20240527@074546.7029 n3harbp4ba54u0a2av9qprji7c Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074546.7043 n3harbp4ba54u0a2av9qprji7c Query : use flama_phc
20240527@074546.7046 n3harbp4ba54u0a2av9qprji7c Query : select no, estab,szadrsdesc from szadrs where u_coddest=4801
20240527@074546.7117 n3harbp4ba54u0a2av9qprji7c Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.499.00.01'
20240527@074546.7256 n3harbp4ba54u0a2av9qprji7c 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 = 2403730 and bi.ref ='324.499.00.01' and bi.lordem =1
20240527@074546.7573 n3harbp4ba54u0a2av9qprji7c 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'
20240527@074546.7713 n3harbp4ba54u0a2av9qprji7c 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 = 2403730 and bi.ref ='324.4723.00.2' and bi.lordem =2
20240527@074546.8025 n3harbp4ba54u0a2av9qprji7c Query : use flama_phc
20240527@074546.8029 n3harbp4ba54u0a2av9qprji7c Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074546.8044 n3harbp4ba54u0a2av9qprji7c Query : use flama_phc
20240527@074546.8047 n3harbp4ba54u0a2av9qprji7c Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074546.8057 n3harbp4ba54u0a2av9qprji7c Query : use flama_phc
20240527@074546.8060 n3harbp4ba54u0a2av9qprji7c 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')
20240527@074546.8557 jd062u7q7h1e1oo9lt1n0pi8c8 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074546.8574 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074546.8588 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='81';
20240527@074546.8626 jd062u7q7h1e1oo9lt1n0pi8c8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='81';
20240527@074546.8637 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='81';
20240527@074546.8648 jd062u7q7h1e1oo9lt1n0pi8c8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='81';
20240527@074546.8658 jd062u7q7h1e1oo9lt1n0pi8c8 Query : use flama_phc
20240527@074546.8660 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074546.8675 jd062u7q7h1e1oo9lt1n0pi8c8 Query : use flama_phc
20240527@074546.8678 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select no, estab,szadrsdesc from szadrs where u_coddest=5338
20240527@074546.8756 jd062u7q7h1e1oo9lt1n0pi8c8 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'
20240527@074546.8910 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='324.691.00.01' and bi.lordem =1
20240527@074546.9219 jd062u7q7h1e1oo9lt1n0pi8c8 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'
20240527@074546.9230 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='324.691.00.01' and bi.lordem =2
20240527@074546.9992 jd062u7q7h1e1oo9lt1n0pi8c8 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'
20240527@074547.4000 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='304.421.00.04' and bi.lordem =3
20240527@074547.3300 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1578.00.1'
20240527@074547.4660 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='324.1578.00.1' and bi.lordem =4
20240527@074547.7830 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1675.00.2'
20240527@074547.9270 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='324.1675.00.2' and bi.lordem =5
20240527@074547.1232 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1675.00.2'
20240527@074547.1242 jd062u7q7h1e1oo9lt1n0pi8c8 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 = 2403738 and bi.ref ='324.1675.00.2' and bi.lordem =6
20240527@074547.1547 jd062u7q7h1e1oo9lt1n0pi8c8 Query : use flama_phc
20240527@074547.1550 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074547.1563 jd062u7q7h1e1oo9lt1n0pi8c8 Query : use flama_phc
20240527@074547.1566 jd062u7q7h1e1oo9lt1n0pi8c8 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074547.1576 jd062u7q7h1e1oo9lt1n0pi8c8 Query : use flama_phc
20240527@074547.1579 jd062u7q7h1e1oo9lt1n0pi8c8 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')
20240527@074547.3425 70g3a3dpgjahk3rao7rmlbc76u Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074547.3439 70g3a3dpgjahk3rao7rmlbc76u Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074547.3452 70g3a3dpgjahk3rao7rmlbc76u Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='82';
20240527@074547.3488 70g3a3dpgjahk3rao7rmlbc76u Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='82';
20240527@074547.3499 70g3a3dpgjahk3rao7rmlbc76u Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='82';
20240527@074547.3509 70g3a3dpgjahk3rao7rmlbc76u Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='82';
20240527@074547.3527 70g3a3dpgjahk3rao7rmlbc76u Query : use flama_phc
20240527@074547.3529 70g3a3dpgjahk3rao7rmlbc76u Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074547.3542 70g3a3dpgjahk3rao7rmlbc76u Query : use flama_phc
20240527@074547.3545 70g3a3dpgjahk3rao7rmlbc76u Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240527@074547.3612 70g3a3dpgjahk3rao7rmlbc76u Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4906.00.1'
20240527@074547.3796 70g3a3dpgjahk3rao7rmlbc76u 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 = 2403740 and bi.ref ='324.4906.00.1' and bi.lordem =1
20240527@074547.4113 70g3a3dpgjahk3rao7rmlbc76u Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4906.00.1'
20240527@074547.4124 70g3a3dpgjahk3rao7rmlbc76u 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 = 2403740 and bi.ref ='324.4906.00.1' and bi.lordem =1
20240527@074547.4131 70g3a3dpgjahk3rao7rmlbc76u Query : use flama_phc
20240527@074547.4134 70g3a3dpgjahk3rao7rmlbc76u Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074547.4149 70g3a3dpgjahk3rao7rmlbc76u Query : use flama_phc
20240527@074547.4152 70g3a3dpgjahk3rao7rmlbc76u Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074547.4163 70g3a3dpgjahk3rao7rmlbc76u Query : use flama_phc
20240527@074547.4166 70g3a3dpgjahk3rao7rmlbc76u 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')
20240527@074547.5192 holo4cp6l3j9anfn7aqgfq2io9 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074547.5207 holo4cp6l3j9anfn7aqgfq2io9 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074547.5221 holo4cp6l3j9anfn7aqgfq2io9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='83';
20240527@074547.5256 holo4cp6l3j9anfn7aqgfq2io9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='83';
20240527@074547.5268 holo4cp6l3j9anfn7aqgfq2io9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='83';
20240527@074547.5278 holo4cp6l3j9anfn7aqgfq2io9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='83';
20240527@074547.5288 holo4cp6l3j9anfn7aqgfq2io9 Query : use flama_phc
20240527@074547.5291 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074547.5304 holo4cp6l3j9anfn7aqgfq2io9 Query : use flama_phc
20240527@074547.5307 holo4cp6l3j9anfn7aqgfq2io9 Query : select no, estab,szadrsdesc from szadrs where u_coddest=6975
20240527@074547.5378 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.5526 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.4840.00.1' and bi.lordem =1
20240527@074547.5836 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.5848 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='304.421.00.04' and bi.lordem =2
20240527@074547.6159 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.6302 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.2221.00.1' and bi.lordem =3
20240527@074547.6616 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.6756 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.2222.00.1' and bi.lordem =4
20240527@074547.7082 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.7221 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.2223.00.1' and bi.lordem =5
20240527@074547.7530 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.7690 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.2224.00.1' and bi.lordem =6
20240527@074547.7999 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240527@074547.8139 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.646.00.01' and bi.lordem =7
20240527@074547.8451 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240527@074547.8488 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.646.00.01' and bi.lordem =7
20240527@074547.8977 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.9198 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.642.00.01' and bi.lordem =8
20240527@074547.9619 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074547.9631 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.4521.00.1' and bi.lordem =9
20240527@074547.9943 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1528.00.1'
20240527@074548.8000 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.1528.00.1' and bi.lordem =10
20240527@074548.3790 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1536.00.1'
20240527@074548.5180 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.1536.00.1' and bi.lordem =11
20240527@074548.8710 holo4cp6l3j9anfn7aqgfq2io9 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'
20240527@074548.1012 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.4964.00.1' and bi.lordem =12
20240527@074548.1404 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.948.00.01'
20240527@074548.1548 holo4cp6l3j9anfn7aqgfq2io9 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 = 2403741 and bi.ref ='324.948.00.01' and bi.lordem =13
20240527@074548.3064 holo4cp6l3j9anfn7aqgfq2io9 Query : use flama_phc
20240527@074548.3110 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074548.3127 holo4cp6l3j9anfn7aqgfq2io9 Query : use flama_phc
20240527@074548.3131 holo4cp6l3j9anfn7aqgfq2io9 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074548.3143 holo4cp6l3j9anfn7aqgfq2io9 Query : use flama_phc
20240527@074548.3146 holo4cp6l3j9anfn7aqgfq2io9 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')
20240527@074548.3682 660tdipd1ujc4ntl6ae7akqnur Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074548.3695 660tdipd1ujc4ntl6ae7akqnur Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074548.3707 660tdipd1ujc4ntl6ae7akqnur Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='84';
20240527@074548.3744 660tdipd1ujc4ntl6ae7akqnur Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='84';
20240527@074548.3755 660tdipd1ujc4ntl6ae7akqnur Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='84';
20240527@074548.3765 660tdipd1ujc4ntl6ae7akqnur Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='84';
20240527@074548.3775 660tdipd1ujc4ntl6ae7akqnur Query : use flama_phc
20240527@074548.3777 660tdipd1ujc4ntl6ae7akqnur Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074548.3790 660tdipd1ujc4ntl6ae7akqnur Query : use flama_phc
20240527@074548.3793 660tdipd1ujc4ntl6ae7akqnur Query : select no, estab,szadrsdesc from szadrs where u_coddest=227
20240527@074548.4018 660tdipd1ujc4ntl6ae7akqnur Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2232.00.1'
20240527@074548.4171 660tdipd1ujc4ntl6ae7akqnur 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 = 2403744 and bi.ref ='324.2232.00.1' and bi.lordem =1
20240527@074548.4825 660tdipd1ujc4ntl6ae7akqnur Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2232.00.1'
20240527@074548.4957 660tdipd1ujc4ntl6ae7akqnur 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 = 2403744 and bi.ref ='324.2232.00.1' and bi.lordem =1
20240527@074548.4968 660tdipd1ujc4ntl6ae7akqnur Query : use flama_phc
20240527@074548.4971 660tdipd1ujc4ntl6ae7akqnur Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074548.4983 660tdipd1ujc4ntl6ae7akqnur Query : use flama_phc
20240527@074548.4986 660tdipd1ujc4ntl6ae7akqnur Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074548.4996 660tdipd1ujc4ntl6ae7akqnur Query : use flama_phc
20240527@074548.4999 660tdipd1ujc4ntl6ae7akqnur 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')
20240527@074548.5576 rvq7edvg1vit906df0c36cob00 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074548.5607 rvq7edvg1vit906df0c36cob00 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074548.5622 rvq7edvg1vit906df0c36cob00 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='85';
20240527@074548.5658 rvq7edvg1vit906df0c36cob00 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='85';
20240527@074548.5668 rvq7edvg1vit906df0c36cob00 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='85';
20240527@074548.5678 rvq7edvg1vit906df0c36cob00 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='85';
20240527@074548.5688 rvq7edvg1vit906df0c36cob00 Query : use flama_phc
20240527@074548.5691 rvq7edvg1vit906df0c36cob00 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074548.5870 rvq7edvg1vit906df0c36cob00 Query : use flama_phc
20240527@074548.5874 rvq7edvg1vit906df0c36cob00 Query : select no, estab,szadrsdesc from szadrs where u_coddest=3674
20240527@074548.5946 rvq7edvg1vit906df0c36cob00 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.5343.00.1'
20240527@074548.6097 rvq7edvg1vit906df0c36cob00 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 = 2403745 and bi.ref ='324.5343.00.1' and bi.lordem =1
20240527@074548.6400 rvq7edvg1vit906df0c36cob00 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.5343.00.1'
20240527@074548.6411 rvq7edvg1vit906df0c36cob00 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 = 2403745 and bi.ref ='324.5343.00.1' and bi.lordem =1
20240527@074548.6417 rvq7edvg1vit906df0c36cob00 Query : use flama_phc
20240527@074548.6420 rvq7edvg1vit906df0c36cob00 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074548.6432 rvq7edvg1vit906df0c36cob00 Query : use flama_phc
20240527@074548.6435 rvq7edvg1vit906df0c36cob00 Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074548.6445 rvq7edvg1vit906df0c36cob00 Query : use flama_phc
20240527@074548.6448 rvq7edvg1vit906df0c36cob00 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')
20240527@074548.6903 pmvf60rt69sqpm7d2tsg65dm3g Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074548.6917 pmvf60rt69sqpm7d2tsg65dm3g Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074548.6932 pmvf60rt69sqpm7d2tsg65dm3g Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='86';
20240527@074548.6969 pmvf60rt69sqpm7d2tsg65dm3g Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='86';
20240527@074548.6981 pmvf60rt69sqpm7d2tsg65dm3g Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='86';
20240527@074548.6990 pmvf60rt69sqpm7d2tsg65dm3g Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='86';
20240527@074548.7000 pmvf60rt69sqpm7d2tsg65dm3g Query : use flama_phc
20240527@074548.7002 pmvf60rt69sqpm7d2tsg65dm3g Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074548.7015 pmvf60rt69sqpm7d2tsg65dm3g Query : use flama_phc
20240527@074548.7018 pmvf60rt69sqpm7d2tsg65dm3g Query : select no, estab,szadrsdesc from szadrs where u_coddest=3674
20240527@074548.7048 pmvf60rt69sqpm7d2tsg65dm3g Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4930.00.1'
20240527@074548.7190 pmvf60rt69sqpm7d2tsg65dm3g 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 = 2403748 and bi.ref ='324.4930.00.1' and bi.lordem =1
20240527@074548.7587 pmvf60rt69sqpm7d2tsg65dm3g Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4724.00.1'
20240527@074548.7734 pmvf60rt69sqpm7d2tsg65dm3g 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 = 2403748 and bi.ref ='324.4724.00.1' and bi.lordem =2
20240527@074548.8052 pmvf60rt69sqpm7d2tsg65dm3g Query : use flama_phc
20240527@074548.8055 pmvf60rt69sqpm7d2tsg65dm3g Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074548.8068 pmvf60rt69sqpm7d2tsg65dm3g Query : use flama_phc
20240527@074548.8071 pmvf60rt69sqpm7d2tsg65dm3g Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074548.8082 pmvf60rt69sqpm7d2tsg65dm3g Query : use flama_phc
20240527@074548.8084 pmvf60rt69sqpm7d2tsg65dm3g 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')
20240527@074549.9910 riqpj5eee4klies5tlcidgqk5t Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074549.1005 riqpj5eee4klies5tlcidgqk5t Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074549.1019 riqpj5eee4klies5tlcidgqk5t Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='87';
20240527@074549.1055 riqpj5eee4klies5tlcidgqk5t Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='87';
20240527@074549.1066 riqpj5eee4klies5tlcidgqk5t Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='87';
20240527@074549.1078 riqpj5eee4klies5tlcidgqk5t Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='87';
20240527@074549.1089 riqpj5eee4klies5tlcidgqk5t Query : use flama_phc
20240527@074549.1092 riqpj5eee4klies5tlcidgqk5t Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074549.1107 riqpj5eee4klies5tlcidgqk5t Query : use flama_phc
20240527@074549.1110 riqpj5eee4klies5tlcidgqk5t Query : select no, estab,szadrsdesc from szadrs where u_coddest=2214
20240527@074549.1181 riqpj5eee4klies5tlcidgqk5t Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4930.00.1'
20240527@074549.1192 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.4930.00.1' and bi.lordem =1
20240527@074549.1733 riqpj5eee4klies5tlcidgqk5t 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'
20240527@074549.1876 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.4421.00.1' and bi.lordem =2
20240527@074549.2190 riqpj5eee4klies5tlcidgqk5t 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'
20240527@074549.2327 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.1824.00.1' and bi.lordem =3
20240527@074549.2629 riqpj5eee4klies5tlcidgqk5t 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'
20240527@074549.3489 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.1879.00.1' and bi.lordem =4
20240527@074549.3814 riqpj5eee4klies5tlcidgqk5t 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'
20240527@074549.3952 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='304.4320.00.1' and bi.lordem =5
20240527@074549.4277 riqpj5eee4klies5tlcidgqk5t Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2231.00.1'
20240527@074549.4419 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.2231.00.1' and bi.lordem =6
20240527@074549.4729 riqpj5eee4klies5tlcidgqk5t 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'
20240527@074549.4739 riqpj5eee4klies5tlcidgqk5t 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 = 2403749 and bi.ref ='324.4521.00.1' and bi.lordem =7
20240527@074549.5140 riqpj5eee4klies5tlcidgqk5t Query : use flama_phc
20240527@074549.5145 riqpj5eee4klies5tlcidgqk5t Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074549.5160 riqpj5eee4klies5tlcidgqk5t Query : use flama_phc
20240527@074549.5163 riqpj5eee4klies5tlcidgqk5t Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074549.5191 riqpj5eee4klies5tlcidgqk5t Query : use flama_phc
20240527@074549.5194 riqpj5eee4klies5tlcidgqk5t 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')
20240527@074549.6721 456dbs2npml18dhg2ccto5n9nn Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074549.6734 456dbs2npml18dhg2ccto5n9nn Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074549.6747 456dbs2npml18dhg2ccto5n9nn Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='88';
20240527@074549.6783 456dbs2npml18dhg2ccto5n9nn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='88';
20240527@074549.6794 456dbs2npml18dhg2ccto5n9nn Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='88';
20240527@074549.6824 456dbs2npml18dhg2ccto5n9nn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='88';
20240527@074549.6835 456dbs2npml18dhg2ccto5n9nn Query : use flama_phc
20240527@074549.6838 456dbs2npml18dhg2ccto5n9nn Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240527@074549.6852 456dbs2npml18dhg2ccto5n9nn Query : use flama_phc
20240527@074549.6855 456dbs2npml18dhg2ccto5n9nn Query : select no, estab,szadrsdesc from szadrs where u_coddest=2821
20240527@074549.6922 456dbs2npml18dhg2ccto5n9nn 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'
20240527@074549.7068 456dbs2npml18dhg2ccto5n9nn 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 = 2403750 and bi.ref ='324.692.00.01' and bi.lordem =1
20240527@074549.7919 456dbs2npml18dhg2ccto5n9nn 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'
20240527@074549.7933 456dbs2npml18dhg2ccto5n9nn 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 = 2403750 and bi.ref ='324.692.00.01' and bi.lordem =1
20240527@074549.7941 456dbs2npml18dhg2ccto5n9nn 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'
20240527@074549.7951 456dbs2npml18dhg2ccto5n9nn 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 = 2403750 and bi.ref ='324.691.00.01' and bi.lordem =2
20240527@074549.8276 456dbs2npml18dhg2ccto5n9nn Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2231.00.1'
20240527@074549.8287 456dbs2npml18dhg2ccto5n9nn 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 = 2403750 and bi.ref ='324.2231.00.1' and bi.lordem =3
20240527@074549.8609 456dbs2npml18dhg2ccto5n9nn Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.2232.00.1'
20240527@074549.8620 456dbs2npml18dhg2ccto5n9nn 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 = 2403750 and bi.ref ='324.2232.00.1' and bi.lordem =4
20240527@074549.8941 456dbs2npml18dhg2ccto5n9nn Query : use flama_phc
20240527@074549.8944 456dbs2npml18dhg2ccto5n9nn Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240527@074549.8959 456dbs2npml18dhg2ccto5n9nn Query : use flama_phc
20240527@074549.8962 456dbs2npml18dhg2ccto5n9nn Query : select top 1 1 valor from td where td.ndoc = 39
20240527@074549.8973 456dbs2npml18dhg2ccto5n9nn Query : use flama_phc
20240527@074549.8976 456dbs2npml18dhg2ccto5n9nn 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')
20240527@074549.9482 e3q1icva6np1hhraq5spnecpdr Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240527@074549.9496 e3q1icva6np1hhraq5spnecpdr Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240527@074549.9510 e3q1icva6np1hhraq5spnecpdr Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='89';
20240527@074549.9546 e3q1icva6np1hhraq5spnecpdr Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='89';
20240527@074549.9558 e3q1icva6np1hhraq5spnecpdr Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='89';
20240527@074549.9569 e3q1icva6np1hhraq5spnecpdr Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='89';

20240527@133726.1809 coqlkfuvimfaa8u760t5mcftiu Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='90';
20240527@133726.1830 coqlkfuvimfaa8u760t5mcftiu Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='90';
20240527@133726.1847 coqlkfuvimfaa8u760t5mcftiu Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='90';

20240528@073058.4340 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='91';
20240528@073058.4560 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='91';
20240528@073058.4700 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='91';
20240528@073058.4810 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : use flama_phc
20240528@073058.4850 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073058.5300 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : use flama_phc
20240528@073058.5330 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select no, estab,szadrsdesc from szadrs where u_coddest=5546
20240528@073058.6160 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.7510 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1089 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1100 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1107 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1117 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1124 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1135 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1141 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1151 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1158 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1167 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1174 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1184 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1191 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1201 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1208 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1218 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1225 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1234 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1241 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1251 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1259 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.646.00.01'
20240528@073058.1269 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.646.00.01' and bi.lordem =1
20240528@073058.1276 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1418 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1835 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1846 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1854 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1865 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1872 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1923 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1931 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1941 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1947 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1956 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1964 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1974 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1981 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.1990 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.1998 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.2008 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.2015 pe0mhrtgrd0ov2a3uqgt1dvqhc 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'
20240528@073058.2025 pe0mhrtgrd0ov2a3uqgt1dvqhc 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 = 2403727 and bi.ref ='324.645.00.01' and bi.lordem =2
20240528@073058.2032 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : use flama_phc
20240528@073058.2035 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073058.2217 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : use flama_phc
20240528@073058.2220 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073058.2320 pe0mhrtgrd0ov2a3uqgt1dvqhc Query : use flama_phc
20240528@073058.2323 pe0mhrtgrd0ov2a3uqgt1dvqhc 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')
20240528@073058.2978 kv1gn36t73alg8r4lp7quoq046 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073058.2991 kv1gn36t73alg8r4lp7quoq046 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073058.3004 kv1gn36t73alg8r4lp7quoq046 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='92';
20240528@073058.3038 kv1gn36t73alg8r4lp7quoq046 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='92';
20240528@073058.3049 kv1gn36t73alg8r4lp7quoq046 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='92';
20240528@073058.3059 kv1gn36t73alg8r4lp7quoq046 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='92';
20240528@073058.3069 kv1gn36t73alg8r4lp7quoq046 Query : use flama_phc
20240528@073058.3072 kv1gn36t73alg8r4lp7quoq046 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073058.3086 kv1gn36t73alg8r4lp7quoq046 Query : use flama_phc
20240528@073058.3088 kv1gn36t73alg8r4lp7quoq046 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4787
20240528@073058.3161 kv1gn36t73alg8r4lp7quoq046 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'
20240528@073058.3301 kv1gn36t73alg8r4lp7quoq046 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 = 2403734 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240528@073058.3602 kv1gn36t73alg8r4lp7quoq046 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4743.00.1'
20240528@073058.3734 kv1gn36t73alg8r4lp7quoq046 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 = 2403734 and bi.ref ='324.4743.00.1' and bi.lordem =2
20240528@073058.4048 kv1gn36t73alg8r4lp7quoq046 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'
20240528@073058.4276 kv1gn36t73alg8r4lp7quoq046 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 = 2403734 and bi.ref ='324.4751.00.1' and bi.lordem =3
20240528@073058.4596 kv1gn36t73alg8r4lp7quoq046 Query : use flama_phc
20240528@073058.4600 kv1gn36t73alg8r4lp7quoq046 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073058.4613 kv1gn36t73alg8r4lp7quoq046 Query : use flama_phc
20240528@073058.4616 kv1gn36t73alg8r4lp7quoq046 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073058.4626 kv1gn36t73alg8r4lp7quoq046 Query : use flama_phc
20240528@073058.4629 kv1gn36t73alg8r4lp7quoq046 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')
20240528@073058.5129 cbc7k7so41djsbmfel3tctti6h Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073058.5142 cbc7k7so41djsbmfel3tctti6h Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073058.5154 cbc7k7so41djsbmfel3tctti6h Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='93';
20240528@073058.5188 cbc7k7so41djsbmfel3tctti6h Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='93';
20240528@073058.5199 cbc7k7so41djsbmfel3tctti6h Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='93';
20240528@073058.5209 cbc7k7so41djsbmfel3tctti6h Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='93';
20240528@073058.5219 cbc7k7so41djsbmfel3tctti6h Query : use flama_phc
20240528@073058.5222 cbc7k7so41djsbmfel3tctti6h Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073058.5235 cbc7k7so41djsbmfel3tctti6h Query : use flama_phc
20240528@073058.5238 cbc7k7so41djsbmfel3tctti6h Query : select no, estab,szadrsdesc from szadrs where u_coddest=4782
20240528@073058.5304 cbc7k7so41djsbmfel3tctti6h 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'
20240528@073058.5316 cbc7k7so41djsbmfel3tctti6h 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 = 2403735 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240528@073058.5630 cbc7k7so41djsbmfel3tctti6h Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1470.00.1'
20240528@073058.5765 cbc7k7so41djsbmfel3tctti6h 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 = 2403735 and bi.ref ='324.1470.00.1' and bi.lordem =2
20240528@073058.6066 cbc7k7so41djsbmfel3tctti6h Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4960.00.1'
20240528@073058.6206 cbc7k7so41djsbmfel3tctti6h 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 = 2403735 and bi.ref ='324.4960.00.1' and bi.lordem =3
20240528@073058.6512 cbc7k7so41djsbmfel3tctti6h Query : use flama_phc
20240528@073058.6515 cbc7k7so41djsbmfel3tctti6h Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073058.6528 cbc7k7so41djsbmfel3tctti6h Query : use flama_phc
20240528@073058.6531 cbc7k7so41djsbmfel3tctti6h Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073058.6540 cbc7k7so41djsbmfel3tctti6h Query : use flama_phc
20240528@073058.6544 cbc7k7so41djsbmfel3tctti6h 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')
20240528@073058.7173 1fcse0d5uanhuqg31giskq8dp8 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073058.7187 1fcse0d5uanhuqg31giskq8dp8 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073058.7199 1fcse0d5uanhuqg31giskq8dp8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='94';
20240528@073058.7643 1fcse0d5uanhuqg31giskq8dp8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='94';
20240528@073058.8580 1fcse0d5uanhuqg31giskq8dp8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='94';
20240528@073058.8592 1fcse0d5uanhuqg31giskq8dp8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='94';
20240528@073058.8602 1fcse0d5uanhuqg31giskq8dp8 Query : use flama_phc
20240528@073058.8605 1fcse0d5uanhuqg31giskq8dp8 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073058.8618 1fcse0d5uanhuqg31giskq8dp8 Query : use flama_phc
20240528@073058.8620 1fcse0d5uanhuqg31giskq8dp8 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4781
20240528@073058.8692 1fcse0d5uanhuqg31giskq8dp8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4990.00.1'
20240528@073058.8858 1fcse0d5uanhuqg31giskq8dp8 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 = 2403736 and bi.ref ='324.4990.00.1' and bi.lordem =1
20240528@073058.9163 1fcse0d5uanhuqg31giskq8dp8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4960.00.1'
20240528@073058.9173 1fcse0d5uanhuqg31giskq8dp8 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 = 2403736 and bi.ref ='324.4960.00.1' and bi.lordem =2
20240528@073058.9491 1fcse0d5uanhuqg31giskq8dp8 Query : use flama_phc
20240528@073058.9494 1fcse0d5uanhuqg31giskq8dp8 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073058.9508 1fcse0d5uanhuqg31giskq8dp8 Query : use flama_phc
20240528@073058.9511 1fcse0d5uanhuqg31giskq8dp8 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073058.9521 1fcse0d5uanhuqg31giskq8dp8 Query : use flama_phc
20240528@073058.9523 1fcse0d5uanhuqg31giskq8dp8 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')
20240528@073059.1700 ara7t9o9ljgcudg6gu90k314m9 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.3100 ara7t9o9ljgcudg6gu90k314m9 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.4300 ara7t9o9ljgcudg6gu90k314m9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='95';
20240528@073059.8000 ara7t9o9ljgcudg6gu90k314m9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='95';
20240528@073059.9100 ara7t9o9ljgcudg6gu90k314m9 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='95';
20240528@073059.1010 ara7t9o9ljgcudg6gu90k314m9 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='95';
20240528@073059.1110 ara7t9o9ljgcudg6gu90k314m9 Query : use flama_phc
20240528@073059.1140 ara7t9o9ljgcudg6gu90k314m9 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.1270 ara7t9o9ljgcudg6gu90k314m9 Query : use flama_phc
20240528@073059.1300 ara7t9o9ljgcudg6gu90k314m9 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4785
20240528@073059.1960 ara7t9o9ljgcudg6gu90k314m9 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'
20240528@073059.2060 ara7t9o9ljgcudg6gu90k314m9 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 = 2403737 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240528@073059.5340 ara7t9o9ljgcudg6gu90k314m9 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4743.00.1'
20240528@073059.5440 ara7t9o9ljgcudg6gu90k314m9 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 = 2403737 and bi.ref ='324.4743.00.1' and bi.lordem =2
20240528@073059.8550 ara7t9o9ljgcudg6gu90k314m9 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'
20240528@073059.9960 ara7t9o9ljgcudg6gu90k314m9 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 = 2403737 and bi.ref ='304.422.00.07' and bi.lordem =3
20240528@073059.1312 ara7t9o9ljgcudg6gu90k314m9 Query : use flama_phc
20240528@073059.1315 ara7t9o9ljgcudg6gu90k314m9 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073059.1328 ara7t9o9ljgcudg6gu90k314m9 Query : use flama_phc
20240528@073059.1331 ara7t9o9ljgcudg6gu90k314m9 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073059.1341 ara7t9o9ljgcudg6gu90k314m9 Query : use flama_phc
20240528@073059.1343 ara7t9o9ljgcudg6gu90k314m9 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')
20240528@073059.1928 nucnaenia2r5orh4e0ofu2t3lj Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.2023 nucnaenia2r5orh4e0ofu2t3lj Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.2036 nucnaenia2r5orh4e0ofu2t3lj Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='96';
20240528@073059.2073 nucnaenia2r5orh4e0ofu2t3lj Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='96';
20240528@073059.2091 nucnaenia2r5orh4e0ofu2t3lj Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='96';
20240528@073059.2102 nucnaenia2r5orh4e0ofu2t3lj Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='96';
20240528@073059.2112 nucnaenia2r5orh4e0ofu2t3lj Query : use flama_phc
20240528@073059.2115 nucnaenia2r5orh4e0ofu2t3lj Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.2214 nucnaenia2r5orh4e0ofu2t3lj Query : use flama_phc
20240528@073059.2218 nucnaenia2r5orh4e0ofu2t3lj Query : select no, estab,szadrsdesc from szadrs where u_coddest=4783
20240528@073059.2355 nucnaenia2r5orh4e0ofu2t3lj 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'
20240528@073059.2365 nucnaenia2r5orh4e0ofu2t3lj 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 = 2403747 and bi.ref ='304.4320.00.1' and bi.lordem =1
20240528@073059.2676 nucnaenia2r5orh4e0ofu2t3lj Query : use flama_phc
20240528@073059.2679 nucnaenia2r5orh4e0ofu2t3lj Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073059.2692 nucnaenia2r5orh4e0ofu2t3lj Query : use flama_phc
20240528@073059.2695 nucnaenia2r5orh4e0ofu2t3lj Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073059.2705 nucnaenia2r5orh4e0ofu2t3lj Query : use flama_phc
20240528@073059.2709 nucnaenia2r5orh4e0ofu2t3lj 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')
20240528@073059.3226 1cue0bo7hbjec6dsass19o692a Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.3239 1cue0bo7hbjec6dsass19o692a Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.3252 1cue0bo7hbjec6dsass19o692a Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='97';
20240528@073059.3288 1cue0bo7hbjec6dsass19o692a Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='97';
20240528@073059.3300 1cue0bo7hbjec6dsass19o692a Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='97';
20240528@073059.3312 1cue0bo7hbjec6dsass19o692a Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='97';
20240528@073059.3322 1cue0bo7hbjec6dsass19o692a Query : use flama_phc
20240528@073059.3325 1cue0bo7hbjec6dsass19o692a Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.3339 1cue0bo7hbjec6dsass19o692a Query : use flama_phc
20240528@073059.3342 1cue0bo7hbjec6dsass19o692a Query : select no, estab,szadrsdesc from szadrs where u_coddest=6076
20240528@073059.3421 1cue0bo7hbjec6dsass19o692a 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'
20240528@073059.3564 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='304.4211.00.1' and bi.lordem =1
20240528@073059.3878 1cue0bo7hbjec6dsass19o692a 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'
20240528@073059.3888 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='304.4211.00.1' and bi.lordem =1
20240528@073059.3895 1cue0bo7hbjec6dsass19o692a 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'
20240528@073059.4038 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='324.4521.00.1' and bi.lordem =3
20240528@073059.4472 1cue0bo7hbjec6dsass19o692a 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'
20240528@073059.4632 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='324.4902.00.1' and bi.lordem =5
20240528@073059.4948 1cue0bo7hbjec6dsass19o692a Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1470.00.1'
20240528@073059.4965 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='324.1470.00.1' and bi.lordem =7
20240528@073059.5298 1cue0bo7hbjec6dsass19o692a Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1470.00.1'
20240528@073059.5310 1cue0bo7hbjec6dsass19o692a 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 = 2403752 and bi.ref ='324.1470.00.1' and bi.lordem =7
20240528@073059.5319 1cue0bo7hbjec6dsass19o692a Query : use flama_phc
20240528@073059.5322 1cue0bo7hbjec6dsass19o692a Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073059.5336 1cue0bo7hbjec6dsass19o692a Query : use flama_phc
20240528@073059.5339 1cue0bo7hbjec6dsass19o692a Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073059.5350 1cue0bo7hbjec6dsass19o692a Query : use flama_phc
20240528@073059.5353 1cue0bo7hbjec6dsass19o692a 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')
20240528@073059.5890 tpllisj49bnmsdr4vb39pmph3s Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.5903 tpllisj49bnmsdr4vb39pmph3s Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.5916 tpllisj49bnmsdr4vb39pmph3s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='98';
20240528@073059.5953 tpllisj49bnmsdr4vb39pmph3s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='98';
20240528@073059.5964 tpllisj49bnmsdr4vb39pmph3s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='98';
20240528@073059.5975 tpllisj49bnmsdr4vb39pmph3s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='98';
20240528@073059.5985 tpllisj49bnmsdr4vb39pmph3s Query : use flama_phc
20240528@073059.5988 tpllisj49bnmsdr4vb39pmph3s Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.6001 tpllisj49bnmsdr4vb39pmph3s Query : use flama_phc
20240528@073059.6004 tpllisj49bnmsdr4vb39pmph3s Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240528@073059.6073 tpllisj49bnmsdr4vb39pmph3s Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1643.00.1'
20240528@073059.6216 tpllisj49bnmsdr4vb39pmph3s 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 = 2403754 and bi.ref ='324.1643.00.1' and bi.lordem =1
20240528@073059.6521 tpllisj49bnmsdr4vb39pmph3s Query : use flama_phc
20240528@073059.6525 tpllisj49bnmsdr4vb39pmph3s Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073059.6538 tpllisj49bnmsdr4vb39pmph3s Query : use flama_phc
20240528@073059.6541 tpllisj49bnmsdr4vb39pmph3s Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073059.6551 tpllisj49bnmsdr4vb39pmph3s Query : use flama_phc
20240528@073059.6553 tpllisj49bnmsdr4vb39pmph3s 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')
20240528@073059.7060 7q8164gep30j6to0afj0dc8nmn Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.7072 7q8164gep30j6to0afj0dc8nmn Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.7086 7q8164gep30j6to0afj0dc8nmn Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='99';
20240528@073059.7121 7q8164gep30j6to0afj0dc8nmn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='99';
20240528@073059.7132 7q8164gep30j6to0afj0dc8nmn Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='99';
20240528@073059.7143 7q8164gep30j6to0afj0dc8nmn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='99';
20240528@073059.7155 7q8164gep30j6to0afj0dc8nmn Query : use flama_phc
20240528@073059.7159 7q8164gep30j6to0afj0dc8nmn Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.7173 7q8164gep30j6to0afj0dc8nmn Query : use flama_phc
20240528@073059.7176 7q8164gep30j6to0afj0dc8nmn Query : select no, estab,szadrsdesc from szadrs where u_coddest=1246
20240528@073059.7253 7q8164gep30j6to0afj0dc8nmn Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1685.00.1'
20240528@073059.7394 7q8164gep30j6to0afj0dc8nmn 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 = 2403767 and bi.ref ='324.1685.00.1' and bi.lordem =1
20240528@073059.7714 7q8164gep30j6to0afj0dc8nmn 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'
20240528@073059.7855 7q8164gep30j6to0afj0dc8nmn 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 = 2403767 and bi.ref ='323.318.09.00' and bi.lordem =2
20240528@073059.8171 7q8164gep30j6to0afj0dc8nmn Query : use flama_phc
20240528@073059.8174 7q8164gep30j6to0afj0dc8nmn Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073059.8189 7q8164gep30j6to0afj0dc8nmn Query : use flama_phc
20240528@073059.8192 7q8164gep30j6to0afj0dc8nmn Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073059.8203 7q8164gep30j6to0afj0dc8nmn Query : use flama_phc
20240528@073059.8205 7q8164gep30j6to0afj0dc8nmn 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')
20240528@073059.9659 gd8t859m864gp7f69i8l8oecrl Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073059.9672 gd8t859m864gp7f69i8l8oecrl Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073059.9686 gd8t859m864gp7f69i8l8oecrl Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='100';
20240528@073059.9728 gd8t859m864gp7f69i8l8oecrl Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='100';
20240528@073059.9742 gd8t859m864gp7f69i8l8oecrl Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='100';
20240528@073059.9754 gd8t859m864gp7f69i8l8oecrl Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='100';
20240528@073059.9764 gd8t859m864gp7f69i8l8oecrl Query : use flama_phc
20240528@073059.9768 gd8t859m864gp7f69i8l8oecrl Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073059.9783 gd8t859m864gp7f69i8l8oecrl Query : use flama_phc
20240528@073059.9802 gd8t859m864gp7f69i8l8oecrl Query : select no, estab,szadrsdesc from szadrs where u_coddest=170
20240528@073059.9879 gd8t859m864gp7f69i8l8oecrl 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'
20240528@073100.1800 gd8t859m864gp7f69i8l8oecrl 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 = 2403769 and bi.ref ='324.1706.00.1' and bi.lordem =1
20240528@073100.3380 gd8t859m864gp7f69i8l8oecrl 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'
20240528@073100.3490 gd8t859m864gp7f69i8l8oecrl 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 = 2403769 and bi.ref ='324.1706.00.1' and bi.lordem =2
20240528@073100.6700 gd8t859m864gp7f69i8l8oecrl Query : use flama_phc
20240528@073100.6730 gd8t859m864gp7f69i8l8oecrl Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.6860 gd8t859m864gp7f69i8l8oecrl Query : use flama_phc
20240528@073100.6890 gd8t859m864gp7f69i8l8oecrl Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.7000 gd8t859m864gp7f69i8l8oecrl Query : use flama_phc
20240528@073100.7030 gd8t859m864gp7f69i8l8oecrl 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')
20240528@073100.1462 1d3l0l8dv4igomm31u8491enur Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.1498 1d3l0l8dv4igomm31u8491enur Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.1623 1d3l0l8dv4igomm31u8491enur Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='101';
20240528@073100.1820 1d3l0l8dv4igomm31u8491enur Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='101';
20240528@073100.1832 1d3l0l8dv4igomm31u8491enur Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='101';
20240528@073100.1844 1d3l0l8dv4igomm31u8491enur Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='101';
20240528@073100.1853 1d3l0l8dv4igomm31u8491enur Query : use flama_phc
20240528@073100.1856 1d3l0l8dv4igomm31u8491enur Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073100.1869 1d3l0l8dv4igomm31u8491enur Query : use flama_phc
20240528@073100.1872 1d3l0l8dv4igomm31u8491enur Query : select no, estab,szadrsdesc from szadrs where u_coddest=6737
20240528@073100.2021 1d3l0l8dv4igomm31u8491enur Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '328.9106.00.1'
20240528@073100.2318 1d3l0l8dv4igomm31u8491enur 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 = 2403774 and bi.ref ='328.9106.00.1' and bi.lordem =1
20240528@073100.2649 1d3l0l8dv4igomm31u8491enur Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '328.9345.00.1'
20240528@073100.2783 1d3l0l8dv4igomm31u8491enur 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 = 2403774 and bi.ref ='328.9345.00.1' and bi.lordem =2
20240528@073100.3092 1d3l0l8dv4igomm31u8491enur Query : use flama_phc
20240528@073100.3095 1d3l0l8dv4igomm31u8491enur Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.3108 1d3l0l8dv4igomm31u8491enur Query : use flama_phc
20240528@073100.3110 1d3l0l8dv4igomm31u8491enur Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.3120 1d3l0l8dv4igomm31u8491enur Query : use flama_phc
20240528@073100.3123 1d3l0l8dv4igomm31u8491enur 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')
20240528@073100.3655 54haqto68u8n161e7oegl8vns3 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.3668 54haqto68u8n161e7oegl8vns3 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.3680 54haqto68u8n161e7oegl8vns3 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='102';
20240528@073100.3715 54haqto68u8n161e7oegl8vns3 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='102';
20240528@073100.3726 54haqto68u8n161e7oegl8vns3 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='102';
20240528@073100.3737 54haqto68u8n161e7oegl8vns3 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='102';
20240528@073100.3747 54haqto68u8n161e7oegl8vns3 Query : use flama_phc
20240528@073100.3750 54haqto68u8n161e7oegl8vns3 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073100.3764 54haqto68u8n161e7oegl8vns3 Query : use flama_phc
20240528@073100.3767 54haqto68u8n161e7oegl8vns3 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240528@073100.3797 54haqto68u8n161e7oegl8vns3 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1684.00.1'
20240528@073100.3938 54haqto68u8n161e7oegl8vns3 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 = 2403775 and bi.ref ='324.1684.00.1' and bi.lordem =1
20240528@073100.4243 54haqto68u8n161e7oegl8vns3 Query : use flama_phc
20240528@073100.4246 54haqto68u8n161e7oegl8vns3 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.4258 54haqto68u8n161e7oegl8vns3 Query : use flama_phc
20240528@073100.4261 54haqto68u8n161e7oegl8vns3 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.4271 54haqto68u8n161e7oegl8vns3 Query : use flama_phc
20240528@073100.4273 54haqto68u8n161e7oegl8vns3 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')
20240528@073100.4747 ab1qsul6ce323vmpg7cugs9t8s Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.4760 ab1qsul6ce323vmpg7cugs9t8s Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.4772 ab1qsul6ce323vmpg7cugs9t8s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='103';
20240528@073100.4807 ab1qsul6ce323vmpg7cugs9t8s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='103';
20240528@073100.4817 ab1qsul6ce323vmpg7cugs9t8s Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='103';
20240528@073100.4828 ab1qsul6ce323vmpg7cugs9t8s Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='103';
20240528@073100.4837 ab1qsul6ce323vmpg7cugs9t8s Query : use flama_phc
20240528@073100.4840 ab1qsul6ce323vmpg7cugs9t8s Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073100.4853 ab1qsul6ce323vmpg7cugs9t8s Query : use flama_phc
20240528@073100.4856 ab1qsul6ce323vmpg7cugs9t8s Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240528@073100.4885 ab1qsul6ce323vmpg7cugs9t8s 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'
20240528@073100.5027 ab1qsul6ce323vmpg7cugs9t8s 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 = 2403776 and bi.ref ='324.1832.00.2' and bi.lordem =1
20240528@073100.5339 ab1qsul6ce323vmpg7cugs9t8s 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'
20240528@073100.5350 ab1qsul6ce323vmpg7cugs9t8s 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 = 2403776 and bi.ref ='324.1832.00.2' and bi.lordem =1
20240528@073100.5357 ab1qsul6ce323vmpg7cugs9t8s 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'
20240528@073100.5366 ab1qsul6ce323vmpg7cugs9t8s 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 = 2403776 and bi.ref ='324.1832.00.2' and bi.lordem =1
20240528@073100.5373 ab1qsul6ce323vmpg7cugs9t8s 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'
20240528@073100.5382 ab1qsul6ce323vmpg7cugs9t8s 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 = 2403776 and bi.ref ='324.1832.00.2' and bi.lordem =1
20240528@073100.5389 ab1qsul6ce323vmpg7cugs9t8s Query : use flama_phc
20240528@073100.5392 ab1qsul6ce323vmpg7cugs9t8s Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.5404 ab1qsul6ce323vmpg7cugs9t8s Query : use flama_phc
20240528@073100.5407 ab1qsul6ce323vmpg7cugs9t8s Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.5417 ab1qsul6ce323vmpg7cugs9t8s Query : use flama_phc
20240528@073100.5419 ab1qsul6ce323vmpg7cugs9t8s 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')
20240528@073100.5917 6v11l97p4ombhp6f48qa1dvsg1 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.5930 6v11l97p4ombhp6f48qa1dvsg1 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.5943 6v11l97p4ombhp6f48qa1dvsg1 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='104';
20240528@073100.5976 6v11l97p4ombhp6f48qa1dvsg1 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='104';
20240528@073100.5987 6v11l97p4ombhp6f48qa1dvsg1 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='104';
20240528@073100.5997 6v11l97p4ombhp6f48qa1dvsg1 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='104';
20240528@073100.6007 6v11l97p4ombhp6f48qa1dvsg1 Query : use flama_phc
20240528@073100.6010 6v11l97p4ombhp6f48qa1dvsg1 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073100.6023 6v11l97p4ombhp6f48qa1dvsg1 Query : use flama_phc
20240528@073100.6026 6v11l97p4ombhp6f48qa1dvsg1 Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240528@073100.6055 6v11l97p4ombhp6f48qa1dvsg1 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'
20240528@073100.6193 6v11l97p4ombhp6f48qa1dvsg1 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 = 2403777 and bi.ref ='324.1834.00.1' and bi.lordem =1
20240528@073100.6499 6v11l97p4ombhp6f48qa1dvsg1 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'
20240528@073100.6509 6v11l97p4ombhp6f48qa1dvsg1 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 = 2403777 and bi.ref ='324.1834.00.1' and bi.lordem =1
20240528@073100.6516 6v11l97p4ombhp6f48qa1dvsg1 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'
20240528@073100.6525 6v11l97p4ombhp6f48qa1dvsg1 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 = 2403777 and bi.ref ='324.1834.00.1' and bi.lordem =1
20240528@073100.6532 6v11l97p4ombhp6f48qa1dvsg1 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'
20240528@073100.6541 6v11l97p4ombhp6f48qa1dvsg1 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 = 2403777 and bi.ref ='324.1834.00.1' and bi.lordem =1
20240528@073100.6547 6v11l97p4ombhp6f48qa1dvsg1 Query : use flama_phc
20240528@073100.6550 6v11l97p4ombhp6f48qa1dvsg1 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.6562 6v11l97p4ombhp6f48qa1dvsg1 Query : use flama_phc
20240528@073100.6565 6v11l97p4ombhp6f48qa1dvsg1 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.6575 6v11l97p4ombhp6f48qa1dvsg1 Query : use flama_phc
20240528@073100.6577 6v11l97p4ombhp6f48qa1dvsg1 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')
20240528@073100.7089 6q4a7sq8dj0lqqi7ev582pt163 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.7101 6q4a7sq8dj0lqqi7ev582pt163 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.7114 6q4a7sq8dj0lqqi7ev582pt163 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='105';
20240528@073100.7150 6q4a7sq8dj0lqqi7ev582pt163 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='105';
20240528@073100.7160 6q4a7sq8dj0lqqi7ev582pt163 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='105';
20240528@073100.7170 6q4a7sq8dj0lqqi7ev582pt163 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='105';
20240528@073100.7180 6q4a7sq8dj0lqqi7ev582pt163 Query : use flama_phc
20240528@073100.7183 6q4a7sq8dj0lqqi7ev582pt163 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073100.7196 6q4a7sq8dj0lqqi7ev582pt163 Query : use flama_phc
20240528@073100.7199 6q4a7sq8dj0lqqi7ev582pt163 Query : select no, estab,szadrsdesc from szadrs where u_coddest=2679
20240528@073100.7292 6q4a7sq8dj0lqqi7ev582pt163 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'
20240528@073100.7302 6q4a7sq8dj0lqqi7ev582pt163 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 = 2403778 and bi.ref ='323.318.09.00' and bi.lordem =1
20240528@073100.7866 6q4a7sq8dj0lqqi7ev582pt163 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'
20240528@073100.8116 6q4a7sq8dj0lqqi7ev582pt163 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 = 2403778 and bi.ref ='323.367.09.00' and bi.lordem =2
20240528@073100.8634 6q4a7sq8dj0lqqi7ev582pt163 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'
20240528@073100.8645 6q4a7sq8dj0lqqi7ev582pt163 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 = 2403778 and bi.ref ='323.367.09.00' and bi.lordem =3
20240528@073100.8957 6q4a7sq8dj0lqqi7ev582pt163 Query : use flama_phc
20240528@073100.8960 6q4a7sq8dj0lqqi7ev582pt163 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073100.8972 6q4a7sq8dj0lqqi7ev582pt163 Query : use flama_phc
20240528@073100.8975 6q4a7sq8dj0lqqi7ev582pt163 Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073100.8985 6q4a7sq8dj0lqqi7ev582pt163 Query : use flama_phc
20240528@073100.8987 6q4a7sq8dj0lqqi7ev582pt163 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')
20240528@073100.9526 imfvhgfn8i0mnmk4hhj7jqc8qf Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073100.9652 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073100.9860 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='106';
20240528@073101.9100 imfvhgfn8i0mnmk4hhj7jqc8qf Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='106';
20240528@073101.3000 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='106';
20240528@073101.4870 imfvhgfn8i0mnmk4hhj7jqc8qf Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='106';
20240528@073101.5000 imfvhgfn8i0mnmk4hhj7jqc8qf Query : use flama_phc
20240528@073101.5430 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073101.6420 imfvhgfn8i0mnmk4hhj7jqc8qf Query : use flama_phc
20240528@073101.6450 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select no, estab,szadrsdesc from szadrs where u_coddest=4740
20240528@073101.6800 imfvhgfn8i0mnmk4hhj7jqc8qf 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'
20240528@073101.1042 imfvhgfn8i0mnmk4hhj7jqc8qf 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 = 2403779 and bi.ref ='326.595.00.01' and bi.lordem =1
20240528@073101.1879 imfvhgfn8i0mnmk4hhj7jqc8qf 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'
20240528@073101.2087 imfvhgfn8i0mnmk4hhj7jqc8qf 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 = 2403779 and bi.ref ='326.595.00.01' and bi.lordem =1
20240528@073101.2212 imfvhgfn8i0mnmk4hhj7jqc8qf Query : use flama_phc
20240528@073101.2254 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073101.2271 imfvhgfn8i0mnmk4hhj7jqc8qf Query : use flama_phc
20240528@073101.2273 imfvhgfn8i0mnmk4hhj7jqc8qf Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073101.2407 imfvhgfn8i0mnmk4hhj7jqc8qf Query : use flama_phc
20240528@073101.2410 imfvhgfn8i0mnmk4hhj7jqc8qf 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')
20240528@073101.2973 4dqp929qkk71dlohvp1g8ku6ad Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073101.2987 4dqp929qkk71dlohvp1g8ku6ad Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073101.3001 4dqp929qkk71dlohvp1g8ku6ad Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='107';
20240528@073101.3037 4dqp929qkk71dlohvp1g8ku6ad Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='107';
20240528@073101.3049 4dqp929qkk71dlohvp1g8ku6ad Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='107';
20240528@073101.3060 4dqp929qkk71dlohvp1g8ku6ad Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='107';
20240528@073101.3070 4dqp929qkk71dlohvp1g8ku6ad Query : use flama_phc
20240528@073101.3073 4dqp929qkk71dlohvp1g8ku6ad Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@073101.3087 4dqp929qkk71dlohvp1g8ku6ad Query : use flama_phc
20240528@073101.3090 4dqp929qkk71dlohvp1g8ku6ad Query : select no, estab,szadrsdesc from szadrs where u_coddest=3674
20240528@073101.3170 4dqp929qkk71dlohvp1g8ku6ad Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.4930.00.1'
20240528@073101.3323 4dqp929qkk71dlohvp1g8ku6ad 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 = 2403780 and bi.ref ='324.4930.00.1' and bi.lordem =1
20240528@073101.3636 4dqp929qkk71dlohvp1g8ku6ad Query : use flama_phc
20240528@073101.3640 4dqp929qkk71dlohvp1g8ku6ad Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240528@073101.3653 4dqp929qkk71dlohvp1g8ku6ad Query : use flama_phc
20240528@073101.3655 4dqp929qkk71dlohvp1g8ku6ad Query : select top 1 1 valor from td where td.ndoc = 39
20240528@073101.3666 4dqp929qkk71dlohvp1g8ku6ad Query : use flama_phc
20240528@073101.3669 4dqp929qkk71dlohvp1g8ku6ad 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')
20240528@073101.4234 d0lg2q8jbc4nlpj986h4de967d Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@073101.4247 d0lg2q8jbc4nlpj986h4de967d Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@073101.4262 d0lg2q8jbc4nlpj986h4de967d Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='108';
20240528@073101.4299 d0lg2q8jbc4nlpj986h4de967d Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='108';
20240528@073101.4357 d0lg2q8jbc4nlpj986h4de967d Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='108';
20240528@073101.4401 d0lg2q8jbc4nlpj986h4de967d Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='108';

20240528@142040.7290 0r2hmookm4635d1ousjk3ls17q Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='109';
20240528@142040.7314 0r2hmookm4635d1ousjk3ls17q Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='109';
20240528@142040.7335 0r2hmookm4635d1ousjk3ls17q Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='109';
20240528@142040.8309 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240528@142040.8391 8dtfh00eh3lipcu1olcf9ta9m4 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240528@142040.8639 8dtfh00eh3lipcu1olcf9ta9m4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='110';
20240528@142040.8677 8dtfh00eh3lipcu1olcf9ta9m4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='110';
20240528@142040.8689 8dtfh00eh3lipcu1olcf9ta9m4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='110';
20240528@142040.8703 8dtfh00eh3lipcu1olcf9ta9m4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='110';
20240528@142040.8714 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.8718 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@142040.8771 8dtfh00eh3lipcu1olcf9ta9m4 Query : select no, estab,szadrsdesc from szadrs where u_coddest=2
20240528@142040.8849 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.2200.94.1'
20240528@142040.8970 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.2200.94.1'
20240528@142040.8980 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.1684.00.1'
20240528@142040.9103 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9107 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 1 valor from ts where ts.ndos = 5
20240528@142040.9190 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9193 8dtfh00eh3lipcu1olcf9ta9m4 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')
20240528@142040.9264 8dtfh00eh3lipcu1olcf9ta9m4 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 =5
20240528@142040.9404 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9408 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 ~inactivo valor from fl where no = '100500' and estab = 0 order by inactivo desc
20240528@142040.9491 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9505 8dtfh00eh3lipcu1olcf9ta9m4 Query : select szadrsstamp valor from szadrs where szadrsdesc='espaÇotrans,lda'
20240528@142040.9545 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9548 8dtfh00eh3lipcu1olcf9ta9m4 Query : select szadrsstamp valor from szadrs where szadrsdesc='n/instalaÇÕes sede'
20240528@142040.9569 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142040.9572 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from ts where ndos = 5
20240528@142040.9643 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142040.9942 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 5
20240528@142041.7000 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.2000 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 5
20240528@142041.2800 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.4000 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 5
20240528@142041.5200 8dtfh00eh3lipcu1olcf9ta9m4 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 = 5
20240528@142041.1950 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 5 and boano=2024 order by obrano desc
20240528@142041.3440 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 bo.obrano valor from wsbodata bo where bo.ndos = 5 and boano=2024 order by obrano desc
20240528@142041.5000 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.5040 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='100500' and estab=0
20240528@142041.5870 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.6030 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 5
20240528@142041.6330 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbo3data (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut6655d731856655da290c',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240528@142041.6930 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.7060 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 5
20240528@142041.7140 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbo2data (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis,xpddata,xpdhora,carga,descar) values ('aut6655d731856655da290c','ga','bo',0 ,0,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut','20240528','14:50',?,?)
20240528@142041.1162 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.1180 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 5
20240528@142041.1195 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbodata (bostamp, nmdos, dataobra, ndos, obrano, no, estab, nome, ncont, morada, local, codpost, moeda, boano, memissao,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis,maquina ) values ('aut6655d731856655da290c','trf entre armazéns a','2024-05-28',5,292,?,?,?,?,?,?,?,?,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',?)
20240528@142041.1888 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.1892 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.usalote valor from st where st.ref = '324.2200.94.1'
20240528@142041.2003 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.2006 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.2200.94.1'
20240528@142041.2395 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.2398 8dtfh00eh3lipcu1olcf9ta9m4 Query : select isnull(sum(stock) ,0)stock ,isnull(sum(qttrec),0) qttrec ,0 qttcat ,isnull(sum(rescli),0) rescli ,isnull(sum(resfor),0) resfor from sa where sa.ref = '324.2200.94.1' and sa.armazem = 133 
20240528@142041.2457 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.2460 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.2200.94.1'
20240528@142041.2480 8dtfh00eh3lipcu1olcf9ta9m4 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 = '324.2200.94.1'
20240528@142041.2649 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.2663 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.2674 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.2685 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.2697 8dtfh00eh3lipcu1olcf9ta9m4 Query : select sestamp valor from se where ref ='324.2200.94.1' and lote = 'r2300912200a'
20240528@142041.2790 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240528@142041.2831 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.2848 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.2857 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbi2data (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut6655d927646655da2945','aut6655d731856655da290c',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.3056 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.3071 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.3083 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbidata (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,eslvu,slvu,esltt,sltt,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,ar2mazem,stipo) select 'aut6655d927646655da2945',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 3.000, 3.000*.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 ,0,0*200.48,0,0*200.48 ,0,0,'un ','' ,bo.marcada,1 ,0*3.000,0*3.000*200.48 ,12.614000,12.614000*200.48 ,12.614000,12.614000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0*200.48,0*3.000,0*3.000*200.48,0,0*3.000,0,0*3.000,?,?,?,4 from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.3500 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.3521 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.usalote valor from st where st.ref = '324.2200.94.1'
20240528@142041.3531 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.3534 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.2200.94.1'
20240528@142041.3623 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.3646 8dtfh00eh3lipcu1olcf9ta9m4 Query : select isnull(sum(stock) ,0)stock ,isnull(sum(qttrec),0) qttrec ,0 qttcat ,isnull(sum(rescli),0) rescli ,isnull(sum(resfor),0) resfor from sa where sa.ref = '324.2200.94.1' and sa.armazem = 133 
20240528@142041.3788 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.3829 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.2200.94.1'
20240528@142041.3855 8dtfh00eh3lipcu1olcf9ta9m4 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 = '324.2200.94.1'
20240528@142041.3866 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.3897 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.3908 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.3920 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.3926 8dtfh00eh3lipcu1olcf9ta9m4 Query : select sestamp valor from se where ref ='324.2200.94.1' and lote = 'r2400046200a'
20240528@142041.3937 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240528@142041.3948 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.3960 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.3967 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbi2data (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut6655d501296655da2960','aut6655d731856655da290c',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.4093 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.4109 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.4123 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbidata (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,eslvu,slvu,esltt,sltt,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,ar2mazem,stipo) select 'aut6655d501296655da2960',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 9.000, 9.000*.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,20000 ,0,0*200.48,0,0*200.48 ,0,0,'un ','' ,bo.marcada,1 ,0*9.000,0*9.000*200.48 ,12.614000,12.614000*200.48 ,12.614000,12.614000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0*200.48,0*9.000,0*9.000*200.48,0,0*9.000,0,0*9.000,?,?,?,4 from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.4402 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.4406 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.usalote valor from st where st.ref = '324.1684.00.1'
20240528@142041.4417 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.4420 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.1684.00.1'
20240528@142041.4430 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.4433 8dtfh00eh3lipcu1olcf9ta9m4 Query : select isnull(sum(stock) ,0)stock ,isnull(sum(qttrec),0) qttrec ,0 qttcat ,isnull(sum(rescli),0) rescli ,isnull(sum(resfor),0) resfor from sa where sa.ref = '324.1684.00.1' and sa.armazem = 133 
20240528@142041.4527 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.4531 8dtfh00eh3lipcu1olcf9ta9m4 Query : select st.stns valor from st where st.ref = '324.1684.00.1'
20240528@142041.4574 8dtfh00eh3lipcu1olcf9ta9m4 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 = '324.1684.00.1'
20240528@142041.4744 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.4761 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.4774 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.4787 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.4794 8dtfh00eh3lipcu1olcf9ta9m4 Query : select sestamp valor from se where ref ='324.1684.00.1' and lote = 'r2301217200a'
20240528@142041.4811 8dtfh00eh3lipcu1olcf9ta9m4 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240528@142041.4823 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.4839 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 5
20240528@142041.4849 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbi2data (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut6655d274406655da2975','aut6655d731856655da290c',bo.morada, bo.local,bo.codpost ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut' from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.4987 8dtfh00eh3lipcu1olcf9ta9m4 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@142041.5003 8dtfh00eh3lipcu1olcf9ta9m4 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 5
20240528@142041.5020 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbidata (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,eslvu,slvu,esltt,sltt,vumoeda,ttmoeda,slvumoeda,slttmoeda,lote,armazem,ar2mazem,stipo) select 'aut6655d274406655da2975',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 48.000, 48.000*.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,30000 ,0,0*200.48,0,0*200.48 ,0,0,'un ','' ,bo.marcada,1 ,0*48.000,0*48.000*200.48 ,20.129000,20.129000*200.48 ,20.129000,20.129000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0*200.48,0*48.000,0*48.000*200.48,0,0*48.000,0,0*48.000,?,?,?,4 from wsbodata bo where bo.bostamp = 'aut6655d731856655da290c'
20240528@142041.5280 8dtfh00eh3lipcu1olcf9ta9m4 Query : insert into wsbocreationlog (initialstamp,externalid,creationstatus,documenttypeid,idustamp,transactionid) values ('aut6655d731856655da290c','','wait',5,'','')
20240528@142041.5359 8dtfh00eh3lipcu1olcf9ta9m4 Query : use flama_phc
20240528@142041.5363 8dtfh00eh3lipcu1olcf9ta9m4 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240528@142041.5375 8dtfh00eh3lipcu1olcf9ta9m4 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='110';
20240528@142041.5390 8dtfh00eh3lipcu1olcf9ta9m4 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='110';

20240528@163541.5536 k3gdk2sffbmts0p4dq12ur76rn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='111';
20240528@163541.5559 k3gdk2sffbmts0p4dq12ur76rn Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='111';
20240528@163541.5571 k3gdk2sffbmts0p4dq12ur76rn Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='111';
20240528@163541.5587 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.5590 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240528@163541.5663 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.1667.00.1'
20240528@163541.5773 k3gdk2sffbmts0p4dq12ur76rn 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 = 2400065 and bi.ref ='324.1667.00.1' and bi.lordem =20000
20240528@163541.6117 k3gdk2sffbmts0p4dq12ur76rn 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 = 'cps24011644612,696000002 ' 
20240528@163541.6421 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.6424 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 1 valor from ts where ts.ndos = 61
20240528@163541.6503 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.6506 k3gdk2sffbmts0p4dq12ur76rn 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')
20240528@163541.6580 k3gdk2sffbmts0p4dq12ur76rn 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
20240528@163541.6725 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.6728 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 ~inactivo valor from fl where no = '202247' and estab = 00 order by inactivo desc
20240528@163541.6809 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.6813 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from ts where ndos = 61
20240528@163541.6885 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.7213 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240528@163541.7271 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.7290 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240528@163541.7297 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.7310 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240528@163541.7318 k3gdk2sffbmts0p4dq12ur76rn 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
20240528@163541.7438 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240528@163541.7532 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240528@163541.7549 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163541.7553 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202247' and estab=00
20240528@163541.7633 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.7647 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240528@163541.7701 k3gdk2sffbmts0p4dq12ur76rn Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut6655f832416655f9cdb8',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240528@163541.7759 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.7774 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240528@163541.8818 k3gdk2sffbmts0p4dq12ur76rn Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut6655f832416655f9cdb8','--','bo',1.1159874608150470219 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240528@163541.9098 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163541.9115 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240528@163541.9124 k3gdk2sffbmts0p4dq12ur76rn 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 ('aut6655f832416655f9cdb8','guia r. fornecedor','2024-05-28',61,2401519,?,?,?,?,?,?,?,?,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')
20240528@163542.7189 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163542.7193 k3gdk2sffbmts0p4dq12ur76rn Query : select st.usalote valor from st where st.ref = '324.1667.00.1'
20240528@163542.7311 k3gdk2sffbmts0p4dq12ur76rn 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 = '324.1667.00.1'
20240528@163542.7470 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.7485 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240528@163542.7499 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.7512 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240528@163542.7520 k3gdk2sffbmts0p4dq12ur76rn Query : select sestamp valor from se where ref ='324.1667.00.1' and lote = 'r2400065200a'
20240528@163542.7573 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.7588 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'se' and documentnumber = 0
20240528@163542.7596 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.7610 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'se' and documentnumber = 0
20240528@163542.7618 k3gdk2sffbmts0p4dq12ur76rn Query : insert into se (sestamp,ref, lote, data,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut6655f850206655f9ceb9',?,?,'20240528',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut;','aut;')
20240528@163542.8538 k3gdk2sffbmts0p4dq12ur76rn Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240528@163542.9192 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.9289 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240528@163542.9298 k3gdk2sffbmts0p4dq12ur76rn Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut6655f564776655f9cee0','aut6655f832416655f9cdb8',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 = 'aut6655f832416655f9cdb8'
20240528@163542.9485 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240528@163542.9504 k3gdk2sffbmts0p4dq12ur76rn Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240528@163542.9520 k3gdk2sffbmts0p4dq12ur76rn 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 'aut6655f564776655f9cee0',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 950, 950*.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 ,31.9,31.9*200.48,31.9,31.9*200.48 ,0,0,'un',' ' ,bo.marcada,1 ,31.9*950,31.9*950*200.48 ,36.465000,36.465000*200.48 ,36.465000,36.465000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,31.9,31.9*200.48,31.9*950,31.9*950*200.48,'cps24011644612,696000002 ',35.6,35.6*950,35.6,35.6*950,?,?,?,4 from bo bo where bo.bostamp = 'aut6655f832416655f9cdb8'
20240528@163558.1120 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163558.1180 k3gdk2sffbmts0p4dq12ur76rn Query : declare @bostamp varchar(25) = 'aut6655f832416655f9cdb8' ,@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 
20240528@163611.8222 k3gdk2sffbmts0p4dq12ur76rn Query : use flama_phc
20240528@163611.8952 k3gdk2sffbmts0p4dq12ur76rn Query : select 1 valor from bo where bo.bostamp = 'aut6655f832416655f9cdb8'
20240528@163611.9200 k3gdk2sffbmts0p4dq12ur76rn 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) = 'aut6655f832416655f9cdb8' 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 
