20240815@183610.7838 rqin08ddkladk44b0su1iidprv Query : use flama_phc
20240815@183610.7843 rqin08ddkladk44b0su1iidprv Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@191911.7537 vaseaajm7lvc9to6q46efslrfc Query : use flama_phc
20240815@191911.7544 vaseaajm7lvc9to6q46efslrfc Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@191911.7905 vaseaajm7lvc9to6q46efslrfc Query : use flama_phc
20240815@191911.7909 vaseaajm7lvc9to6q46efslrfc Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@193612.2780 98ktb49phaj90ctv82c9g37a41 Query : use flama_phc
20240815@193612.2830 98ktb49phaj90ctv82c9g37a41 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@193612.3850 98ktb49phaj90ctv82c9g37a41 Query : use flama_phc
20240815@193612.3890 98ktb49phaj90ctv82c9g37a41 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@201914.7447 u32b509au6hvg61o3de7ku0mrq Query : use flama_phc
20240815@201914.7452 u32b509au6hvg61o3de7ku0mrq Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@201914.7547 u32b509au6hvg61o3de7ku0mrq Query : use flama_phc
20240815@201914.7551 u32b509au6hvg61o3de7ku0mrq Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@203614.6413 3na37hs0h6huiv8rksunuf2idn Query : use flama_phc
20240815@203614.6419 3na37hs0h6huiv8rksunuf2idn Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@203614.6646 3na37hs0h6huiv8rksunuf2idn Query : use flama_phc
20240815@203614.6650 3na37hs0h6huiv8rksunuf2idn Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@211914.6720 qmjpertu1dog11t3gqte0b768r Query : use flama_phc
20240815@211914.6790 qmjpertu1dog11t3gqte0b768r Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@211914.7840 qmjpertu1dog11t3gqte0b768r Query : use flama_phc
20240815@211914.7880 qmjpertu1dog11t3gqte0b768r Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@213614.3201 u963ocht238310v21seq627cep Query : use flama_phc
20240815@213614.3207 u963ocht238310v21seq627cep Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@213614.3302 u963ocht238310v21seq627cep Query : use flama_phc
20240815@213614.3306 u963ocht238310v21seq627cep Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@221912.7734 7vv754alqdl2ddhuj8a2aiq9it Query : use flama_phc
20240815@221912.7739 7vv754alqdl2ddhuj8a2aiq9it Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@221912.7868 7vv754alqdl2ddhuj8a2aiq9it Query : use flama_phc
20240815@221912.7872 7vv754alqdl2ddhuj8a2aiq9it Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@223612.6535 ml4v2qbeh5ptbobdeiq3hug3vo Query : use flama_phc
20240815@223612.6542 ml4v2qbeh5ptbobdeiq3hug3vo Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@223612.6639 ml4v2qbeh5ptbobdeiq3hug3vo Query : use flama_phc
20240815@223612.6643 ml4v2qbeh5ptbobdeiq3hug3vo Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@231913.6750 ie583guj88oqjsi6q3dj0v2cjv Query : use flama_phc
20240815@231913.6756 ie583guj88oqjsi6q3dj0v2cjv Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@231913.6874 ie583guj88oqjsi6q3dj0v2cjv Query : use flama_phc
20240815@231913.6879 ie583guj88oqjsi6q3dj0v2cjv Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240815@233613.8933 p87eaauq36mtngktio21i8bi3f Query : use flama_phc
20240815@233613.8937 p87eaauq36mtngktio21i8bi3f Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240815@233613.9039 p87eaauq36mtngktio21i8bi3f Query : use flama_phc
20240815@233613.9042 p87eaauq36mtngktio21i8bi3f Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@071911.1410 o4uv4s34thh76vskni3e96gu65 Query : use flama_phc
20240816@071911.1415 o4uv4s34thh76vskni3e96gu65 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@071911.1575 o4uv4s34thh76vskni3e96gu65 Query : use flama_phc
20240816@071911.1579 o4uv4s34thh76vskni3e96gu65 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@073645.5849 mrhc6hqu0798hu7n4s5g6roj0d Query : use flama_phc
20240816@073645.5854 mrhc6hqu0798hu7n4s5g6roj0d Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@073645.5950 mrhc6hqu0798hu7n4s5g6roj0d Query : use flama_phc
20240816@073645.5955 mrhc6hqu0798hu7n4s5g6roj0d Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@081909.2199 iudkmnn5hk8v1bk2veetu3g6c5 Query : use flama_phc
20240816@081909.2205 iudkmnn5hk8v1bk2veetu3g6c5 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@081909.2311 iudkmnn5hk8v1bk2veetu3g6c5 Query : use flama_phc
20240816@081909.2314 iudkmnn5hk8v1bk2veetu3g6c5 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@083609.1054 7cjp5nr3dvkvgaifq4ajsgk1vt Query : use flama_phc
20240816@083609.1059 7cjp5nr3dvkvgaifq4ajsgk1vt Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@083609.1153 7cjp5nr3dvkvgaifq4ajsgk1vt Query : use flama_phc
20240816@083609.1156 7cjp5nr3dvkvgaifq4ajsgk1vt Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@091914.3137 6bt8a0lvpcpd8iqd4a3pifi2s5 Query : use flama_phc
20240816@091914.3142 6bt8a0lvpcpd8iqd4a3pifi2s5 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@091914.3736 6bt8a0lvpcpd8iqd4a3pifi2s5 Query : use flama_phc
20240816@091914.3741 6bt8a0lvpcpd8iqd4a3pifi2s5 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@093613.6114 95ngs7elicldkl4ko9u4vj1skr Query : use flama_phc
20240816@093613.6119 95ngs7elicldkl4ko9u4vj1skr Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@093613.6217 95ngs7elicldkl4ko9u4vj1skr Query : use flama_phc
20240816@093613.6220 95ngs7elicldkl4ko9u4vj1skr Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@101910.1366 6iqjb95bljm1fq87hk2jr8jvii Query : use flama_phc
20240816@101910.1371 6iqjb95bljm1fq87hk2jr8jvii Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@101910.1487 6iqjb95bljm1fq87hk2jr8jvii Query : use flama_phc
20240816@101910.1491 6iqjb95bljm1fq87hk2jr8jvii Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@103610.7530 sdqcub5obldnla1fviak0mo4km Query : use flama_phc
20240816@103610.7570 sdqcub5obldnla1fviak0mo4km Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@103610.8560 sdqcub5obldnla1fviak0mo4km Query : use flama_phc
20240816@103610.8600 sdqcub5obldnla1fviak0mo4km Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@111912.1680 m9q5f9do7108k69nnrqrlurafq Query : use flama_phc
20240816@111912.1685 m9q5f9do7108k69nnrqrlurafq Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@111912.1830 m9q5f9do7108k69nnrqrlurafq Query : use flama_phc
20240816@111912.1835 m9q5f9do7108k69nnrqrlurafq Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@113611.9856 e764qgaa2l8can7stmvenhm49p Query : use flama_phc
20240816@113611.9862 e764qgaa2l8can7stmvenhm49p Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@113611.9957 e764qgaa2l8can7stmvenhm49p Query : use flama_phc
20240816@113611.9960 e764qgaa2l8can7stmvenhm49p Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@121917.3385 k8n8j305rv59621ghrmfhjnrer Query : use flama_phc
20240816@121917.3390 k8n8j305rv59621ghrmfhjnrer Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@121917.3534 k8n8j305rv59621ghrmfhjnrer Query : use flama_phc
20240816@121917.3538 k8n8j305rv59621ghrmfhjnrer Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@123617.2329 j2a6rmopdc9b1cmujuff3lbdh6 Query : use flama_phc
20240816@123617.2334 j2a6rmopdc9b1cmujuff3lbdh6 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@123617.2541 j2a6rmopdc9b1cmujuff3lbdh6 Query : use flama_phc
20240816@123617.2545 j2a6rmopdc9b1cmujuff3lbdh6 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@131912.8765 dn67o7i2q08e83hfbtudna572a Query : use flama_phc
20240816@131912.8771 dn67o7i2q08e83hfbtudna572a Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@131912.8863 dn67o7i2q08e83hfbtudna572a Query : use flama_phc
20240816@131912.8867 dn67o7i2q08e83hfbtudna572a Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@133612.5204 99cp1n1b90n2v4726t70e7k4oq Query : use flama_phc
20240816@133612.5208 99cp1n1b90n2v4726t70e7k4oq Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@133612.5310 99cp1n1b90n2v4726t70e7k4oq Query : use flama_phc
20240816@133612.5314 99cp1n1b90n2v4726t70e7k4oq Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@141910.7542 v9jmpnt5a2hduqvujjfa5h7029 Query : use flama_phc
20240816@141910.7547 v9jmpnt5a2hduqvujjfa5h7029 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@141910.7656 v9jmpnt5a2hduqvujjfa5h7029 Query : use flama_phc
20240816@141910.7660 v9jmpnt5a2hduqvujjfa5h7029 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@143610.9042 bfh1iacp39armlag6pflsd7b2u Query : use flama_phc
20240816@143610.9048 bfh1iacp39armlag6pflsd7b2u Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@143610.9173 bfh1iacp39armlag6pflsd7b2u Query : use flama_phc
20240816@143610.9176 bfh1iacp39armlag6pflsd7b2u Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@151911.7893 m4u93517tnptn5ma32532ba1ql Query : use flama_phc
20240816@151911.7899 m4u93517tnptn5ma32532ba1ql Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@151911.8005 m4u93517tnptn5ma32532ba1ql Query : use flama_phc
20240816@151911.8009 m4u93517tnptn5ma32532ba1ql Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@153612.9580 lr245r8943ge797kfb2j88tq61 Query : use flama_phc
20240816@153612.9630 lr245r8943ge797kfb2j88tq61 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@153612.1067 lr245r8943ge797kfb2j88tq61 Query : use flama_phc
20240816@153612.1070 lr245r8943ge797kfb2j88tq61 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@161912.1059 de4hkgsca761v2gha5n8883g02 Query : use flama_phc
20240816@161912.1066 de4hkgsca761v2gha5n8883g02 Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@161912.1168 de4hkgsca761v2gha5n8883g02 Query : use flama_phc
20240816@161912.1172 de4hkgsca761v2gha5n8883g02 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@163612.3921 brd7v8kp275m1v5dppkbkibrpa Query : use flama_phc
20240816@163612.3929 brd7v8kp275m1v5dppkbkibrpa Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@163612.4032 brd7v8kp275m1v5dppkbkibrpa Query : use flama_phc
20240816@163612.4036 brd7v8kp275m1v5dppkbkibrpa Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@171910.8533 jb4v1lqhmojh4aavuukk5efocs Query : use flama_phc
20240816@171910.8537 jb4v1lqhmojh4aavuukk5efocs Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@171910.8624 jb4v1lqhmojh4aavuukk5efocs Query : use flama_phc
20240816@171910.8627 jb4v1lqhmojh4aavuukk5efocs Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@173611.1978 oa4mpqcargggr3fbh99j9h902u Query : use flama_phc
20240816@173611.1983 oa4mpqcargggr3fbh99j9h902u Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@173611.2080 oa4mpqcargggr3fbh99j9h902u Query : use flama_phc
20240816@173611.2083 oa4mpqcargggr3fbh99j9h902u Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@181909.8350 hed362d7heech70ujeqeth25fm Query : use flama_phc
20240816@181909.8356 hed362d7heech70ujeqeth25fm Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@181909.8453 hed362d7heech70ujeqeth25fm Query : use flama_phc
20240816@181909.8456 hed362d7heech70ujeqeth25fm Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@182010.6320 4r2abf9n2rbncngh7q5h1g8q01 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240816@182010.6367 4r2abf9n2rbncngh7q5h1g8q01 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240816@182010.6707 4r2abf9n2rbncngh7q5h1g8q01 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1565';
20240816@182010.6770 4r2abf9n2rbncngh7q5h1g8q01 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1565';
20240816@182010.6839 4r2abf9n2rbncngh7q5h1g8q01 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1565';
20240816@182010.6868 4r2abf9n2rbncngh7q5h1g8q01 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1565';
20240816@182010.6922 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.6926 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240816@182010.7036 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.988.00.01'
20240816@182010.7188 4r2abf9n2rbncngh7q5h1g8q01 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 = 2400410 and bi.ref ='324.988.00.01' and bi.lordem =20000
20240816@182010.7573 4r2abf9n2rbncngh7q5h1g8q01 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 = 'cps24041135338,012000002 ' 
20240816@182010.7939 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.7943 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 1 valor from ts where ts.ndos = 61
20240816@182010.8058 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.8062 4r2abf9n2rbncngh7q5h1g8q01 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')
20240816@182010.8216 4r2abf9n2rbncngh7q5h1g8q01 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
20240816@182010.8457 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.8462 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 ~inactivo valor from fl where no = '202383' and estab = 00 order by inactivo desc
20240816@182010.8609 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.8613 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from ts where ndos = 61
20240816@182010.8717 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182010.9077 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240816@182010.9125 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182010.9143 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240816@182010.9154 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182010.9171 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240816@182010.9182 4r2abf9n2rbncngh7q5h1g8q01 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
20240816@182010.9330 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240816@182010.9500 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240816@182010.9523 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182010.9541 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202383' and estab=00
20240816@182010.9640 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182010.9659 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240816@182010.9706 4r2abf9n2rbncngh7q5h1g8q01 Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf88113866bf8a4ae8',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240816@182010.9791 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182010.9815 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240816@182010.9831 4r2abf9n2rbncngh7q5h1g8q01 Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf88113866bf8a4ae8','--','bo',7.8651685393258426966 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240816@182011.2270 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.2480 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240816@182011.2640 4r2abf9n2rbncngh7q5h1g8q01 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 ('aut66bf88113866bf8a4ae8','guia r. fornecedor','2024-08-16',61,2402308,?,?,?,?,?,?,?,?,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')
20240816@182011.8610 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182011.8650 4r2abf9n2rbncngh7q5h1g8q01 Query : select st.usalote valor from st where st.ref = '324.988.00.01'
20240816@182011.9960 4r2abf9n2rbncngh7q5h1g8q01 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.988.00.01'
20240816@182011.1143 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.1164 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240816@182011.1181 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.1200 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240816@182011.1215 4r2abf9n2rbncngh7q5h1g8q01 Query : select sestamp valor from se where ref ='324.988.00.01' and lote = 'r2400410200a'
20240816@182011.1282 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.1302 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'se' and documentnumber = 0
20240816@182011.1315 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.1333 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'se' and documentnumber = 0
20240816@182011.1349 4r2abf9n2rbncngh7q5h1g8q01 Query : insert into se (sestamp,ref, lote, data,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf82462566bf8a4b20',?,?,'20240816',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut;','aut;')
20240816@182011.1608 4r2abf9n2rbncngh7q5h1g8q01 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240816@182011.1919 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.2033 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240816@182011.2050 4r2abf9n2rbncngh7q5h1g8q01 Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut66bf89110466bf8a4b2e','aut66bf88113866bf8a4ae8',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 = 'aut66bf88113866bf8a4ae8'
20240816@182011.2464 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182011.2685 4r2abf9n2rbncngh7q5h1g8q01 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240816@182011.2710 4r2abf9n2rbncngh7q5h1g8q01 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 'aut66bf89110466bf8a4b2e',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 2800, 2800*.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 ,8.9,8.9*200.48,8.9,8.9*200.48 ,0,0,'un ',' ' ,bo.marcada,1 ,8.9*2800,8.9*2800*200.48 ,10.294000,10.294000*200.48 ,10.294000,10.294000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,8.9,8.9*200.48,8.9*2800,8.9*2800*200.48,'cps24041135338,012000002 ',70,70*2800,70,70*2800,?,?,?,4 from bo bo where bo.bostamp = 'aut66bf88113866bf8a4ae8'
20240816@182011.7945 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182011.7951 4r2abf9n2rbncngh7q5h1g8q01 Query : declare @bostamp varchar(25) = 'aut66bf88113866bf8a4ae8' ,@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 
20240816@182012.5120 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182012.5170 4r2abf9n2rbncngh7q5h1g8q01 Query : select 1 valor from bo where bo.bostamp = 'aut66bf88113866bf8a4ae8'
20240816@182012.6790 4r2abf9n2rbncngh7q5h1g8q01 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) = 'aut66bf88113866bf8a4ae8' 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 
20240816@182012.3096 4r2abf9n2rbncngh7q5h1g8q01 Query : use flama_phc
20240816@182012.3100 4r2abf9n2rbncngh7q5h1g8q01 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@182012.3172 4r2abf9n2rbncngh7q5h1g8q01 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1565';
20240816@182012.3207 4r2abf9n2rbncngh7q5h1g8q01 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1565';
20240816@182012.3899 4tso5301cdruhbuhptoj8vp0mh Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240816@182012.3911 4tso5301cdruhbuhptoj8vp0mh Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240816@182012.3973 4tso5301cdruhbuhptoj8vp0mh Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1566';
20240816@182012.4047 4tso5301cdruhbuhptoj8vp0mh Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1566';
20240816@182012.4111 4tso5301cdruhbuhptoj8vp0mh Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1566';
20240816@182012.4147 4tso5301cdruhbuhptoj8vp0mh Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1566';
20240816@182012.4192 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.4197 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240816@182012.4285 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 isnull(design,'') valor from st (nolock) where st.ref = '324.600.94.01'
20240816@182012.4418 4tso5301cdruhbuhptoj8vp0mh 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 = 2400295 and bi.ref ='324.600.94.01' and bi.lordem =20000
20240816@182012.4788 4tso5301cdruhbuhptoj8vp0mh 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 = 'cps24031535323,849000002 ' 
20240816@182012.5163 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.5167 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 1 valor from ts where ts.ndos = 61
20240816@182012.5208 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.5212 4tso5301cdruhbuhptoj8vp0mh 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')
20240816@182012.5249 4tso5301cdruhbuhptoj8vp0mh 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
20240816@182012.5293 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.5299 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 ~inactivo valor from fl where no = '202292' and estab = 00 order by inactivo desc
20240816@182012.5473 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.5478 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from ts where ndos = 61
20240816@182012.5498 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5537 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo' and documentnumber = 61
20240816@182012.5553 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5577 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo2' and documentnumber = 61
20240816@182012.5590 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5611 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bo3' and documentnumber = 61
20240816@182012.5623 4tso5301cdruhbuhptoj8vp0mh 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
20240816@182012.5643 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240816@182012.5673 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 bo.obrano valor from bo bo where bo.ndos = 61 and boano=2024 order by obrano desc
20240816@182012.5705 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.5718 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 no,estab,nome, morada, local,codpost,ncont,pncont,pais,inactivo,motiseimp,codmotiseimp from fl where no='202292' and estab=00
20240816@182012.5870 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5896 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo3' and documentnumber = 61
20240816@182012.5914 4tso5301cdruhbuhptoj8vp0mh Query : insert into bo3 (bo3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf82016766bf8a4c8b',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240816@182012.5920 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5944 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo2' and documentnumber = 61
20240816@182012.5960 4tso5301cdruhbuhptoj8vp0mh Query : insert into bo2 (bo2stamp, tiposaft, idserie,cambio,cambiofixo,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf82016766bf8a4c8b','--','bo',1.0948275862068965517 ,1,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut')
20240816@182012.5967 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.5988 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bo' and documentnumber = 61
20240816@182012.6002 4tso5301cdruhbuhptoj8vp0mh 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 ('aut66bf82016766bf8a4c8b','guia r. fornecedor','2024-08-16',61,2402309,?,?,?,?,?,?,?,?,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')
20240816@182012.9531 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182012.9536 4tso5301cdruhbuhptoj8vp0mh Query : select st.usalote valor from st where st.ref = '324.600.94.01'
20240816@182012.9574 4tso5301cdruhbuhptoj8vp0mh 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.600.94.01'
20240816@182012.9882 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.9905 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi' and documentnumber = 61
20240816@182012.9924 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182012.9945 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'bi2' and documentnumber = 61
20240816@182012.9957 4tso5301cdruhbuhptoj8vp0mh Query : select sestamp valor from se where ref ='324.600.94.01' and lote = 'r2400295200a'
20240816@182012.9987 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182013.1000 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'se' and documentnumber = 0
20240816@182013.2500 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182013.1440 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'se' and documentnumber = 0
20240816@182013.1620 4tso5301cdruhbuhptoj8vp0mh Query : insert into se (sestamp,ref, lote, data,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf83584266bf8a4d00',?,?,'20240816',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut;','aut;')
20240816@182013.2540 4tso5301cdruhbuhptoj8vp0mh Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240816@182013.2840 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182013.3050 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi2' and documentnumber = 61
20240816@182013.3200 4tso5301cdruhbuhptoj8vp0mh Query : insert into bi2 (bi2stamp,bostamp,morada, local,codpost ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) select 'aut66bf86538166bf8a4d06','aut66bf82016766bf8a4c8b',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 = 'aut66bf82016766bf8a4c8b'
20240816@182013.5640 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@182013.5900 4tso5301cdruhbuhptoj8vp0mh Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'bi' and documentnumber = 61
20240816@182013.6110 4tso5301cdruhbuhptoj8vp0mh 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 'aut66bf86538166bf8a4d06',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'aut','aut',bo.obrano, 1460, 1460*.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 ,23.2,23.2*200.48,23.2,23.2*200.48 ,0,0,'un ','' ,bo.marcada,1 ,23.2*1460,23.2*1460*200.48 ,26.208000,26.208000*200.48 ,26.208000,26.208000*200.48 ,bo.vendedor,bo.vendnm,bo.ccusto,bo.ncusto ,0,2,23.00,?,?,?,0,0,0,0,23.2,23.2*200.48,23.2*1460,23.2*1460*200.48,'cps24031535323,849000002 ',25.4,25.4*1460,25.4,25.4*1460,?,?,?,4 from bo bo where bo.bostamp = 'aut66bf82016766bf8a4c8b'
20240816@182013.2417 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182013.2422 4tso5301cdruhbuhptoj8vp0mh Query : declare @bostamp varchar(25) = 'aut66bf82016766bf8a4c8b' ,@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 
20240816@182013.4542 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182013.4546 4tso5301cdruhbuhptoj8vp0mh Query : select 1 valor from bo where bo.bostamp = 'aut66bf82016766bf8a4c8b'
20240816@182013.4565 4tso5301cdruhbuhptoj8vp0mh 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) = 'aut66bf82016766bf8a4c8b' 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 
20240816@182013.7779 4tso5301cdruhbuhptoj8vp0mh Query : use flama_phc
20240816@182013.7784 4tso5301cdruhbuhptoj8vp0mh Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@182013.7840 4tso5301cdruhbuhptoj8vp0mh Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1566';
20240816@182013.7869 4tso5301cdruhbuhptoj8vp0mh Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1566';
20240816@183609.9455 40opmdr06bfrurs3c24jgg02su Query : use flama_phc
20240816@183609.9459 40opmdr06bfrurs3c24jgg02su Query : select secretkey valor from u_wsusers u where u.userid = ? and u.username=? and u.password=? and u.inactivo=0
20240816@183609.9556 40opmdr06bfrurs3c24jgg02su Query : use flama_phc
20240816@183609.9561 40opmdr06bfrurs3c24jgg02su Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@185834.9618 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240816@185834.9634 rjs8s5bv3cjne9hgebuk19smh8 Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240816@185834.9693 rjs8s5bv3cjne9hgebuk19smh8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1567';
20240816@185834.9750 rjs8s5bv3cjne9hgebuk19smh8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1567';
20240816@185834.9806 rjs8s5bv3cjne9hgebuk19smh8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1567';
20240816@185834.9836 rjs8s5bv3cjne9hgebuk19smh8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1567';
20240816@185834.9885 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185834.9890 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240816@185834.9961 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185834.9965 rjs8s5bv3cjne9hgebuk19smh8 Query : select no, estab,szadrsdesc from szadrs where u_coddest=8748
20240816@185835.5900 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1805.00.1'
20240816@185835.2490 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 isnull(design,'') valor from st (nolock) left join stobs (nolock) on st.ref = stobs.ref where st.ref = '324.1805.00.1'
20240816@185835.2730 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.2770 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240816@185835.6020 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.6060 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 1 valor from td where td.ndoc = 39
20240816@185835.7080 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.7110 rjs8s5bv3cjne9hgebuk19smh8 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')
20240816@185835.8000 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 manternumero ,assinadoc issigned ,tiposaft ,assinaimp ,nmdos ,td.assinadoc ,'cl' origin ,lancasl stocks ,case when cmsl<50 and td.lancasl=1 then 1 else 0 end entrada ,case when cmsl>50 and td.lancasl=1 then 1 else 0 end saida ,temserie assets ,~semgre usegridfields from td inner join td2 on td.tdstamp=td2.td2stamp where td.ndoc = 1
20240816@185835.1000 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.1004 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 ~inactivo valor from cl where no = '102253' and estab = 0 order by inactivo desc
20240816@185835.1134 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.1138 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 tipodoc,regrd from td where ndoc = 39
20240816@185835.1271 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.1275 rjs8s5bv3cjne9hgebuk19smh8 Query : select szadrsstamp valor from szadrs where szadrsdesc='espaÇotrans,lda'
20240816@185835.1455 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.1459 rjs8s5bv3cjne9hgebuk19smh8 Query : select szadrsstamp valor from szadrs where szadrsdesc='fnac - entrega'
20240816@185835.1513 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.1516 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from td where ndoc = 39
20240816@185835.1599 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 manternumero, tiposaft, nmdos,td.assinadoc from td where td.ndoc = 39
20240816@185835.1663 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.1683 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'ft' and documentnumber = 39
20240816@185835.1713 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.1736 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'ft2' and documentnumber = 39
20240816@185835.1770 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.1790 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'ft3' and documentnumber = 39
20240816@185835.1806 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 ft.fno valor from ft ft where ft.ndoc = 39 and ftano=2024 order by fno desc
20240816@185835.2013 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 ft.fno valor from wsftdata ft where ft.ndoc = 39 and ftano=2024 order by fno desc
20240816@185835.2107 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.2127 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'ft3' and documentnumber = 39
20240816@185835.2146 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsft3data (ft3stamp, ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis,taxpointdt ) values ('aut66bf97701866bf934b2c' ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv',?)
20240816@185835.2336 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.2356 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'ft2' and documentnumber = 39
20240816@185835.2408 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.u_nomeenv valor from bo where bo.bostamp=''
20240816@185835.2508 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.u_moradaen valor from bo where bo.bostamp=''
20240816@185835.2590 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.u_codposen valor from bo where bo.bostamp=''
20240816@185835.2676 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.u_localenv valor from bo where bo.bostamp=''
20240816@185835.2750 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.trab5 valor from bo where bo.bostamp=''
20240816@185835.2823 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 bo.serie valor from bo where bo.bostamp=''
20240816@185835.2898 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsft2data (ft2stamp, ousrdata,ousrhora, usrdata,usrhora,ousrinis,usrinis,u_nomeenv ,u_moradaen ,u_codposen ,u_localenv ,u_coddest ,u_codby ) values ('aut66bf97701866bf934b2c',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv',?,?,?,?,?,?)
20240816@185835.3197 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 fno valor from wsftdata order by fno desc
20240816@185835.3283 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.3302 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'ft' and documentnumber = 39
20240816@185835.3335 rjs8s5bv3cjne9hgebuk19smh8 Query : select 'normal' from dummy
20240816@185835.3373 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsftdata (ftstamp, ousrdata,ousrhora, usrdata,usrhora,ousrinis,usrinis,fno,no,estab,fdata,ndoc,moeda,cambio,cambiofixo,ftano,site ,classe ) values ('aut66bf97701866bf934b2c',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv',378,102253,0,'2024-08-16',39,'euro',0,0,2024 ,?,?)
20240816@185835.3882 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.3886 rjs8s5bv3cjne9hgebuk19smh8 Query : select st.usalote valor from st where st.ref = '324.1805.00.1'
20240816@185835.3915 rjs8s5bv3cjne9hgebuk19smh8 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.1805.00.1'
20240816@185835.4075 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4102 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'fi' and documentnumber = 39
20240816@185835.4137 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4155 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'fi2' and documentnumber = 39
20240816@185835.4167 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240816@185835.4183 rjs8s5bv3cjne9hgebuk19smh8 Query : select sestamp valor from se where ref ='324.1805.00.1' and lote = 'r2400290200a'
20240816@185835.4201 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4220 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'fi2' and documentnumber = 39
20240816@185835.4234 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsfi2data (fi2stamp,ftstamp ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf96567666bf934b66','aut66bf97701866bf934b2c' ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv')
20240816@185835.4297 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4317 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'fi' and documentnumber = 39
20240816@185835.4350 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsfidata (fistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,qtt ,ftstamp ,epv,pvmoeda ,tabiva,iva,lordem ,ref, design ,lote,armazem) values ('aut66bf96567666bf934b66',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv',6.000 ,'aut66bf97701866bf934b2c' ,0,0 ,2,23.00,10000,?,?,?,?)
20240816@185835.4628 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.4631 rjs8s5bv3cjne9hgebuk19smh8 Query : select st.usalote valor from st where st.ref = '324.1805.00.1'
20240816@185835.4657 rjs8s5bv3cjne9hgebuk19smh8 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.1805.00.1'
20240816@185835.4673 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4690 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'fi' and documentnumber = 39
20240816@185835.4723 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4740 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,mandatory from wstablefields where tablename = 'fi2' and documentnumber = 39
20240816@185835.4751 rjs8s5bv3cjne9hgebuk19smh8 Query : select top 1 convert(numeric(6,2),t.taxa) valor from taxasiva t where t.codigo='2'
20240816@185835.4771 rjs8s5bv3cjne9hgebuk19smh8 Query : select sestamp valor from se where ref ='324.1805.00.1' and lote = 'r2400290200a'
20240816@185835.4786 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4803 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'fi2' and documentnumber = 39
20240816@185835.4817 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsfi2data (fi2stamp,ftstamp ,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis) values ('aut66bf93465966bf934b74','aut66bf97701866bf934b2c' ,getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv')
20240816@185835.4822 rjs8s5bv3cjne9hgebuk19smh8 Query : select 1 valor from information_schema.tables where table_type='base table' and table_name='wstablefields'
20240816@185835.4840 rjs8s5bv3cjne9hgebuk19smh8 Query : select fieldkey,fieldname,fieldtype,calcformula from wstablefields where tablename = 'fi' and documentnumber = 39
20240816@185835.4875 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsfidata (fistamp,ousrdata, ousrhora, usrdata,usrhora,ousrinis,usrinis ,qtt ,ftstamp ,epv,pvmoeda ,tabiva,iva,lordem ,ref, design ,lote,armazem) values ('aut66bf93465966bf934b74',getdate(),convert(char(8),convert (time,getdate())),getdate(),convert(char(8),convert (time,getdate())),'wsv','wsv',14.000 ,'aut66bf97701866bf934b2c' ,0,0 ,2,23.00,20000,?,?,?,?)
20240816@185835.5189 rjs8s5bv3cjne9hgebuk19smh8 Query : insert into wsftcreationlog (initialftstamp,externalid,creationstatus,documenttypeid,idustamp) values ('aut66bf97701866bf934b2c','2405406','wait',39,'adm09112754980.682000002')
20240816@185835.5294 rjs8s5bv3cjne9hgebuk19smh8 Query : use flama_phc
20240816@185835.5297 rjs8s5bv3cjne9hgebuk19smh8 Query : update u_wsusers set rqsttoken =? where userid ='userls001'
20240816@185835.5331 rjs8s5bv3cjne9hgebuk19smh8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1567';
20240816@185835.5360 rjs8s5bv3cjne9hgebuk19smh8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1567';
20240816@185835.5401 rjs8s5bv3cjne9hgebuk19smh8 Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1567';
20240816@185835.5427 rjs8s5bv3cjne9hgebuk19smh8 Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1567';
20240816@185835.6042 7t9446gtqaab0fu1vcpo7hp6ct Query : insert into uploadfiles ( name_original, name_new, option_type, relative_path, whencreated ) values ( ?, ?, ?, ?, getdate() )
20240816@185835.6053 7t9446gtqaab0fu1vcpo7hp6ct Query : select uploadfile_id valor from uploadfiles where name_new = ? and option_type = ? 
20240816@185835.6324 7t9446gtqaab0fu1vcpo7hp6ct Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1568';
20240816@185835.6384 7t9446gtqaab0fu1vcpo7hp6ct Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1568';
20240816@185835.6440 7t9446gtqaab0fu1vcpo7hp6ct Query : select concat(rtrim(relative_path),ltrim(name_new)) as valor from uploadfiles where uploadfile_id='1568';
20240816@185835.6504 7t9446gtqaab0fu1vcpo7hp6ct Query : update uploadfiles set whenupdated=current_timestamp where uploadfile_id='1568';
20240816@185835.6649 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.6653 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 secretkey valor from u_wsusers u where u.userid = ? and u.inactivo=0
20240816@185835.6721 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.6725 7t9446gtqaab0fu1vcpo7hp6ct Query : select no, estab,szadrsdesc from szadrs where u_coddest=4779
20240816@185835.6818 7t9446gtqaab0fu1vcpo7hp6ct 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'
20240816@185835.6980 7t9446gtqaab0fu1vcpo7hp6ct 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'
20240816@185835.7204 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7208 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 convert(date,fdata) valor from ft where ndoc = 39 and anulado= 0 and fno>0 order by fdata desc
20240816@185835.7246 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7250 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 1 valor from td where td.ndoc = 39
20240816@185835.7284 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7287 7t9446gtqaab0fu1vcpo7hp6ct 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')
20240816@185835.7322 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 manternumero ,assinadoc issigned ,tiposaft ,assinaimp ,nmdos ,td.assinadoc ,'cl' origin ,lancasl stocks ,case when cmsl<50 and td.lancasl=1 then 1 else 0 end entrada ,case when cmsl>50 and td.lancasl=1 then 1 else 0 end saida ,temserie assets ,~semgre usegridfields from td inner join td2 on td.tdstamp=td2.td2stamp where td.ndoc = 1
20240816@185835.7361 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7365 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 ~inactivo valor from cl where no = '101900' and estab = 0 order by inactivo desc
20240816@185835.7494 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7498 7t9446gtqaab0fu1vcpo7hp6ct Query : select top 1 tipodoc,regrd from td where ndoc = 39
20240816@185835.7533 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7537 7t9446gtqaab0fu1vcpo7hp6ct Query : select szadrsstamp valor from szadrs where szadrsdesc='espaÇotrans,lda'
20240816@185835.7581 7t9446gtqaab0fu1vcpo7hp6ct Query : use flama_phc
20240816@185835.7585 7t9446gtqaab0fu1vcpo7hp6ct Query : select szadrsstamp valor from szadrs where szadrsdesc='101900 - pd - alcochete'
