Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | /** |
| 2 | * |
||
| 3 | */ |
||
| 4 | package nfe; |
||
| 5 | |||
| 6 | import javax.xml.bind.JAXBException; |
||
| 7 | |||
| 8 | import br.inf.portalfiscal.nfe.schema.envEventoCancNFe.TEnvEvento; |
||
| 9 | import br.inf.portalfiscal.nfe.schema.envEventoCancNFe.TRetEnvEvento; |
||
| 10 | import br.inf.portalfiscal.nfe.schema.retConsCad.TRetConsCad; |
||
| 11 | import br.inf.portalfiscal.nfe.schema.retdistdfeint.RetDistDFeInt; |
||
| 12 | import br.inf.portalfiscal.nfe.schema_4.enviNFe.TEnviNFe; |
||
| 13 | import br.inf.portalfiscal.nfe.schema_4.enviNFe.TRetEnviNFe; |
||
| 14 | import br.inf.portalfiscal.nfe.schema_4.inutNFe.TInutNFe; |
||
| 15 | import br.inf.portalfiscal.nfe.schema_4.inutNFe.TRetInutNFe; |
||
| 16 | import br.inf.portalfiscal.nfe.schema_4.retConsReciNFe.TRetConsReciNFe; |
||
| 17 | import br.inf.portalfiscal.nfe.schema_4.retConsSitNFe.TRetConsSitNFe; |
||
| 18 | import br.inf.portalfiscal.nfe.schema_4.retConsStatServ.TRetConsStatServ; |
||
| 19 | import nfe.dom.Enum.TipoManifestacao; |
||
| 20 | import nfe.exception.NfeException; |
||
| 21 | import nfe.util.XmlUtil; |
||
| 22 | |||
| 23 | |||
| 24 | /** |
||
| 25 | * @author Samuel Oliveira - samuk.exe@hotmail.com - www.samuelweb.com.br |
||
| 26 | */ |
||
| 27 | public class Nfe { |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Construtor privado |
||
| 31 | */ |
||
| 32 | private Nfe() { |
||
| 33 | } |
||
| 34 | |||
| 35 | |||
| 36 | /** |
||
| 37 | * Classe Reponsavel Por Consultar a Distribuiçao da NFE na SEFAZ |
||
| 38 | * |
||
| 39 | * @param tipoCliente Informar DistribuicaoDFe.CPF ou DistribuicaoDFe.CNPJ |
||
| 40 | * @param cpfCnpj |
||
| 41 | * @param tipoConsulta Informar DistribuicaoDFe.NSU ou DistribuicaoDFe.CHAVE |
||
| 42 | * @param nsuChave |
||
| 43 | * @return |
||
| 44 | * @throws NfeException |
||
| 45 | */ |
||
| 46 | public static RetDistDFeInt distribuicaoDfe(String tipoCliente, String cpfCnpj, String tipoConsulta, String nsuChave) throws NfeException { |
||
| 47 | |||
| 48 | return DistribuicaoDFe.consultaNfe(tipoCliente, cpfCnpj, tipoConsulta, nsuChave); |
||
| 49 | |||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Metodo Responsavel Buscar o Status de Serviço do Servidor da Sefaz |
||
| 54 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 55 | * |
||
| 56 | * @param tipo |
||
| 57 | * @return |
||
| 58 | * @throws NfeException |
||
| 59 | */ |
||
| 60 | public static TRetConsStatServ statusServico(String tipo) throws NfeException { |
||
| 61 | |||
| 62 | return Status.statusServico(tipo); |
||
| 63 | |||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Classe Reponsavel Por Consultar o status da NFE na SEFAZ |
||
| 68 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 69 | * |
||
| 70 | * @param chave |
||
| 71 | * @param tipo |
||
| 72 | * @return TRetConsSitNFe |
||
| 73 | * @throws NfeException |
||
| 74 | */ |
||
| 75 | public static TRetConsSitNFe consultaXml(String chave, String tipo) throws NfeException { |
||
| 76 | |||
| 77 | return ConsultaXml.consultaXml(chave, tipo); |
||
| 78 | |||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Classe Reponsavel Por Consultar o cadastro do Cnpj/CPF na SEFAZ |
||
| 83 | * |
||
| 84 | * @param tipo Usar ConsultaCadastro.CNPJ ou ConsultaCadastro.CPF |
||
| 85 | * @param cnpjCpf |
||
| 86 | * @return TRetConsCad |
||
| 87 | * @throws NfeException |
||
| 88 | */ |
||
| 89 | public static TRetConsCad consultaCadastro(String tipo, String cnpjCpf) throws NfeException { |
||
| 90 | |||
| 91 | return ConsultaCadastro.consultaCadastro(tipo, cnpjCpf); |
||
| 92 | |||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Classe Reponsavel Por Consultar o retorno da NFE na SEFAZ |
||
| 97 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 98 | * |
||
| 99 | * @param recibo |
||
| 100 | * @param tipo |
||
| 101 | * @return |
||
| 102 | * @throws NfeException |
||
| 103 | */ |
||
| 104 | public static TRetConsReciNFe consultaRecibo(String recibo, String tipo) throws NfeException { |
||
| 105 | |||
| 106 | return ConsultaRecibo.reciboNfe(recibo, tipo); |
||
| 107 | |||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Classe Reponsavel Por Inutilizar a NFE na SEFAZ |
||
| 112 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 113 | * Id = Código da UF + Ano (2 posições) + CNPJ |
||
| 114 | * + modelo + série + número inicial e número final |
||
| 115 | * precedida do literal “ID” |
||
| 116 | * |
||
| 117 | * @param id |
||
| 118 | * @param valida |
||
| 119 | * @param tipo |
||
| 120 | * @return |
||
| 121 | * @throws NfeException |
||
| 122 | */ |
||
| 123 | public static TRetInutNFe inutilizacao(String id, String motivo, String tipo) throws NfeException{ |
||
| 124 | |||
| 125 | return Inutilizar.inutiliza(id , motivo, tipo); |
||
| 126 | |||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Classe Reponsavel Por criar o Objeto de Inutilização |
||
| 131 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 132 | * Id = Código da UF + Ano (2 posições) + CNPJ |
||
| 133 | * + modelo + série + número inicial e número final |
||
| 134 | * precedida do literal “ID” |
||
| 135 | * |
||
| 136 | * @param id |
||
| 137 | * @param valida |
||
| 138 | * @param tipo |
||
| 139 | * @return |
||
| 140 | * @throws NfeException |
||
| 141 | */ |
||
| 142 | public static TInutNFe criaObjetoInutilizacao(String id, String motivo, String tipo) throws NfeException, JAXBException { |
||
| 143 | |||
| 144 | TInutNFe inutNFe = Inutilizar.criaObjetoInutiliza(id , motivo, tipo); |
||
| 145 | |||
| 146 | String xml = XmlUtil.objectToXml(inutNFe); |
||
| 147 | xml = xml.replaceAll(" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\"", ""); |
||
| 148 | |||
| 149 | return XmlUtil.xmlToObject(Assinar.assinaNfe(xml, Assinar.INFINUT), TInutNFe.class ); |
||
| 150 | |||
| 151 | } |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Metodo para Montar a NFE. |
||
| 155 | * |
||
| 156 | * @param enviNFe |
||
| 157 | * @param valida |
||
| 158 | * @return |
||
| 159 | * @throws NfeException |
||
| 160 | */ |
||
| 161 | public static TEnviNFe montaNfe(TEnviNFe enviNFe, boolean valida) throws NfeException { |
||
| 162 | |||
| 163 | return Enviar.montaNfe(enviNFe, valida); |
||
| 164 | |||
| 165 | } |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Metodo para Enviar a NFE. |
||
| 169 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 170 | * |
||
| 171 | * @param enviNFe |
||
| 172 | * @param tipo |
||
| 173 | * @return |
||
| 174 | * @throws NfeException |
||
| 175 | */ |
||
| 176 | public static TRetEnviNFe enviarNfe(TEnviNFe enviNFe, String tipo) throws NfeException { |
||
| 177 | |||
| 178 | return Enviar.enviaNfe(enviNFe, tipo); |
||
| 179 | |||
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * * Metodo para Cancelar a NFE. |
||
| 184 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 185 | * |
||
| 186 | * @param envEvento |
||
| 187 | * @return |
||
| 188 | * @throws NfeException |
||
| 189 | */ |
||
| 190 | public static TRetEnvEvento cancelarNfe(TEnvEvento envEvento, boolean valida, String tipo) throws NfeException { |
||
| 191 | |||
| 192 | return Cancelar.eventoCancelamento(envEvento, valida, tipo); |
||
| 193 | |||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * * Metodo para Envio da Carta De Correção da NFE. |
||
| 198 | * No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE |
||
| 199 | * |
||
| 200 | * @param evento |
||
| 201 | * @param valida |
||
| 202 | * @param tipo |
||
| 203 | * @return |
||
| 204 | * @throws NfeException |
||
| 205 | */ |
||
| 206 | public static br.inf.portalfiscal.nfe.schema.envcce.TRetEnvEvento cce(br.inf.portalfiscal.nfe.schema.envcce.TEnvEvento evento, boolean valida, String tipo) throws NfeException { |
||
| 207 | |||
| 208 | return CartaCorrecao.eventoCCe(evento, valida, tipo); |
||
| 209 | |||
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Metodo para Manifestação da NFE. |
||
| 214 | * |
||
| 215 | * @param envEvento |
||
| 216 | * @param valida |
||
| 217 | * @return |
||
| 218 | * @throws NfeException |
||
| 219 | */ |
||
| 220 | public static br.inf.portalfiscal.nfe.schema.envConfRecebto.TRetEnvEvento manifestacao(String chave, TipoManifestacao manifestacao, String cnpj, String motivo, String data) throws NfeException { |
||
| 221 | |||
| 222 | return ManifestacaoDestinatario.eventoManifestacao(chave, manifestacao, cnpj, data, motivo); |
||
| 223 | |||
| 224 | } |
||
| 225 | |||
| 226 | |||
| 227 | } |