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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations