Skip to content

Commit a38d33d

Browse files
Ajuste validaciones 2021/03/24 (#28)
* Set default codigo de local for proveedor * Add license
1 parent 728c564 commit a38d33d

File tree

65 files changed

+226
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+226
-17
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
3+
* and other contributors as indicated by the @author tags.
4+
*
5+
* Licensed under the Eclipse Public License - v 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.eclipse.org/legal/epl-2.0/
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.github.project.openubl.xmlbuilderlib.config;
18+
19+
public class Constants {
20+
21+
public static final String DEFAULT_CODIGO_LOCAL = "0000";
22+
23+
}

src/main/java/io/github/project/openubl/xmlbuilderlib/factory/common/ProveedorOutputModelFactory.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
*/
1717
package io.github.project.openubl.xmlbuilderlib.factory.common;
1818

19+
import io.github.project.openubl.xmlbuilderlib.config.Constants;
1920
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
21+
import io.github.project.openubl.xmlbuilderlib.models.output.common.DireccionOutputModel;
2022
import io.github.project.openubl.xmlbuilderlib.models.output.common.ProveedorOutputModel;
2123

2224
public class ProveedorOutputModelFactory {
@@ -30,10 +32,15 @@ public static ProveedorOutputModel getProveedor(ProveedorInputModel input) {
3032
.withRuc(input.getRuc())
3133
.withRazonSocial(input.getRazonSocial())
3234
.withNombreComercial(input.getNombreComercial())
33-
.withDireccion(input.getDireccion() != null ? DireccionOutputModelFactory.getDireccion(input.getDireccion()) : null)
35+
.withDireccion(input.getDireccion() != null ? DireccionOutputModelFactory.getDireccion(input.getDireccion()) : getDefaultDireccion())
3436
.withContacto(input.getContacto() != null ? ContactoOutputModelFactory.getContacto(input.getContacto()) : null)
3537
.build();
3638

3739
}
3840

41+
private static DireccionOutputModel getDefaultDireccion() {
42+
return DireccionOutputModel.Builder.aDireccionOutputModel()
43+
.withCodigoLocal(Constants.DEFAULT_CODIGO_LOCAL)
44+
.build();
45+
}
3946
}

src/main/java/io/github/project/openubl/xmlbuilderlib/models/output/common/DireccionOutputModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
*/
1717
package io.github.project.openubl.xmlbuilderlib.models.output.common;
1818

19+
import javax.validation.constraints.NotBlank;
1920
import javax.validation.constraints.Size;
2021

2122
public class DireccionOutputModel {
2223

2324
@Size(min = 6, max = 6)
2425
private String ubigeo;
2526

27+
@NotBlank
28+
@Size(min = 4, max = 4)
2629
private String codigoLocal;
2730
private String urbanizacion;
2831
private String provincia;

src/main/java/io/github/project/openubl/xmlbuilderlib/models/output/common/ProveedorOutputModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import javax.validation.Valid;
2020
import javax.validation.constraints.NotBlank;
21+
import javax.validation.constraints.NotNull;
2122
import javax.validation.constraints.Size;
2223

2324
public class ProveedorOutputModel {
@@ -31,6 +32,7 @@ public class ProveedorOutputModel {
3132
@NotBlank
3233
private String razonSocial;
3334

35+
@NotNull
3436
@Valid
3537
private DireccionOutputModel direccion;
3638

src/test/java/io/github/project/openubl/xmlbuilderlib/integrationtest/ubl/invoice/InvoiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void testInvoiceWithCustomClienteDireccionAndContacto() throws Exception {
150150
.withDepartamento("Ayacucho")
151151
.withProvincia("Huamanga")
152152
.withDistrito("Jesus Nazareno")
153-
.withCodigoLocal("010101")
153+
.withCodigoLocal("0101")
154154
.withUrbanizacion("000000")
155155
.withDireccion("Jr. Las piedras 123")
156156
.withCodigoPais("PE")

src/test/java/io/github/project/openubl/xmlbuilderlib/integrationtest/ubl/invoice/formapago/InvoiceFormaPagoTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void testFacturaWithFormaPagoContadoPorDefecto() throws Exception {
7676
// Then
7777
assertOutputHasNoConstraintViolations(validator, output);
7878
assertSnapshot(xml, "xml/invoice/formapago/sinFormaPagoFactura.xml");
79-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
79+
assertSendSunat(xml);
8080
}
8181

8282
@Test
@@ -118,7 +118,7 @@ void testBoletaFacturaWithFormaPagoContadoPorDefecto() throws Exception {
118118
// Then
119119
assertOutputHasNoConstraintViolations(validator, output);
120120
assertSnapshot(xml, "xml/invoice/formapago/sinFormaPagoBoleta.xml");
121-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
121+
assertSendSunat(xml);
122122
}
123123

124124
@Test
@@ -185,7 +185,7 @@ void testFacturaWithFormaPagoCredito() throws Exception {
185185
// Then
186186
assertOutputHasNoConstraintViolations(validator, output);
187187
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoFactura.xml");
188-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
188+
assertSendSunat(xml);
189189
}
190190

191191
@Test
@@ -252,7 +252,7 @@ void testBoletaWithFormaPagoCredito() throws Exception {
252252
// Then
253253
assertOutputHasNoConstraintViolations(validator, output);
254254
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoBoleta.xml");
255-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
255+
assertSendSunat(xml);
256256
}
257257

258258
@Test
@@ -319,6 +319,6 @@ void testFacturaWithFormaPagoCredito_usingPercetajePayments() throws Exception {
319319
// Then
320320
assertOutputHasNoConstraintViolations(validator, output);
321321
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoFactura_porcentaje.xml");
322-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
322+
assertSendSunat(xml);
323323
}
324324
}

src/test/java/io/github/project/openubl/xmlbuilderlib/integrationtest/ubl/invoice/mindata/InvoiceMinDataTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void testInvoiceWithMinDataSent_customerWithRuc() throws Exception {
7676
// Then
7777
assertOutputHasNoConstraintViolations(validator, output);
7878
assertSnapshot(xml, "xml/invoice/mindata/MinData_RUC.xml");
79-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
79+
assertSendSunat(xml);
8080
}
8181

8282
@Test
@@ -118,7 +118,7 @@ void testInvoiceWithMinDataSent_customerWithDni() throws Exception {
118118
// Then
119119
assertOutputHasNoConstraintViolations(validator, output);
120120
assertSnapshot(xml, "xml/invoice/mindata/MinData_DNI.xml");
121-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
121+
assertSendSunat(xml);
122122
}
123123

124124
@Test
@@ -160,7 +160,7 @@ void testInvoiceWithMinDataSent_customerWithDocTribNoDomSinRuc() throws Exceptio
160160
// Then
161161
assertOutputHasNoConstraintViolations(validator, output);
162162
assertSnapshot(xml, "xml/invoice/mindata/MinData_DocTribNoDomSinRuc.xml");
163-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
163+
assertSendSunat(xml);
164164
}
165165

166166
@Test
@@ -202,7 +202,7 @@ void testInvoiceWithMinDataSent_customerWithExtranjeria() throws Exception {
202202
// Then
203203
assertOutputHasNoConstraintViolations(validator, output);
204204
assertSnapshot(xml, "xml/invoice/mindata/MinData_Extranjeria.xml");
205-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
205+
assertSendSunat(xml);
206206
}
207207

208208
@Test
@@ -244,7 +244,7 @@ void testInvoiceWithMinDataSent_customerWithPasaporte() throws Exception {
244244
// Then
245245
assertOutputHasNoConstraintViolations(validator, output);
246246
assertSnapshot(xml, "xml/invoice/mindata/MinData_Pasaporte.xml");
247-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
247+
assertSendSunat(xml);
248248
}
249249

250250
@Test
@@ -328,7 +328,7 @@ void testInvoiceWithMinDataSent_usePrecioUnitario() throws Exception {
328328
// Then
329329
assertOutputHasNoConstraintViolations(validator, output);
330330
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgv.xml");
331-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
331+
assertSendSunat(xml);
332332
}
333333

334334
@Test
@@ -370,7 +370,7 @@ void testInvoiceWithMinDataSent_usePrecioConIgv() throws Exception {
370370
// Then
371371
assertOutputHasNoConstraintViolations(validator, output);
372372
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgv.xml");
373-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
373+
assertSendSunat(xml);
374374
}
375375

376376
@Test
@@ -412,7 +412,7 @@ void testInvoiceWithMinDataSent_usePrecioUnitarioAndCantidadThreeDecimals() thro
412412
// Then
413413
assertOutputHasNoConstraintViolations(validator, output);
414414
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgvAndCantidadThreeDecimals.xml");
415-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
415+
assertSendSunat(xml);
416416
}
417417

418418
@Test
@@ -454,6 +454,6 @@ void testInvoiceWithMinDataSent_usePrecioConIgvAndCantidadThreeDecimals() throws
454454
// Then
455455
assertOutputHasNoConstraintViolations(validator, output);
456456
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgvAndCantidadThreeDecimals.xml");
457-
assertSendSunat(xml, "3030 - El XML no contiene el tag o no existe información del código de local anexo del emisor - INFO: 3030 (nodo: \"/\" valor: \"\")");
457+
assertSendSunat(xml);
458458
}
459459
}

src/test/resources/xml/creditnote/formapago/conFormaPago_afectaBoleta.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</cac:PartyIdentification>
6262
<cac:PartyLegalEntity>
6363
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
64+
<cac:RegistrationAddress>
65+
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
66+
</cac:RegistrationAddress>
6467
</cac:PartyLegalEntity>
6568
</cac:Party>
6669
</cac:AccountingSupplierParty>

src/test/resources/xml/creditnote/formapago/conFormaPago_afectaFactura.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
</cac:PartyIdentification>
6565
<cac:PartyLegalEntity>
6666
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
67+
<cac:RegistrationAddress>
68+
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
69+
</cac:RegistrationAddress>
6770
</cac:PartyLegalEntity>
6871
</cac:Party>
6972
</cac:AccountingSupplierParty>

src/test/resources/xml/creditnote/formapago/sinFormaPago_afectaBoleta.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</cac:PartyIdentification>
6262
<cac:PartyLegalEntity>
6363
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
64+
<cac:RegistrationAddress>
65+
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
66+
</cac:RegistrationAddress>
6467
</cac:PartyLegalEntity>
6568
</cac:Party>
6669
</cac:AccountingSupplierParty>

0 commit comments

Comments
 (0)