Skip to content

Commit

Permalink
Ajuste validaciones 2021/03/24 (#28)
Browse files Browse the repository at this point in the history
* Set default codigo de local for proveedor

* Add license
  • Loading branch information
carlosthe19916 authored Apr 6, 2021
1 parent 728c564 commit a38d33d
Show file tree
Hide file tree
Showing 65 changed files with 226 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Eclipse Public License - v 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.eclipse.org/legal/epl-2.0/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under 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 permissions and
* limitations under the License.
*/
package io.github.project.openubl.xmlbuilderlib.config;

public class Constants {

public static final String DEFAULT_CODIGO_LOCAL = "0000";

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/
package io.github.project.openubl.xmlbuilderlib.factory.common;

import io.github.project.openubl.xmlbuilderlib.config.Constants;
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
import io.github.project.openubl.xmlbuilderlib.models.output.common.DireccionOutputModel;
import io.github.project.openubl.xmlbuilderlib.models.output.common.ProveedorOutputModel;

public class ProveedorOutputModelFactory {
Expand All @@ -30,10 +32,15 @@ public static ProveedorOutputModel getProveedor(ProveedorInputModel input) {
.withRuc(input.getRuc())
.withRazonSocial(input.getRazonSocial())
.withNombreComercial(input.getNombreComercial())
.withDireccion(input.getDireccion() != null ? DireccionOutputModelFactory.getDireccion(input.getDireccion()) : null)
.withDireccion(input.getDireccion() != null ? DireccionOutputModelFactory.getDireccion(input.getDireccion()) : getDefaultDireccion())
.withContacto(input.getContacto() != null ? ContactoOutputModelFactory.getContacto(input.getContacto()) : null)
.build();

}

private static DireccionOutputModel getDefaultDireccion() {
return DireccionOutputModel.Builder.aDireccionOutputModel()
.withCodigoLocal(Constants.DEFAULT_CODIGO_LOCAL)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
*/
package io.github.project.openubl.xmlbuilderlib.models.output.common;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

public class DireccionOutputModel {

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

@NotBlank
@Size(min = 4, max = 4)
private String codigoLocal;
private String urbanizacion;
private String provincia;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

public class ProveedorOutputModel {
Expand All @@ -31,6 +32,7 @@ public class ProveedorOutputModel {
@NotBlank
private String razonSocial;

@NotNull
@Valid
private DireccionOutputModel direccion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void testInvoiceWithCustomClienteDireccionAndContacto() throws Exception {
.withDepartamento("Ayacucho")
.withProvincia("Huamanga")
.withDistrito("Jesus Nazareno")
.withCodigoLocal("010101")
.withCodigoLocal("0101")
.withUrbanizacion("000000")
.withDireccion("Jr. Las piedras 123")
.withCodigoPais("PE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void testFacturaWithFormaPagoContadoPorDefecto() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/sinFormaPagoFactura.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -118,7 +118,7 @@ void testBoletaFacturaWithFormaPagoContadoPorDefecto() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/sinFormaPagoBoleta.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -185,7 +185,7 @@ void testFacturaWithFormaPagoCredito() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoFactura.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -252,7 +252,7 @@ void testBoletaWithFormaPagoCredito() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoBoleta.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -319,6 +319,6 @@ void testFacturaWithFormaPagoCredito_usingPercetajePayments() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/conFormaPagoFactura_porcentaje.xml");
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: \"\")");
assertSendSunat(xml);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void testInvoiceWithMinDataSent_customerWithRuc() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_RUC.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -118,7 +118,7 @@ void testInvoiceWithMinDataSent_customerWithDni() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_DNI.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -160,7 +160,7 @@ void testInvoiceWithMinDataSent_customerWithDocTribNoDomSinRuc() throws Exceptio
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_DocTribNoDomSinRuc.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -202,7 +202,7 @@ void testInvoiceWithMinDataSent_customerWithExtranjeria() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_Extranjeria.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -244,7 +244,7 @@ void testInvoiceWithMinDataSent_customerWithPasaporte() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_Pasaporte.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -328,7 +328,7 @@ void testInvoiceWithMinDataSent_usePrecioUnitario() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgv.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -370,7 +370,7 @@ void testInvoiceWithMinDataSent_usePrecioConIgv() throws Exception {
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgv.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -412,7 +412,7 @@ void testInvoiceWithMinDataSent_usePrecioUnitarioAndCantidadThreeDecimals() thro
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgvAndCantidadThreeDecimals.xml");
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: \"\")");
assertSendSunat(xml);
}

@Test
Expand Down Expand Up @@ -454,6 +454,6 @@ void testInvoiceWithMinDataSent_usePrecioConIgvAndCantidadThreeDecimals() throws
// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/mindata/MinData_UsePrecioUnitarioOPrecioConIgvAndCantidadThreeDecimals.xml");
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: \"\")");
assertSendSunat(xml);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/xml/creditnote/mindata/MinData_DNI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/xml/creditnote/mindata/MinData_RUC.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/xml/debitnote/mindata/MinData_DNI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
Expand Down
Loading

0 comments on commit a38d33d

Please sign in to comment.