Skip to content

Commit 4b5b8a9

Browse files
authored
Merge pull request #9 from asaasdev/BASE-2453-Atualizar-java_nfe-para-a-versão-v4.00.18---13/05/2022---Schemas-PL.009i
Base 2453 atualizar java nfe para a versão v4.00.18 13/05/2022 schemas pl.009i
2 parents 45e82c5 + 12573e0 commit 4b5b8a9

File tree

13 files changed

+969
-27
lines changed

13 files changed

+969
-27
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/target/
1+
/target/

.settings/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/org.eclipse.core.resources.prefs
2+
/org.eclipse.jdt.core.prefs

java-nfe-4.00.12.jar

17.4 MB
Binary file not shown.

mavensettings.xml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<!-- <?xml version="1.0" encoding="UTF-8"?>-->
2+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information
3+
regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4+
License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under
5+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing
6+
permissions and limitations under the License. -->
7+
8+
<!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and
9+
is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level.
10+
This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml.
11+
| | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start
12+
at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | | -->
13+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
14+
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> -->
15+
<localRepository>/home/hugo/desenvolvimento/repo-spring</localRepository>
16+
<!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some
17+
other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> -->
18+
19+
<!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment,
20+
and others. | | Default: false <offline>false</offline> -->
21+
22+
<!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn
23+
prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. | -->
24+
<pluginGroups>
25+
<!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> -->
26+
</pluginGroups>
27+
28+
<!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch),
29+
the first proxy | specification in this list marked as active will be used. | -->
30+
<proxies>
31+
<!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username>
32+
<password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> -->
33+
</proxies>
34+
35+
<!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection
36+
to a remote server. | -->
37+
<servers>
38+
<server>
39+
<!-- usuário para download de artefatos -->
40+
<id>down.nexus.baseerp.com.br</id>
41+
<username>admin</username>
42+
<password>@Base@2018</password>
43+
</server>
44+
<server>
45+
<!-- usuário para upload de artefatos -->
46+
<id>up.nexus.baseerp.com.br</id>
47+
<username>admin</username>
48+
<password>@Base@2018</password>
49+
</server>
50+
51+
<!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id'
52+
attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id>
53+
<username>repouser</username> <password>repopwd</password> </server> -->
54+
55+
<!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase>
56+
</server> -->
57+
</servers>
58+
59+
<!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving
60+
certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will
61+
have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that
62+
repository. | -->
63+
<mirrors>
64+
<!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element
65+
of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf>
66+
<name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> -->
67+
<mirror>
68+
<id>down.nexus.baseerp.com.br</id>
69+
<mirrorOf>*</mirrorOf>
70+
<url>https://nexuskube.baseerp.com.br/repository/maven-public/</url>
71+
</mirror>
72+
<mirror>
73+
<id>up.nexus.baseerp.com.br</id>
74+
<mirrorOf>*</mirrorOf>
75+
<url>https://nexuskube.baseerp.com.br/</url>
76+
</mirror>
77+
</mirrors>
78+
79+
<!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are
80+
intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration
81+
testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during
82+
the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document
83+
(settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely
84+
testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of
85+
'1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to
86+
specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | | -->
87+
<profiles>
88+
<!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and
89+
to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is
90+
to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive
91+
to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses
92+
the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id>
93+
<name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories>
94+
</profile> -->
95+
96+
<!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this,
97+
your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration>
98+
| <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env'
99+
to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value>
100+
</property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> -->
101+
102+
<profile>
103+
<id>nexus</id>
104+
<!--Enable snapshots for the built in central repo to direct -->
105+
<!--all requests to nexus via the mirror -->
106+
<repositories>
107+
<repository>
108+
<id>central</id>
109+
<url>http://central</url>
110+
<releases>
111+
<enabled>true</enabled>
112+
</releases>
113+
<snapshots>
114+
<enabled>true</enabled>
115+
</snapshots>
116+
</repository>
117+
</repositories>
118+
<pluginRepositories>
119+
<pluginRepository>
120+
<id>central</id>
121+
<url>http://central</url>
122+
<releases>
123+
<enabled>true</enabled>
124+
</releases>
125+
<snapshots>
126+
<enabled>true</enabled>
127+
</snapshots>
128+
</pluginRepository>
129+
</pluginRepositories>
130+
</profile>
131+
<profile>
132+
<id>down.nexus.baseerp.com.br</id>
133+
<repositories>
134+
<repository>
135+
<id>down.nexus.baseerp.com.br</id>
136+
<url>https://nexuskube.baseerp.com.br</url>
137+
<releases>
138+
<enabled>true</enabled>
139+
</releases>
140+
<snapshots>
141+
<enabled>true</enabled>
142+
</snapshots>
143+
</repository>
144+
</repositories>
145+
</profile>
146+
<profile>
147+
<id>up.nexus.baseerp.com.br</id>
148+
<repositories>
149+
<repository>
150+
<id>up.nexus.baseerp.com.br</id>
151+
<url>https://nexuskube.baseerp.com.br</url>
152+
<releases>
153+
<enabled>true</enabled>
154+
</releases>
155+
<snapshots>
156+
<enabled>true</enabled>
157+
</snapshots>
158+
</repository>
159+
</repositories>
160+
</profile>
161+
162+
</profiles>
163+
164+
<activeProfiles>
165+
<!--make the profile active all the time -->
166+
<activeProfile>down.nexus.baseerp.com.br</activeProfile>
167+
</activeProfiles>
168+
169+
<!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile>
170+
</activeProfiles> -->
171+
172+
</settings>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package br.com.swconsultoria.nfe;
2+
3+
import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
4+
import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum;
5+
import br.com.swconsultoria.nfe.dom.enuns.ServicosEnum;
6+
import br.com.swconsultoria.nfe.exception.NfeException;
7+
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento;
8+
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento;
9+
import br.com.swconsultoria.nfe.util.XmlNfeUtil;
10+
11+
import javax.xml.bind.JAXBException;
12+
13+
14+
15+
public class CancelarA3 {
16+
/**
17+
* Metodo para Cancelar a NFE. com certificado A3 No tipo Informar ConstantesUtil.NFE ou ConstantesUtil.NFCE
18+
*
19+
* @author Hugo
20+
* @since 26/06/2018 -- NFE 4.0
21+
*
22+
* @param envEvento
23+
* @return
24+
* @throws NfeException
25+
*/
26+
static TRetEnvEvento eventoCancelamento(ConfiguracoesNfe config, boolean valida, DocumentoEnum tipoDocumento, String xmlAssinado)
27+
throws NfeException {
28+
29+
try {
30+
String xmlRetorno = EventosA3.enviarEvento(config, xmlAssinado, ServicosEnum.CANCELAMENTO, valida, tipoDocumento);
31+
return XmlNfeUtil.xmlToObject(xmlRetorno, TRetEnvEvento.class);
32+
33+
} catch (JAXBException e) {
34+
throw new NfeException(e.getMessage());
35+
}
36+
37+
}
38+
39+
/**
40+
* Metodo retorno o XML de cancelamento sem assinatura
41+
*
42+
* @author Hugo
43+
* @since 26/06/2018 -- NFE 4.0
44+
*
45+
* @param envEvento
46+
* @return
47+
* @throws NfeException
48+
*/
49+
static String montaXmleventoCancelamento(TEnvEvento enviEvento)
50+
throws NfeException {
51+
52+
try {
53+
String xml = XmlNfeUtil.objectToXml(enviEvento);
54+
xml = xml.replaceAll(" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\"", "");
55+
xml = xml.replaceAll("<evento v", "<evento xmlns=\"http://www.portalfiscal.inf.br/nfe\" v");
56+
return xml;
57+
} catch (JAXBException e) {
58+
throw new NfeException(e.getMessage());
59+
}
60+
61+
}
62+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package br.com.swconsultoria.nfe;
2+
3+
import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
4+
import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum;
5+
import br.com.swconsultoria.nfe.dom.enuns.ServicosEnum;
6+
import br.com.swconsultoria.nfe.exception.NfeException;
7+
import br.com.swconsultoria.nfe.schema.envcce.TEnvEvento;
8+
import br.com.swconsultoria.nfe.schema.envcce.TRetEnvEvento;
9+
import br.com.swconsultoria.nfe.util.XmlNfeUtil;
10+
11+
import javax.xml.bind.JAXBException;
12+
public class CartaCorrecaoA3 {
13+
14+
15+
16+
/**
17+
* Envia a carta de correção com certificado A3
18+
*
19+
* @author Hugo
20+
* @since 04/08/2018 -- NFE 4.0
21+
*
22+
* @param config
23+
* @param valida
24+
* @param tipo
25+
* @param xmlAssinado
26+
* @return
27+
* @throws NfeException
28+
*/
29+
static TRetEnvEvento eventoCCe(ConfiguracoesNfe config, boolean valida, String xmlAssinado)
30+
throws NfeException {
31+
try {
32+
String xmlRetorno = EventosA3.enviarEvento(config, xmlAssinado, ServicosEnum.CCE, valida, DocumentoEnum.NFE);
33+
return XmlNfeUtil.xmlToObject(xmlRetorno, TRetEnvEvento.class);
34+
35+
} catch (JAXBException e) {
36+
throw new NfeException(e.getMessage());
37+
}
38+
39+
}
40+
41+
/**
42+
* Metodo retorna o XML da carta de correção sem assinatura
43+
*
44+
* @author Hugo
45+
* @since 04/08/2018 -- NFE 4.0
46+
*
47+
* @param envEvento
48+
* @return
49+
* @throws NfeException
50+
*/
51+
static String montaXmlCartaCorrecao(TEnvEvento enviEvento)
52+
throws NfeException {
53+
54+
try {
55+
String xml = XmlNfeUtil.objectToXml(enviEvento);
56+
xml = xml.replaceAll(" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\"", "");
57+
xml = xml.replaceAll("<evento v", "<evento xmlns=\"http://www.portalfiscal.inf.br/nfe\" v");
58+
return xml;
59+
} catch (JAXBException e) {
60+
throw new NfeException(e.getMessage());
61+
}
62+
63+
}
64+
}

0 commit comments

Comments
 (0)