public Det() { Prod = new Prod(); Imposto = new Imposto(); impostoDevol = new impostoDevol(); }
/// <summary> /// GerarDetImpostoISSQN /// </summary> /// <param name="nfe"></param> /// <param name="imposto"></param> /// <param name="nodeImposto"></param> private void GerarDetImpostoISSQN(NFe nfe, Imposto imposto, XmlElement nodeImposto) { if ((imposto.ISSQN.vBC > 0) || (imposto.ISSQN.vAliq > 0) || (imposto.ISSQN.vISSQN > 0) || (imposto.ISSQN.cMunFG > 0) || (!string.IsNullOrEmpty(imposto.ISSQN.cListServ))) { nodeCurrent = doc.CreateElement("ISSQN"); nodeImposto.AppendChild(nodeCurrent); wCampo(imposto.ISSQN.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ISSQN.vAliq, nDecimaisPerc, TpcnResources.vAliq); wCampo(imposto.ISSQN.vISSQN, TpcnTipoCampo.tcDec2, TpcnResources.vISSQN); wCampo(imposto.ISSQN.cMunFG, TpcnTipoCampo.tcInt, TpcnResources.cMunFG, ObOp.Obrigatorio, 7); wCampo(imposto.ISSQN.cListServ, TpcnTipoCampo.tcStr, TpcnResources.cListServ); if ((double)nfe.infNFe.Versao >= 3.10) { wCampo(imposto.ISSQN.vDeducao, TpcnTipoCampo.tcDec2, TpcnResources.vDeducao, ObOp.Opcional); wCampo(imposto.ISSQN.vOutro, TpcnTipoCampo.tcDec2, TpcnResources.vOutro, ObOp.Opcional); wCampo(imposto.ISSQN.vDescIncond, TpcnTipoCampo.tcDec2, TpcnResources.vDescIncond, ObOp.Opcional); wCampo(imposto.ISSQN.vDescCond, TpcnTipoCampo.tcDec2, TpcnResources.vDescCond, ObOp.Opcional); wCampo(imposto.ISSQN.vISSRet, TpcnTipoCampo.tcDec2, TpcnResources.vISSRet, ObOp.Opcional); wCampo((int)imposto.ISSQN.indISS, TpcnTipoCampo.tcInt, TpcnResources.indISS); wCampo(imposto.ISSQN.cServico, TpcnTipoCampo.tcStr, TpcnResources.cServico, ObOp.Opcional); wCampo(imposto.ISSQN.cMun, TpcnTipoCampo.tcInt, TpcnResources.cMun, ObOp.Opcional); wCampo(imposto.ISSQN.cPais, TpcnTipoCampo.tcInt, TpcnResources.cPais, ObOp.Opcional); wCampo(imposto.ISSQN.nProcesso, TpcnTipoCampo.tcStr, TpcnResources.nProcesso, ObOp.Opcional); wCampo(imposto.ISSQN.indIncentivo ? 1 : 2, TpcnTipoCampo.tcInt, TpcnResources.indIncentivo, ObOp.Opcional); } else { wCampo(imposto.ISSQN.cSitTrib, TpcnTipoCampo.tcStr, TpcnResources.cSitTrib); } } }
/// <summary> /// GerarDetImpostoICMS /// </summary> /// <param name="nfe"></param> /// <param name="imposto"></param> /// <param name="nodeImposto"></param> private void GerarDetImpostoICMS(NFe nfe, Imposto imposto, XmlElement nodeImposto) { if (!string.IsNullOrEmpty(imposto.ICMS.CST)) { if (imposto.ICMS.ICMSst == 1) { XmlElement e0 = doc.CreateElement(TpcnResources.ICMS.ToString()); nodeCurrent = doc.CreateElement("ICMSST"); e0.AppendChild(nodeCurrent); nodeImposto.AppendChild(e0); wCampo(imposto.ICMS.orig, TpcnTipoCampo.tcInt, TpcnResources.orig); wCampo(imposto.ICMS.CST, TpcnTipoCampo.tcStr, TpcnResources.CST); wCampo(imposto.ICMS.vBCSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vBCSTRet); wCampo(imposto.ICMS.vICMSSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vICMSSTRet); wCampo(imposto.ICMS.vBCSTDest, TpcnTipoCampo.tcDec2, TpcnResources.vBCSTDest); wCampo(imposto.ICMS.vICMSSTDest, TpcnTipoCampo.tcDec2, TpcnResources.vICMSSTDest); } else { XmlElement e0 = doc.CreateElement(TpcnResources.ICMS.ToString()); if (imposto.ICMS.ICMSPart10 == 1 || imposto.ICMS.ICMSPart90 == 1) nodeCurrent = doc.CreateElement("ICMSPart"); else nodeCurrent = doc.CreateElement(TpcnResources.ICMS.ToString() + (imposto.ICMS.CST == "41" || imposto.ICMS.CST == "50" ? "40" : imposto.ICMS.CST)); e0.AppendChild(nodeCurrent); nodeImposto.AppendChild(e0); wCampo(imposto.ICMS.orig, TpcnTipoCampo.tcInt, TpcnResources.orig); wCampo(imposto.ICMS.CST, TpcnTipoCampo.tcStr, TpcnResources.CST); switch (imposto.ICMS.CST) { case "00": wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); break; case "10": wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); if (imposto.ICMS.ICMSPart10 == 1) wCampo(imposto.ICMS.pRedBC, TpcnTipoCampo.tcDec2, TpcnResources.pRedBC, ObOp.Opcional); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); if (imposto.ICMS.ICMSPart10 == 1) { wCampo(imposto.ICMS.pBCOp, this.nDecimaisPerc, TpcnResources.pBCOp); wCampo(imposto.ICMS.UFST, TpcnTipoCampo.tcStr, TpcnResources.UFST); } break; case "20": wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); wCampo(imposto.ICMS.pRedBC, this.nDecimaisPerc, TpcnResources.pRedBC); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); if ((double)nfe.infNFe.Versao >= 3.10 && imposto.ICMS.vICMSDeson > 0) { wCampo(imposto.ICMS.vICMSDeson, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDeson); wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS); } break; case "30": wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); if ((double)nfe.infNFe.Versao >= 3.10 && imposto.ICMS.vICMSDeson > 0) { wCampo(imposto.ICMS.vICMSDeson, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDeson); wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS); } break; case "40": case "41": case "50": if ((double)nfe.infNFe.Versao >= 3.10) { if (imposto.ICMS.vICMSDeson > 0) { wCampo(imposto.ICMS.vICMSDeson, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDeson); wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS); } } else { wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS, ObOp.Opcional); if (imposto.ICMS.vICMS > 0) wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS, ObOp.Opcional); } break; case "51": //Esse bloco fica a critério de cada UF a obrigação das informações, conforme o manual { var obop = ObOp.Opcional; if ((double)nfe.infNFe.Versao >= 3.10) { if (imposto.ICMS.pRedBC > 0 || imposto.ICMS.vBC > 0 || imposto.ICMS.vICMSOp > 0 || imposto.ICMS.pDif > 0 || imposto.ICMS.vICMSDif > 0 || imposto.ICMS.vICMS > 0) obop = ObOp.Obrigatorio; } wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC, ObOp.Opcional); wCampo(imposto.ICMS.pRedBC, this.nDecimaisPerc, TpcnResources.pRedBC, obop); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC, obop); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS, obop); if ((double)nfe.infNFe.Versao >= 3.10) { wCampo(imposto.ICMS.vICMSOp, TpcnTipoCampo.tcDec2, TpcnResources.vICMSOp, obop); wCampo(imposto.ICMS.pDif, this.nDecimaisPerc, TpcnResources.pDif, obop); wCampo(imposto.ICMS.vICMSDif, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDif, obop); } wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS, obop); } break; case "60": if ((double)nfe.infNFe.Versao >= 2.0) { if (imposto.ICMS.vBCSTRet > 0 || imposto.ICMS.vICMSSTRet > 0) { wCampo(imposto.ICMS.vBCSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vBCSTRet); wCampo(imposto.ICMS.vICMSSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vICMSSTRet); } } else { wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); } break; case "70": wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); wCampo(imposto.ICMS.pRedBC, this.nDecimaisPerc, TpcnResources.pRedBC); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); if ((double)nfe.infNFe.Versao >= 3.10 && imposto.ICMS.vICMSDeson > 0) { wCampo(imposto.ICMS.vICMSDeson, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDeson); wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS); } break; case "90": wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); if (imposto.ICMS.ICMSPart90 == 1) wCampo(imposto.ICMS.pRedBC, this.nDecimaisPerc, TpcnResources.pRedBC, ObOp.Opcional); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); if (imposto.ICMS.vBCST > 0 || imposto.ICMS.vICMSST > 0) { wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); } if (imposto.ICMS.ICMSPart90 == 1) { wCampo(imposto.ICMS.pBCOp, this.nDecimaisPerc, TpcnResources.pBCOp); wCampo(imposto.ICMS.UFST, TpcnTipoCampo.tcStr, TpcnResources.UFST); } else if ((double)nfe.infNFe.Versao >= 3.10 && imposto.ICMS.vICMSDeson > 0) { wCampo(imposto.ICMS.vICMSDeson, TpcnTipoCampo.tcDec2, TpcnResources.vICMSDeson); wCampo(imposto.ICMS.motDesICMS, TpcnTipoCampo.tcInt, TpcnResources.motDesICMS); } break; } if (imposto.ICMS.ICMSPart10 == 1 || imposto.ICMS.ICMSPart90 == 1 && (double)nfe.infNFe.Versao >= 3.10) { if (imposto.ICMS.ICMSUFDest.vBCUFDest > 0 || imposto.ICMS.ICMSUFDest.pICMSUFDest > 0 || imposto.ICMS.ICMSUFDest.pICMSInter > 0 || imposto.ICMS.ICMSUFDest.pICMSInterPart > 0 || imposto.ICMS.ICMSUFDest.vICMSUFDest > 0 || imposto.ICMS.ICMSUFDest.vICMSUFRemet > 0) { var x_nodeCurrent = nodeCurrent; XmlElement ee0 = doc.CreateElement(TpcnResources.ICMSUFDest.ToString()); nodeCurrent.AppendChild(ee0); wCampo(imposto.ICMS.ICMSUFDest.vBCUFDest, TpcnTipoCampo.tcDec2, TpcnResources.vBCUFDest); wCampo(imposto.ICMS.ICMSUFDest.pICMSUFDest, TpcnTipoCampo.tcDec4, TpcnResources.pICMSUFDest); wCampo(imposto.ICMS.ICMSUFDest.pICMSInter, TpcnTipoCampo.tcDec4, TpcnResources.pICMSInter); wCampo(imposto.ICMS.ICMSUFDest.pICMSInterPart, TpcnTipoCampo.tcDec4, TpcnResources.pICMSInterPart); wCampo(imposto.ICMS.ICMSUFDest.vICMSUFDest, TpcnTipoCampo.tcDec2, TpcnResources.vICMSUFDest); wCampo(imposto.ICMS.ICMSUFDest.vICMSUFRemet, TpcnTipoCampo.tcDec2, TpcnResources.vICMSUFRemet); nodeCurrent = x_nodeCurrent; } } } } if (imposto.ICMS.CSOSN > 100) { XmlElement e0 = doc.CreateElement(TpcnResources.ICMS.ToString()); switch (imposto.ICMS.CSOSN) { case 101: nodeCurrent = doc.CreateElement("ICMSSN101"); break; case 102: case 103: case 300: case 400: nodeCurrent = doc.CreateElement("ICMSSN102"); break; case 201: nodeCurrent = doc.CreateElement("ICMSSN201"); break; case 202: case 203: nodeCurrent = doc.CreateElement("ICMSSN202"); break; case 500: nodeCurrent = doc.CreateElement("ICMSSN500"); break; case 900: nodeCurrent = doc.CreateElement("ICMSSN900"); break; } e0.AppendChild(nodeCurrent); nodeImposto.AppendChild(e0); wCampo(imposto.ICMS.orig, TpcnTipoCampo.tcInt, TpcnResources.orig); wCampo(imposto.ICMS.CSOSN, TpcnTipoCampo.tcInt, TpcnResources.CSOSN); switch (imposto.ICMS.CSOSN) { case 101: wCampo(imposto.ICMS.pCredSN, TpcnTipoCampo.tcDec2, TpcnResources.pCredSN); wCampo(imposto.ICMS.vCredICMSSN, TpcnTipoCampo.tcDec2, TpcnResources.vCredICMSSN); break; case 201: wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); wCampo(imposto.ICMS.pCredSN, this.nDecimaisPerc, TpcnResources.pCredSN); wCampo(imposto.ICMS.vCredICMSSN, TpcnTipoCampo.tcDec2, TpcnResources.vCredICMSSN); break; case 202: case 203: wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); break; case 500: //wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST, false); wCampo(imposto.ICMS.vBCSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vBCSTRet); wCampo(imposto.ICMS.vICMSSTRet, TpcnTipoCampo.tcDec2, TpcnResources.vICMSSTRet); break; case 900: wCampo(imposto.ICMS.modBC, TpcnTipoCampo.tcInt, TpcnResources.modBC); wCampo(imposto.ICMS.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC); wCampo(imposto.ICMS.pRedBC, this.nDecimaisPerc, TpcnResources.pRedBC, ObOp.Opcional); wCampo(imposto.ICMS.pICMS, this.nDecimaisPerc, TpcnResources.pICMS); wCampo(imposto.ICMS.vICMS, TpcnTipoCampo.tcDec2, TpcnResources.vICMS); wCampo(imposto.ICMS.modBCST, TpcnTipoCampo.tcInt, TpcnResources.modBCST); wCampo(imposto.ICMS.pMVAST, this.nDecimaisPerc, TpcnResources.pMVAST, ObOp.Opcional); wCampo(imposto.ICMS.pRedBCST, this.nDecimaisPerc, TpcnResources.pRedBCST, ObOp.Opcional); wCampo(imposto.ICMS.vBCST, TpcnTipoCampo.tcDec2, TpcnResources.vBCST); wCampo(imposto.ICMS.pICMSST, this.nDecimaisPerc, TpcnResources.pICMSST); wCampo(imposto.ICMS.vICMSST, TpcnTipoCampo.tcDec2, TpcnResources.vICMSST); wCampo(imposto.ICMS.pCredSN, this.nDecimaisPerc, TpcnResources.pCredSN); wCampo(imposto.ICMS.vCredICMSSN, TpcnTipoCampo.tcDec2, TpcnResources.vCredICMSSN); break; } } }
/// <summary> /// GerarDetImposto /// </summary> /// <param name="nfe"></param> /// <param name="imposto"></param> /// <param name="root"></param> private void GerarDetImposto(NFe nfe, Imposto imposto, XmlElement root) { XmlElement nodeImposto = doc.CreateElement("imposto"); root.AppendChild(nodeImposto); nodeCurrent = nodeImposto; wCampo(imposto.vTotTrib, TpcnTipoCampo.tcDec2, TpcnResources.vTotTrib, ObOp.Opcional); if ((double)nfe.infNFe.Versao < 3.10) { if (!string.IsNullOrEmpty(imposto.ISSQN.cSitTrib)) { GerarDetImpostoISSQN(nfe, imposto, nodeImposto); } else { GerarDetImpostoICMS(nfe, imposto, nodeImposto); GerarDetImpostoIPI(nfe, imposto.IPI, nodeImposto); if (nfe.det[0].Prod.DI.Count > 0) GerarDetImpostoII(imposto.II, nodeImposto); } } else { GerarDetImpostoICMS(nfe, imposto, nodeImposto); GerarDetImpostoIPI(nfe, imposto.IPI, nodeImposto); if (nfe.det[0].Prod.DI.Count > 0) GerarDetImpostoII(imposto.II, nodeImposto); GerarDetImpostoISSQN(nfe, imposto, nodeImposto); } GerarDetImpostoPIS(nfe, imposto.PIS, nodeImposto); GerarDetImpostoPISST(nfe, imposto.PISST, nodeImposto); GerarDetImpostoCOFINS(nfe, imposto.COFINS, nodeImposto); GerarDetImpostoCOFINSST(nfe, imposto.COFINSST, nodeImposto); }