Search in sources :

Example 11 with RestClientResponseException

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

the class ClientesGUI method btn_setPredeterminadoActionPerformed.

//GEN-LAST:event_formInternalFrameOpened
private void btn_setPredeterminadoActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_setPredeterminadoActionPerformed
    if (tbl_Resultados.getSelectedRow() != -1) {
        try {
            int indexFilaSeleccionada = Utilidades.getSelectedRowModelIndice(tbl_Resultados);
            Cliente cliente = RestClient.getRestTemplate().getForObject("/clientes/" + clientes.get(indexFilaSeleccionada).getId_Cliente(), Cliente.class);
            if (cliente != null) {
                RestClient.getRestTemplate().put("/clientes/" + cliente.getId_Cliente() + "/predeterminado", null);
                btn_BuscarActionPerformed(evt);
            } else {
                JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_no_se_encontro_cliente_predeterminado"), "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);
        }
    } else {
        JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_seleccionar_cliente"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : RestClientResponseException(org.springframework.web.client.RestClientResponseException) Cliente(sic.modelo.Cliente) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 12 with RestClientResponseException

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

the class ClientesGUI method cargarComboBoxProvinciasDelPais.

public void cargarComboBoxProvinciasDelPais(Pais paisSeleccionado) {
    cmb_Provincia.removeAllItems();
    try {
        List<Provincia> provincias = new ArrayList(Arrays.asList(RestClient.getRestTemplate().getForObject("/provincias/paises/" + ((Pais) cmb_Pais.getSelectedItem()).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) Pais(sic.modelo.Pais) Provincia(sic.modelo.Provincia) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 13 with RestClientResponseException

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

the class CajasGUI method buscar.

private void buscar() {
    cambiarEstadoEnabled(false);
    pb_barra.setIndeterminate(true);
    SwingWorker<List<Caja>, Void> worker = new SwingWorker<List<Caja>, Void>() {

        @Override
        protected List<Caja> doInBackground() throws Exception {
            String criteria = "/cajas/busqueda/criteria?";
            if (chk_Fecha.isSelected()) {
                criteria += "desde=" + dc_FechaDesde.getDate().getTime() + "&hasta=" + dc_FechaHasta.getDate().getTime();
            }
            if (chk_Usuario.isSelected()) {
                criteria += "&idUsuario=" + ((Usuario) cmb_Usuarios.getSelectedItem()).getId_Usuario();
            }
            criteria += "&idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa();
            cajas = new ArrayList(Arrays.asList(RestClient.getRestTemplate().getForObject(criteria, Caja[].class)));
            cargarResultadosAlTable();
            cambiarEstadoEnabled(true);
            return cajas;
        }

        @Override
        protected void done() {
            pb_barra.setIndeterminate(false);
            try {
                if (get().isEmpty()) {
                    JOptionPane.showInternalMessageDialog(getParent(), ResourceBundle.getBundle("Mensajes").getString("mensaje_busqueda_sin_resultados"), "Aviso", JOptionPane.INFORMATION_MESSAGE);
                }
            } catch (InterruptedException ex) {
                String msjError = "La tarea que se estaba realizando fue interrumpida. Intente nuevamente.";
                LOGGER.error(msjError + " - " + ex.getMessage());
                JOptionPane.showInternalMessageDialog(getParent(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
            } catch (ExecutionException ex) {
                if (ex.getCause() instanceof RestClientResponseException) {
                    JOptionPane.showMessageDialog(getParent(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                } else if (ex.getCause() instanceof ResourceAccessException) {
                    LOGGER.error(ex.getMessage());
                    JOptionPane.showMessageDialog(getParent(), ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
                } else {
                    String msjError = "Se produjo un error en la ejecuciĆ³n de la tarea solicitada. Intente nuevamente.";
                    LOGGER.error(msjError + " - " + ex.getMessage());
                    JOptionPane.showInternalMessageDialog(getParent(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
                }
                cambiarEstadoEnabled(true);
            }
        }
    };
    worker.execute();
}
Also used : Usuario(sic.modelo.Usuario) ArrayList(java.util.ArrayList) SwingWorker(javax.swing.SwingWorker) Caja(sic.modelo.Caja) EstadoCaja(sic.modelo.EstadoCaja) ArrayList(java.util.ArrayList) List(java.util.List) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 14 with RestClientResponseException

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

the class CerrarVentaGUI method finalizarVenta.

private void finalizarVenta() {
    FacturaVenta facturaVenta = gui_puntoDeVenta.construirFactura();
    facturaVenta.setTransportista((Transportista) cmb_Transporte.getSelectedItem());
    facturaVenta = this.agregarPagosAFactura(facturaVenta);
    try {
        String uri = "/facturas?idPedido=";
        if (gui_puntoDeVenta.getPedido() != null) {
            uri += gui_puntoDeVenta.getPedido().getId_Pedido();
        }
        if (dividir) {
            String indices = "&indices=" + Arrays.toString(indicesParaDividir).substring(1, Arrays.toString(indicesParaDividir).length() - 1);
            List<Factura> facturasDivididas = Arrays.asList(RestClient.getRestTemplate().postForObject(uri + indices, facturaVenta, Factura[].class));
            int indice = facturasDivididas.size();
            for (int i = 0; i < indice; i++) {
                facturasDivididas.get(i).setRenglones(Arrays.asList(RestClient.getRestTemplate().getForObject("/facturas/" + facturasDivididas.get(i).getId_Factura() + "/renglones", RenglonFactura[].class)));
                if (facturasDivididas.size() == 2 && !facturasDivididas.get(i).getRenglones().isEmpty()) {
                    if (i == 0) {
                        this.lanzarReporteFactura(facturasDivididas.get(i), "ComprobanteX");
                    } else {
                        this.lanzarReporteFactura(facturasDivididas.get(i), "Factura");
                    }
                    exito = true;
                } else if (facturasDivididas.size() == 1 && !facturasDivididas.get(i).getRenglones().isEmpty()) {
                    this.lanzarReporteFactura(facturasDivididas.get(i), "Factura");
                }
            }
        } else {
            this.lanzarReporteFactura(Arrays.asList(RestClient.getRestTemplate().postForObject(uri, facturaVenta, FacturaVenta[].class)).get(0), "Factura");
            exito = true;
        }
        if (gui_puntoDeVenta.getPedido() != null) {
            gui_puntoDeVenta.dispose();
        }
        this.dispose();
    } 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 : FacturaVenta(sic.modelo.FacturaVenta) RenglonFactura(sic.modelo.RenglonFactura) Factura(sic.modelo.Factura) RenglonFactura(sic.modelo.RenglonFactura) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 15 with RestClientResponseException

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

the class DetalleFacturaCompraGUI method calcularResultados.

private void calcularResultados() {
    double subTotal;
    double descuento_porcentaje;
    double descuento_neto;
    double recargo_porcentaje;
    double recargo_neto;
    double subTotalBruto;
    double iva105_netoFactura;
    double iva21_netoFactura;
    double total;
    this.validarComponentesDeResultados();
    //subtotal        
    double[] importes = new double[renglones.size()];
    double[] cantidades = new double[renglones.size()];
    double[] ivaPorcentajeRenglones = new double[renglones.size()];
    double[] ivaNetoRenglones = new double[renglones.size()];
    int indice = 0;
    for (RenglonFactura renglon : renglones) {
        importes[indice] = renglon.getImporte();
        cantidades[indice] = renglon.getCantidad();
        ivaPorcentajeRenglones[indice] = renglon.getIva_porcentaje();
        ivaNetoRenglones[indice] = renglon.getIva_neto();
        indice++;
    }
    try {
        subTotal = RestClient.getRestTemplate().getForObject("/facturas/subtotal?importe=" + Arrays.toString(importes).substring(1, Arrays.toString(importes).length() - 1), double.class);
        txt_SubTotal.setValue(subTotal);
        //descuento
        descuento_porcentaje = Double.parseDouble(txt_Descuento_Porcentaje.getValue().toString());
        descuento_neto = RestClient.getRestTemplate().getForObject("/facturas/descuento-neto?subTotal=" + subTotal + "&descuentoPorcentaje=" + descuento_porcentaje, double.class);
        txt_Descuento_Neto.setValue(descuento_neto);
        //recargo
        recargo_porcentaje = Double.parseDouble(txt_Recargo_Porcentaje.getValue().toString());
        recargo_neto = RestClient.getRestTemplate().getForObject("/facturas/recargo-neto?" + "subTotal=" + subTotal + "&recargoPorcentaje=" + recargo_porcentaje, double.class);
        txt_Recargo_Neto.setValue(recargo_neto);
        //IVA 10,5% neto
        iva105_netoFactura = RestClient.getRestTemplate().getForObject("/facturas/iva-neto?" + "tipoDeComprobante=" + this.tipoDeComprobante.name() + "&cantidades=" + Arrays.toString(cantidades).substring(1, Arrays.toString(cantidades).length() - 1) + "&ivaPorcentajeRenglones=" + Arrays.toString(ivaPorcentajeRenglones).substring(1, Arrays.toString(ivaPorcentajeRenglones).length() - 1) + "&ivaNetoRenglones=" + Arrays.toString(ivaNetoRenglones).substring(1, Arrays.toString(ivaNetoRenglones).length() - 1) + "&ivaPorcentaje=10.5" + "&descuentoPorcentaje=" + descuento_porcentaje + "&recargoPorcentaje=" + recargo_porcentaje, double.class);
        txt_IVA_105.setValue(iva105_netoFactura);
        //IVA 21% neto
        iva21_netoFactura = RestClient.getRestTemplate().getForObject("/facturas/iva-neto?" + "tipoDeComprobante=" + this.tipoDeComprobante.name() + "&cantidades=" + Arrays.toString(cantidades).substring(1, Arrays.toString(cantidades).length() - 1) + "&ivaPorcentajeRenglones=" + Arrays.toString(ivaPorcentajeRenglones).substring(1, Arrays.toString(ivaPorcentajeRenglones).length() - 1) + "&ivaNetoRenglones=" + Arrays.toString(ivaNetoRenglones).substring(1, Arrays.toString(ivaNetoRenglones).length() - 1) + "&ivaPorcentaje=21" + "&descuentoPorcentaje=" + descuento_porcentaje + "&recargoPorcentaje=" + recargo_porcentaje, double.class);
        txt_IVA_21.setValue(iva21_netoFactura);
        //subtotal bruto
        subTotalBruto = RestClient.getRestTemplate().getForObject("/facturas/subtotal-bruto?" + "tipoDeComprobante=" + tipoDeComprobante.name() + "&subTotal=" + subTotal + "&recargoNeto=" + recargo_neto + "&descuentoNeto=" + descuento_neto + "&iva105Neto=" + iva105_netoFactura + "&iva21Neto=" + iva21_netoFactura, double.class);
        txt_SubTotal_Neto.setValue(subTotalBruto);
        //total
        total = RestClient.getRestTemplate().getForObject("/facturas/total?" + "subTotalBruto=" + subTotalBruto + "&iva105Neto=" + iva105_netoFactura + "&iva21Neto=" + iva21_netoFactura, double.class);
        txt_Total.setValue(total);
    } 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 : RenglonFactura(sic.modelo.RenglonFactura) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Point(java.awt.Point) 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