...
Code Block | ||
---|---|---|
| ||
CREATE OR REPLACE FORCE VIEW VIASOFTVTRINA.V_VT_NOTAPEDIDO AS SELECT NF.IDNOTA, NF.NUMDOC, NF.CHVNFE, NF.SERIE, NF.DTRECPROTAUT, NF.NPROTAUTORIZA, CASE WHEN ( NF.IDNOTA IS NOT NULL ) AND ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML NOT LIKE '%<infProt%' ) AND ( NX.PROTAUT LIKE '%<infProt%' ) THEN '<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="4.00" xmlns="http://www.portalfiscal.inf.br/nfe">'||REPLACE(NX.XML,'<?xml version="1.0" encoding="UTF-8"?>','')||'<protNFe versao="4.00">'||NX.PROTAUT||'</protNFe></nfeProc>' ELSE NX.XML END AS XML, WP.IGNORA, WP.PEDCODIGO, CASE WHEN NF.IDNOTA IS NULL THEN 'Em Preparação' WHEN ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML LIKE '%<infProt%' ) THEN 'Faturado' WHEN ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML NOT LIKE '%<infProt%' ) AND ( NX.PROTAUT LIKE '%<infProt%' ) THEN 'Faturado' ELSE 'Em Processamento' END AS STATUS FROM VIASOFTMCP.WECPEDIDO WP LEFT JOIN VIASOFTBASE.NOTA NF ON NF.ESTAB=WP.ESTAB AND NF.IDNOTA=WP.IDNOTA LEFT JOIN VIASOFTBASE.NOTAXML NX ON NX.ESTAB=NF.ESTAB AND NX.IDNOTA=NF.IDNOTA; |
...
Code Block | ||
---|---|---|
| ||
CREATE OR REPLACE FORCE VIEW VIASOFTVTRINA.V_VT_NOTAPEDIDOTRANSP AS SELECT NF.IDNOTA, NF.NUMDOC, NF.CHVNFE, NF.SERIE, NF.DTRECPROTAUT, NF.NPROTAUTORIZA, CASE WHEN ( NF.IDNOTA IS NOT NULL ) AND ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML NOT LIKE '%<infProt%' ) AND ( NX.PROTAUT LIKE '%<infProt%' ) THEN '<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="4.00" xmlns="http://www.portalfiscal.inf.br/nfe">'||REPLACE(NX.XML,'<?xml version="1.0" encoding="UTF-8"?>','')||'<protNFe versao="4.00">'||NX.PROTAUT||'</protNFe></nfeProc>' ELSE NX.XML END AS XML, WP.IGNORA, WP.PEDCODIGO, CASE WHEN NF.IDNOTA IS NULL THEN 'Em Preparação' WHEN ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML LIKE '%<infProt%' ) THEN 'Faturado' WHEN ( LENGTH(NF.NPROTAUTORIZA) > 0 ) AND ( NX.XML LIKE '%<Signature%' ) AND ( NX.XML NOT LIKE '%<infProt%' ) AND ( NX.PROTAUT LIKE '%<infProt%' ) THEN 'Faturado' ELSE 'Em Processamento' END AS STATUS FROM VIASOFTMCP.WECPEDIDO WP LEFT JOIN VIASOFTMCP.NOTAREFITE NR ON NR.ESTABREF=WP.ESTAB AND NR.IDNOTAREF=WP.IDNOTA LEFT JOIN VIASOFTBASE.NOTA NF ON NF.ESTAB=NR.ESTAB AND NF.IDNOTA=NR.IDNOTA LEFT JOIN VIASOFTBASE.NOTAXML NX ON NX.ESTAB=NF.ESTAB AND NX.IDNOTA=NF.IDNOTA; |
...