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