diff --git a/scripts/issues/issue417.sql b/scripts/issues/issue417.sql new file mode 100644 index 000000000..0555bdf2e --- /dev/null +++ b/scripts/issues/issue417.sql @@ -0,0 +1,13 @@ +ALTER TABLE recibo +ADD estado varchar(255) AFTER idPagoMercadoPago; + +ALTER TABLE recibo +ADD urlImagen varchar(255) AFTER estado; + +SET SQL_SAFE_UPDATES = 0; + +update recibo +set recibo.estado = 'APROBADO'; + +SET SQL_SAFE_UPDATES = 1; + diff --git a/src/main/java/sic/controller/ReciboController.java b/src/main/java/sic/controller/ReciboController.java index b284f1ad6..6ed642929 100644 --- a/src/main/java/sic/controller/ReciboController.java +++ b/src/main/java/sic/controller/ReciboController.java @@ -1,7 +1,5 @@ package sic.controller; -import io.jsonwebtoken.Claims; -import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.http.HttpHeaders; @@ -10,10 +8,13 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import sic.aspect.AccesoRolesPermitidos; +import sic.modelo.EstadoRecibo; import sic.modelo.criteria.BusquedaReciboCriteria; import sic.modelo.Recibo; import sic.modelo.Rol; -import sic.modelo.dto.ReciboDTO; +import sic.modelo.dto.NuevoReciboClienteDTO; +import sic.modelo.dto.NuevoReciboDepositoDTO; +import sic.modelo.dto.NuevoReciboProveedorDTO; import sic.service.*; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -29,8 +30,6 @@ public class ReciboController { private final IProveedorService proveedorService; private final IFormaDePagoService formaDePagoService; private final IAuthService authService; - private final ModelMapper modelMapper; - @Autowired public ReciboController( IReciboService reciboService, @@ -39,8 +38,7 @@ public ReciboController( IClienteService clienteService, IProveedorService proveedorService, IFormaDePagoService formaDePagoService, - IAuthService authService, - ModelMapper modelMapper) { + IAuthService authService) { this.reciboService = reciboService; this.sucursalService = sucursalService; this.usuarioService = usuarioService; @@ -48,7 +46,6 @@ public ReciboController( this.formaDePagoService = formaDePagoService; this.proveedorService = proveedorService; this.authService = authService; - this.modelMapper = modelMapper; } @GetMapping("/recibos/{idRecibo}") @@ -71,35 +68,57 @@ public BigDecimal getTotalRecibos(@RequestBody BusquedaReciboCriteria criteria) @PostMapping("/recibos/clientes") @AccesoRolesPermitidos({Rol.ADMINISTRADOR, Rol.ENCARGADO}) public Recibo guardarReciboCliente( - @RequestBody ReciboDTO reciboDTO, + @RequestBody NuevoReciboClienteDTO nuevoReciboClienteDTO, @RequestHeader("Authorization") String authorizationHeader) { - Recibo recibo = modelMapper.map(reciboDTO, Recibo.class); - recibo.setSucursal(sucursalService.getSucursalPorId(reciboDTO.getIdSucursal())); - recibo.setCliente(clienteService.getClienteNoEliminadoPorId(reciboDTO.getIdCliente())); - recibo.setFormaDePago(formaDePagoService.getFormasDePagoNoEliminadoPorId(reciboDTO.getIdFormaDePago())); - Claims claims = authService.getClaimsDelToken(authorizationHeader); + var recibo = new Recibo(); + recibo.setConcepto(nuevoReciboClienteDTO.getConcepto()); + recibo.setSucursal(sucursalService.getSucursalPorId(nuevoReciboClienteDTO.getIdSucursal())); + recibo.setCliente( + clienteService.getClienteNoEliminadoPorId(nuevoReciboClienteDTO.getIdCliente())); + recibo.setFormaDePago( + formaDePagoService.getFormasDePagoNoEliminadoPorId( + nuevoReciboClienteDTO.getIdFormaDePago())); + var claims = authService.getClaimsDelToken(authorizationHeader); recibo.setUsuario( usuarioService.getUsuarioNoEliminadoPorId(((Integer) claims.get("idUsuario")).longValue())); recibo.setFecha(LocalDateTime.now()); + recibo.setEstado(EstadoRecibo.APROBADO); + recibo.setMonto(nuevoReciboClienteDTO.getMonto()); return reciboService.guardar(recibo); } @PostMapping("/recibos/proveedores") @AccesoRolesPermitidos({Rol.ADMINISTRADOR, Rol.ENCARGADO}) public Recibo guardarReciboProveedor( - @RequestBody ReciboDTO reciboDTO, + @RequestBody NuevoReciboProveedorDTO nuevoReciboProveedorDTO, @RequestHeader("Authorization") String authorizationHeader) { - Recibo recibo = modelMapper.map(reciboDTO, Recibo.class); - recibo.setSucursal(sucursalService.getSucursalPorId(reciboDTO.getIdSucursal())); - recibo.setProveedor(proveedorService.getProveedorNoEliminadoPorId(reciboDTO.getIdProveedor())); - recibo.setFormaDePago(formaDePagoService.getFormasDePagoNoEliminadoPorId(reciboDTO.getIdFormaDePago())); - Claims claims = authService.getClaimsDelToken(authorizationHeader); + var recibo = new Recibo(); + recibo.setConcepto(nuevoReciboProveedorDTO.getConcepto()); + recibo.setSucursal(sucursalService.getSucursalPorId(nuevoReciboProveedorDTO.getIdSucursal())); + recibo.setProveedor( + proveedorService.getProveedorNoEliminadoPorId(nuevoReciboProveedorDTO.getIdProveedor())); + recibo.setFormaDePago( + formaDePagoService.getFormasDePagoNoEliminadoPorId( + nuevoReciboProveedorDTO.getIdFormaDePago())); + var claims = authService.getClaimsDelToken(authorizationHeader); recibo.setUsuario( usuarioService.getUsuarioNoEliminadoPorId(((Integer) claims.get("idUsuario")).longValue())); recibo.setFecha(LocalDateTime.now()); + recibo.setMonto(nuevoReciboProveedorDTO.getMonto()); + recibo.setEstado(EstadoRecibo.APROBADO); return reciboService.guardar(recibo); } + @PostMapping("/recibos/clientes/depositos") + @AccesoRolesPermitidos({Rol.COMPRADOR}) + public Recibo guardarReciboPorDeposito( + @RequestBody NuevoReciboDepositoDTO nuevoReciboDepositoDTO, + @RequestHeader("Authorization") String authorizationHeader) { + return reciboService.guardarReciboPorDeposito( + nuevoReciboDepositoDTO, + (Integer) authService.getClaimsDelToken(authorizationHeader).get("idUsuario")); + } + @DeleteMapping("/recibos/{idRecibo}") @AccesoRolesPermitidos({Rol.ADMINISTRADOR}) public void eliminar(@PathVariable long idRecibo) { @@ -108,11 +127,17 @@ public void eliminar(@PathVariable long idRecibo) { @GetMapping("/recibos/{idRecibo}/reporte") public ResponseEntity getReporteRecibo(@PathVariable long idRecibo) { - HttpHeaders headers = new HttpHeaders(); + var headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_PDF); headers.add("content-disposition", "inline; filename=Recibo.pdf"); headers.setCacheControl("must-revalidate, post-check=0, pre-check=0"); byte[] reportePDF = reciboService.getReporteRecibo(reciboService.getReciboNoEliminadoPorId(idRecibo)); return new ResponseEntity<>(reportePDF, headers, HttpStatus.OK); } + + @PutMapping("/recibos/{idRecibo}/aprobar") + @AccesoRolesPermitidos({Rol.ADMINISTRADOR, Rol.ENCARGADO}) + public void aprobarRecibo(@PathVariable long idRecibo) { + reciboService.aprobarRecibo(idRecibo); + } } diff --git a/src/main/java/sic/modelo/EstadoRecibo.java b/src/main/java/sic/modelo/EstadoRecibo.java new file mode 100644 index 000000000..92ddf81da --- /dev/null +++ b/src/main/java/sic/modelo/EstadoRecibo.java @@ -0,0 +1,7 @@ +package sic.modelo; + +public enum EstadoRecibo { + SIN_CHEQUEAR, + APROBADO, + RECHAZADO +} diff --git a/src/main/java/sic/modelo/Recibo.java b/src/main/java/sic/modelo/Recibo.java index ffc2ecdec..4037d7299 100644 --- a/src/main/java/sic/modelo/Recibo.java +++ b/src/main/java/sic/modelo/Recibo.java @@ -73,8 +73,18 @@ public class Recibo implements Serializable { @Column(precision = 25, scale = 15) @Positive(message = "{mensaje_recibo_monto_igual_menor_cero}") + @NotNull(message = "{mensaje_recibo_sin_monto}") private BigDecimal monto; + @Pattern( + regexp = "^https:\\/\\/res.cloudinary.com\\/.*", + message = "{mensaje_url_imagen_no_valida}") + @JsonView(Views.Comprador.class) + private String urlImagen; + + @Enumerated(EnumType.STRING) + private EstadoRecibo estado; + @JsonGetter("idFormaDePago") public long getIdFormaDePago() { return formaDePago.getIdFormaDePago(); diff --git a/src/main/java/sic/modelo/dto/NuevoReciboClienteDTO.java b/src/main/java/sic/modelo/dto/NuevoReciboClienteDTO.java new file mode 100644 index 000000000..008b39e55 --- /dev/null +++ b/src/main/java/sic/modelo/dto/NuevoReciboClienteDTO.java @@ -0,0 +1,21 @@ +package sic.modelo.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class NuevoReciboClienteDTO { + + private long idCliente; + private long idSucursal; + private long idFormaDePago; + private String concepto; + private BigDecimal monto; +} diff --git a/src/main/java/sic/modelo/dto/NuevoReciboDepositoDTO.java b/src/main/java/sic/modelo/dto/NuevoReciboDepositoDTO.java new file mode 100644 index 000000000..6730acfc1 --- /dev/null +++ b/src/main/java/sic/modelo/dto/NuevoReciboDepositoDTO.java @@ -0,0 +1,21 @@ +package sic.modelo.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class NuevoReciboDepositoDTO { + + private Long idPedido; + private Long idSucursal; + private String concepto; + private byte[] imagen; + private BigDecimal monto; +} diff --git a/src/main/java/sic/modelo/dto/NuevoReciboProveedorDTO.java b/src/main/java/sic/modelo/dto/NuevoReciboProveedorDTO.java new file mode 100644 index 000000000..1b1b78cd1 --- /dev/null +++ b/src/main/java/sic/modelo/dto/NuevoReciboProveedorDTO.java @@ -0,0 +1,21 @@ +package sic.modelo.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class NuevoReciboProveedorDTO { + + private long idProveedor; + private long idSucursal; + private long idFormaDePago; + private String concepto; + private BigDecimal monto; +} diff --git a/src/main/java/sic/repository/ReciboRepository.java b/src/main/java/sic/repository/ReciboRepository.java index 3de8f2aeb..b9e2213c1 100644 --- a/src/main/java/sic/repository/ReciboRepository.java +++ b/src/main/java/sic/repository/ReciboRepository.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.repository.PagingAndSortingRepository; @@ -26,7 +27,8 @@ Optional findReciboByIdPagoMercadoPagoAndEliminado( "SELECT r FROM Recibo r " + "WHERE r.sucursal.idSucursal = :idSucursal " + "AND r.formaDePago.idFormaDePago = :idFormaDePago " - + "AND r.fecha BETWEEN :desde AND :hasta AND r.eliminado = false") + + "AND r.fecha BETWEEN :desde AND :hasta AND r.eliminado = false " + + "AND r.estado = sic.modelo.EstadoRecibo.APROBADO") List getRecibosEntreFechasPorFormaDePago( @Param("idSucursal") long idSucursal, @Param("idFormaDePago") long idFormaDePago, @@ -98,4 +100,9 @@ BigDecimal getTotalRecibosProveedoresEntreFechas( @Param("idSucursal") long idSucursal, @Param("desde") LocalDateTime desde, @Param("hasta") LocalDateTime hasta); + + @Modifying + @Query("UPDATE Recibo r SET r.urlImagen = :urlImagen WHERE r.idRecibo = :idRecibo") + int actualizarUrlImagen(@Param("idRecibo") long idRecibo, @Param("urlImagen") String urlImagen); + } diff --git a/src/main/java/sic/service/IReciboService.java b/src/main/java/sic/service/IReciboService.java index 9f9764e38..e2611802c 100644 --- a/src/main/java/sic/service/IReciboService.java +++ b/src/main/java/sic/service/IReciboService.java @@ -10,6 +10,7 @@ import org.springframework.data.domain.Page; import sic.modelo.*; import sic.modelo.criteria.BusquedaReciboCriteria; +import sic.modelo.dto.NuevoReciboDepositoDTO; public interface IReciboService { @@ -38,6 +39,10 @@ List construirRecibos( Recibo construirReciboPorPayment( Sucursal sucursal, Usuario usuario, Cliente cliente, Payment payment); + Recibo guardarReciboPorDeposito(NuevoReciboDepositoDTO nuevoReciboDepositoDTO, long idUsuario); + + void aprobarRecibo(long idRecibo); + long getSiguienteNumeroRecibo(long idSucursal, long serie); void eliminar(long idRecibo); @@ -62,4 +67,6 @@ BigDecimal getTotalRecibosProveedoresQueAfectanCajaEntreFechas( BigDecimal getTotalRecibosClientesEntreFechas(long idSucursal, LocalDateTime desde, LocalDateTime hasta); BigDecimal getTotalRecibosProveedoresEntreFechas(long idSucursal, LocalDateTime desde, LocalDateTime hasta); + + String subirImagenRecibo(long idRecibo, byte[] imagen); } diff --git a/src/main/java/sic/service/impl/NotaServiceImpl.java b/src/main/java/sic/service/impl/NotaServiceImpl.java index 0dc94ef84..2e6b1a1b1 100644 --- a/src/main/java/sic/service/impl/NotaServiceImpl.java +++ b/src/main/java/sic/service/impl/NotaServiceImpl.java @@ -117,7 +117,7 @@ public Nota getNotaNoEliminadaPorId(long idNota) { @Override @Transactional public void eliminarNota(long idNota) { - Nota nota = this.getNotaNoEliminadaPorId(idNota); + var nota = this.getNotaNoEliminadaPorId(idNota); if (nota.getMovimiento() == Movimiento.COMPRA && nota.getFacturaCompra() != null) { throw new BusinessServiceException( messageSource.getMessage( @@ -178,7 +178,7 @@ public Page buscarNotasDebito( private Pageable getPageable(Integer pagina, String ordenarPor, String sentido) { if (pagina == null) pagina = 0; - String ordenDefault = "fecha"; + var ordenDefault = "fecha"; if (ordenarPor == null || sentido == null) { return PageRequest.of(pagina, TAMANIO_PAGINA_DEFAULT, Sort.by(Sort.Direction.DESC, ordenDefault)); } else { @@ -195,8 +195,8 @@ private Pageable getPageable(Integer pagina, String ordenarPor, String sentido) private BooleanBuilder getBuilderNotaCredito( BusquedaNotaCriteria criteria, long idUsuarioLoggedIn) { - QNotaCredito qNotaCredito = QNotaCredito.notaCredito; - BooleanBuilder builder = new BooleanBuilder(); + var qNotaCredito = QNotaCredito.notaCredito; + var builder = new BooleanBuilder(); builder.and( qNotaCredito .sucursal @@ -231,8 +231,8 @@ private BooleanBuilder getBuilderNotaCredito( builder .and(qNotaCredito.serie.eq(criteria.getNumSerie())) .and(qNotaCredito.nroNota.eq(criteria.getNumNota())); - Usuario usuarioLogueado = usuarioService.getUsuarioNoEliminadoPorId(idUsuarioLoggedIn); - BooleanBuilder rsPredicate = new BooleanBuilder(); + var usuarioLogueado = usuarioService.getUsuarioNoEliminadoPorId(idUsuarioLoggedIn); + var rsPredicate = new BooleanBuilder(); if (!usuarioLogueado.getRoles().contains(Rol.ADMINISTRADOR) && !usuarioLogueado.getRoles().contains(Rol.VENDEDOR) && !usuarioLogueado.getRoles().contains(Rol.ENCARGADO)) { @@ -242,7 +242,7 @@ private BooleanBuilder getBuilderNotaCredito( rsPredicate.or(qNotaCredito.cliente.viajante.eq(usuarioLogueado)); break; case COMPRADOR: - Cliente clienteRelacionado = + var clienteRelacionado = clienteService.getClientePorIdUsuario(idUsuarioLoggedIn); if (clienteRelacionado != null) { rsPredicate.or(qNotaCredito.cliente.eq(clienteRelacionado)); @@ -259,8 +259,8 @@ private BooleanBuilder getBuilderNotaCredito( private BooleanBuilder getBuilderNotaDebito( BusquedaNotaCriteria criteria, long idUsuarioLoggedIn) { - QNotaDebito qNotaDebito = QNotaDebito.notaDebito; - BooleanBuilder builder = new BooleanBuilder(); + var qNotaDebito = QNotaDebito.notaDebito; + var builder = new BooleanBuilder(); builder.and( qNotaDebito .sucursal @@ -295,8 +295,8 @@ private BooleanBuilder getBuilderNotaDebito( builder .and(qNotaDebito.serie.eq(criteria.getNumSerie())) .and(qNotaDebito.nroNota.eq(criteria.getNumNota())); - Usuario usuarioLogueado = usuarioService.getUsuarioNoEliminadoPorId(idUsuarioLoggedIn); - BooleanBuilder rsPredicate = new BooleanBuilder(); + var usuarioLogueado = usuarioService.getUsuarioNoEliminadoPorId(idUsuarioLoggedIn); + var rsPredicate = new BooleanBuilder(); if (!usuarioLogueado.getRoles().contains(Rol.ADMINISTRADOR) && !usuarioLogueado.getRoles().contains(Rol.VENDEDOR) && !usuarioLogueado.getRoles().contains(Rol.ENCARGADO)) { @@ -337,8 +337,8 @@ public boolean existsNotaDebitoPorRecibo(Recibo recibo) { @Override public List getTipoNotaCreditoCliente(Long idCliente, Long idSucursal) { List tiposPermitidos = new ArrayList<>(); - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); - Cliente cliente = clienteService.getClienteNoEliminadoPorId(idCliente); + var sucursal = sucursalService.getSucursalPorId(idSucursal); + var cliente = clienteService.getClienteNoEliminadoPorId(idCliente); if (CategoriaIVA.discriminaIVA(sucursal.getCategoriaIVA()) && CategoriaIVA.discriminaIVA(cliente.getCategoriaIVA())) { tiposPermitidos.add(TipoDeComprobante.NOTA_CREDITO_A); @@ -356,8 +356,8 @@ public List getTipoNotaCreditoCliente(Long idCliente, Long id @Override public List getTipoNotaDebitoCliente(Long idCliente, Long idSucursal) { List tiposPermitidos = new ArrayList<>(); - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); - Cliente cliente = clienteService.getClienteNoEliminadoPorId(idCliente); + var sucursal = sucursalService.getSucursalPorId(idSucursal); + var cliente = clienteService.getClienteNoEliminadoPorId(idCliente); if (CategoriaIVA.discriminaIVA(sucursal.getCategoriaIVA()) && CategoriaIVA.discriminaIVA(cliente.getCategoriaIVA())) { tiposPermitidos.add(TipoDeComprobante.NOTA_DEBITO_A); @@ -375,8 +375,8 @@ public List getTipoNotaDebitoCliente(Long idCliente, Long idS @Override public List getTipoNotaCreditoProveedor(Long idProveedor, Long idSucursal) { List tiposPermitidos = new ArrayList<>(); - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); - Proveedor proveedor = proveedorService.getProveedorNoEliminadoPorId(idProveedor); + var sucursal = sucursalService.getSucursalPorId(idSucursal); + var proveedor = proveedorService.getProveedorNoEliminadoPorId(idProveedor); if (CategoriaIVA.discriminaIVA(sucursal.getCategoriaIVA())) { if (CategoriaIVA.discriminaIVA(proveedor.getCategoriaIVA())) { tiposPermitidos.add(TipoDeComprobante.NOTA_CREDITO_A); @@ -398,8 +398,8 @@ public List getTipoNotaCreditoProveedor(Long idProveedor, Lon @Override public List getTipoNotaDebitoProveedor(Long idProveedor, Long idSucursal) { List tiposPermitidos = new ArrayList<>(); - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); - Proveedor proveedor = proveedorService.getProveedorNoEliminadoPorId(idProveedor); + var sucursal = sucursalService.getSucursalPorId(idSucursal); + var proveedor = proveedorService.getProveedorNoEliminadoPorId(idProveedor); if (CategoriaIVA.discriminaIVA(sucursal.getCategoriaIVA())) { if (CategoriaIVA.discriminaIVA(proveedor.getCategoriaIVA())) { tiposPermitidos.add(TipoDeComprobante.NOTA_DEBITO_A); @@ -421,7 +421,7 @@ public List getTipoNotaDebitoProveedor(Long idProveedor, Long @Override public List getNotasCreditoPorFactura(Long idFactura) { List notasCredito = new ArrayList<>(); - Factura factura = facturaService.getFacturaNoEliminadaPorId(idFactura); + var factura = facturaService.getFacturaNoEliminadaPorId(idFactura); if (factura instanceof FacturaVenta) { notasCredito = notaCreditoRepository.findAllByFacturaVentaAndEliminada((FacturaVenta) factura, false); @@ -470,7 +470,7 @@ public List getRenglonesFacturaModificadosParaNotaCredito(long i @Override public long getSiguienteNumeroNotaDebitoCliente( Long idSucursal, TipoDeComprobante tipoDeComprobante) { - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); + var sucursal = sucursalService.getSucursalPorId(idSucursal); Long numeroNota = notaDebitoRepository.buscarMayorNumNotaDebitoClienteSegunTipo( tipoDeComprobante, @@ -482,7 +482,7 @@ public long getSiguienteNumeroNotaDebitoCliente( @Override public long getSiguienteNumeroNotaCreditoCliente( Long idSucursal, TipoDeComprobante tipoDeComprobante) { - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); + var sucursal = sucursalService.getSucursalPorId(idSucursal); Long numeroNota = notaCreditoRepository.buscarMayorNumNotaCreditoClienteSegunTipo( tipoDeComprobante, @@ -585,6 +585,11 @@ public void validarReglasDeNegocio(Nota nota) { messageSource.getMessage("mensaje_nota_de_renglones_vacio", null, Locale.getDefault())); } } else { + var recibo = ((NotaDebito) nota).getRecibo(); + if (recibo != null && recibo.getEstado() != EstadoRecibo.APROBADO) + throw new BusinessServiceException( + messageSource.getMessage( + "mensaje_nota_debito_recibo_no_aprobado", null, Locale.getDefault())); if (((NotaDebito) nota).getRenglonesNotaDebito() == null || ((NotaDebito) nota).getRenglonesNotaDebito().isEmpty()) { throw new BusinessServiceException( @@ -598,8 +603,8 @@ public void validarCalculosCredito(NotaCredito notaCredito) { List renglonesNotaCredito = notaCredito.getRenglonesNotaCredito(); BigDecimal subTotal = BigDecimal.ZERO; BigDecimal[] importes = new BigDecimal[renglonesNotaCredito.size()]; - int i = 0; - int sizeRenglonesCredito = renglonesNotaCredito.size(); + var i = 0; + var sizeRenglonesCredito = renglonesNotaCredito.size(); // IVA - importe BigDecimal iva21 = BigDecimal.ZERO; BigDecimal iva105 = BigDecimal.ZERO; @@ -819,8 +824,8 @@ public NotaCredito guardarNotaCredito(NotaCredito notaCredito) { @Override public NotaCredito calcularNotaCreditoConFactura( NuevaNotaCreditoDeFacturaDTO nuevaNotaCreditoDeFacturaDTO, Usuario usuario) { - NotaCredito notaCreditoNueva = new NotaCredito(); - Factura factura = + var notaCreditoNueva = new NotaCredito(); + var factura = facturaService.getFacturaNoEliminadaPorId(nuevaNotaCreditoDeFacturaDTO.getIdFactura()); if (Arrays.asList(nuevaNotaCreditoDeFacturaDTO.getCantidades()).contains(null) || Arrays.asList(nuevaNotaCreditoDeFacturaDTO.getIdsRenglonesFactura()).contains(null)) { @@ -911,7 +916,7 @@ public NotaCredito calcularNotaCreditoConFactura( @Override public NotaCredito calcularNotaCreditoSinFactura( NuevaNotaCreditoSinFacturaDTO nuevaNotaCreditoSinFacturaDTO, Usuario usuario) { - NotaCredito notaCreditoNueva = new NotaCredito(); + var notaCreditoNueva = new NotaCredito(); if (nuevaNotaCreditoSinFacturaDTO.getDetalle() == null || nuevaNotaCreditoSinFacturaDTO.getDetalle().isEmpty()) { throw new BusinessServiceException( @@ -981,9 +986,9 @@ public NotaCredito calcularNotaCreditoSinFactura( @Override public NotaDebito calcularNotaDebitoConRecibo( NuevaNotaDebitoDeReciboDTO nuevaNotaDebitoDeReciboDTO, Usuario usuario) { - NotaDebito notaDebitoCalculada = new NotaDebito(); + var notaDebitoCalculada = new NotaDebito(); notaDebitoCalculada.setFecha(LocalDateTime.now()); - Recibo reciboRelacionado = + var reciboRelacionado = reciboService.getReciboNoEliminadoPorId(nuevaNotaDebitoDeReciboDTO.getIdRecibo()); if (reciboRelacionado.getCliente() != null) { notaDebitoCalculada.setCliente(reciboRelacionado.getCliente()); @@ -1053,12 +1058,12 @@ public NotaDebito calcularNotaDebitoConRecibo( @Override public NotaDebito calcularNotaDebitoSinRecibo( NuevaNotaDebitoSinReciboDTO nuevaNotaDebitoSinReciboDTO, Usuario usuario) { - NotaDebito notaDebitoCalculada = new NotaDebito(); + var notaDebitoCalculada = new NotaDebito(); notaDebitoCalculada.setFecha(LocalDateTime.now()); notaDebitoCalculada.setSucursal(sucursalService.getSucursalPorId(nuevaNotaDebitoSinReciboDTO.getIdSucursal())); if (nuevaNotaDebitoSinReciboDTO.getTipoDeComprobante() != null) { if (nuevaNotaDebitoSinReciboDTO.getIdCliente() != null) { - Cliente cliente = + var cliente = clienteService.getClienteNoEliminadoPorId(nuevaNotaDebitoSinReciboDTO.getIdCliente()); notaDebitoCalculada.setCliente(cliente); notaDebitoCalculada.setMovimiento(Movimiento.VENTA); @@ -1069,7 +1074,7 @@ public NotaDebito calcularNotaDebitoSinRecibo( messageSource.getMessage("mensaje_nota_tipo_no_valido", null, Locale.getDefault())); } } else if (nuevaNotaDebitoSinReciboDTO.getIdProveedor() != null) { - Proveedor proveedor = + var proveedor = proveedorService.getProveedorNoEliminadoPorId( nuevaNotaDebitoSinReciboDTO.getIdProveedor()); notaDebitoCalculada.setProveedor(proveedor); @@ -1242,7 +1247,7 @@ public byte[] getReporteNota(Nota nota) { ds = new JRBeanCollectionDataSource(renglones); params.put("notaDebito", nota); } - ConfiguracionSucursal configuracionSucursal = nota.getSucursal().getConfiguracionSucursal(); + var configuracionSucursal = nota.getSucursal().getConfiguracionSucursal(); params.put("preImpresa", configuracionSucursal.isUsarFacturaVentaPreImpresa()); if (nota.getTipoComprobante().equals(TipoDeComprobante.NOTA_CREDITO_B) || nota.getTipoComprobante().equals(TipoDeComprobante.NOTA_CREDITO_C) @@ -1308,8 +1313,8 @@ public List calcularRenglonesCreditoProducto( List renglonesNota = new ArrayList<>(); RenglonNotaCredito renglonNota; if (cantidad.length == idRenglonFactura.length) { - for (int i = 0; i < idRenglonFactura.length; i++) { - RenglonFactura renglonFactura = facturaService.getRenglonFactura(idRenglonFactura[i]); + for (var i = 0; i < idRenglonFactura.length; i++) { + var renglonFactura = facturaService.getRenglonFactura(idRenglonFactura[i]); if (renglonFactura.getCantidad().compareTo(cantidad[i]) < 0 || cantidad[i].compareTo(BigDecimal.ZERO) < 0) { throw new BusinessServiceException( @@ -1374,7 +1379,7 @@ public List calcularRenglonesCreditoProducto( public RenglonNotaCredito calcularRenglonCredito( TipoDeComprobante tipo, String detalle, BigDecimal monto) { this.validarTipoNotaCredito(tipo); - RenglonNotaCredito renglonNota = new RenglonNotaCredito(); + var renglonNota = new RenglonNotaCredito(); renglonNota.setIdProductoItem(null); renglonNota.setCodigoItem(null); renglonNota.setDescripcionItem(detalle); @@ -1447,7 +1452,7 @@ private void validarTipoNotaCredito(TipoDeComprobante tipo) { @Override public RenglonNotaDebito calcularRenglonDebitoConRecibo(Recibo recibo) { - RenglonNotaDebito renglonNota = new RenglonNotaDebito(); + var renglonNota = new RenglonNotaDebito(); String descripcion = "Nº Recibo " + recibo.getNumSerie() + "-" + recibo.getNumRecibo() + ": " + recibo.getConcepto(); renglonNota.setDescripcion(descripcion); @@ -1462,35 +1467,31 @@ public RenglonNotaDebito calcularRenglonDebitoConRecibo(Recibo recibo) { @Override public RenglonNotaDebito calcularRenglonDebito( BigDecimal monto, TipoDeComprobante tipoDeComprobante) { - RenglonNotaDebito renglonNota = new RenglonNotaDebito(); + var renglonNota = new RenglonNotaDebito(); renglonNota.setDescripcion("Gasto Administrativo"); switch (tipoDeComprobante) { - case NOTA_DEBITO_A: - case NOTA_DEBITO_B: - case NOTA_DEBITO_PRESUPUESTO: + case NOTA_DEBITO_A, NOTA_DEBITO_B, NOTA_DEBITO_PRESUPUESTO -> { renglonNota.setMonto( - monto.multiply(CIEN).divide(new BigDecimal("121"), 15, RoundingMode.HALF_UP)); + monto.multiply(CIEN).divide(new BigDecimal("121"), 15, RoundingMode.HALF_UP)); renglonNota.setIvaPorcentaje(IVA_21); renglonNota.setIvaNeto( - renglonNota.getMonto().multiply(IVA_21.divide(CIEN, 15, RoundingMode.HALF_UP))); - break; - case NOTA_DEBITO_C: - case NOTA_DEBITO_X: + renglonNota.getMonto().multiply(IVA_21.divide(CIEN, 15, RoundingMode.HALF_UP))); + } + case NOTA_DEBITO_C, NOTA_DEBITO_X -> { renglonNota.setMonto(monto); renglonNota.setIvaPorcentaje(BigDecimal.ZERO); renglonNota.setIvaNeto(BigDecimal.ZERO); - break; - case NOTA_DEBITO_Y: + } + case NOTA_DEBITO_Y -> { renglonNota.setMonto( - monto.multiply(CIEN).divide(new BigDecimal("110.5"), 15, RoundingMode.HALF_UP)); + monto.multiply(CIEN).divide(new BigDecimal("110.5"), 15, RoundingMode.HALF_UP)); renglonNota.setIvaPorcentaje(IVA_105); renglonNota.setIvaNeto( - renglonNota.getMonto().multiply(IVA_105.divide(CIEN, 15, RoundingMode.HALF_UP))); - break; - default: - throw new BusinessServiceException( - messageSource.getMessage( - "mensaje_tipo_de_comprobante_no_valido", null, Locale.getDefault())); + renglonNota.getMonto().multiply(IVA_105.divide(CIEN, 15, RoundingMode.HALF_UP))); + } + default -> throw new BusinessServiceException( + messageSource.getMessage( + "mensaje_tipo_de_comprobante_no_valido", null, Locale.getDefault())); } renglonNota.setImporteBruto(renglonNota.getMonto()); renglonNota.setImporteNeto(renglonNota.getIvaNeto().add(renglonNota.getImporteBruto())); @@ -1633,8 +1634,8 @@ public BigDecimal calcularTotalIVADebito(BusquedaNotaCriteria criteria, long idU @Override public boolean existeNotaCreditoAnteriorSinAutorizar(ComprobanteAFIP comprobante) { - QNotaCredito qNotaCredito = QNotaCredito.notaCredito; - BooleanBuilder builder = new BooleanBuilder(); + var qNotaCredito = QNotaCredito.notaCredito; + var builder = new BooleanBuilder(); builder.and( qNotaCredito .idNota @@ -1651,8 +1652,8 @@ public boolean existeNotaCreditoAnteriorSinAutorizar(ComprobanteAFIP comprobante @Override public boolean existeNotaDebitoAnteriorSinAutorizar(ComprobanteAFIP comprobante) { - QNotaDebito qNotaDebito = QNotaDebito.notaDebito; - BooleanBuilder builder = new BooleanBuilder(); + var qNotaDebito = QNotaDebito.notaDebito; + var builder = new BooleanBuilder(); builder.and( qNotaDebito .idNota diff --git a/src/main/java/sic/service/impl/ReciboServiceImpl.java b/src/main/java/sic/service/impl/ReciboServiceImpl.java index 3a75a34e6..bfc6801e1 100644 --- a/src/main/java/sic/service/impl/ReciboServiceImpl.java +++ b/src/main/java/sic/service/impl/ReciboServiceImpl.java @@ -1,5 +1,6 @@ package sic.service.impl; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.math.BigDecimal; import java.net.URL; @@ -12,6 +13,9 @@ import com.mercadopago.resources.Payment; import com.querydsl.core.BooleanBuilder; import net.sf.jasperreports.engine.*; +import net.sf.jasperreports.engine.export.JRPdfExporter; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import sic.modelo.*; import sic.modelo.criteria.BusquedaReciboCriteria; +import sic.modelo.dto.NuevoReciboDepositoDTO; import sic.repository.ReciboRepository; import sic.service.*; import sic.exception.BusinessServiceException; @@ -40,8 +45,13 @@ public class ReciboServiceImpl implements IReciboService { private final INotaService notaService; private final IFormaDePagoService formaDePagoService; private final ICajaService cajaService; + private final IPedidoService pedidoService; + private final IClienteService clienteService; + private final IUsuarioService usuarioService; + private final IPhotoVideoUploader photoVideoUploader; private final Logger logger = LoggerFactory.getLogger(this.getClass()); private static final int TAMANIO_PAGINA_DEFAULT = 25; + private static final String URL_SIN_IMAGEN = "https://res.cloudinary.com/hf0vu1bg2/image/upload/q_10/f_jpg/v1545616229/assets/sin_imagen.jpg"; private final MessageSource messageSource; private final CustomValidator customValidator; @@ -54,6 +64,10 @@ public ReciboServiceImpl( INotaService notaService, IFormaDePagoService formaDePagoService, ICajaService cajaService, + IPedidoService pedidoService, + IClienteService clienteService, + IUsuarioService usuarioService, + IPhotoVideoUploader photoVideoUploader, MessageSource messageSource, CustomValidator customValidator) { this.reciboRepository = reciboRepository; @@ -62,6 +76,10 @@ public ReciboServiceImpl( this.notaService = notaService; this.formaDePagoService = formaDePagoService; this.cajaService = cajaService; + this.pedidoService = pedidoService; + this.clienteService = clienteService; + this.usuarioService = usuarioService; + this.photoVideoUploader = photoVideoUploader; this.messageSource = messageSource; this.customValidator = customValidator; } @@ -84,8 +102,8 @@ public Optional getReciboPorIdMercadoPago(String idPagoMercadoPago) { @Override public BooleanBuilder getBuilder(BusquedaReciboCriteria criteria) { - QRecibo qRecibo = QRecibo.recibo; - BooleanBuilder builder = new BooleanBuilder(); + var qRecibo = QRecibo.recibo; + var builder = new BooleanBuilder(); if (criteria.getConcepto() != null) { String[] terminos = criteria.getConcepto().split(" "); BooleanBuilder rsPredicate = new BooleanBuilder(); @@ -138,7 +156,7 @@ public Page buscarRecibos(BusquedaReciboCriteria criteria) { private Pageable getPageable(Integer pagina, String ordenarPor, String sentido) { if (pagina == null) pagina = 0; - String ordenDefault = "fecha"; + var ordenDefault = "fecha"; if (ordenarPor == null || sentido == null) { return PageRequest.of( pagina, TAMANIO_PAGINA_DEFAULT, Sort.by(Sort.Direction.DESC, ordenDefault)); @@ -173,7 +191,8 @@ public Recibo guardar(Recibo recibo) { recibo.getSucursal().getConfiguracionSucursal().getNroPuntoDeVentaAfip())); this.validarReglasDeNegocio(recibo); recibo = reciboRepository.save(recibo); - this.cuentaCorrienteService.asentarEnCuentaCorriente(recibo, TipoDeOperacion.ALTA); + if (recibo.getEstado() == EstadoRecibo.APROBADO) + this.cuentaCorrienteService.asentarEnCuentaCorriente(recibo, TipoDeOperacion.ALTA); logger.warn("El Recibo {} se guardó correctamente.", recibo); return recibo; } @@ -202,7 +221,7 @@ public void validarReglasDeNegocio(Recibo recibo) { @Override public long getSiguienteNumeroRecibo(long idSucursal, long serie) { - Recibo recibo = + var recibo = reciboRepository.findTopBySucursalAndNumSerieOrderByNumReciboDesc( sucursalService.getSucursalPorId(idSucursal), serie); if (recibo == null) { @@ -223,7 +242,7 @@ public List construirRecibos( List recibos = new ArrayList<>(); if (idsFormaDePago != null && montos != null && idsFormaDePago.length == montos.length) { HashMap mapIdsFormaDePago = new HashMap<>(); - for (int i = 0; i < idsFormaDePago.length; i++) { + for (var i = 0; i < idsFormaDePago.length; i++) { if (mapIdsFormaDePago.containsKey(idsFormaDePago[i])) { mapIdsFormaDePago.put( idsFormaDePago[i], mapIdsFormaDePago.get(idsFormaDePago[i]).add(montos[i])); @@ -233,13 +252,13 @@ public List construirRecibos( } mapIdsFormaDePago.forEach( (k, v) -> { - Recibo recibo = new Recibo(); + var recibo = new Recibo(); recibo.setCliente(cliente); recibo.setUsuario(usuario); - Sucursal sucursal = sucursalService.getSucursalPorId(idSucursal); + var sucursal = sucursalService.getSucursalPorId(idSucursal); recibo.setSucursal(sucursal); recibo.setFecha(fecha); - FormaDePago fdp = formaDePagoService.getFormasDePagoNoEliminadoPorId(k); + var fdp = formaDePagoService.getFormasDePagoNoEliminadoPorId(k); recibo.setFormaDePago(fdp); recibo.setMonto(v); recibo.setNumSerie( @@ -256,7 +275,7 @@ public List construirRecibos( @Override public Recibo construirReciboPorPayment( Sucursal sucursal, Usuario usuario, Cliente cliente, Payment payment) { - Recibo nuevoRecibo = new Recibo(); + var nuevoRecibo = new Recibo(); nuevoRecibo.setSucursal(sucursal); nuevoRecibo.setFormaDePago( formaDePagoService.getFormaDePagoPorNombre(FormaDePagoEnum.MERCADO_PAGO)); @@ -269,10 +288,68 @@ public Recibo construirReciboPorPayment( return nuevoRecibo; } + @Transactional + @Override + public Recibo guardarReciboPorDeposito(NuevoReciboDepositoDTO nuevoReciboDepositoDTO, long idUsuario) { + if (nuevoReciboDepositoDTO.getImagen() == null) + throw new BusinessServiceException( + messageSource.getMessage("mensaje_recibo_deposito_sin_imagen", null, Locale.getDefault())); + var recibo = new Recibo(); + if (nuevoReciboDepositoDTO.getIdPedido() != null && nuevoReciboDepositoDTO.getIdPedido() != 0L) { + var pedidoRelacionadoAlDeposito = + pedidoService.getPedidoNoEliminadoPorId(nuevoReciboDepositoDTO.getIdPedido()); + if (pedidoRelacionadoAlDeposito.getEstado() == EstadoPedido.CERRADO + || pedidoRelacionadoAlDeposito.getEstado() == EstadoPedido.CANCELADO) + throw new BusinessServiceException( + messageSource.getMessage( + "mensaje_recibo_pedido_incorrecto", null, Locale.getDefault())); + recibo.setSucursal( + sucursalService.getSucursalPorId(pedidoRelacionadoAlDeposito.getIdSucursal())); + recibo.setCliente(pedidoRelacionadoAlDeposito.getCliente()); + recibo.setUsuario(pedidoRelacionadoAlDeposito.getUsuario()); + } else { + recibo.setSucursal(sucursalService.getSucursalPorId(nuevoReciboDepositoDTO.getIdSucursal())); + recibo.setCliente(clienteService.getClientePorIdUsuario(idUsuario)); + recibo.setUsuario(usuarioService.getUsuarioNoEliminadoPorId(idUsuario)); + } + recibo.setConcepto(nuevoReciboDepositoDTO.getConcepto()); + recibo.setFormaDePago( + formaDePagoService.getFormaDePagoPorNombre(FormaDePagoEnum.TRANSFERENCIA_BANCARIA)); + recibo.setFecha(LocalDateTime.now()); + recibo.setEstado(EstadoRecibo.SIN_CHEQUEAR); + recibo.setMonto(nuevoReciboDepositoDTO.getMonto()); + recibo = this.guardar(recibo); + recibo.setUrlImagen( + this.subirImagenRecibo(recibo.getIdRecibo(), nuevoReciboDepositoDTO.getImagen())); + return recibo; + } + + @Override + @Transactional + public void aprobarRecibo(long idRecibo) { + var recibo = this.getReciboNoEliminadoPorId(idRecibo); + if (recibo.getEstado() == EstadoRecibo.APROBADO) + throw new BusinessServiceException(messageSource.getMessage( + "mensaje_recibo_ya_aprobado", null, Locale.getDefault())); + recibo.setEstado(EstadoRecibo.APROBADO); + this.cuentaCorrienteService.asentarEnCuentaCorriente(recibo, TipoDeOperacion.ALTA); + logger.warn("El Recibo {} se aprobó correctamente.", recibo); + reciboRepository.save(recibo); + } + + @Override + @Transactional + public String subirImagenRecibo(long idRecibo, byte[] imagen) { + String urlImagen = + photoVideoUploader.subirImagen(Recibo.class.getSimpleName() + idRecibo, imagen); + reciboRepository.actualizarUrlImagen(idRecibo, urlImagen); + return urlImagen; + } + @Override @Transactional public void eliminar(long idRecibo) { - Recibo r = this.getReciboNoEliminadoPorId(idRecibo); + var r = this.getReciboNoEliminadoPorId(idRecibo); if (!notaService.existsNotaDebitoPorRecibo(r)) { r.setEliminado(true); this.cuentaCorrienteService.asentarEnCuentaCorriente(r, TipoDeOperacion.ELIMINACION); @@ -286,7 +363,7 @@ public void eliminar(long idRecibo) { } private void actualizarCajaPorEliminacionDeRecibo(Recibo recibo) { - Caja caja = + var caja = this.cajaService.encontrarCajaCerradaQueContengaFechaEntreFechaAperturaYFechaCierre( recibo.getSucursal().getIdSucursal(), recibo.getFecha()); BigDecimal monto = BigDecimal.ZERO; @@ -312,33 +389,54 @@ public List getRecibosEntreFechasPorFormaDePago( @Override public byte[] getReporteRecibo(Recibo recibo) { if (recibo.getProveedor() != null) { - throw new BusinessServiceException(messageSource.getMessage( - "mensaje_recibo_reporte_proveedor", null, Locale.getDefault())); + throw new BusinessServiceException( + messageSource.getMessage("mensaje_recibo_reporte_proveedor", null, Locale.getDefault())); } Map params = new HashMap<>(); params.put("recibo", recibo); if (recibo.getSucursal().getLogo() != null && !recibo.getSucursal().getLogo().isEmpty()) { try { params.put( - "logo", new ImageIcon(ImageIO.read(new URL(recibo.getSucursal().getLogo()))).getImage()); + "logo", + new ImageIcon(ImageIO.read(new URL(recibo.getSucursal().getLogo()))).getImage()); + params.put( + "sinImagen", new ImageIcon(ImageIO.read(new URL(URL_SIN_IMAGEN))).getImage()); } catch (IOException ex) { - throw new ServiceException(messageSource.getMessage( - "mensaje_sucursal_404_logo", null, Locale.getDefault()), ex); + throw new ServiceException( + messageSource.getMessage("mensaje_sucursal_404_logo", null, Locale.getDefault()), ex); } } - JasperReport jasperDesign; + JasperReport reporteRecibo; + JasperReport reporteComprobante; + JasperPrint printReporte; + JasperPrint printComprobante; + List reportes = new ArrayList<>(); try { - jasperDesign = JasperCompileManager.compileReport("src/main/resources/sic/vista/reportes/Recibo.jrxml"); + reporteRecibo = + JasperCompileManager.compileReport("src/main/resources/sic/vista/reportes/Recibo.jrxml"); + printReporte = JasperFillManager.fillReport(reporteRecibo, params); + reportes.add(printReporte); + if (recibo.getUrlImagen() != null) { + reporteComprobante = + JasperCompileManager.compileReport( + "src/main/resources/sic/vista/reportes/ComprobanteRecibo.jrxml"); + printComprobante = JasperFillManager.fillReport(reporteComprobante, params); + reportes.add(printComprobante); + } } catch (JRException ex) { - throw new ServiceException(messageSource.getMessage( - "mensaje_error_reporte", null, Locale.getDefault()), ex); + throw new ServiceException( + messageSource.getMessage("mensaje_error_reporte", null, Locale.getDefault()), ex); } try { - return JasperExportManager.exportReportToPdf( - JasperFillManager.fillReport(jasperDesign, params)); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(SimpleExporterInput.getInstance(reportes)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); + exporter.exportReport(); + return baos.toByteArray(); } catch (JRException ex) { - throw new ServiceException(messageSource.getMessage( - "mensaje_error_reporte", null, Locale.getDefault()), ex); + throw new ServiceException( + messageSource.getMessage("mensaje_error_reporte", null, Locale.getDefault()), ex); } } diff --git a/src/main/resources/ValidationMessages.properties b/src/main/resources/ValidationMessages.properties index 3f12d45f1..40d2d9ea6 100644 --- a/src/main/resources/ValidationMessages.properties +++ b/src/main/resources/ValidationMessages.properties @@ -109,6 +109,7 @@ mensaje_recibo_concepto_vacio=El concepto se encuentra vacío mensaje_recibo_monto_igual_menor_cero=El monto del recibo debe ser superior a cero mensaje_recibo_fecha_vacia=La fecha del recibo se encuentra vacía mensaje_recibo_fecha_futura_no_permitida=La fecha del recibo debe ser actual o anterior +mensaje_recibo_sin_monto=El monto del recibo se encuentra vacío #Ubicacion mensaje_ubicacion_costoEnvio_negativo=El costo del envio no puede ser negativo diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 55ddf12a0..ed95ae650 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -102,6 +102,9 @@ mensaje_recibo_cliente_proveedor_vacio=El recibo debe tener un cliente o un prov mensaje_recibo_cliente_proveedor_simultaneos=El recibo no puede poseer cliente y proveedor simultaneamente mensaje_recibo_reporte_proveedor=El recibo pertenece a una factura de compra. No posee reporte mensaje_recibo_no_existente=El recibo solicitado no existe +mensaje_recibo_ya_aprobado=El recibo ya se encuentra aprobado +mensaje_recibo_deposito_sin_imagen=El recibo debe contener la imagen del comprobante +mensaje_recibo_pedido_incorrecto=El pedido debe encontrarse abierto para realizar la operación #Sucursal mensaje_sucursal_duplicado_nombre=Ya existe una sucursal con el nombre ingresado @@ -196,6 +199,9 @@ mensaje_nota_recargo_neto_no_valido=El recargo neto de la nota es invalido mensaje_nota_monto_no_gravado_no_valido=El monto no gravado no es coincidente con el pago mensaje_nota_c_x_monto_no_gravado_no_valido=El monto no gravado debe ser igual a cero +#NotaDebito +mensaje_nota_debito_recibo_no_aprobado=El recibo asociado debe encontrarse aprobado + #Proveedor mensaje_proveedor_duplicado_idFiscal=Ya existe un proveedor con el ID fiscal ingresado mensaje_proveedor_duplicado_razonSocial=Ya existe un proveedor con la razon social ingresada diff --git a/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jasper b/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jasper new file mode 100644 index 000000000..30d247057 Binary files /dev/null and b/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jasper differ diff --git a/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jrxml b/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jrxml new file mode 100644 index 000000000..7a54b16e2 --- /dev/null +++ b/src/main/resources/sic/vista/reportes/ComprobanteRecibo.jrxml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="161" splitType="Stretch"> + <textField pattern="#0000"> + <reportElement x="459" y="15" width="43" height="15" uuid="6b61a93a-bc81-42c1-90de-30be6c6fd27b"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getNumSerie()]]></textFieldExpression> + </textField> + <staticText> + <reportElement x="360" y="30" width="99" height="15" uuid="77044937-fc7c-464e-9cb7-28123e5819dc"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Left"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Fecha:]]></text> + </staticText> + <textField pattern="dd/MM/yyyy"> + <reportElement x="459" y="30" width="96" height="15" uuid="be69d158-2a80-42ef-b029-4cff6ade861a"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[java.util.Date.from($P{recibo}.getFecha().atZone(java.time.ZoneId.systemDefault()).toInstant())]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="100" width="555" height="15" uuid="48165e8f-802d-48ab-b527-f040ad65579a"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement> + <font size="8" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getNombre()]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="115" width="555" height="15" uuid="6fb6fe21-b26a-4f5f-8847-da585e165dae"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement> + <font size="8" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[($P{recibo}.getSucursal().getUbicacion() != null) ? +$P{recibo}.getSucursal().getUbicacion() : ""]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="130" width="555" height="15" uuid="3c596225-a4e6-4283-92e6-74a5552f2211"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement> + <font size="8" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getCategoriaIVA().toString().equals("RESPONSABLE_INSCRIPTO") ? "Responsable Inscripto" : +$P{recibo}.getSucursal().getCategoriaIVA().toString().equals("EXENTO") ? "Exento" : +$P{recibo}.getSucursal().getCategoriaIVA().toString().equals("CONSUMIDOR_FINAL") ? "Consumidor Final" : +$P{recibo}.getSucursal().getCategoriaIVA().toString().equals("MONOTRIBUTO") ? "Monotributo" : ""]]></textFieldExpression> + </textField> + <line> + <reportElement x="0" y="160" width="555" height="1" uuid="bbd9e748-9b14-42c1-b03e-08e8289d6627"/> + </line> + <image hAlign="Center" vAlign="Middle"> + <reportElement x="40" y="0" width="140" height="100" uuid="a3439a7b-148b-4af2-8d4b-612d8d0beb47"/> + <imageExpression><![CDATA[$P{logo}]]></imageExpression> + </image> + <textField> + <reportElement x="459" y="45" width="96" height="15" uuid="4d472ca2-fe0a-4f11-b2c2-eaff1fd6d51e"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getIdFiscal()]]></textFieldExpression> + </textField> + <textField> + <reportElement x="459" y="60" width="96" height="15" uuid="4630ada4-f911-45f3-bf8d-1026e289cc77"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getIngresosBrutos()]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy" isBlankWhenNull="true"> + <reportElement x="459" y="75" width="96" height="15" uuid="71f82348-4ecf-4a46-9fcc-3681e588c04e"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[java.util.Date.from($P{recibo}.getSucursal().getFechaInicioActividad().atZone(java.time.ZoneId.systemDefault()).toInstant())]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="145" width="279" height="15" uuid="0ac9e3dd-2252-49da-8d4a-ae5da578c748"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement> + <font size="8" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getTelefono()]]></textFieldExpression> + </textField> + <textField> + <reportElement x="279" y="145" width="276" height="15" uuid="ecc2a8ba-e539-458c-93ed-17ae5e7a70df"> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement> + <font size="8" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getSucursal().getEmail()]]></textFieldExpression> + </textField> + <textField pattern="#00000000"> + <reportElement x="510" y="15" width="45" height="15" uuid="a3046cbb-4b9c-4ffb-9c57-c20771497933"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <textElement textAlignment="Right"> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{recibo}.getNumRecibo()]]></textFieldExpression> + </textField> + <staticText> + <reportElement mode="Transparent" x="360" y="45" width="99" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="9e7dfcda-5c8c-4987-88c2-2b820976c1bf"/> + <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/> + </textElement> + <text><![CDATA[CUIT:]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="360" y="60" width="99" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="b14c524c-faa9-4313-afa5-6d41ff2095b7"/> + <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/> + </textElement> + <text><![CDATA[Ingresos Brutos:]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="360" y="75" width="99" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="65b16deb-9ce0-4137-ad4c-53495b7cdeaa"/> + <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/> + </textElement> + <text><![CDATA[Inicio Actividades:]]></text> + </staticText> + <staticText> + <reportElement x="200" y="15" width="150" height="60" uuid="9f209d00-b442-47d4-a7bd-291fb3b1c8be"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + </reportElement> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="16" isBold="true"/> + </textElement> + <text><![CDATA[COMPROBANTE +RECIBO]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="360" y="15" width="99" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="4f584c9b-889f-4b77-ba6c-cfc29ead7cea"/> + <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/> + </textElement> + <text><![CDATA[Nº de Recibo:]]></text> + </staticText> + <staticText> + <reportElement x="502" y="15" width="8" height="15" uuid="94fd470d-5e8c-4022-b04a-2e1f3f304721"> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="pixel"/> + </reportElement> + <textElement textAlignment="Right" verticalAlignment="Justified"> + <font size="8"/> + </textElement> + <text><![CDATA[-]]></text> + </staticText> + </band> + + + + + + + + + + + + + + + + diff --git a/src/main/resources/sic/vista/reportes/Recibo.jasper b/src/main/resources/sic/vista/reportes/Recibo.jasper index a02a2be2a..0d0944aa7 100644 Binary files a/src/main/resources/sic/vista/reportes/Recibo.jasper and b/src/main/resources/sic/vista/reportes/Recibo.jasper differ diff --git a/src/main/resources/sic/vista/reportes/Recibo.jrxml b/src/main/resources/sic/vista/reportes/Recibo.jrxml index 0cbd28e94..fde1c98d6 100644 --- a/src/main/resources/sic/vista/reportes/Recibo.jrxml +++ b/src/main/resources/sic/vista/reportes/Recibo.jrxml @@ -1,5 +1,5 @@ - + @@ -19,14 +19,6 @@ - - - - - - - - diff --git a/src/test/java/sic/integration/AppIntegrationTest.java b/src/test/java/sic/integration/AppIntegrationTest.java index 8d799dcb7..f6ea5360f 100644 --- a/src/test/java/sic/integration/AppIntegrationTest.java +++ b/src/test/java/sic/integration/AppIntegrationTest.java @@ -531,9 +531,9 @@ void testEscenarioCompraEscenario1() { new BigDecimal("-554.540000000000000"), restTemplate.getForObject( apiPrefix + "/cuentas-corriente/proveedores/1/saldo", BigDecimal.class)); - Recibo recibo = - Recibo.builder() - .monto(554.54) + NuevoReciboProveedorDTO recibo = + NuevoReciboProveedorDTO.builder() + .monto(new BigDecimal("554.54")) .concepto("Recibo para proveedor") .idSucursal(sucursal.getIdSucursal()) .idProveedor(proveedorRecuperado.getIdProveedor()) @@ -541,7 +541,11 @@ void testEscenarioCompraEscenario1() { .build(); Recibo reciboRecuperado = restTemplate.postForObject(apiPrefix + "/recibos/proveedores", recibo, Recibo.class); - assertEquals(recibo, reciboRecuperado); + assertEquals(recibo.getMonto().doubleValue(), reciboRecuperado.getMonto()); + assertEquals(recibo.getIdFormaDePago(), reciboRecuperado.getIdFormaDePago()); + assertEquals(recibo.getIdSucursal(), reciboRecuperado.getIdSucursal()); + assertEquals(recibo.getIdProveedor(), reciboRecuperado.getIdProveedor()); + assertEquals(recibo.getConcepto(), reciboRecuperado.getConcepto()); assertEquals( 0.0, restTemplate @@ -1212,10 +1216,9 @@ void testEscenarioVenta1() { restTemplate .getForObject(apiPrefix + "/cuentas-corriente/clientes/1/saldo", BigDecimal.class) .doubleValue()); - Recibo recibo = - Recibo.builder() + NuevoReciboClienteDTO recibo = NuevoReciboClienteDTO.builder() .concepto("Recibo Test") - .monto(108320.27151325) + .monto(new BigDecimal("108320.27151325")) .idSucursal(sucursal.getIdSucursal()) .idCliente(cliente.getIdCliente()) .idFormaDePago(1L) @@ -1225,7 +1228,11 @@ void testEscenarioVenta1() { assertNotNull( restTemplate.getForObject( apiPrefix + "/recibos/" + reciboDeFactura.getIdRecibo() + "/reporte", byte[].class)); - assertEquals(recibo, reciboDeFactura); + assertEquals(recibo.getConcepto(), reciboDeFactura.getConcepto()); + assertEquals(recibo.getMonto().doubleValue(), reciboDeFactura.getMonto()); + assertEquals(recibo.getIdSucursal(), reciboDeFactura.getIdSucursal()); + assertEquals(recibo.getIdSucursal(), reciboDeFactura.getIdCliente()); + assertEquals(recibo.getIdFormaDePago(), reciboDeFactura.getIdFormaDePago()); assertEquals( 0.0, restTemplate @@ -1453,10 +1460,10 @@ void testEscenarioRegistracionYPedidoDelNuevoCliente() { assertEquals("theRedWolf", cliente.getNombreFiscal()); assertEquals(0.0, cliente.getMontoCompraMinima().doubleValue()); assertFalse(cliente.isPuedeComprarAPlazo()); - sic.model.CuentaCorrienteCliente cuentaCorrienteCliente = + CuentaCorrienteCliente cuentaCorrienteCliente = restTemplate.getForObject( apiPrefix + "/cuentas-corriente/clientes/" + cliente.getIdCliente(), - sic.model.CuentaCorrienteCliente.class); + CuentaCorrienteCliente.class); assertNotNull(cuentaCorrienteCliente); assertEquals(0.0, cuentaCorrienteCliente.getSaldo().doubleValue()); cliente.setUbicacionFacturacion(Ubicacion.builder().idLocalidad(2L).idProvincia(2L).build()); @@ -1538,8 +1545,68 @@ void testEscenarioRegistracionYPedidoDelNuevoCliente() { } @Test - @DisplayName("Cerrar caja y verificar movimientos") + @DisplayName("Realizar una transferencia para un pedido, luego aprobarlo") @Order(14) + void testEscenarioTransferencia() throws IOException { + this.iniciarSesionComoAdministrador(); + Usuario usuario = restTemplate.getForObject(apiPrefix + "/usuarios/4", Usuario.class); + assertEquals("Sansa María", usuario.getNombre()); + assertEquals("Stark", usuario.getApellido()); + assertTrue(usuario.isHabilitado()); + this.token = + restTemplate + .postForEntity( + apiPrefix + "/login", + new Credencial(usuario.getUsername(), "caraDeMala"), + String.class) + .getBody(); + BusquedaPedidoCriteria pedidoCriteria = + BusquedaPedidoCriteria.builder().idSucursal(1L).build(); + HttpEntity requestEntity = new HttpEntity<>(pedidoCriteria); + PaginaRespuestaRest resultadoBusquedaPedido = + restTemplate + .exchange( + apiPrefix + "/pedidos/busqueda/criteria", + HttpMethod.POST, + requestEntity, + new ParameterizedTypeReference>() {}) + .getBody(); + assertNotNull(resultadoBusquedaPedido); + List pedidosRecuperados = resultadoBusquedaPedido.getContent(); + assertEquals(1, pedidosRecuperados.size()); + BufferedImage bImage = ImageIO.read(getClass().getResource("/imagenProductoTest.jpeg")); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ImageIO.write(bImage, "jpeg", bos); + NuevoReciboDepositoDTO reciboDepositoDTO = NuevoReciboDepositoDTO.builder() + .concepto("Transferencia Bancaria") + .idPedido(pedidosRecuperados.get(0).getIdPedido()) + .imagen(bos.toByteArray()) + .monto(new BigDecimal("3000")) + .build(); + Recibo reciboCreado = restTemplate.postForObject(apiPrefix + "/recibos/clientes/depositos", reciboDepositoDTO, Recibo.class); + assertEquals(reciboDepositoDTO.getConcepto(), reciboCreado.getConcepto()); + assertEquals(reciboDepositoDTO.getMonto().doubleValue(), reciboCreado.getMonto()); + assertNotNull(reciboCreado.getUrlImagen()); + assertEquals(EstadoRecibo.SIN_CHEQUEAR, reciboCreado.getEstado()); + this.iniciarSesionComoAdministrador(); + assertEquals( + 0.0, + restTemplate + .getForObject(apiPrefix + "/cuentas-corriente/clientes/2/saldo", BigDecimal.class) + .doubleValue()); + restTemplate.put(apiPrefix + "/recibos/" + reciboCreado.getIdRecibo() + "/aprobar",null); + reciboCreado = restTemplate.getForObject(apiPrefix + "/recibos/" + reciboCreado.getIdRecibo(), Recibo.class); + assertEquals(EstadoRecibo.APROBADO, reciboCreado.getEstado()); + assertEquals( + 3000.00, + restTemplate + .getForObject(apiPrefix + "/cuentas-corriente/clientes/2/saldo", BigDecimal.class) + .doubleValue()); + } + + @Test + @DisplayName("Cerrar caja y verificar movimientos") + @Order(15) void testEscenarioCerrarCaja1() { this.iniciarSesionComoAdministrador(); List sucursales = @@ -1606,7 +1673,7 @@ void testEscenarioCerrarCaja1() { apiPrefix + "/cajas/" + cajasRecuperadas.get(0).getIdCaja() + "/saldo-afecta-caja", BigDecimal.class)); assertEquals( - new BigDecimal("108265.731513250000000"), + new BigDecimal("111265.731513250000000"), restTemplate.getForObject( apiPrefix + "/cajas/" + cajasRecuperadas.get(0).getIdCaja() + "/saldo-sistema", BigDecimal.class)); @@ -1614,7 +1681,7 @@ void testEscenarioCerrarCaja1() { @Test @DisplayName("Reabrir caja, corregir saldo con un gasto por $750 en efectivo") - @Order(15) + @Order(16) void testEscenarioCerrarCaja2() { this.iniciarSesionComoAdministrador(); List sucursales = @@ -1692,7 +1759,7 @@ void testEscenarioCerrarCaja2() { apiPrefix + "/cajas/" + cajasRecuperadas.get(0).getIdCaja() + "/saldo-afecta-caja", BigDecimal.class)); assertEquals( - new BigDecimal("107615.731513250000000"), + new BigDecimal("110615.731513250000000"), restTemplate.getForObject( apiPrefix + "/cajas/" + cajasRecuperadas.get(0).getIdCaja() + "/saldo-sistema", BigDecimal.class)); @@ -1700,7 +1767,7 @@ void testEscenarioCerrarCaja2() { @Test @DisplayName("Facturar un pedido, luego intentar cancelarlo sin éxito") - @Order(16) + @Order(17) void testEscenarioFacturarPedidoAndIntentarEliminarlo() { this.iniciarSesionComoAdministrador(); BusquedaProductoCriteria productosCriteria = BusquedaProductoCriteria.builder().build(); @@ -1834,7 +1901,7 @@ void testEscenarioFacturarPedidoAndIntentarEliminarlo() { @Test @DisplayName("Actualizar stock de un producto para tener cantidades en dos sucursales") - @Order(17) + @Order(18) void testEscenarioActualizarStockParaDosSucursales() { this.iniciarSesionComoAdministrador(); Cliente clienteParaEditar = restTemplate.getForObject(apiPrefix + "/clientes/2", Cliente.class); @@ -1914,7 +1981,7 @@ void testEscenarioActualizarStockParaDosSucursales() { @Test @DisplayName("Realizar un pedido que requiera del stock de ambas") - @Order(18) + @Order(19) void testEscenarioPedidoConStockDeDosSucursales() { this.iniciarSesionComoAdministrador(); Usuario usuario = restTemplate.getForObject(apiPrefix + "/usuarios/4", Usuario.class); @@ -2004,7 +2071,7 @@ void testEscenarioPedidoConStockDeDosSucursales() { @Test @DisplayName("Facturar el pedido anterior") - @Order(19) + @Order(20) void testEscenarioFacturarPedido() { this.iniciarSesionComoAdministrador(); BusquedaPedidoCriteria pedidoCriteria = @@ -2060,7 +2127,7 @@ void testEscenarioFacturarPedido() { @Test @DisplayName("Verificar stock y cerrar caja") - @Order(20) + @Order(21) void testEscenarioVerificarStockAndCerrarCaja() { this.iniciarSesionComoAdministrador(); BusquedaProductoCriteria productosCriteria = BusquedaProductoCriteria.builder().build(); diff --git a/src/test/java/sic/model/Recibo.java b/src/test/java/sic/model/Recibo.java index 485b8d494..d113318ac 100644 --- a/src/test/java/sic/model/Recibo.java +++ b/src/test/java/sic/model/Recibo.java @@ -1,6 +1,7 @@ package sic.model; import lombok.*; +import sic.modelo.EstadoRecibo; import java.time.LocalDateTime; @@ -40,4 +41,6 @@ public class Recibo { private Long idViajante; private String nombreViajante; private double monto; + private String urlImagen; + private EstadoRecibo estado; } diff --git a/src/test/java/sic/service/impl/ReciboServiceImplTest.java b/src/test/java/sic/service/impl/ReciboServiceImplTest.java index bef7419d9..700bbf89c 100644 --- a/src/test/java/sic/service/impl/ReciboServiceImplTest.java +++ b/src/test/java/sic/service/impl/ReciboServiceImplTest.java @@ -11,6 +11,7 @@ import sic.exception.BusinessServiceException; import sic.modelo.*; import sic.modelo.criteria.BusquedaReciboCriteria; +import sic.modelo.dto.NuevoReciboDepositoDTO; import sic.repository.ReciboRepository; import sic.service.IConfiguracionSucursalService; import sic.service.IFormaDePagoService; @@ -215,4 +216,10 @@ void shouldValidarReglasDeNegocioWhenExisteUnPagoPorPaymentId() { verify(messageSource).getMessage(eq("mensaje_recibo_de_pago_ya_existente"), any(), any()); } + @Test + void should() { + NuevoReciboDepositoDTO nuevoReciboDepositoDTO = NuevoReciboDepositoDTO.builder() + .build(); + } + } diff --git a/src/test/resources/data.sql b/src/test/resources/data.sql index 6eff61c63..1f11eda4b 100644 --- a/src/test/resources/data.sql +++ b/src/test/resources/data.sql @@ -7,7 +7,7 @@ VALUES ('N3400',50.000000000000000,false,'Corrientes',1), ('H3500',150.000000000000000,false,'Resistencia',3); INSERT INTO formadepago(afecta_caja, eliminada, nombre, predeterminado) -VALUES (true,false,'Efectivo',true), (false, false, 'Cheque de 3ros', false); +VALUES (true,false,'Efectivo',true), (false, false, 'Cheque de 3ros', false), (false, false, 'Transferencia Bancaria', false); INSERT INTO usuario (apellido, eliminado, email, habilitado, id_sucursal_predeterminada, nombre, password, password_recovery_key, password_recovery_key_expiration_date, username)