diff --git a/db/data.sql b/db/data.sql index f9f6375..648ffab 100644 --- a/db/data.sql +++ b/db/data.sql @@ -1,3 +1,8 @@ +start transaction; + +set foreign_key_checks = 0; +set autocommit = 0; + INSERT INTO `autor` VALUES (1, 'Howard Philips', 'Lovecraft', NULL, '2019-06-12 20:18:57'), (2, 'Stephen', 'King', NULL, '2019-06-12 20:18:57'), @@ -107,3 +112,8 @@ VALUES (4, 1), INSERT INTO `usuario` VALUES (2, 'admin', 0x243168097E0BA82B896F348BABCEB600A8DCA30488C6F238F97FD8737BD00B27, 0x3564ECCCD85CF0583F9C090602E998B7, 2, '2019-06-13 20:04:53'); + +set autocommit = 1; +set foreign_key_checks = 1; + +commit; \ No newline at end of file diff --git a/src/main/java/xyz/danielcortes/controllers/LaunchController.java b/src/main/java/xyz/danielcortes/controllers/LaunchController.java index 133cd65..5281b35 100644 --- a/src/main/java/xyz/danielcortes/controllers/LaunchController.java +++ b/src/main/java/xyz/danielcortes/controllers/LaunchController.java @@ -89,8 +89,10 @@ import xyz.danielcortes.controllers.trabajador.usuario.UsuarioUpdateController; import xyz.danielcortes.controllers.trabajador.usuario.UsuarioViewController; import xyz.danielcortes.controllers.vender.VenderSearchController; import xyz.danielcortes.controllers.vender.VenderVenderController; +import xyz.danielcortes.controllers.vender.VenderVerController; import xyz.danielcortes.framework.BaseController; import xyz.danielcortes.framework.PanelName; +import xyz.danielcortes.models.Trabajador; import xyz.danielcortes.models.Usuario; import xyz.danielcortes.views.LaunchFrame; import xyz.danielcortes.views.autor.AutorCreatePanel; @@ -152,6 +154,7 @@ import xyz.danielcortes.views.usuario.UsuarioUpdatePanel; import xyz.danielcortes.views.usuario.UsuarioViewPanel; import xyz.danielcortes.views.vender.VenderSearchPanel; import xyz.danielcortes.views.vender.VenderVenderPanel; +import xyz.danielcortes.views.vender.VenderVerPanel; /** * Controlador principal de la aplicacion @@ -311,6 +314,7 @@ public class LaunchController { this.controllers.put(PanelName.VENDER_SEARCH, new VenderSearchController(new VenderSearchPanel(), this)); this.controllers.put(PanelName.VENDER_VENDER, new VenderVenderController(new VenderVenderPanel(), this)); + this.controllers.put(PanelName.VENDER_VER, new VenderVerController(new VenderVerPanel(), this)); for (Entry entry : this.controllers.entrySet()) { this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey()); @@ -405,4 +409,8 @@ public class LaunchController { this.controllers.get(name).show(); } + public Trabajador getTrabajador() { + return this.user.getTrabajador(); + } + } diff --git a/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraAceptarController.java b/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraAceptarController.java index 80970e1..6d7c7af 100644 --- a/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraAceptarController.java +++ b/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraAceptarController.java @@ -112,13 +112,11 @@ public class OrdenCompraAceptarController extends BaseController { factura.setPrecioNeto(Integer.parseInt(precioNeto)); this.facturaRepository.save(factura); - for (Ejemplar ejemplar : ejemplares) { - this.ejemplarRepository.save(ejemplar); - } + this.ejemplarRepository.save(ejemplares); Compra compra = new Compra(); compra.setDistribuidor(this.ordenCompra.getDistribuidor()); - compra.getEjemplares().addAll(ejemplares); + compra.setEjemplares(ejemplares); compra.setFactura(factura); this.compraRepository.save(compra); diff --git a/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraSearchController.java b/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraSearchController.java index e918ad6..feb1827 100644 --- a/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraSearchController.java +++ b/src/main/java/xyz/danielcortes/controllers/orden_compra/OrdenCompraSearchController.java @@ -114,10 +114,10 @@ public class OrdenCompraSearchController extends BaseController { JOptionPane.ERROR_MESSAGE ); return; - } else if (ordenCompra.getEstado().equals("Aceptada")) { + } else if (ordenCompra.getEstado().equals("Recibida")) { JOptionPane.showMessageDialog( null, - "La orden ya fue aceptada", + "La orden ya fue recibida", "Error", JOptionPane.ERROR_MESSAGE ); diff --git a/src/main/java/xyz/danielcortes/controllers/vender/VenderSearchController.java b/src/main/java/xyz/danielcortes/controllers/vender/VenderSearchController.java index cee1885..57fea80 100644 --- a/src/main/java/xyz/danielcortes/controllers/vender/VenderSearchController.java +++ b/src/main/java/xyz/danielcortes/controllers/vender/VenderSearchController.java @@ -1,23 +1,24 @@ package xyz.danielcortes.controllers.vender; import java.util.List; +import javax.swing.JOptionPane; import xyz.danielcortes.controllers.LaunchController; import xyz.danielcortes.framework.BaseController; import xyz.danielcortes.framework.BasePanel; import xyz.danielcortes.framework.PanelName; import xyz.danielcortes.models.Venta; -import xyz.danielcortes.repository.VenderRepository; +import xyz.danielcortes.repository.VentaRepository; import xyz.danielcortes.views.vender.VenderSearchPanel; public class VenderSearchController extends BaseController { private VenderSearchPanel view; - private VenderRepository repository; + private VentaRepository repository; public VenderSearchController(VenderSearchPanel view, LaunchController parent) { super(parent); this.view = view; - this.repository = new VenderRepository(); + this.repository = new VentaRepository(); this.setupListeners(); } @@ -29,6 +30,9 @@ public class VenderSearchController extends BaseController { } private void search() { + String term = this.view.getBuscarField().getText(); + List ventas = this.repository.search(term); + this.loadTable(ventas); } private void vender() { @@ -36,6 +40,32 @@ public class VenderSearchController extends BaseController { } private void ver() { + Venta venta = this.getSelectedVenta(); + if (venta == null) + return; + + VenderVerController controller = (VenderVerController) this.parentController.getCard(PanelName.VENDER_VER); + controller.setVenta(venta); + this.parentController.showCard(PanelName.VENDER_VER); + } + + private void loadTable(List ventas) { + this.view.getVentaTableModel().setRows(ventas); + } + + private Venta getSelectedVenta() { + int selectedRow = this.view.getVentasTable().getSelectedRow(); + if (selectedRow == -1) { + JOptionPane.showMessageDialog( + null, + "No hay ninguna venta seleccionada", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return null; + } + + return this.view.getVentaTableModel().getRow(selectedRow); } @Override @@ -47,7 +77,7 @@ public class VenderSearchController extends BaseController { private void loadTable() { List ventas = this.repository.getAll(); - this.view.getVentaTableModel().setRows(ventas); + this.loadTable(ventas); } @Override diff --git a/src/main/java/xyz/danielcortes/controllers/vender/VenderVenderController.java b/src/main/java/xyz/danielcortes/controllers/vender/VenderVenderController.java index 0bc6025..efe98e5 100644 --- a/src/main/java/xyz/danielcortes/controllers/vender/VenderVenderController.java +++ b/src/main/java/xyz/danielcortes/controllers/vender/VenderVenderController.java @@ -1,38 +1,171 @@ package xyz.danielcortes.controllers.vender; +import java.time.LocalDate; import java.util.List; +import java.util.UUID; +import javax.swing.JOptionPane; import xyz.danielcortes.controllers.LaunchController; import xyz.danielcortes.framework.BaseController; import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.PanelName; +import xyz.danielcortes.framework.ValidationResult; +import xyz.danielcortes.models.Boleta; import xyz.danielcortes.models.Cliente; import xyz.danielcortes.models.Ejemplar; +import xyz.danielcortes.models.Estado; +import xyz.danielcortes.models.Trabajador; +import xyz.danielcortes.models.Venta; +import xyz.danielcortes.repository.BoletaRepository; import xyz.danielcortes.repository.ClienteRepository; import xyz.danielcortes.repository.EjemplarRepository; -import xyz.danielcortes.repository.VenderRepository; +import xyz.danielcortes.repository.EstadoRepository; +import xyz.danielcortes.repository.VentaRepository; +import xyz.danielcortes.validator.VentaValidator; import xyz.danielcortes.views.vender.VenderVenderPanel; public class VenderVenderController extends BaseController { private VenderVenderPanel view; - private VenderRepository venderRepository; + private VentaRepository ventaRepository; + private VentaValidator ventaValidator; private ClienteRepository clienteRepository; private EjemplarRepository ejemplarRepository; + private EstadoRepository estadoRepository; + private BoletaRepository boletaRepository; + + private float precioNeto; public VenderVenderController(VenderVenderPanel view, LaunchController parentController) { super(parentController); this.view = view; - this.venderRepository = new VenderRepository(); + this.ventaRepository = new VentaRepository(); + this.ventaValidator = new VentaValidator(); this.clienteRepository = new ClienteRepository(); this.ejemplarRepository = new EjemplarRepository(); + this.estadoRepository = new EstadoRepository(); + this.boletaRepository = new BoletaRepository(); this.setupListeners(); } private void setupListeners() { this.view.getAgregarButton().addActionListener(e -> this.agregar()); + this.view.getRemoverButton().addActionListener(e -> this.remover()); + this.view.getCancelarButton().addActionListener(e -> this.parentController.showCard(PanelName.VENDER_SEARCH)); + this.view.getVenderButton().addActionListener(e -> this.vender()); } private void agregar() { + if (this.view.getEjemplaresComboModel().getSize() == 0) { + JOptionPane.showMessageDialog( + null, + "No hay ningun ejemplar que agregar", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return; + } + Ejemplar ejemplar = (Ejemplar) this.view.getEjemplaresCombo().getSelectedItem(); + if (ejemplar == null) { + JOptionPane.showMessageDialog( + null, + "El ejemplar seleccionado es nulo, NO DEBERIA PASAR!!", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return; + } + this.view.getEjemplaresCombo().removeItem(ejemplar); + this.view.getEjemplaresTableModel().addRow(ejemplar); + this.updatePrice(); + } + + private void remover() { + if (this.view.getEjemplaresTableModel().getRowCount() == 0) { + JOptionPane.showMessageDialog( + null, + "No hay ningun ejemplar que remover", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return; + } + Ejemplar ejemplar = this.getSelectedEjemplar(); + if (ejemplar == null) + return; + + this.view.getEjemplaresCombo().addItem(ejemplar); + this.view.getEjemplaresTableModel().removeRow(ejemplar); + this.updatePrice(); + } + + private void vender() { + Cliente cliente = (Cliente) this.view.getClienteCombo().getSelectedItem(); + ValidationResult clienteValidation = this.ventaValidator.validateCliente(cliente); + if (clienteValidation.hasError()) { + clienteValidation.showErrorDialog(); + return; + } + + Trabajador trabajador = this.getParentController().getTrabajador(); + ValidationResult trabajadorValidation = this.ventaValidator.validateTrabajador(trabajador); + if (trabajadorValidation.hasError()) { + clienteValidation.showErrorDialog(); + return; + } + + List ejemplares = this.view.getEjemplaresTableModel().getRows(); + ValidationResult ejemplaresValidation = this.ventaValidator.validateEjemplares(ejemplares); + if (ejemplaresValidation.hasError()) { + ejemplaresValidation.showErrorDialog(); + return; + } + + Boleta boleta = new Boleta(); + boleta.setFolio(UUID.randomUUID().toString()); + boleta.setPrecioNeto((int) this.precioNeto); + boleta.setFechaEmision(LocalDate.now()); + this.boletaRepository.save(boleta); + + Venta venta = new Venta(); + venta.setCliente(cliente); + venta.setEjemplares(ejemplares); + venta.setTrabajador(trabajador); + venta.setBoleta(boleta); + this.ventaRepository.save(venta); + + Estado vendido = this.estadoRepository.getByNombre("Vendido"); + ejemplares.forEach(ejemplar -> ejemplar.setEstado(vendido)); + this.ejemplarRepository.update(ejemplares); + + this.parentController.showCard(PanelName.VENDER_SEARCH); + } + + private void updatePrice() { + this.precioNeto = (float) this.view.getEjemplaresTableModel().getRows().stream() + .mapToInt(ejemplar -> ejemplar.getLibro().getPrecioReferencia()) + .reduce((i, j) -> i + j).orElse(0); + float iva = this.precioNeto * .19f; + float precioBruto = this.precioNeto + iva; + + this.view.getPrecioNetoField().setText(String.valueOf(this.precioNeto)); + this.view.getIvaField().setText(String.valueOf(iva)); + this.view.getPrecioBrutoField().setText(String.valueOf(precioBruto)); + } + + private Ejemplar getSelectedEjemplar() { + int selectedRow = this.view.getEjemplaresTable().getSelectedRow(); + if (selectedRow == -1) { + JOptionPane.showMessageDialog( + null, + "No hay ningun ejemplar seleccionado", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return null; + } + + return this.view.getEjemplaresTableModel().getRow(selectedRow); } @Override @@ -40,18 +173,25 @@ public class VenderVenderController extends BaseController { this.fillCliente(); this.fillEjemplares(); this.view.getEjemplaresTableModel().removeRows(); + this.view.getPrecioNetoField().setText("0"); + this.view.getIvaField().setText("0"); + this.view.getPrecioBrutoField().setText("0"); + this.precioNeto = 0; } private void fillCliente() { List cliente = this.clienteRepository.getAll(); this.view.getClienteComboModel().removeAllElements(); this.view.getClienteComboModel().addAll(cliente); + this.view.getClienteCombo().setSelectedIndex(0); } private void fillEjemplares() { - List ejemplares = this.ejemplarRepository.getAll(); + Estado disponible = this.estadoRepository.getByNombre("Disponible"); + List ejemplares = this.ejemplarRepository.getByEstado(disponible); this.view.getEjemplaresComboModel().removeAllElements(); this.view.getEjemplaresComboModel().addAll(ejemplares); + this.view.getEjemplaresCombo().setSelectedIndex(0); } @Override diff --git a/src/main/java/xyz/danielcortes/controllers/vender/VenderVerController.java b/src/main/java/xyz/danielcortes/controllers/vender/VenderVerController.java index fd621f7..3207926 100644 --- a/src/main/java/xyz/danielcortes/controllers/vender/VenderVerController.java +++ b/src/main/java/xyz/danielcortes/controllers/vender/VenderVerController.java @@ -3,21 +3,49 @@ package xyz.danielcortes.controllers.vender; import xyz.danielcortes.controllers.LaunchController; import xyz.danielcortes.framework.BaseController; import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.PanelName; +import xyz.danielcortes.models.Venta; +import xyz.danielcortes.views.vender.VenderVerPanel; public class VenderVerController extends BaseController { + private VenderVerPanel view; + private Venta venta; - public VenderVerController(LaunchController parentController) { + public VenderVerController(VenderVerPanel view, LaunchController parentController) { super(parentController); + this.view = view; + this.setupListener(); + } + + private void setupListener() { + this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.VENDER_SEARCH)); } @Override public void show() { + if (this.venta != null) { + this.view.getEjemplaresTableModel().setRows(this.venta.getEjemplares()); + this.view.getClienteField().setText(this.venta.getCliente().getRut()); + this.view.getTrabajadorField().setText(this.venta.getTrabajador().getRut()); + this.view.getFolioField().setText(this.venta.getBoleta().getFolio()); + float precioNeto = this.venta.getBoleta().getPrecioNeto(); + float iva = precioNeto * .19f; + float precioTotal = precioNeto + iva; + + this.view.getPrecioNetoField().setText(String.valueOf(precioNeto)); + this.view.getIvaField().setText(String.valueOf(precioNeto)); + this.view.getPrecioTotalField().setText(String.valueOf(precioTotal)); + } } @Override public BasePanel getView() { - return null; + return this.view; + } + + public void setVenta(Venta venta) { + this.venta = venta; } } diff --git a/src/main/java/xyz/danielcortes/framework/BaseRepository.java b/src/main/java/xyz/danielcortes/framework/BaseRepository.java index 8b1638b..348efda 100644 --- a/src/main/java/xyz/danielcortes/framework/BaseRepository.java +++ b/src/main/java/xyz/danielcortes/framework/BaseRepository.java @@ -35,6 +35,19 @@ public abstract class BaseRepository { this.em.getTransaction().commit(); } + public void save(List entities) { + this.em.getTransaction().begin(); + + try { + entities.forEach(entity -> this.em.persist(entity)); + } catch (PersistenceException e) { + e.printStackTrace(); + this.em.getTransaction().rollback(); + } + + this.em.getTransaction().commit(); + } + public void update(E entity) { this.em.getTransaction().begin(); @@ -48,6 +61,19 @@ public abstract class BaseRepository { this.em.getTransaction().commit(); } + public void update(List entities) { + this.em.getTransaction().begin(); + + try { + entities.forEach(entity -> this.em.merge(entity)); + } catch (PersistenceException e) { + e.printStackTrace(); + this.em.getTransaction().rollback(); + } + + this.em.getTransaction().commit(); + } + public void delete(E entity) { this.em.getTransaction().begin(); @@ -61,6 +87,19 @@ public abstract class BaseRepository { this.em.getTransaction().commit(); } + public void delete(List entities) { + this.em.getTransaction().begin(); + + try { + entities.forEach(entity -> this.em.remove(entity)); + } catch (PersistenceException e) { + e.printStackTrace(); + this.em.getTransaction().rollback(); + } + + this.em.getTransaction().commit(); + } + public void delete(Collection entities) { this.em.getTransaction().begin(); diff --git a/src/main/java/xyz/danielcortes/framework/BaseTableModel.java b/src/main/java/xyz/danielcortes/framework/BaseTableModel.java index 96fd276..c79e3af 100644 --- a/src/main/java/xyz/danielcortes/framework/BaseTableModel.java +++ b/src/main/java/xyz/danielcortes/framework/BaseTableModel.java @@ -68,13 +68,14 @@ public class BaseTableModel extends AbstractTableModel { public void removeRow(T t) { int removed = this.rows.indexOf(t); - this.rows.remove(removed); - this.fireTableRowsDeleted(removed, removed); - + if (removed != -1) { + this.rows.remove(removed); + this.fireTableRowsDeleted(removed, removed); + } } public T getRow(int row) { - if (row > -1 || row < this.getRowCount()) { + if (row > -1 && row < this.getRowCount()) { return this.rows.get(row); } else { return null; diff --git a/src/main/java/xyz/danielcortes/framework/PanelName.java b/src/main/java/xyz/danielcortes/framework/PanelName.java index ded0214..f828362 100644 --- a/src/main/java/xyz/danielcortes/framework/PanelName.java +++ b/src/main/java/xyz/danielcortes/framework/PanelName.java @@ -106,6 +106,7 @@ public enum PanelName { VENDER_SEARCH, VENDER_VENDER, + VENDER_VER, ARRENDAR_SEARCH, ARRENDAR_ARRENDAR, diff --git a/src/main/java/xyz/danielcortes/models/Cliente.java b/src/main/java/xyz/danielcortes/models/Cliente.java index cab0444..4230943 100644 --- a/src/main/java/xyz/danielcortes/models/Cliente.java +++ b/src/main/java/xyz/danielcortes/models/Cliente.java @@ -135,4 +135,13 @@ public class Cliente { public void setVentas(List ventas) { this.ventas = ventas; } + + @Override + public String toString() { + return this.rut + " - " + this.getNombreCompleto(); + } + + public String getNombreCompleto() { + return this.nombre + " " + this.apellidoPaterno + " " + this.apellidoMaterno; + } } diff --git a/src/main/java/xyz/danielcortes/models/Ejemplar.java b/src/main/java/xyz/danielcortes/models/Ejemplar.java index b1ef20f..764342c 100644 --- a/src/main/java/xyz/danielcortes/models/Ejemplar.java +++ b/src/main/java/xyz/danielcortes/models/Ejemplar.java @@ -106,6 +106,6 @@ public class Ejemplar { @Override public String toString() { - return this.serie + " " + this.estado.getNombre(); + return this.serie + " " + this.libro.getIsbn() + " " + this.libro.getTitulo(); } } diff --git a/src/main/java/xyz/danielcortes/repository/BoletaRepository.java b/src/main/java/xyz/danielcortes/repository/BoletaRepository.java new file mode 100644 index 0000000..3021d68 --- /dev/null +++ b/src/main/java/xyz/danielcortes/repository/BoletaRepository.java @@ -0,0 +1,11 @@ +package xyz.danielcortes.repository; + +import xyz.danielcortes.framework.BaseRepository; +import xyz.danielcortes.models.Boleta; + +public class BoletaRepository extends BaseRepository { + + public BoletaRepository() { + super(Boleta.class); + } +} diff --git a/src/main/java/xyz/danielcortes/repository/EjemplarRepository.java b/src/main/java/xyz/danielcortes/repository/EjemplarRepository.java index 646a74b..ba9fdd0 100644 --- a/src/main/java/xyz/danielcortes/repository/EjemplarRepository.java +++ b/src/main/java/xyz/danielcortes/repository/EjemplarRepository.java @@ -2,11 +2,13 @@ package xyz.danielcortes.repository; import java.util.List; import javax.persistence.Query; +import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import xyz.danielcortes.framework.BaseRepository; import xyz.danielcortes.models.Ejemplar; +import xyz.danielcortes.models.Estado; public class EjemplarRepository extends BaseRepository { @@ -33,4 +35,10 @@ public class EjemplarRepository extends BaseRepository { query.setParameter("libro_id", libroId); return (Long) query.getResultList().get(0) == 1; } + + public List getByEstado(Estado estado) { + TypedQuery query = this.em.createQuery("SELECT e FROM Ejemplar e WHERE e.estado.id = :estado_id", Ejemplar.class); + query.setParameter("estado_id", estado.getId()); + return query.getResultList(); + } } diff --git a/src/main/java/xyz/danielcortes/repository/VenderRepository.java b/src/main/java/xyz/danielcortes/repository/VenderRepository.java deleted file mode 100644 index 88242b3..0000000 --- a/src/main/java/xyz/danielcortes/repository/VenderRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.danielcortes.repository; - -import xyz.danielcortes.framework.BaseRepository; -import xyz.danielcortes.models.Venta; - -public class VenderRepository extends BaseRepository { - - public VenderRepository() { - super(Venta.class); - } - - -} diff --git a/src/main/java/xyz/danielcortes/repository/VentaRepository.java b/src/main/java/xyz/danielcortes/repository/VentaRepository.java new file mode 100644 index 0000000..bce198c --- /dev/null +++ b/src/main/java/xyz/danielcortes/repository/VentaRepository.java @@ -0,0 +1,26 @@ +package xyz.danielcortes.repository; + +import java.util.List; +import javax.persistence.TypedQuery; +import xyz.danielcortes.framework.BaseRepository; +import xyz.danielcortes.models.Venta; + +public class VentaRepository extends BaseRepository { + + public VentaRepository() { + super(Venta.class); + } + + public List search(String term) { + TypedQuery query = this.em.createQuery( + "SELECT o FROM Venta o WHERE" + + " CONCAT(o.boleta.fechaEmision, '') LIKE :term OR" + + " LOWER(o.boleta.folio) LIKE :term OR " + + " CONCAT(o.ejemplares.size, '') LIKE :term OR " + + " LOWER(o.trabajador.rut) LIKE :term OR " + + " LOWER(o.cliente.rut) LIKE :term", + Venta.class); + query.setParameter("term", "%" + term.toLowerCase() + "%"); + return query.getResultList(); + } +} diff --git a/src/main/java/xyz/danielcortes/validator/VentaValidator.java b/src/main/java/xyz/danielcortes/validator/VentaValidator.java new file mode 100644 index 0000000..d8935ec --- /dev/null +++ b/src/main/java/xyz/danielcortes/validator/VentaValidator.java @@ -0,0 +1,40 @@ +package xyz.danielcortes.validator; + +import java.util.List; +import xyz.danielcortes.framework.ValidationResult; +import xyz.danielcortes.models.Cliente; +import xyz.danielcortes.models.Ejemplar; +import xyz.danielcortes.models.Trabajador; + +public class VentaValidator { + + public ValidationResult validateCliente(Cliente cliente) { + if (cliente == null) { + return new ValidationResult("No hay cliente"); + } + + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateTrabajador(Trabajador trabajador) { + if (trabajador == null) { + return new ValidationResult("No hay trabajador, no deberia pasar!!!"); + } + + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateEjemplares(List ejemplares) { + if (ejemplares == null) { + return new ValidationResult("No hay ejemplares, no deberia pasar!!!"); + } + if (ejemplares.size() == 0) { + return new ValidationResult("No hay ejemplares"); + } + if (ejemplares.stream().anyMatch(ejemplar -> !ejemplar.getEstado().getNombre().equals("Disponible"))) { + return new ValidationResult("Por alguna razon hay un ejemplar no disponible, NO DEBERIA PASAR TAMPOCO!"); + } + + return ValidationResult.NON_ERROR; + } +} diff --git a/src/main/java/xyz/danielcortes/views/libro/LibroSearchPanel.java b/src/main/java/xyz/danielcortes/views/libro/LibroSearchPanel.java index c9a9aba..9d87cdc 100644 --- a/src/main/java/xyz/danielcortes/views/libro/LibroSearchPanel.java +++ b/src/main/java/xyz/danielcortes/views/libro/LibroSearchPanel.java @@ -139,7 +139,7 @@ public class LibroSearchPanel extends BasePanel { case 0: return rows.get(rowIndex).getIsbn(); case 1: return rows.get(rowIndex).getTitulo(); case 2: return rows.get(rowIndex).getPrecioReferencia(); - case 3: return rows.get(rowIndex).getEjemplares().size(); + case 3: return rows.get(rowIndex).getEjemplares().stream().filter(ejemplar -> ejemplar.getEstado().getNombre().equals("Disponible")).count(); default: return null; } } diff --git a/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.form b/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.form index d2d3b94..99050e2 100644 --- a/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.form +++ b/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.form @@ -1,6 +1,6 @@
- + @@ -11,7 +11,7 @@ - + @@ -40,17 +40,17 @@ - + - + - + @@ -74,7 +74,7 @@ - + @@ -106,6 +106,16 @@ + + + + + + + + + + @@ -117,50 +127,14 @@ - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + @@ -170,15 +144,23 @@ - + + + + + + + + + - + - + @@ -188,6 +170,16 @@ + + + + + + + + + + diff --git a/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.java b/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.java index 60558a2..12ef210 100644 --- a/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.java +++ b/src/main/java/xyz/danielcortes/views/vender/VenderVenderPanel.java @@ -32,10 +32,10 @@ public class VenderVenderPanel extends BasePanel { private JComboBox ejemplaresCombo; private DefaultComboBoxModel ejemplaresComboModel; private JButton agregarButton; - private JTextField precioTotalField; + private JTextField precioBrutoField; private JTextField precioNetoField; private JTextField ivaField; - private JTextField folioField; + private JButton removerButton; { // GUI initializer generated by IntelliJ IDEA GUI Designer @@ -61,11 +61,11 @@ public class VenderVenderPanel extends BasePanel { return this.ejemplaresTable; } - public JComboBox getClienteCombo() { + public JComboBox getClienteCombo() { return this.clienteCombo; } - public JComboBox getEjemplaresCombo() { + public JComboBox getEjemplaresCombo() { return this.ejemplaresCombo; } @@ -73,8 +73,8 @@ public class VenderVenderPanel extends BasePanel { return this.agregarButton; } - public JTextField getPrecioTotalField() { - return this.precioTotalField; + public JTextField getPrecioBrutoField() { + return this.precioBrutoField; } public JTextField getPrecioNetoField() { @@ -85,8 +85,8 @@ public class VenderVenderPanel extends BasePanel { return this.ivaField; } - public JTextField getFolioField() { - return this.folioField; + public JButton getRemoverButton() { + return this.removerButton; } public BaseTableModel getEjemplaresTableModel() { @@ -109,10 +109,10 @@ public class VenderVenderPanel extends BasePanel { private void $$$setupUI$$$() { createUIComponents(); contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(14, 3, new Insets(20, 20, 20, 20), -1, -1)); + contentPane.setLayout(new GridLayoutManager(12, 3, new Insets(20, 20, 20, 20), -1, -1)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - contentPane.add(panel1, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + contentPane.add(panel1, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); venderButton = new JButton(); @@ -127,15 +127,15 @@ public class VenderVenderPanel extends BasePanel { null, 0, false)); final Spacer spacer1 = new Spacer(); contentPane.add(spacer1, - new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); contentPane.add(spacer2, - new GridConstraints(13, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, + new GridConstraints(11, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final Spacer spacer3 = new Spacer(); contentPane.add(spacer3, - new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, + new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Cliente:"); @@ -147,7 +147,7 @@ public class VenderVenderPanel extends BasePanel { GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); scrollPane1.setViewportView(ejemplaresTable); final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); contentPane.add(panel2, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); @@ -163,44 +163,40 @@ public class VenderVenderPanel extends BasePanel { panel2.add(agregarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(30, -1), null, 0, false)); + removerButton = new JButton(); + removerButton.setText("-"); + panel2.add(removerButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(30, -1), + null, 0, false)); contentPane.add(clienteCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); final JLabel label3 = new JLabel(); - label3.setText("Precio Total:"); - contentPane.add(label3, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + label3.setText("Precio Bruto:"); + contentPane.add(label3, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - precioTotalField = new JTextField(); - precioTotalField.setEditable(false); - contentPane.add(precioTotalField, - new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + precioBrutoField = new JTextField(); + precioBrutoField.setEditable(false); + contentPane.add(precioBrutoField, + new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); final JLabel label4 = new JLabel(); label4.setText("IVA:"); - contentPane.add(label4, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label4, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label5 = new JLabel(); label5.setText("Precio Neto:"); - contentPane.add(label5, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label5, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); precioNetoField = new JTextField(); precioNetoField.setEditable(false); contentPane.add(precioNetoField, - new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); ivaField = new JTextField(); ivaField.setEditable(false); contentPane.add(ivaField, - new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, - GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); - final JLabel label6 = new JLabel(); - label6.setText("Folio:"); - contentPane.add(label6, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, - GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - folioField = new JTextField(); - folioField.setEditable(false); - contentPane.add(folioField, - new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); } @@ -213,12 +209,13 @@ public class VenderVenderPanel extends BasePanel { // @formatter:off this.ejemplaresTableModel = new BaseTableModel<>( - new String[]{"ISBN", "Serie", "Titulo"}, + new String[]{"ISBN", "Serie", "Titulo", "Precio"}, (row, rowIndex, colIndex) -> { switch (colIndex) { case 0: return row.get(rowIndex).getLibro().getIsbn(); case 1: return row.get(rowIndex).getSerie(); case 2: return row.get(rowIndex).getLibro().getTitulo(); + case 3: return row.get(rowIndex).getLibro().getPrecioReferencia(); default: return null; } } diff --git a/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.form b/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.form index 3f932e4..d822546 100644 --- a/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.form +++ b/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.form @@ -1,6 +1,6 @@
- + @@ -11,7 +11,7 @@ - + @@ -30,17 +30,17 @@ - + - + - + @@ -53,7 +53,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -84,7 +84,7 @@ - + @@ -92,23 +92,13 @@ - + - - - - - - - - - - @@ -118,9 +108,19 @@ + + + + + + + + + + - + @@ -128,7 +128,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -152,6 +152,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.java b/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.java index e4c4fbe..0d49d02 100644 --- a/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.java +++ b/src/main/java/xyz/danielcortes/views/vender/VenderVerPanel.java @@ -20,16 +20,15 @@ import xyz.danielcortes.models.Ejemplar; public class VenderVerPanel extends BasePanel { private JPanel contentPane; - private JButton venderButton; private JButton volverButton; private JTable ejemplaresTable; private BaseTableModel ejemplaresTableModel; - private JButton agregarButton; private JTextField precioTotalField; private JTextField precioNetoField; private JTextField ivaField; private JTextField folioField; private JTextField clienteField; + private JTextField trabajadorField; { // GUI initializer generated by IntelliJ IDEA GUI Designer @@ -43,10 +42,6 @@ public class VenderVerPanel extends BasePanel { return this.contentPane; } - public JButton getVenderButton() { - return this.venderButton; - } - public JButton getVolverButton() { return this.volverButton; } @@ -55,8 +50,8 @@ public class VenderVerPanel extends BasePanel { return this.ejemplaresTable; } - public JButton getAgregarButton() { - return this.agregarButton; + public BaseTableModel getEjemplaresTableModel() { + return this.ejemplaresTableModel; } public JTextField getPrecioTotalField() { @@ -79,6 +74,10 @@ public class VenderVerPanel extends BasePanel { return this.clienteField; } + public JTextField getTrabajadorField() { + return this.trabajadorField; + } + /** * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code! * @@ -87,10 +86,10 @@ public class VenderVerPanel extends BasePanel { private void $$$setupUI$$$() { createUIComponents(); contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(14, 3, new Insets(20, 20, 20, 20), -1, -1)); + contentPane.setLayout(new GridLayoutManager(16, 3, new Insets(20, 20, 20, 20), -1, -1)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - contentPane.add(panel1, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + contentPane.add(panel1, new GridConstraints(14, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); volverButton = new JButton(); @@ -100,69 +99,78 @@ public class VenderVerPanel extends BasePanel { null, 0, false)); final Spacer spacer1 = new Spacer(); contentPane.add(spacer1, - new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new GridConstraints(15, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); contentPane.add(spacer2, - new GridConstraints(13, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, + new GridConstraints(15, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final Spacer spacer3 = new Spacer(); contentPane.add(spacer3, - new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, + new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Cliente:"); contentPane.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JScrollPane scrollPane1 = new JScrollPane(); - contentPane.add(scrollPane1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + contentPane.add(scrollPane1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); scrollPane1.setViewportView(ejemplaresTable); final JLabel label2 = new JLabel(); label2.setText("Precio Total:"); - contentPane.add(label2, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label2, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); precioTotalField = new JTextField(); precioTotalField.setEditable(false); contentPane.add(precioTotalField, - new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); final JLabel label3 = new JLabel(); label3.setText("IVA:"); - contentPane.add(label3, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label3, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label4 = new JLabel(); label4.setText("Precio Neto:"); - contentPane.add(label4, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label4, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); precioNetoField = new JTextField(); precioNetoField.setEditable(false); contentPane.add(precioNetoField, - new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); ivaField = new JTextField(); ivaField.setEditable(false); contentPane.add(ivaField, - new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); final JLabel label5 = new JLabel(); label5.setText("Folio:"); - contentPane.add(label5, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label5, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); folioField = new JTextField(); folioField.setEditable(false); contentPane.add(folioField, - new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); final JLabel label6 = new JLabel(); label6.setText("Ejemplares:"); - contentPane.add(label6, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + contentPane.add(label6, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); clienteField = new JTextField(); contentPane.add(clienteField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("Trabajador:"); + contentPane.add(label7, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + trabajadorField = new JTextField(); + trabajadorField.setEditable(false); + contentPane.add(trabajadorField, + new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); } private void createUIComponents() {