Skip to content

Add tests for FormaPago #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CreditNoteFormaPagoTest() throws Exception {
}

@Test
public void testCreditNoteSinFormaPago() throws Exception {
public void testCreditNoteSinFormaPago_afectaFactura() throws Exception {
// Given
CreditNoteInputModel input = CreditNoteInputModel.Builder.aCreditNoteInputModel()
.withSerie("FC01")
Expand Down Expand Up @@ -77,12 +77,56 @@ public void testCreditNoteSinFormaPago() throws Exception {

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/creditnote/formapago/sinFormaPago.xml");
assertSnapshot(xml, "xml/creditnote/formapago/sinFormaPago_afectaFactura.xml");
assertSendSunat(xml, PROVIDER_WITHOUT_ADDRESS_NOTE);
}

@Test
public void testCreditNoteConFormaPago() throws Exception {
public void testCreditNoteSinFormaPago_afectaBoleta() throws Exception {
// Given
CreditNoteInputModel input = CreditNoteInputModel.Builder.aCreditNoteInputModel()
.withSerie("BC01")
.withNumero(1)
.withSerieNumeroComprobanteAfectado("B001-1")
.withDescripcionSustento("mi sustento")
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Softgreen S.A.C.")
.build()
)
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Carlos Feria")
.withNumeroDocumentoIdentidad("12345678")
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
.build()
)
.withDetalle(Arrays.asList(
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item1")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build(),
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item2")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build())
)
.build();

// When
DocumentWrapper<CreditNoteOutputModel> result = DocumentManager.createXML(input, config, systemClock);
CreditNoteOutputModel output = result.getOutput();
String xml = result.getXml();

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/creditnote/formapago/sinFormaPago_afectaBoleta.xml");
assertSendSunat(xml, PROVIDER_WITHOUT_ADDRESS_NOTE);
}

@Test
public void testCreditNoteConFormaPago_afectaFactura() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(2019, Calendar.JANUARY, 6, 0, 0, 0);
calendar.setTimeZone(timeZone);
Expand Down Expand Up @@ -144,7 +188,74 @@ public void testCreditNoteConFormaPago() throws Exception {

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/creditnote/formapago/conFormaPago.xml");
assertSnapshot(xml, "xml/creditnote/formapago/conFormaPago_afectaFactura.xml");
assertSendSunat(xml, PROVIDER_WITHOUT_ADDRESS_NOTE);
}

@Test
public void testCreditNoteConFormaPago_afectaBoleta() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(2019, Calendar.JANUARY, 6, 0, 0, 0);
calendar.setTimeZone(timeZone);

long fechaEmision = calendar.getTimeInMillis();

calendar.add(Calendar.DAY_OF_MONTH, 1);
long fechaCuota1 = calendar.getTimeInMillis();

calendar.add(Calendar.DAY_OF_MONTH, 1);
long fechaCuota2 = calendar.getTimeInMillis();

// Given
CreditNoteInputModel input = CreditNoteInputModel.Builder.aCreditNoteInputModel()
.withSerie("BC01")
.withNumero(1)
.withFechaEmision(fechaEmision)
.withSerieNumeroComprobanteAfectado("B001-1")
.withDescripcionSustento("mi sustento")
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Softgreen S.A.C.")
.build()
)
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Carlos Feria")
.withNumeroDocumentoIdentidad("12345678")
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
.build()
)
.withDetalle(Arrays.asList(
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item1")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build(),
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item2")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build())
)
.withCuotasDePago(Arrays.asList(
CuotaDePagoInputModel.Builder.aFormaPagoCuotaInputModel()
.withMonto(new BigDecimal(2000))
.withFechaPago(fechaCuota1)
.build(),
CuotaDePagoInputModel.Builder.aFormaPagoCuotaInputModel()
.withMonto(new BigDecimal(360))
.withFechaPago(fechaCuota2)
.build()
))
.build();

// When
DocumentWrapper<CreditNoteOutputModel> result = DocumentManager.createXML(input, config, systemClock);
CreditNoteOutputModel output = result.getOutput();
String xml = result.getXml();

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/creditnote/formapago/conFormaPago_afectaBoleta.xml");
assertSendSunat(xml, PROVIDER_WITHOUT_ADDRESS_NOTE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public InvoiceFormaPagoTest() throws Exception {
}

@Test
void testInvoiceWithFormaPagoContadoPorDefecto() throws Exception {
void testFacturaWithFormaPagoContadoPorDefecto() throws Exception {
// Given
InvoiceInputModel input = InvoiceInputModel.Builder.anInvoiceInputModel()
.withSerie("F001")
Expand Down Expand Up @@ -66,7 +66,47 @@ void testInvoiceWithFormaPagoContadoPorDefecto() throws Exception {
)
.build();

// When
DocumentWrapper<InvoiceOutputModel> result = DocumentManager.createXML(input, config, systemClock);
InvoiceOutputModel output = result.getOutput();
String xml = result.getXml();

// 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: \"\")");
}

@Test
void testBoletaFacturaWithFormaPagoContadoPorDefecto() throws Exception {
// Given
InvoiceInputModel input = InvoiceInputModel.Builder.anInvoiceInputModel()
.withSerie("B001")
.withNumero(1)
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Softgreen S.A.C.")
.build()
)
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Carlos Feria")
.withNumeroDocumentoIdentidad("12345678")
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
.build()
)
.withDetalle(Arrays.asList(
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item1")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build(),
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item2")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build())
)
.build();

// When
DocumentWrapper<InvoiceOutputModel> result = DocumentManager.createXML(input, config, systemClock);
Expand All @@ -75,12 +115,12 @@ void testInvoiceWithFormaPagoContadoPorDefecto() throws Exception {

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/default.xml");
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: \"\")");
}

@Test
void testInvoiceWithFormaPagoCredito() throws Exception {
void testFacturaWithFormaPagoCredito() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(2019, Calendar.JANUARY, 6, 0, 0, 0);
calendar.setTimeZone(timeZone);
Expand Down Expand Up @@ -142,7 +182,74 @@ void testInvoiceWithFormaPagoCredito() throws Exception {

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/invoice/formapago/alCredito.xml");
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: \"\")");
}

@Test
void testBoletaWithFormaPagoCredito() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(2019, Calendar.JANUARY, 6, 0, 0, 0);
calendar.setTimeZone(timeZone);

long fechaEmision = calendar.getTimeInMillis();

calendar.add(Calendar.DAY_OF_MONTH, 1);
long fechaCuota1 = calendar.getTimeInMillis();

calendar.add(Calendar.DAY_OF_MONTH, 1);
long fechaCuota2 = calendar.getTimeInMillis();

// Given
InvoiceInputModel input = InvoiceInputModel.Builder.anInvoiceInputModel()
.withSerie("B001")
.withNumero(1)
.withFechaEmision(fechaEmision)
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Softgreen S.A.C.")
.build()
)
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Carlos Feria")
.withNumeroDocumentoIdentidad("12345678")
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
.build()
)
.withDetalle(Arrays.asList(
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item1")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build(),
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item2")
.withCantidad(new BigDecimal(10))
.withPrecioUnitario(new BigDecimal(100))
.build())
)
.withCuotasDePago(Arrays.asList(
CuotaDePagoInputModel.Builder.aFormaPagoCuotaInputModel()
.withMonto(new BigDecimal(2000))
.withFechaPago(fechaCuota1)
.build(),
CuotaDePagoInputModel.Builder.aFormaPagoCuotaInputModel()
.withMonto(new BigDecimal(360))
.withFechaPago(fechaCuota2)
.build()
))
.build();



// When
DocumentWrapper<InvoiceOutputModel> result = DocumentManager.createXML(input, config, systemClock);
InvoiceOutputModel output = result.getOutput();
String xml = result.getXml();

// 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: \"\")");
}
}
Loading