Boa noite. (e desculpem o post longo...)
Estou com problemas em notas conjugadas.
O erro é o seguinte: "O elemento ICMSSN é inesperado"
Estou gerando o xml com este código:
while not DM2.qrNf02.Eof do begin
with Det.Add do begin
Inc(nSequen);
Prod.nItem := nSequen;
Prod.CFOP := DM2.qrNf02CFOP.AsString
Prod.cProd := DM2.qrNf02Codigo.AsString;
Prod.cEAN := xEAN;
Prod.xProd := txt;
Prod.NCM := SemDigitos(DM2.qrNf02NCM.AsString);
Prod.qCom := DM2.qrNf02Quantidade.Value;
Prod.uCom := DM2.qrNf02UM.Value;
Prod.vUnCom := DM2.qrNf02PrecoUni.Value;
Prod.qTrib := DM2.qrNf02Quantidade.Value;
Prod.uTrib := DM2.qrNf02UM.Value;
Prod.vUnTrib := DM2.qrNf02PrecoUni.Value;
Prod.vProd := DM2.qrNf02PrecoTot.Value;
Prod.vFrete := DM2.qrNf02Frete.AsFloat;
Prod.vSeg := DM2.qrNf02Seguro.AsFloat;
Prod.vDesc := DM2.qrNf02Desconto.AsFloat;
Prod.vOutro := DM2.qrNf02Despesas.AsFloat;
Prod.cEANTrib := '';
// SE FOR UM SERVIÇO
if DM2.qrNf02ProdServ.AsString='S' then begin
Prod.IndTot := itNaoSomaTotalNFe;
IssItem:=DM2.qrNf02PrecoTot.AsFloat * AliquotaIss/100;
somaServicos:=somaServicos+DM2.qrNf02PrecoTot.Value;
* NESTA PARTE, SE INFORMO O CSOSN, A NOTA É VALIDADA, MAS O XML FICA MEIO DOIDO COMO PODEM VER MAIS ABAIXO
{
if (CRT='1') then begin
aCSOSN:= csosn400;
with Imposto do begin
with ICMS do begin
orig := xOrigem;
CSOSN := aCSOSN;
end;
end;
end else begin
aCST:=cst40;
with Imposto do begin
with ICMS do begin
CST := aCST;
vBC := 0;
pICMS := 0;
vICMS := 0;
end;
end;
end;
}
* SE FOR INFORMADO SOMENTE O ISSQN, DÁ O ERRO [b]"O elemento ICMSSN é inesperado"[/b]
with Imposto do begin
with ISSQN do begin
vAliq := AliquotaIss;
vISSQN := IssItem;;
vBC := DM2.qrNf02PrecoTot.AsFloat;
cMunFG := StrToInt(xIBGE);
cListServ :=1401;
end;
end;
else begin // SE FOR UM PRODUTO
Prod.IndTot := itSomaTotalNFe;
vCredItem:= Arredonda(DM2.qrNf02PrecoTot.Value*AlqIcmsDAS/100);
with Imposto do begin
with ICMS do begin
orig := xOrigem;
if (CRT='1') then begin // Simples Nacional
CSOSN := aCSOSN ;
//modBC := dbiPrecoTabelado;
case aCSOSN of
csosn101:
begin
pCredSN := AlqIcmsDAS;
vCredICMSSN := vCredItem;
end;
csosn102,csosn103,csosn300,csosn400:
begin
//Tags ORIG e CSON já criadas antes do case
//102 - Tributada pelo Simples Nacional sem permissão de crédito.
//103 – Isenção do ICMS no Simples Nacional para faixa de receita bruta.
//300 – Imune.
//400 – Não tributada pelo Simples Nacional (v.2.0) (v.2.0)
vCredItem:=0;
end;
csosn201:
begin
modBCST := dbisMargemValorAgregado;
pMVAST := DM2.qrNf02pMVAST.AsFloat;
pRedBCST := DM2.qrNf02pRedBCST.AsFloat;
vBCST := DM2.qrNf02vBCST.AsFloat;
pICMSST := DM2.qrNf02pICMSST.AsFloat;
vICMSST := DM2.qrNf02vICMSST.AsFloat;
pCredSN := AlqIcmsDAS;
vCredICMSSN := vCredItem;
end;
csosn202,csosn203:
begin
modBCST := dbisMargemValorAgregado;
pMVAST := DM2.qrNf02pMVAST.AsFloat;
pRedBCST := DM2.qrNf02pRedBCST.AsFloat;
vBCST := DM2.qrNf02vBCST.AsFloat;
pICMSST := DM2.qrNf02pICMSST.AsFloat;
vICMSST := DM2.qrNf02vICMSST.AsFloat;
vCredItem:=0;
end;
csosn500:
begin
vBCSTRET := 0;
vICMSSTRET := 0;
vCredItem:=0;
end;
csosn900:
begin
modBC := dbiMargemValorAgregado;
pRedBC := DM2.qrNf02pRedBCST.AsFloat;
vBC := DM2.qrNf02BaseICMS.AsFloat;
pICMS := DM2.qrNf02ICMS.AsFloat;
vICMS := DM2.qrNf02ValorICMS.AsFloat;
modBCST := dbisMargemValorAgregado;
pMVAST := DM2.qrNf02pMVAST.AsFloat;
pRedBCST := DM2.qrNf02pRedBCST.AsFloat;
vBCST := DM2.qrNf02vBCST.AsFloat;
pICMSST := DM2.qrNf02pICMSST.AsFloat;
vICMSST := DM2.qrNf02vICMSST.AsFloat;
pCredSN := AlqIcmsDAS;
vCredICMSSN := vCredItem;
end;
end;
vTotCred:=vTotCred+vCredItem;
end else begin // Regime Normal
CST := aCST ;
//modBC := dbiPrecoTabelado;
if txt='20' then
pRedBC := DM2.qrNf02Reducao.AsFloat;
if (txt='40') or (txt='41') then begin
vBC := 0;
pICMS := 0;
vICMS := 0;
end else begin
vBC := DM2.qrNf02BaseICMS.AsFloat;
pICMS := DM2.qrNf02ICMS.AsFloat;
vICMS := DM2.qrNf02ValorICMS.AsFloat;
end;
end;
end;
end;
if DM2.qrNf02IPI.AsFloat>0 then begin
with Imposto do begin
with IPI do begin
CST := ipi49;
IPI.pIPI:= DM2.qrNf02IPI.AsFloat;
IPI.vIPI:= DM2.qrNf02ValorIPI.AsFloat;;
IPI.vBC := DM2.qrNf02Quantidade.Value * DM2.qrNf02PrecoUni.Value;
end;
end;
end;
with Imposto do begin
with PIS do begin
CST := pis99;
PIS.qBCProd := 0;
PIS.vAliqProd := 0;
PIS.vPIS := 0;
end;
end;
with Imposto do begin
with COFINS do begin
CST := cof99;
COFINS.qBCProd := 0;
COFINS.vAliqProd := 0;
COFINS.vCOFINS := 0;
end;
end;
O XML gerado está assim:
-
-
P0425
OE CEDRO 10ML
33012912
5102
FR
1.0000
7.2100000000
7.21
FR
1.0000
7.2100000000
1
-
-
-
0
101
2.58
0.19
-
-
99
0.00
0.00
0.00
-
-
99
0.00
0.00
0.00
-
-
S-001
PRESTACAO DE SERVICOS
99
5933
SV
1.0000
100.0000000000
100.00
SV
1.0000
100.0000000000
0
-
-
-
0
0
-
-
01
0.00
0.00
0.00
-
-
01
0.00
0.00
0.00
-
-
0.00
0.00
0.00
0.00
7.21
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
107.21
-
100.00
100.00
2.00
Como podem ver, o item 001 está correto, mas o 002 (Serviço) não contém a tag ISSQN.
No manual de integração, página 128 temos:
"O grupo ISSQN é mutuamente exclusivo com os grupos ICMS, IPI e II, isto é se ISSQN for informado os grupos ICMS, IPI e
II não serão informados e viceversa (v2.0)."
Estou fazendo algo errado na forma de passar os valores ? (Antes da versão 2.0 usava desta forma e funcionava corretamente)
Se você leu até aqui, sou muito grato !
Edson