Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91d8ea3

Browse files
feat(add documentation): add documentation and tests
1 parent ece0cbe commit 91d8ea3

5 files changed

Lines changed: 74 additions & 2 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,45 @@
44

55
# sunat-web-services
66
Libreria que contiene los web endpoints para conectarse con la SUNAT
7+
8+
## SUNAT Web Services
9+
10+
BETA | URL
11+
--- | ---
12+
**Factura** | https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService
13+
**Guía remisión** | https://e-beta.sunat.gob.pe/ol-ti-itemision-guia-gem-beta/billService
14+
**Retenciones** | https://e-beta.sunat.gob.pe/ol-ti-itemision-otroscpe-gem-beta/billService
15+
16+
PRODUCCIÓN | URL
17+
--- | ---
18+
**Factura** | https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService
19+
**Guía remisión** | https://e-guiaremision.sunat.gob.pe/ol-ti-itemision-guia-gem/billService
20+
**Retenciones** | https://e-factura.sunat.gob.pe/ol-ti-itemision-otroscpe-gem/billService
21+
**Consulta validez** | https://e-factura.sunat.gob.pe/ol-it-wsconsvalidcpe/billValidService
22+
**Consulta CDR** | https://e-factura.sunat.gob.pe/ol-it-wsconscpegem/billConsultService
23+
24+
# Enviar Comprobantes de Pago mediante BillService
25+
Para enviar Boletas, Facturas, Notas de Crédito, Notas de Débito, Guias de Remisión, Percepciones, Retenciones se debe de usar la clase BillServiceSender.
26+
27+
El valor de URL dependerá de qué tipo de documento está intentando enviar.
28+
```
29+
String URL = "https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService";
30+
USERNAME = "12345678959MODDATOS"; // RUC + USUARIO SOL
31+
PASSWORD = "MODDATOS"; // PASSWORD SOL
32+
33+
File file = new File(".../myFolder/12345678959-01-F001-00000001.xml");
34+
byte[] result = BillServiceSender.sendBill(file, URL, USERNAME, PASSWORD);
35+
```
36+
37+
# Enviar Resumenes diarios y Bajas mediante BillService
38+
Para Enviar Resumenes diarios y Bajas se debe de usar la clase BillServiceSender.
39+
40+
```
41+
String URL = "https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService";
42+
USERNAME = "12345678959MODDATOS"; // RUC + USUARIO SOL
43+
PASSWORD = "MODDATOS"; // PASSWORD SOL
44+
45+
File file = new File(".../myFolder/12345678959-RA-20180316-00001.xml");
46+
47+
String ticket = BillServiceSender.sendSummary(file, URL, USERNAME, PASSWORD);
48+
```

