Search in sources :

Example 66 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class PuntoDeVentaGUI method actualizarPedido.

private void actualizarPedido(Pedido pedido) {
    try {
        pedido = RestClient.getRestTemplate().getForObject("/pedidos/" + pedido.getId_Pedido(), Pedido.class);
        pedido.setRenglones(this.convertirRenglonesFacturaARenglonesPedido(this.renglones));
        double[] importes = new double[renglones.size()];
        int indice = 0;
        for (RenglonFactura renglon : renglones) {
            importes[indice] = renglon.getImporte();
            indice++;
        }
        pedido.setTotalEstimado(RestClient.getRestTemplate().getForObject("/facturas/subtotal?" + "importe=" + Arrays.toString(importes).substring(1, Arrays.toString(importes).length() - 1), double.class));
        RestClient.getRestTemplate().put("/pedidos", pedido);
    } 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);
    }
}
Also used : RenglonPedido(sic.modelo.RenglonPedido) Pedido(sic.modelo.Pedido) EstadoPedido(sic.modelo.EstadoPedido) RenglonFactura(sic.modelo.RenglonFactura) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Point(java.awt.Point) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 67 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class PuntoDeVentaGUI method agregarRenglon.

private void agregarRenglon(RenglonFactura renglon) {
    try {
        boolean agregado = false;
        //busca entre los renglones al producto, aumenta la cantidad y recalcula el descuento        
        for (int i = 0; i < renglones.size(); i++) {
            if (renglones.get(i).getId_ProductoItem() == renglon.getId_ProductoItem()) {
                Producto producto = RestClient.getRestTemplate().getForObject("/productos/" + renglon.getId_ProductoItem(), Producto.class);
                renglones.set(i, RestClient.getRestTemplate().getForObject("/facturas/renglon?" + "idProducto=" + producto.getId_Producto() + "&tipoDeComprobante=" + this.tipoDeComprobante.name() + "&movimiento=" + Movimiento.VENTA + "&cantidad=" + (renglones.get(i).getCantidad() + renglon.getCantidad()) + "&descuentoPorcentaje=" + renglon.getDescuento_porcentaje(), RenglonFactura.class));
                agregado = true;
            }
        }
        //si no encuentra el producto entre los renglones, carga un nuevo renglon        
        if (agregado == false) {
            renglones.add(renglon);
        }
        //para que baje solo el scroll vertical
        Point p = new Point(0, tbl_Resultado.getHeight());
        sp_Resultado.getViewport().setViewPosition(p);
    } 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);
    }
}
Also used : Producto(sic.modelo.Producto) RenglonFactura(sic.modelo.RenglonFactura) Point(java.awt.Point) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Point(java.awt.Point) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 68 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class TransportistasGUI method cargarComboBoxLocalidadesDeLaProvincia.

private void cargarComboBoxLocalidadesDeLaProvincia(Provincia provSeleccionada) {
    cmb_Localidad.removeAllItems();
    try {
        List<Localidad> Localidades = new ArrayList(Arrays.asList(RestClient.getRestTemplate().getForObject("/localidades/provincias/" + provSeleccionada.getId_Provincia(), Localidad[].class)));
        Localidad localidadTodas = new Localidad();
        localidadTodas.setNombre("Todas");
        cmb_Localidad.addItem(localidadTodas);
        Localidades.stream().forEach((l) -> {
            cmb_Localidad.addItem(l);
        });
    } 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);
    }
}
Also used : ArrayList(java.util.ArrayList) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Localidad(sic.modelo.Localidad) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 69 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class TransportistasGUI method cargarComboBoxProvinciasDelPais.

private void cargarComboBoxProvinciasDelPais(Pais paisSeleccionado) {
    cmb_Provincia.removeAllItems();
    try {
        List<Provincia> provincias = new ArrayList(Arrays.asList(RestClient.getRestTemplate().getForObject("/provincias/paises/" + paisSeleccionado.getId_Pais(), Provincia[].class)));
        Provincia provinciaTodas = new Provincia();
        provinciaTodas.setNombre("Todas");
        cmb_Provincia.addItem(provinciaTodas);
        provincias.stream().forEach((p) -> {
            cmb_Provincia.addItem(p);
        });
    } 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);
    }
}
Also used : ArrayList(java.util.ArrayList) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Provincia(sic.modelo.Provincia) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Aggregations

RestClientResponseException (org.springframework.web.client.RestClientResponseException)69 ResourceAccessException (org.springframework.web.client.ResourceAccessException)68 ArrayList (java.util.ArrayList)23 Point (java.awt.Point)9 Pais (sic.modelo.Pais)9 Provincia (sic.modelo.Provincia)9 RenglonFactura (sic.modelo.RenglonFactura)9 EstadoPedido (sic.modelo.EstadoPedido)8 Localidad (sic.modelo.Localidad)8 Pedido (sic.modelo.Pedido)8 RenglonPedido (sic.modelo.RenglonPedido)8 IOException (java.io.IOException)6 FormaDePago (sic.modelo.FormaDePago)6 File (java.io.File)5 Producto (sic.modelo.Producto)5 Proveedor (sic.modelo.Proveedor)5 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 SwingWorker (javax.swing.SwingWorker)4 Rubro (sic.modelo.Rubro)4