use of sic.modelo.Pedido in project sic by belluccifranco.
the class PedidoServiceImpl method buscarConCriteria.
@Override
public List<Pedido> buscarConCriteria(BusquedaPedidoCriteria criteria) {
//Fecha
if (criteria.isBuscaPorFecha() == true & (criteria.getFechaDesde() == null | criteria.getFechaHasta() == null)) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_fechas_busqueda_invalidas"));
}
if (criteria.isBuscaPorFecha() == true) {
Calendar cal = new GregorianCalendar();
cal.setTime(criteria.getFechaDesde());
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
criteria.setFechaDesde(cal.getTime());
cal.setTime(criteria.getFechaHasta());
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
criteria.setFechaHasta(cal.getTime());
}
//Empresa
if (criteria.getEmpresa() == null) {
throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
}
//Cliente
if (criteria.isBuscaCliente() == true && criteria.getCliente() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_cliente_vacio_razonSocial"));
}
//Usuario
if (criteria.isBuscaUsuario() == true && criteria.getUsuario() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_usuario_vacio_nombre"));
}
QPedido qpedido = QPedido.pedido;
BooleanBuilder builder = new BooleanBuilder();
builder.and(qpedido.empresa.eq(criteria.getEmpresa()).and(qpedido.eliminado.eq(false)));
if (criteria.isBuscaPorFecha() == true) {
FormatterFechaHora formateadorFecha = new FormatterFechaHora(FormatterFechaHora.FORMATO_FECHAHORA_INTERNACIONAL);
DateExpression<Date> fDesde = Expressions.dateTemplate(Date.class, "convert({0}, datetime)", formateadorFecha.format(criteria.getFechaDesde()));
DateExpression<Date> fHasta = Expressions.dateTemplate(Date.class, "convert({0}, datetime)", formateadorFecha.format(criteria.getFechaHasta()));
builder.and(qpedido.fecha.between(fDesde, fHasta));
}
if (criteria.isBuscaCliente() == true) {
builder.and(qpedido.cliente.eq(criteria.getCliente()));
}
if (criteria.isBuscaUsuario() == true) {
builder.and(qpedido.usuario.eq(criteria.getUsuario()));
}
if (criteria.isBuscaPorNroPedido() == true) {
builder.and(qpedido.nroPedido.eq(criteria.getNroPedido()));
}
List<Pedido> pedidos = new ArrayList<>();
pedidoRepository.findAll(builder, new Sort(Sort.Direction.DESC, "fecha")).iterator().forEachRemaining(pedidos::add);
return this.calcularTotalActualDePedidos(pedidos);
}
use of sic.modelo.Pedido in project sic by belluccifranco.
the class PedidoServiceImpl method eliminar.
@Override
@Transactional
public boolean eliminar(long idPedido) {
Pedido pedido = this.getPedidoPorId(idPedido);
if (pedido == null) {
throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_no_existente"));
}
if (pedido.getEstado() == EstadoPedido.ABIERTO) {
pedido.setEliminado(true);
pedidoRepository.save(pedido);
}
return pedido.isEliminado();
}
use of sic.modelo.Pedido in project sic by belluccifranco.
the class PedidoBuilder method build.
public Pedido build() {
if (renglones == null) {
RenglonPedido renglon1 = new RenglonPedidoBuilder().build();
RenglonPedido renglon2 = new RenglonPedidoBuilder().withCantidad(1).withIdRenglonPedido(90L).withProducto(new ProductoBuilder().withId_Producto(77L).withDescripcion("Pack 6 Vasos").withEmpresa(new EmpresaBuilder().build()).build()).build();
List<RenglonPedido> renglonesPedido = new ArrayList<>();
renglonesPedido.add(renglon1);
renglonesPedido.add(renglon2);
this.renglones = renglonesPedido;
}
return new Pedido(id_Pedido, nroPedido, fecha, fechaVencimiento, observaciones, empresa, eliminado, cliente, usuario, facturas, renglones, totalEstimado, totalActual, estado);
}
use of sic.modelo.Pedido in project sic by belluccifranco.
the class PedidosGUI method bnt_modificaPedidoActionPerformed.
//GEN-LAST:event_btn_imprimirPedidoActionPerformed
private void bnt_modificaPedidoActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_bnt_modificaPedidoActionPerformed
try {
if (tbl_Pedidos.getSelectedRow() != -1) {
long nroPedido = (long) tbl_Pedidos.getValueAt(tbl_Pedidos.getSelectedRow(), 2);
Pedido pedido = Arrays.asList(RestClient.getRestTemplate().getForObject("/pedidos/busqueda/criteria?nroPedido=" + nroPedido + "&idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa(), Pedido[].class)).get(0);
if (pedido.getEstado() == EstadoPedido.CERRADO) {
JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_facturado"), "Error", JOptionPane.ERROR_MESSAGE);
} else if (pedido.getEstado() == EstadoPedido.ACTIVO) {
JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_procesado"), "Error", JOptionPane.ERROR_MESSAGE);
} else if (this.existeClienteDisponible()) {
PuntoDeVentaGUI gui_puntoDeVenta = new PuntoDeVentaGUI();
gui_puntoDeVenta.setPedido(pedido);
gui_puntoDeVenta.setModificarPedido(true);
gui_puntoDeVenta.setModal(true);
gui_puntoDeVenta.setLocationRelativeTo(this);
gui_puntoDeVenta.setVisible(true);
this.buscar();
} else {
String mensaje = ResourceBundle.getBundle("Mensajes").getString("mensaje_sin_cliente");
JOptionPane.showInternalMessageDialog(this, mensaje, "Error", JOptionPane.ERROR_MESSAGE);
}
}
} catch (RestClientResponseException ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
} catch (ResourceAccessException ex) {
LOGGER.error(ex.getMessage());
JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
}
}
use of sic.modelo.Pedido in project sic by belluccifranco.
the class PedidosGUI method btn_FacturarActionPerformed.
//GEN-LAST:event_btn_NuevoPedidoActionPerformed
private void btn_FacturarActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_btn_FacturarActionPerformed
try {
if (tbl_Pedidos.getSelectedRow() != -1) {
long nroPedido = (long) tbl_Pedidos.getValueAt(tbl_Pedidos.getSelectedRow(), 2);
Pedido pedido = Arrays.asList(RestClient.getRestTemplate().getForObject("/pedidos/busqueda/criteria?nroPedido=" + nroPedido + "&idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa(), Pedido[].class)).get(0);
if (pedido.getEstado() == EstadoPedido.CERRADO) {
JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_facturado"), "Error", JOptionPane.ERROR_MESSAGE);
} else if (this.existeClienteDisponible()) {
PuntoDeVentaGUI gui_puntoDeVenta = new PuntoDeVentaGUI();
gui_puntoDeVenta.setPedido(pedido);
gui_puntoDeVenta.setModal(true);
gui_puntoDeVenta.setLocationRelativeTo(this);
gui_puntoDeVenta.setVisible(true);
this.buscar();
} else {
String mensaje = ResourceBundle.getBundle("Mensajes").getString("mensaje_sin_cliente");
JOptionPane.showInternalMessageDialog(this, mensaje, "Error", JOptionPane.ERROR_MESSAGE);
}
}
} catch (RestClientResponseException ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
} catch (ResourceAccessException ex) {
LOGGER.error(ex.getMessage());
JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
}
}
Aggregations