Search in sources :

Example 1 with Medida

use of sic.modelo.Medida in project sic by belluccifranco.

the class MedidaServiceImplTest method shouldValidarOperacionWhenNombreVacio.

@Test
public void shouldValidarOperacionWhenNombreVacio() {
    thrown.expect(BusinessServiceException.class);
    thrown.expectMessage(ResourceBundle.getBundle("Mensajes").getString("mensaje_medida_vacio_nombre"));
    Medida medidaParaTest = new MedidaBuilder().build();
    Medida medida = new MedidaBuilder().build();
    when(medidaRepository.findByNombreAndEmpresaAndEliminada("", medida.getEmpresa(), false)).thenReturn(medidaParaTest);
    medida.setNombre("");
    medidaService.validarOperacion(TipoDeOperacion.ALTA, medida);
}
Also used : Medida(sic.modelo.Medida) MedidaBuilder(sic.builder.MedidaBuilder) Test(org.junit.Test)

Example 2 with Medida

use of sic.modelo.Medida in project sic by belluccifranco.

the class MedidaServiceImpl method eliminar.

@Override
@Transactional
public void eliminar(long idMedida) {
    Medida medida = this.getMedidaPorId(idMedida);
    if (medida == null) {
        throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_medida_no_existente"));
    }
    medida.setEliminada(true);
    medidaRepository.save(medida);
}
Also used : Medida(sic.modelo.Medida) EntityNotFoundException(javax.persistence.EntityNotFoundException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Medida

use of sic.modelo.Medida in project sic by belluccifranco.

the class ModificacionProductosBulkGUI method btn_GuardarActionPerformed.

// GEN-LAST:event_btn_MedidasActionPerformed
private void btn_GuardarActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_btn_GuardarActionPerformed
    boolean checkPrecios = false;
    boolean checkMedida = false;
    boolean checkRubro = false;
    boolean checkProveedor = false;
    Medida medida = new Medida();
    Rubro rubro = new Rubro();
    Proveedor proveedor = new Proveedor();
    String preciosProducto = "";
    if (chk_Precios.isSelected() == true) {
        checkPrecios = true;
        preciosProducto = "&precioCosto=" + Double.parseDouble(txt_PrecioCosto.getValue().toString()) + "&gananciaPorcentaje=" + Double.parseDouble(txt_Ganancia_Porcentaje.getValue().toString()) + "&gananciaNeto=" + Double.parseDouble(txt_Ganancia_Neto.getValue().toString()) + "&precioVentaPublico=" + Double.parseDouble(txt_PVP.getValue().toString()) + "&IVAPorcentaje=" + Double.parseDouble(cmb_IVA_Porcentaje.getSelectedItem().toString()) + "&IVANeto=" + Double.parseDouble(txt_IVA_Neto.getValue().toString()) + "&precioLista=" + Double.parseDouble(txt_PrecioLista.getValue().toString());
    }
    if (chk_UnidadDeMedida.isSelected() == true) {
        checkMedida = true;
        medida = (Medida) cmb_Medida.getSelectedItem();
    }
    if (chk_Rubro.isSelected() == true) {
        checkRubro = true;
        rubro = (Rubro) cmb_Rubro.getSelectedItem();
    }
    if (chk_Proveedor.isSelected() == true) {
        checkProveedor = true;
        proveedor = (Proveedor) cmb_Proveedor.getSelectedItem();
    }
    try {
        long[] idsProductos = new long[productosParaModificar.size()];
        int i = 0;
        for (Producto producto : productosParaModificar) {
            idsProductos[i] = producto.getId_Producto();
            i++;
        }
        String uri = "/productos/multiples?idProducto=" + Arrays.toString(idsProductos).substring(1, Arrays.toString(idsProductos).length() - 1);
        if (checkMedida) {
            uri += "&idMedida=" + medida.getId_Medida();
        }
        if (checkRubro) {
            uri += "&idRubro=" + rubro.getId_Rubro();
        }
        if (checkProveedor) {
            uri += "&idProveedor=" + proveedor.getId_Proveedor();
        }
        if (checkPrecios) {
            uri = uri.concat(preciosProducto);
        }
        RestClient.getRestTemplate().put(uri, null);
        JOptionPane.showMessageDialog(this, "Los productos se modificaron correctamente.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
        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 : Rubro(sic.modelo.Rubro) Producto(sic.modelo.Producto) Proveedor(sic.modelo.Proveedor) Medida(sic.modelo.Medida) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 4 with Medida

use of sic.modelo.Medida in project sic by belluccifranco.

the class DetalleMedidaGUI method btn_AgregarActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void btn_AgregarActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_btn_AgregarActionPerformed
    try {
        Medida medida = new Medida();
        medida.setNombre(txt_Nuevo.getText().trim());
        medida.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
        RestClient.getRestTemplate().postForObject("/medidas", medida, Medida.class);
        txt_Nuevo.setText("");
        this.cargarListMedidas();
    } 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 : Medida(sic.modelo.Medida) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 5 with Medida

use of sic.modelo.Medida in project sic by belluccifranco.

the class DetalleMedidaGUI method btn_ActualizarActionPerformed.

// GEN-LAST:event_lst_MedidasValueChanged
private void btn_ActualizarActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_btn_ActualizarActionPerformed
    try {
        if (medidaSeleccionada == null) {
            JOptionPane.showMessageDialog(this, "Seleccione una medida de la lista para poder continuar", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            Medida medidaModificada = new Medida();
            medidaModificada.setId_Medida(medidaSeleccionada.getId_Medida());
            medidaModificada.setNombre(txt_ModicaElimina.getText().trim());
            medidaModificada.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
            RestClient.getRestTemplate().put("/medidas", medidaModificada);
            txt_ModicaElimina.setText("");
            medidaSeleccionada = null;
            this.cargarListMedidas();
        }
    } 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 : Medida(sic.modelo.Medida) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Aggregations

Medida (sic.modelo.Medida)12 Test (org.junit.Test)7 MedidaBuilder (sic.builder.MedidaBuilder)6 Producto (sic.modelo.Producto)5 Proveedor (sic.modelo.Proveedor)5 Rubro (sic.modelo.Rubro)5 ArrayList (java.util.ArrayList)4 ClienteBuilder (sic.builder.ClienteBuilder)4 EmpresaBuilder (sic.builder.EmpresaBuilder)4 TransportistaBuilder (sic.builder.TransportistaBuilder)4 FacturaVenta (sic.modelo.FacturaVenta)4 RenglonFactura (sic.modelo.RenglonFactura)4 Usuario (sic.modelo.Usuario)4 Date (java.util.Date)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ResourceAccessException (org.springframework.web.client.ResourceAccessException)3 RestClientResponseException (org.springframework.web.client.RestClientResponseException)3 CondicionIVABuilder (sic.builder.CondicionIVABuilder)3 FormaDePagoBuilder (sic.builder.FormaDePagoBuilder)3 LocalidadBuilder (sic.builder.LocalidadBuilder)3