src/main/java/io/github/carlosthe19916/webservices/cxf/ws/ServiceFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static <T> T getInstance(Class<T> serviceClass, ServiceConfig config) {
3737
/*
3838
* Logging
3939
*/
40-
factory.getInInterceptors().add(new LoggingInInterceptor());
41-
factory.getOutInterceptors().add(new LoggingOutInterceptor());
40+
// factory.getInInterceptors().add(new LoggingInInterceptor());
41+
// factory.getOutInterceptors().add(new LoggingOutInterceptor());
4242

4343
T client = (T) factory.create();
4444
defineTimeouts(client);

src/test/java/io/github/carlosthe19916/webservices/BillServiceSenderTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,28 @@ public void getStatus() {
7272
Assert.assertNotNull(status);
7373
}
7474

75+
@Test
76+
public void sendInvoiceVoidedDocumentXml() throws IOException {
77+
final String FILE_NAME = "20494637074-RA-20180316-00001.xml";
78+
InputStream is = getClass().getResourceAsStream("/ubl/" + FILE_NAME);
79+
80+
byte[] bytes = new byte[is.available()];
81+
int read = is.read(bytes);
82+
83+
String ticket = BillServiceSender.sendSummary(FILE_NAME, bytes, URL_BOLETA_FACTURA, USERNAME, PASSWORD);
84+
Assert.assertNotNull(ticket);
85+
}
86+
87+
@Test
88+
public void sendRetencionVoidedDocumentXml() throws IOException {
89+
final String FILE_NAME = "20494637074-RR-20180713-00001.xml";
90+
InputStream is = getClass().getResourceAsStream("/ubl/" + FILE_NAME);
91+
92+
byte[] bytes = new byte[is.available()];
93+
int read = is.read(bytes);
94+
95+
String ticket = BillServiceSender.sendSummary(FILE_NAME, bytes, URL_RETENCION, USERNAME, PASSWORD);
96+
Assert.assertNotNull(ticket);
97+
}
98+
7599
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="UTF-8"?><VoidedDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:VoidedDocuments-1" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="SignAHREN" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>WM2qxATGM5JKOQ/25V4JYx00px8=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>NmKnE6sxIEVHJkvvgjULLA2m9cfwdLjNZubnymZ88UwKbcT/FUNzJSUqszR1EdF7vMpadCHJfrFFQm/xsINjxGzEwAwKXJqVFMboUzIlFQ3t7b5reqw599/9UG9YRswmdn6uKaZKPTHnBuEdZnf+yjsw7wceabSCExw4NGar96eLNmu80D6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GHH9eBEc</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><cbc:UBLVersionID>2.0</cbc:UBLVersionID><cbc:CustomizationID>1.0</cbc:CustomizationID><cbc:ID>RA-20180316-00001</cbc:ID><cbc:ReferenceDate>2018-03-16</cbc:ReferenceDate><cbc:IssueDate>2018-03-16</cbc:IssueDate><cbc:Note>fghfgh</cbc:Note><cac:Signature><cbc:ID>IDSignAHREN</cbc:ID><cac:SignatoryParty><cac:PartyIdentification><cbc:ID>20494637074</cbc:ID></cac:PartyIdentification><cac:PartyName><cbc:Name>AHREN CONTRATISTAS GENERALES S.A.C</cbc:Name></cac:PartyName></cac:SignatoryParty><cac:DigitalSignatureAttachment><cac:ExternalReference><cbc:URI>#signatureAHREN</cbc:URI></cac:ExternalReference></cac:DigitalSignatureAttachment></cac:Signature><cac:AccountingSupplierParty><cbc:CustomerAssignedAccountID>20494637074</cbc:CustomerAssignedAccountID><cbc:AdditionalAccountID>6</cbc:AdditionalAccountID><cac:Party><cac:PartyName><cbc:Name>AHREN CONTRATISTAS GENERALES S.A.C</cbc:Name></cac:PartyName><cac:PostalAddress><cbc:ID>050101</cbc:ID><cbc:StreetName>Mza. A Lote. 3 A.v. Santa Teresa</cbc:StreetName><cbc:CitySubdivisionName>Huamanga</cbc:CitySubdivisionName><cbc:CityName>Ayacucho</cbc:CityName><cbc:CountrySubentity>Ayacucho</cbc:CountrySubentity><cac:Country><cbc:IdentificationCode>PE</cbc:IdentificationCode></cac:Country></cac:PostalAddress><cac:PartyLegalEntity><cbc:RegistrationName>AHREN CONTRATISTAS GENERALES S.A.C</cbc:RegistrationName></cac:PartyLegalEntity></cac:Party></cac:AccountingSupplierParty><sac:VoidedDocumentsLine><cbc:LineID>1</cbc:LineID><cbc:DocumentTypeCode>01</cbc:DocumentTypeCode><sac:DocumentSerialID>F001</sac:DocumentSerialID><sac:DocumentNumberID>00000063</sac:DocumentNumberID><sac:VoidReasonDescription>fghf</sac:VoidReasonDescription></sac:VoidedDocumentsLine></VoidedDocuments>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?><VoidedDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:VoidedDocuments-1" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="SignAHREN" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>npoaVaMst6gQyhOTSJixAqNE5bE=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>GTEEkfs53lnvxYuAyNbfDsNgqXDWfh+jISDDOYY7Sj8olgifMARJTbwbWyPnXQ5SJGBNhdLk/s4jTYQ4BOFihJpCARZSNHarZF70y2g8hbz2nlE40K3+d2CfMz7Dus3tGDYHsfes0QSzuFlXo2kENsRnhOI7g4V8qh2QyYagS5ANrlpLibXn9SYuDfn3UzKIK+T05J6WlstlDuPbfG+kQ0JeKKuY3eYHH0BTdbDZOC3rHRf866xsxrVU2xM+FeWzuoJAJT89eWZ2+XaAsgw3T5J51Q1V7HvGcVuUZyYaMwbIAB+9NeDNbDECC1ihHqVoNxwgO35YyVjOvWusr2DKHw==</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIICmTCCAYECBgFcjed4uzANBgkqhkiG9w0BAQsFADAQMQ4wDAYDVQQDDAVhaHJlbjAeFw0xNzA2MDkxNzI3NTZaFw0yNzA2MDkxNzI5MzZaMBAxDjAMBgNVBAMMBWFocmVuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnsgbXAsxriga3PwL/a4S+G8GjEgVyq8w0sRkOQ6Db3ZIz7P3cjOFghA13bMw1UXTz1hS9ApcBYY56uMR2t/sTwwwzobMfSMJauWdoXCAuZbfw1jz+r4ZrHWp02SHCcCuvRmwuJqmxTHq/SExNmpHnSBxEOOctlfRlKujvcJcZyozTilYF7vHkBpEj+3DtMlKQWZPgb8nGKwYqRAawKc09y31ZgIl4awmtof91g/4h4c56y48ttJkpts1zi+d3DqGaBqd8SoCfUPqu53ssm8pX/ufkIewEPim3MBShBZq3QYk4nq7p6W6Jo5wtl/3b7dcQLdo36pBYifY7MbwwBYCnwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAJH+T2EivzD24fmNOhIRWSDObz5w6iJek4dO7vJkaeTypUCcdD6oGQbx/Nyihhq0cWPxYBFI/cXhpemsM9otmy3p0Gcl1YTRQaP5JUxcSvY0Ta48RvidNCCi3FvwM46fYqEUq6xbm5xNc5I8KjWGbnoEyrWnz1T5KkRzAunrdUjb8nq36KZn7/eDVg2DphJoSDI9RH83ig+lJP7K/QUMkXjD+DoQjvopQE59GGSDGhGtvnuoVl3TcIabOzK104v6y0u/nllr63eQYmcD9Efjlt67htEJM8SeC4zRA8fRtogZhXurWtKpxKHN8wNEYDML7rWmYTh7/7tQt3GHH9eBEc</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><cbc:UBLVersionID>2.0</cbc:UBLVersionID><cbc:CustomizationID>1.0</cbc:CustomizationID><cbc:ID>RR-20180713-00001</cbc:ID><cbc:ReferenceDate>2018-06-13</cbc:ReferenceDate><cbc:IssueDate>2018-07-13</cbc:IssueDate><cbc:Note>46</cbc:Note><cac:Signature><cbc:ID>IDSignAHREN</cbc:ID><cac:SignatoryParty><cac:PartyIdentification><cbc:ID>20603233591</cbc:ID></cac:PartyIdentification><cac:PartyName><cbc:Name>GASOLINERA PETROX E.I.R.L. </cbc:Name></cac:PartyName></cac:SignatoryParty><cac:DigitalSignatureAttachment><cac:ExternalReference><cbc:URI>#signatureAHREN</cbc:URI></cac:ExternalReference></cac:DigitalSignatureAttachment></cac:Signature><cac:AccountingSupplierParty><cbc:CustomerAssignedAccountID>20603233591</cbc:CustomerAssignedAccountID><cbc:AdditionalAccountID>6</cbc:AdditionalAccountID><cac:Party><cac:PartyName><cbc:Name>GASOLINERA PETROX E.I.R.L. </cbc:Name></cac:PartyName><cac:PostalAddress><cbc:ID>050101</cbc:ID><cbc:StreetName>CAR.AYACUCHO - HUANTA NRO. S/N RUMICHACA CENTRO JESUS NAZARENO AYACUCHO - HUAMANGA - JESUS NAZARENO&lt;/td&gt;&#13;
2+
&lt;/tr&gt;&#13;
3+
&#13;
4+
&lt;tr&gt;&#13;
5+
</cbc:StreetName><cbc:CitySubdivisionName>11 de junio</cbc:CitySubdivisionName><cbc:CityName>HUAMANGA</cbc:CityName><cbc:CountrySubentity>AYACUCHO</cbc:CountrySubentity><cac:Country><cbc:IdentificationCode>PE</cbc:IdentificationCode></cac:Country></cac:PostalAddress><cac:PartyLegalEntity><cbc:RegistrationName>GASOLINERA PETROX E.I.R.L. </cbc:RegistrationName></cac:PartyLegalEntity></cac:Party></cac:AccountingSupplierParty><sac:VoidedDocumentsLine><cbc:LineID>1</cbc:LineID><cbc:DocumentTypeCode>20</cbc:DocumentTypeCode><sac:DocumentSerialID>R001</sac:DocumentSerialID><sac:DocumentNumberID>00000040</sac:DocumentNumberID><sac:VoidReasonDescription>456</sac:VoidReasonDescription></sac:VoidedDocumentsLine></VoidedDocuments>

0 commit comments

Comments
 (0)