Search in sources :

Example 1 with Nota

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) RenglonNotaDebito(sic.modelo.RenglonNotaDebito) NotaDebito(sic.modelo.NotaDebito) Nota(sic.modelo.Nota) NotaCredito(sic.modelo.NotaCredito) RenglonNotaCredito(sic.modelo.RenglonNotaCredito) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 2 with Nota

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"));
        }
    }
}
Also used : BusinessServiceException(sic.service.BusinessServiceException) Nota(sic.modelo.Nota) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Nota

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;
}
Also used : TipoDeComprobante(sic.modelo.TipoDeComprobante) Pago(sic.modelo.Pago) IClienteService(sic.service.IClienteService) URL(java.net.URL) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Movimiento(sic.modelo.Movimiento) Usuario(sic.modelo.Usuario) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) Cliente(sic.modelo.Cliente) NotaCreditoRepository(sic.repository.NotaCreditoRepository) ConfiguracionDelSistema(sic.modelo.ConfiguracionDelSistema) NotaDebito(sic.modelo.NotaDebito) JasperExportManager(net.sf.jasperreports.engine.JasperExportManager) BusinessServiceException(sic.service.BusinessServiceException) Page(org.springframework.data.domain.Page) IAfipService(sic.service.IAfipService) IPagoService(sic.service.IPagoService) List(java.util.List) ComprobanteAFIP(sic.modelo.ComprobanteAFIP) IEmpresaService(sic.service.IEmpresaService) Lazy(org.springframework.context.annotation.Lazy) Factura(sic.modelo.Factura) NotaRepository(sic.repository.NotaRepository) IFacturaService(sic.service.IFacturaService) TipoDeOperacion(sic.modelo.TipoDeOperacion) NotaDebitoRepository(sic.repository.NotaDebitoRepository) JRException(net.sf.jasperreports.engine.JRException) RenglonNotaDebito(sic.modelo.RenglonNotaDebito) HashMap(java.util.HashMap) RenglonFactura(sic.modelo.RenglonFactura) IConfiguracionDelSistemaService(sic.service.IConfiguracionDelSistemaService) ServiceException(sic.service.ServiceException) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle) Service(org.springframework.stereotype.Service) Empresa(sic.modelo.Empresa) Nota(sic.modelo.Nota) EntityNotFoundException(javax.persistence.EntityNotFoundException) BusquedaNotaCriteria(sic.modelo.BusquedaNotaCriteria) ImageIcon(javax.swing.ImageIcon) INotaService(sic.service.INotaService) Logger(org.slf4j.Logger) NotaCredito(sic.modelo.NotaCredito) FormatterFechaHora(sic.util.FormatterFechaHora) FacturaVenta(sic.modelo.FacturaVenta) IOException(java.io.IOException) JasperFillManager(net.sf.jasperreports.engine.JasperFillManager) JRBeanCollectionDataSource(net.sf.jasperreports.engine.data.JRBeanCollectionDataSource) IUsuarioService(sic.service.IUsuarioService) ICuentaCorrienteService(sic.service.ICuentaCorrienteService) RenglonNotaCredito(sic.modelo.RenglonNotaCredito) IProductoService(sic.service.IProductoService) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) Nota(sic.modelo.Nota) NotaCredito(sic.modelo.NotaCredito) RenglonNotaCredito(sic.modelo.RenglonNotaCredito)

Aggregations

Nota (sic.modelo.Nota)3 Transactional (org.springframework.transaction.annotation.Transactional)2 NotaCredito (sic.modelo.NotaCredito)2 NotaDebito (sic.modelo.NotaDebito)2 RenglonNotaCredito (sic.modelo.RenglonNotaCredito)2 RenglonNotaDebito (sic.modelo.RenglonNotaDebito)2 BusinessServiceException (sic.service.BusinessServiceException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 ImageIO (javax.imageio.ImageIO)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 ImageIcon (javax.swing.ImageIcon)1 JRException (net.sf.jasperreports.engine.JRException)1