Primeiro: Identificar qual a agenda da Nota Fiscal.
Segundo: A Flag PIS/COFNS deve ter conteúdo "S" para todos os CRF/CFOP.
Terceiro: A agenda da nota fiscal não pode ser nenhuma das agendas identificadas abaixo.
Para identificar as agendas fazer as consultas abaixo:
select substr(nvl(tab_conteudo, 0), 1, 3),
replace(substr(nvl(tab_conteudo, 0), 4, 3), ' ', '0')
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDVENPDV ';
select substr(nvl(tab_conteudo, 0), 1, 3)
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDDEVPDV ';
select substr(nvl(tab_conteudo, 0), 1, 3)
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDDEVAJS ';
select substr(nvl(tab_conteudo, 0), 1, 3)
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDFISCAL ';
select substr(nvl(tab_conteudo, 0), 1, 3)
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDCFE ';
select substr(nvl(tab_conteudo, 0), 1, 3)
from AA2CTABE
where tab_codigo = 45
and tab_acesso = 'AGDSAT ';
Quarto: Nota fiscal de saída de transferência ou devolução não é selecionada.
Quinto: Nota fiscal de entrada de transferência não é selecionada.