use of sic.modelo.Nota in project sic by belluccifranco.
the class NotaController method getReporteNota.
@GetMapping("/notas/{idNota}/reporte")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<byte[]> getReporteNota(@PathVariable long idNota) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_PDF);
Nota nota = notaService.getNotaPorId(idNota);
String fileName = (nota instanceof NotaCredito) ? "NotaCredito.pdf" : (nota instanceof NotaDebito) ? "NotaDebito.pdf" : "Nota.pdf";
headers.add("content-disposition", "inline; filename=" + fileName);
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
byte[] reportePDF = notaService.getReporteNota(nota);
return new ResponseEntity<>(reportePDF, headers, HttpStatus.OK);
}
use of sic.modelo.Nota in project sic by belluccifranco.
the class NotaServiceImpl method eliminarNota.
@Override
@Transactional
public void eliminarNota(long[] idsNota) {
for (long idNota : idsNota) {
Nota nota = this.getNotaPorId(idNota);
if (nota != null && nota.getCAE() == 0l) {
if (!getPagosNota(idNota).isEmpty()) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_no_se_puede_eliminar"));
}
nota.setEliminada(true);
this.cuentaCorrienteService.asentarEnCuentaCorriente(nota, TipoDeOperacion.ELIMINACION);
notaRepository.save(nota);
LOGGER.warn("La Nota " + nota + " se eliminĂ³ correctamente.");
} else {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_eliminar_factura_aprobada"));
}
}
}
use of sic.modelo.Nota in project sic by belluccifranco.
the class NotaServiceImpl method getIvaNetoNota.
@Override
public double getIvaNetoNota(Long idNota) {
Nota nota = this.getNotaPorId(idNota);
double ivaNeto = 0.0;
if (nota instanceof NotaCredito) {
ivaNeto = this.getRenglonesDeNotaCredito(nota.getIdNota()).stream().map((renglonNota) -> (renglonNota.getIvaPorcentaje() / 100) * renglonNota.getImporte()).reduce(ivaNeto, (accumulator, _item) -> accumulator + _item);
} else {
ivaNeto = this.getRenglonesDeNotaDebito(idNota).stream().map((r) -> r.getIvaNeto()).reduce(ivaNeto, (accumulator, _item) -> accumulator + _item);
}
return ivaNeto;
}
Aggregations