Creo que ya deje las ordenes listas
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#Cosas que quiero arreglar, pero no podre
|
||||
#Cosas que quiero arreglar, pero no podre :c
|
||||
|
||||
## Validaciones
|
||||
|
||||
|
||||
25
create.sql
25
create.sql
@@ -38,6 +38,7 @@ drop table if exists boleta;
|
||||
drop table if exists compra;
|
||||
drop table if exists venta;
|
||||
drop table if exists arriendo;
|
||||
drop table if exists libro_orden_compra;
|
||||
drop table if exists ejemplar_compra;
|
||||
drop table if exists ejemplar_venta;
|
||||
drop table if exists ejemplar_arriendo;
|
||||
@@ -275,22 +276,20 @@ create table trabajador_correo
|
||||
|
||||
create table factura
|
||||
(
|
||||
id int unsigned primary key auto_increment,
|
||||
folio varchar(255) not null,
|
||||
precio_neto int not null,
|
||||
precio_iva int not null,
|
||||
fecha_compra datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
id int unsigned primary key auto_increment,
|
||||
folio varchar(255) not null,
|
||||
precio_neto int not null,
|
||||
fecha_emision datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table boleta
|
||||
(
|
||||
id int unsigned primary key auto_increment,
|
||||
folio varchar(255) not null,
|
||||
precio_neto int not null,
|
||||
precio_iva int not null,
|
||||
fecha_venta datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
id int unsigned primary key auto_increment,
|
||||
folio varchar(255) not null,
|
||||
precio_neto int not null,
|
||||
fecha_emision datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table orden_compra
|
||||
@@ -311,7 +310,7 @@ create table compra
|
||||
distribuidor_id int unsigned not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP,
|
||||
foreign key (factura_id) references factura (id) on delete restrict on update cascade,
|
||||
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade
|
||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade
|
||||
);
|
||||
|
||||
create table venta
|
||||
|
||||
@@ -63,8 +63,10 @@ import xyz.danielcortes.controllers.libro.LibroSearchController;
|
||||
import xyz.danielcortes.controllers.libro.LibroUpdateController;
|
||||
import xyz.danielcortes.controllers.libro.LibroViewController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraAceptarController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraAsignarController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraCrearController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraSearchController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraViewAceptedController;
|
||||
import xyz.danielcortes.controllers.orden_compra.OrdenCompraViewController;
|
||||
import xyz.danielcortes.controllers.trabajador.TrabajadorCreateController;
|
||||
import xyz.danielcortes.controllers.trabajador.TrabajadorSearchController;
|
||||
@@ -130,8 +132,10 @@ import xyz.danielcortes.views.libro.LibroSearchPanel;
|
||||
import xyz.danielcortes.views.libro.LibroUpdatePanel;
|
||||
import xyz.danielcortes.views.libro.LibroViewPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraAceptarPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraAsignarPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraCrearPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraSearchPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraViewAceptedPanel;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraViewPanel;
|
||||
import xyz.danielcortes.views.telefono.TelefonoCreatePanel;
|
||||
import xyz.danielcortes.views.telefono.TelefonoSearchPanel;
|
||||
@@ -297,7 +301,9 @@ public class LaunchController {
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_SEARCH, new OrdenCompraSearchController(new OrdenCompraSearchPanel(), this));
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_CREAR, new OrdenCompraCrearController(new OrdenCompraCrearPanel(), this));
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_VIEW, new OrdenCompraViewController(new OrdenCompraViewPanel(), this));
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_VIEW_ACEPTED, new OrdenCompraViewAceptedController(new OrdenCompraViewAceptedPanel(), this));
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_ACEPTAR, new OrdenCompraAceptarController(new OrdenCompraAceptarPanel(), this));
|
||||
this.controllers.put(PanelName.ORDEN_COMPRA_ASIGNAR, new OrdenCompraAsignarController(new OrdenCompraAsignarPanel(), this));
|
||||
|
||||
for (Entry<PanelName, BaseController> entry : this.controllers.entrySet()) {
|
||||
this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey());
|
||||
|
||||
@@ -1,28 +1,57 @@
|
||||
package xyz.danielcortes.controllers.orden_compra;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import xyz.danielcortes.controllers.LaunchController;
|
||||
import xyz.danielcortes.framework.BaseController;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
import xyz.danielcortes.framework.ChangeListener;
|
||||
import xyz.danielcortes.framework.PanelName;
|
||||
import xyz.danielcortes.framework.ValidationResult;
|
||||
import xyz.danielcortes.models.Compra;
|
||||
import xyz.danielcortes.models.Ejemplar;
|
||||
import xyz.danielcortes.models.Factura;
|
||||
import xyz.danielcortes.models.OrdenCompra;
|
||||
import xyz.danielcortes.repository.CompraRepository;
|
||||
import xyz.danielcortes.repository.EjemplarRepository;
|
||||
import xyz.danielcortes.repository.FacturaRepository;
|
||||
import xyz.danielcortes.repository.OrdenCompraRepository;
|
||||
import xyz.danielcortes.validator.CompraValidator;
|
||||
import xyz.danielcortes.validator.EjemplarValidator;
|
||||
import xyz.danielcortes.validator.FacturaValidator;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraAceptarPanel;
|
||||
|
||||
public class OrdenCompraAceptarController extends BaseController {
|
||||
|
||||
private OrdenCompraAceptarPanel view;
|
||||
private OrdenCompra ordenCompra;
|
||||
private CompraRepository compraRepository;
|
||||
private CompraValidator compraValidator;
|
||||
private EjemplarRepository ejemplarRepository;
|
||||
private EjemplarValidator ejemplarValidator;
|
||||
private FacturaRepository facturaRepository;
|
||||
private FacturaValidator facturaValidator;
|
||||
private OrdenCompraRepository ordenCompraRepository;
|
||||
|
||||
|
||||
public OrdenCompraAceptarController(OrdenCompraAceptarPanel view, LaunchController parent) {
|
||||
super(parent);
|
||||
this.view = view;
|
||||
this.compraRepository = new CompraRepository();
|
||||
this.compraValidator = new CompraValidator(this.compraRepository);
|
||||
this.ejemplarRepository = new EjemplarRepository();
|
||||
this.ejemplarValidator = new EjemplarValidator(this.ejemplarRepository);
|
||||
this.facturaRepository = new FacturaRepository();
|
||||
this.facturaValidator = new FacturaValidator(this.facturaRepository);
|
||||
this.ordenCompraRepository = new OrdenCompraRepository();
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH));
|
||||
this.view.getPrecioNetoField().getDocument().addDocumentListener((ChangeListener) e -> this.calculatePrice());
|
||||
this.view.getAsignarButton().addActionListener(e -> this.asignar());
|
||||
this.view.getGuardarButton().addActionListener(e -> this.save());
|
||||
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||
}
|
||||
|
||||
private void calculatePrice() {
|
||||
@@ -38,6 +67,76 @@ public class OrdenCompraAceptarController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
private void asignar() {
|
||||
OrdenCompraAsignarController controller = (OrdenCompraAsignarController) this.parentController.getCard(PanelName.ORDEN_COMPRA_ASIGNAR);
|
||||
controller.setOrdenCompra(this.ordenCompra);
|
||||
this.getParentController().showCard(PanelName.ORDEN_COMPRA_ASIGNAR);
|
||||
}
|
||||
|
||||
private void save() {
|
||||
OrdenCompraAsignarController controller = (OrdenCompraAsignarController) this.parentController.getCard(PanelName.ORDEN_COMPRA_ASIGNAR);
|
||||
List<Ejemplar> ejemplares = controller.getEjemplares();
|
||||
for (Ejemplar ejemplar : ejemplares) {
|
||||
ValidationResult serieValidation = this.ejemplarValidator.validateSerie(ejemplar, ejemplares);
|
||||
if (serieValidation.hasError()) {
|
||||
serieValidation.showErrorDialog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String folio = this.view.getFolioField().getText();
|
||||
ValidationResult folioValidation = this.facturaValidator.validateFolio(folio);
|
||||
if (folioValidation.hasError()) {
|
||||
folioValidation.showErrorDialog();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String precioNeto = this.view.getPrecioNetoField().getText();
|
||||
ValidationResult precioNetoValidation = this.facturaValidator.validatePrecio(precioNeto);
|
||||
if (precioNetoValidation.hasError()) {
|
||||
precioNetoValidation.showErrorDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
LocalDate fechaEmision = this.view.getFechaEmisionPicker().getDate();
|
||||
ValidationResult fechaEmisionValidation = this.facturaValidator.validateFechaEmision(fechaEmision);
|
||||
if (fechaEmisionValidation.hasError()) {
|
||||
fechaEmisionValidation.showErrorDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
Factura factura = new Factura();
|
||||
factura.setFechaEmision(fechaEmision);
|
||||
factura.setFolio(folio);
|
||||
factura.setPrecioNeto(Integer.parseInt(precioNeto));
|
||||
this.facturaRepository.save(factura);
|
||||
|
||||
for (Ejemplar ejemplar : ejemplares) {
|
||||
this.ejemplarRepository.save(ejemplar);
|
||||
}
|
||||
|
||||
Compra compra = new Compra();
|
||||
compra.setDistribuidor(this.ordenCompra.getDistribuidor());
|
||||
compra.getEjemplares().addAll(ejemplares);
|
||||
compra.setFactura(factura);
|
||||
this.compraRepository.save(compra);
|
||||
|
||||
this.ordenCompra.setEstado("Aceptada");
|
||||
this.ordenCompra.setCompra(compra);
|
||||
this.ordenCompraRepository.update(this.ordenCompra);
|
||||
|
||||
controller.setEjemplares(null);
|
||||
this.getParentController().showCard(PanelName.ORDEN_COMPRA_SEARCH);
|
||||
}
|
||||
|
||||
private void volver() {
|
||||
OrdenCompraAsignarController controller = (OrdenCompraAsignarController) this.parentController.getCard(PanelName.ORDEN_COMPRA_ASIGNAR);
|
||||
controller.setEjemplares(null);
|
||||
|
||||
this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH);
|
||||
}
|
||||
|
||||
public void setOrdenCompra(OrdenCompra ordenCompra) {
|
||||
this.ordenCompra = ordenCompra;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package xyz.danielcortes.controllers.orden_compra;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import xyz.danielcortes.controllers.LaunchController;
|
||||
import xyz.danielcortes.framework.BaseController;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
import xyz.danielcortes.framework.ChangeListener;
|
||||
import xyz.danielcortes.framework.PanelName;
|
||||
import xyz.danielcortes.models.Ejemplar;
|
||||
import xyz.danielcortes.models.Estado;
|
||||
import xyz.danielcortes.models.Libro;
|
||||
import xyz.danielcortes.models.OrdenCompra;
|
||||
import xyz.danielcortes.repository.EstadoRepository;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraAsignarPanel;
|
||||
|
||||
public class OrdenCompraAsignarController extends BaseController {
|
||||
|
||||
private OrdenCompraAsignarPanel view;
|
||||
private OrdenCompra ordenCompra;
|
||||
private EstadoRepository estadoRepository;
|
||||
private List<Ejemplar> ejemplares;
|
||||
private int currentIndex;
|
||||
|
||||
public OrdenCompraAsignarController(OrdenCompraAsignarPanel view, LaunchController parent) {
|
||||
super(parent);
|
||||
this.view = view;
|
||||
this.currentIndex = 0;
|
||||
this.estadoRepository = new EstadoRepository();
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
this.view.getSiguienteButton().addActionListener(e -> this.siguiente());
|
||||
this.view.getAnteriorButton().addActionListener(e -> this.anterior());
|
||||
this.view.getGuardarButton().addActionListener(e -> this.save());
|
||||
this.view.getSerieField().getDocument().addDocumentListener((ChangeListener) e -> this.saveCurrent());
|
||||
}
|
||||
|
||||
private void siguiente() {
|
||||
if (this.currentIndex + 1 < this.ejemplares.size()) {
|
||||
this.currentIndex++;
|
||||
this.actualizar();
|
||||
}
|
||||
}
|
||||
|
||||
private void anterior() {
|
||||
if (this.currentIndex - 1 >= 0) {
|
||||
this.currentIndex--;
|
||||
this.actualizar();
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
OrdenCompraAceptarController controller = (OrdenCompraAceptarController) this.parentController.getCard(PanelName.ORDEN_COMPRA_ACEPTAR);
|
||||
controller.setOrdenCompra(this.ordenCompra);
|
||||
this.parentController.showCard(PanelName.ORDEN_COMPRA_ACEPTAR);
|
||||
}
|
||||
|
||||
private void saveCurrent() {
|
||||
String serie = this.view.getSerieField().getText();
|
||||
this.ejemplares.get(this.currentIndex).setSerie(serie);
|
||||
}
|
||||
|
||||
private void actualizar() {
|
||||
this.view.getLibroField().setText(this.ejemplares.get(this.currentIndex).getLibro().toString());
|
||||
this.view.getSerieField().setText(this.ejemplares.get(this.currentIndex).getSerie());
|
||||
this.view.getCurrentIndexLabel().setText(String.valueOf(this.currentIndex + 1));
|
||||
|
||||
this.view.getSiguienteButton().setEnabled(this.currentIndex + 1 < this.ejemplares.size());
|
||||
this.view.getAnteriorButton().setEnabled(this.currentIndex > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (this.ejemplares == null) {
|
||||
this.createEjemplaresBase();
|
||||
}
|
||||
|
||||
this.view.getSerieField().requestFocus();
|
||||
this.view.getTotalIndexLabel().setText(String.valueOf(this.ejemplares.size()));
|
||||
this.currentIndex = 0;
|
||||
this.actualizar();
|
||||
}
|
||||
|
||||
private void createEjemplaresBase() {
|
||||
this.ejemplares = new ArrayList<>();
|
||||
List<Libro> libros = this.ordenCompra.getLibros();
|
||||
Estado disponible = this.estadoRepository.getByNombre("Disponible");
|
||||
|
||||
for (Libro libro : libros) {
|
||||
Ejemplar ejemplar = new Ejemplar();
|
||||
ejemplar.setLibro(libro);
|
||||
ejemplar.setEstado(disponible);
|
||||
this.ejemplares.add(ejemplar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePanel getView() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
public void setOrdenCompra(OrdenCompra ordenCompra) {
|
||||
this.ordenCompra = ordenCompra;
|
||||
}
|
||||
|
||||
public List<Ejemplar> getEjemplares() {
|
||||
return this.ejemplares;
|
||||
}
|
||||
|
||||
public void setEjemplares(List<Ejemplar> ejemplares) {
|
||||
this.ejemplares = ejemplares;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,15 @@ public class OrdenCompraSearchController extends BaseController {
|
||||
|
||||
private void view() {
|
||||
OrdenCompra ordenCompra = this.getSelectedOrdenCompra();
|
||||
if (ordenCompra != null) {
|
||||
if (ordenCompra == null) {
|
||||
return;
|
||||
}
|
||||
if (ordenCompra.getEstado().equals("Aceptada")) {
|
||||
OrdenCompraViewAceptedController controller = (OrdenCompraViewAceptedController) this.getParentController()
|
||||
.getCard(PanelName.ORDEN_COMPRA_VIEW_ACEPTED);
|
||||
controller.setOrdenCompra(ordenCompra);
|
||||
this.getParentController().showCard(PanelName.ORDEN_COMPRA_VIEW_ACEPTED);
|
||||
} else {
|
||||
OrdenCompraViewController controller = (OrdenCompraViewController) this.getParentController().getCard(PanelName.ORDEN_COMPRA_VIEW);
|
||||
controller.setOrdenCompra(ordenCompra);
|
||||
this.getParentController().showCard(PanelName.ORDEN_COMPRA_VIEW);
|
||||
@@ -156,7 +164,7 @@ public class OrdenCompraSearchController extends BaseController {
|
||||
public void reload() {
|
||||
this.loadComprarTable();
|
||||
this.view.getSearchField().requestFocus();
|
||||
this.view.getTable().setRowSelectionInterval(0, 0);
|
||||
this.view.getTable().clearSelection();
|
||||
}
|
||||
|
||||
private void loadComprarTable() {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.danielcortes.controllers.orden_compra;
|
||||
|
||||
import xyz.danielcortes.controllers.LaunchController;
|
||||
import xyz.danielcortes.framework.BaseController;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
import xyz.danielcortes.framework.PanelName;
|
||||
import xyz.danielcortes.models.OrdenCompra;
|
||||
import xyz.danielcortes.views.orden_compra.OrdenCompraViewAceptedPanel;
|
||||
|
||||
public class OrdenCompraViewAceptedController extends BaseController {
|
||||
|
||||
private OrdenCompraViewAceptedPanel view;
|
||||
private OrdenCompra ordenCompra;
|
||||
|
||||
public OrdenCompraViewAceptedController(OrdenCompraViewAceptedPanel view, LaunchController parent) {
|
||||
super(parent);
|
||||
this.view = view;
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH));
|
||||
}
|
||||
|
||||
public void setOrdenCompra(OrdenCompra ordenCompra) {
|
||||
this.ordenCompra = ordenCompra;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
this.view.getDistribuidorField().setText(this.ordenCompra.getDistribuidor().getRut());
|
||||
this.view.getFolioField().setText(this.ordenCompra.getCompra().getFactura().getFolio());
|
||||
float precioNeto = (float) this.ordenCompra.getCompra().getFactura().getPrecioNeto();
|
||||
float iva = precioNeto * .19f;
|
||||
float precioBruto = precioNeto + iva;
|
||||
this.view.getPrecioNetoField().setText(String.valueOf(precioNeto));
|
||||
this.view.getIvaField().setText(String.valueOf(iva));
|
||||
this.view.getPrecioBrutoField().setText(String.valueOf(precioBruto));
|
||||
this.fillTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePanel getView() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
private void fillTable() {
|
||||
if (this.ordenCompra != null) {
|
||||
this.view.getEjemplaresTableModel().setRows(this.ordenCompra.getCompra().getEjemplares());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,9 @@ public enum PanelName {
|
||||
ORDEN_COMPRA_SEARCH,
|
||||
ORDEN_COMPRA_ACEPTAR,
|
||||
ORDEN_COMPRA_VIEW,
|
||||
ORDEN_COMPRA_VIEW_ACEPTED,
|
||||
ORDEN_COMPRA_CREAR,
|
||||
ORDEN_COMPRA_ASIGNAR,
|
||||
|
||||
VENDER_SEARCH,
|
||||
VENDER_VENDER,
|
||||
|
||||
@@ -26,11 +26,8 @@ public class Boleta {
|
||||
@Column(name = "precio_neto")
|
||||
private Integer precioNeto;
|
||||
|
||||
@Column(name = "precio_iva")
|
||||
private Integer precioIVA;
|
||||
|
||||
@Column(name = "fecha_venta")
|
||||
private LocalDate fechaVenta;
|
||||
@Column(name = "fecha_emision")
|
||||
private LocalDate fechaEmision;
|
||||
|
||||
@OneToMany(mappedBy = "boleta")
|
||||
private List<Venta> ventas;
|
||||
@@ -59,22 +56,6 @@ public class Boleta {
|
||||
this.precioNeto = precioNeto;
|
||||
}
|
||||
|
||||
public Integer getPrecioIVA() {
|
||||
return this.precioIVA;
|
||||
}
|
||||
|
||||
public void setPrecioIVA(Integer precioIVA) {
|
||||
this.precioIVA = precioIVA;
|
||||
}
|
||||
|
||||
public LocalDate getFechaVenta() {
|
||||
return this.fechaVenta;
|
||||
}
|
||||
|
||||
public void setFechaVenta(LocalDate fechaVenta) {
|
||||
this.fechaVenta = fechaVenta;
|
||||
}
|
||||
|
||||
public List<Venta> getVentas() {
|
||||
if (this.ventas == null)
|
||||
this.ventas = new ArrayList<>();
|
||||
@@ -84,4 +65,12 @@ public class Boleta {
|
||||
public void setVentas(List<Venta> ventas) {
|
||||
this.ventas = ventas;
|
||||
}
|
||||
|
||||
public LocalDate getFechaEmision() {
|
||||
return this.fechaEmision;
|
||||
}
|
||||
|
||||
public void setFechaEmision(LocalDate fechaEmision) {
|
||||
this.fechaEmision = fechaEmision;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,8 @@ public class Factura {
|
||||
@Column(name = "precio_neto")
|
||||
private Integer precioNeto;
|
||||
|
||||
@Column(name = "precio_iva")
|
||||
private Integer precioIVA;
|
||||
|
||||
@Column(name = "fecha_compra")
|
||||
private LocalDate fechaVenta;
|
||||
@Column(name = "fecha_emision")
|
||||
private LocalDate fechaEmision;
|
||||
|
||||
@OneToMany(mappedBy = "factura")
|
||||
private List<Compra> compras;
|
||||
@@ -59,24 +56,12 @@ public class Factura {
|
||||
this.precioNeto = precioNeto;
|
||||
}
|
||||
|
||||
public Integer getPrecioIVA() {
|
||||
return this.precioIVA;
|
||||
public LocalDate getFechaEmision() {
|
||||
return this.fechaEmision;
|
||||
}
|
||||
|
||||
public void setPrecioIVA(Integer precioIVA) {
|
||||
this.precioIVA = precioIVA;
|
||||
}
|
||||
|
||||
public Integer getPrecioBruto() {
|
||||
return this.precioNeto + this.precioIVA;
|
||||
}
|
||||
|
||||
public LocalDate getFechaVenta() {
|
||||
return this.fechaVenta;
|
||||
}
|
||||
|
||||
public void setFechaVenta(LocalDate fechaVenta) {
|
||||
this.fechaVenta = fechaVenta;
|
||||
public void setFechaEmision(LocalDate fechaEmision) {
|
||||
this.fechaEmision = fechaEmision;
|
||||
}
|
||||
|
||||
public List<Compra> getCompras() {
|
||||
|
||||
@@ -33,12 +33,4 @@ public class EjemplarRepository extends BaseRepository<Ejemplar> {
|
||||
query.setParameter("libro_id", libroId);
|
||||
return (Long) query.getResultList().get(0) == 1;
|
||||
}
|
||||
|
||||
public boolean exists(String serie, Integer libroId, Integer id) {
|
||||
Query query = this.em.createQuery("SELECT count(e) FROM Ejemplar e WHERE id != :id and serie = :serie and libro.id = :libro_id");
|
||||
query.setParameter("id", id);
|
||||
query.setParameter("serie", serie);
|
||||
query.setParameter("libro_id", libroId);
|
||||
return (Long) query.getResultList().get(0) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package xyz.danielcortes.repository;
|
||||
import java.util.List;
|
||||
import javax.persistence.Query;
|
||||
import xyz.danielcortes.framework.BaseRepository;
|
||||
import xyz.danielcortes.models.Distribuidor;
|
||||
import xyz.danielcortes.models.Factura;
|
||||
|
||||
public class FacturaRepository extends BaseRepository<Factura> {
|
||||
@@ -21,4 +22,11 @@ public class FacturaRepository extends BaseRepository<Factura> {
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public boolean exists(String folio, Distribuidor distribuidor) {
|
||||
Query query = this.em.createQuery("SELECT count(e) FROM Factura e WHERE folio = :folio and distribuidor.id = :distribuidor_id");
|
||||
query.setParameter("folio", folio);
|
||||
query.setParameter("distribuidor_id", distribuidor.getId());
|
||||
return (Long) query.getResultList().get(0) == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,18 +13,22 @@ public class EjemplarValidator {
|
||||
this.ejemplarRepository = ejemplarRepository;
|
||||
}
|
||||
|
||||
public ValidationResult validateSerie(String serie, Integer libroId, List<Ejemplar> ejemplares) {
|
||||
if (serie == null) {
|
||||
return new ValidationResult("La serie es nula");
|
||||
public ValidationResult validateSerie(Ejemplar ejemplar, List<Ejemplar> ejemplares) {
|
||||
if (ejemplar.getSerie() == null) {
|
||||
return new ValidationResult("La serie del libro " + ejemplar.getLibro().toString() + " es nula");
|
||||
}
|
||||
if (serie.isEmpty()) {
|
||||
return new ValidationResult("La serie esta vacia");
|
||||
if (ejemplar.getSerie().isEmpty()) {
|
||||
return new ValidationResult("La serie del libro " + ejemplar.getLibro().toString() + " esta vacia");
|
||||
}
|
||||
if (this.ejemplarRepository.exists(serie, libroId)) {
|
||||
return new ValidationResult("El numero de serie ya existe");
|
||||
if (this.ejemplarRepository.exists(ejemplar.getSerie(), ejemplar.getLibro().getId())) {
|
||||
return new ValidationResult("El numero de serie del libro " + ejemplar.getLibro().toString() + " ya existe");
|
||||
}
|
||||
if (ejemplares.stream().anyMatch(ejemplar -> ejemplar.getLibro().getId().equals(libroId) && ejemplar.getSerie().equals(serie))) {
|
||||
return new ValidationResult("El numero de serie ya existe");
|
||||
if (ejemplares.stream().anyMatch(e ->
|
||||
e != ejemplar &&
|
||||
e.getLibro().getId().equals(ejemplar.getLibro().getId()) &&
|
||||
e.getSerie().equals(ejemplar.getSerie())
|
||||
)) {
|
||||
return new ValidationResult("El numero de serie libro " + ejemplar.getLibro().toString() + " ya existe");
|
||||
}
|
||||
|
||||
return ValidationResult.NON_ERROR;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package xyz.danielcortes.validator;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import xyz.danielcortes.framework.ValidationResult;
|
||||
import xyz.danielcortes.repository.FacturaRepository;
|
||||
|
||||
public class FacturaValidator {
|
||||
|
||||
private FacturaRepository facturaRepository;
|
||||
|
||||
public FacturaValidator(FacturaRepository facturaRepository) {
|
||||
this.facturaRepository = facturaRepository;
|
||||
}
|
||||
|
||||
public ValidationResult validateFolio(String folio) {
|
||||
if (folio == null) {
|
||||
return new ValidationResult("La folio es nulo");
|
||||
}
|
||||
if (folio.isBlank()) {
|
||||
return new ValidationResult("La folio esta vacio");
|
||||
}
|
||||
|
||||
return ValidationResult.NON_ERROR;
|
||||
}
|
||||
|
||||
public ValidationResult validatePrecio(String precioNeto) {
|
||||
if (precioNeto == null) {
|
||||
return new ValidationResult("El precio neto es nulo");
|
||||
}
|
||||
if (precioNeto.isBlank()) {
|
||||
return new ValidationResult("El precio neto esta vacio");
|
||||
}
|
||||
try {
|
||||
float precio = Float.parseFloat(precioNeto);
|
||||
} catch (NumberFormatException e) {
|
||||
return new ValidationResult("El precio neto no es un numero");
|
||||
}
|
||||
|
||||
return ValidationResult.NON_ERROR;
|
||||
}
|
||||
|
||||
public ValidationResult validateFechaEmision(LocalDate fechaEmision) {
|
||||
if (fechaEmision == null) {
|
||||
return new ValidationResult("La fecha emision es nula");
|
||||
}
|
||||
return ValidationResult.NON_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraAsignarPanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="20" left="20" bottom="20" right="20"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="515" height="278"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="23615" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Libro:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="39526">
|
||||
<constraints>
|
||||
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<hspacer id="7b8f3">
|
||||
<constraints>
|
||||
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="8d57b">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="16287" class="javax.swing.JTextField" binding="libroField">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="f273" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e47d6" class="javax.swing.JButton" binding="guardarButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Guardar"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="35661" class="javax.swing.JButton" binding="anteriorButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<<"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7ad1f" class="javax.swing.JButton" binding="siguienteButton">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=">>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="56b1b">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="3d2cb">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="edc2d" class="javax.swing.JTextField" binding="serieField">
|
||||
<constraints>
|
||||
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="35d98" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Serie:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="bc6e8" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="ebccb" class="javax.swing.JLabel" binding="totalIndexLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="1"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5979a" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="de"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="60f14" class="javax.swing.JLabel" binding="currentIndexLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="1"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="f8825">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="e94b5">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,167 @@
|
||||
package xyz.danielcortes.views.orden_compra;
|
||||
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.uiDesigner.core.Spacer;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
|
||||
public class OrdenCompraAsignarPanel extends BasePanel {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField libroField;
|
||||
private JButton guardarButton;
|
||||
private JButton anteriorButton;
|
||||
private JButton siguienteButton;
|
||||
private JTextField serieField;
|
||||
private JLabel currentIndexLabel;
|
||||
private JLabel totalIndexLabel;
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
this.$$$setupUI$$$();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getContentPane() {
|
||||
return this.contentPane;
|
||||
}
|
||||
|
||||
public JTextField getLibroField() {
|
||||
return this.libroField;
|
||||
}
|
||||
|
||||
public JButton getGuardarButton() {
|
||||
return this.guardarButton;
|
||||
}
|
||||
|
||||
public JButton getAnteriorButton() {
|
||||
return this.anteriorButton;
|
||||
}
|
||||
|
||||
public JButton getSiguienteButton() {
|
||||
return this.siguienteButton;
|
||||
}
|
||||
|
||||
public JTextField getSerieField() {
|
||||
return this.serieField;
|
||||
}
|
||||
|
||||
public JLabel getCurrentIndexLabel() {
|
||||
return this.currentIndexLabel;
|
||||
}
|
||||
|
||||
public JLabel getTotalIndexLabel() {
|
||||
return this.totalIndexLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
contentPane = new JPanel();
|
||||
contentPane.setLayout(new GridLayoutManager(7, 4, new Insets(20, 20, 20, 20), -1, -1));
|
||||
final JLabel label1 = new JLabel();
|
||||
label1.setText("Libro:");
|
||||
contentPane.add(label1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
contentPane.add(spacer1,
|
||||
new GridConstraints(6, 2, 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(6, 3, 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(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
|
||||
null, null, 0, false));
|
||||
libroField = new JTextField();
|
||||
libroField.setEditable(false);
|
||||
contentPane.add(libroField,
|
||||
new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPane.add(panel1, new GridConstraints(4, 2, 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));
|
||||
guardarButton = new JButton();
|
||||
guardarButton.setText("Guardar");
|
||||
panel1.add(guardarButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
|
||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
|
||||
null, 0, false));
|
||||
anteriorButton = new JButton();
|
||||
anteriorButton.setText("<<");
|
||||
panel1.add(anteriorButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1),
|
||||
null, 0, false));
|
||||
siguienteButton = new JButton();
|
||||
siguienteButton.setText(">>");
|
||||
panel1.add(siguienteButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1),
|
||||
null, 0, false));
|
||||
final Spacer spacer4 = new Spacer();
|
||||
panel1.add(spacer4,
|
||||
new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
|
||||
null, null, 0, false));
|
||||
final Spacer spacer5 = new Spacer();
|
||||
panel1.add(spacer5,
|
||||
new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
|
||||
null, null, 0, false));
|
||||
serieField = new JTextField();
|
||||
contentPane.add(serieField,
|
||||
new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||
final JLabel label2 = new JLabel();
|
||||
label2.setText("Serie:");
|
||||
contentPane.add(label2, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final JPanel panel2 = new JPanel();
|
||||
panel2.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPane.add(panel2, new GridConstraints(5, 2, 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));
|
||||
totalIndexLabel = new JLabel();
|
||||
totalIndexLabel.setText("1");
|
||||
panel2.add(totalIndexLabel,
|
||||
new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final JLabel label3 = new JLabel();
|
||||
label3.setText("de");
|
||||
panel2.add(label3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
currentIndexLabel = new JLabel();
|
||||
currentIndexLabel.setText("1");
|
||||
panel2.add(currentIndexLabel,
|
||||
new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer6 = new Spacer();
|
||||
panel2.add(spacer6,
|
||||
new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
|
||||
null, null, 0, false));
|
||||
final Spacer spacer7 = new Spacer();
|
||||
panel2.add(spacer7,
|
||||
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
|
||||
null, null, 0, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraViewAceptedPanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="13" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="20" left="20" bottom="20" right="20"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="407" height="598"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="13b47">
|
||||
<constraints>
|
||||
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<scrollpane id="3750c">
|
||||
<constraints>
|
||||
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="400" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2e370" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<hspacer id="32a85">
|
||||
<constraints>
|
||||
<grid row="12" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="bd6b7">
|
||||
<constraints>
|
||||
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="ca98b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="90c0e" class="javax.swing.JButton" binding="volverButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Volver"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="76afc" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Distribuidor:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d0d25" class="javax.swing.JTextField" binding="distribuidorField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="dc563" class="javax.swing.JTextField" binding="folioField">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="ed7d2" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Folio:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9e01b" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Precio neto:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d3b51" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="IVA:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f0baf" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Precio Bruto:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7ae83" class="javax.swing.JTextField" binding="precioNetoField">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="d6551" class="javax.swing.JTextField" binding="ivaField">
|
||||
<constraints>
|
||||
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="6c6c8" class="javax.swing.JTextField" binding="precioBrutoField">
|
||||
<constraints>
|
||||
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,183 @@
|
||||
package xyz.danielcortes.views.orden_compra;
|
||||
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.uiDesigner.core.Spacer;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
import xyz.danielcortes.framework.BaseTableModel;
|
||||
import xyz.danielcortes.models.Ejemplar;
|
||||
|
||||
public class OrdenCompraViewAceptedPanel extends BasePanel {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTable ejemplaresTable;
|
||||
private BaseTableModel<Ejemplar> ejemplaresTableModel;
|
||||
private JButton volverButton;
|
||||
private JTextField distribuidorField;
|
||||
private JTextField folioField;
|
||||
private JTextField precioNetoField;
|
||||
private JTextField ivaField;
|
||||
private JTextField precioBrutoField;
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
this.$$$setupUI$$$();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getContentPane() {
|
||||
return this.contentPane;
|
||||
}
|
||||
|
||||
public JTable getEjemplaresTable() {
|
||||
return this.ejemplaresTable;
|
||||
}
|
||||
|
||||
public BaseTableModel<Ejemplar> getEjemplaresTableModel() {
|
||||
return this.ejemplaresTableModel;
|
||||
}
|
||||
|
||||
public JButton getVolverButton() {
|
||||
return this.volverButton;
|
||||
}
|
||||
|
||||
public JTextField getDistribuidorField() {
|
||||
return this.distribuidorField;
|
||||
}
|
||||
|
||||
public JTextField getFolioField() {
|
||||
return this.folioField;
|
||||
}
|
||||
|
||||
public JTextField getPrecioNetoField() {
|
||||
return this.precioNetoField;
|
||||
}
|
||||
|
||||
public JTextField getIvaField() {
|
||||
return this.ivaField;
|
||||
}
|
||||
|
||||
public JTextField getPrecioBrutoField() {
|
||||
return this.precioBrutoField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
createUIComponents();
|
||||
contentPane = new JPanel();
|
||||
contentPane.setLayout(new GridLayoutManager(13, 3, new Insets(20, 20, 20, 20), -1, -1));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
contentPane.add(spacer1,
|
||||
new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
|
||||
null, null, 0, false));
|
||||
final JScrollPane scrollPane1 = new JScrollPane();
|
||||
contentPane.add(scrollPane1, new GridConstraints(10, 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, new Dimension(400, -1), null, 0, false));
|
||||
scrollPane1.setViewportView(ejemplaresTable);
|
||||
final Spacer spacer2 = new Spacer();
|
||||
contentPane.add(spacer2,
|
||||
new GridConstraints(12, 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(12, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
|
||||
null, null, null, 0, false));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPane.add(panel1, new GridConstraints(11, 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();
|
||||
volverButton.setText("Volver");
|
||||
panel1.add(volverButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
|
||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
|
||||
null, 0, false));
|
||||
final JLabel label1 = new JLabel();
|
||||
label1.setText("Distribuidor:");
|
||||
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));
|
||||
distribuidorField = new JTextField();
|
||||
distribuidorField.setEditable(false);
|
||||
contentPane.add(distribuidorField,
|
||||
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||
folioField = new JTextField();
|
||||
contentPane.add(folioField,
|
||||
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));
|
||||
final JLabel label2 = new JLabel();
|
||||
label2.setText("Folio:");
|
||||
contentPane.add(label2, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final JLabel label3 = new JLabel();
|
||||
label3.setText("Precio neto:");
|
||||
contentPane.add(label3, new GridConstraints(4, 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("IVA:");
|
||||
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 Bruto:");
|
||||
contentPane.add(label5, 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();
|
||||
contentPane.add(precioNetoField,
|
||||
new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||
ivaField = new JTextField();
|
||||
contentPane.add(ivaField,
|
||||
new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||
precioBrutoField = new JTextField();
|
||||
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(150, -1), null, 0, false));
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
|
||||
this.ejemplaresTableModel = new BaseTableModel<>(
|
||||
new String[]{"ISBN", "Serie", "Titulo", "Estado"},
|
||||
(rows, rowIndex, colIndex) -> {
|
||||
switch (colIndex) {
|
||||
case 0:
|
||||
return rows.get(rowIndex).getLibro().getIsbn();
|
||||
case 1:
|
||||
return rows.get(rowIndex).getSerie();
|
||||
case 2:
|
||||
return rows.get(rowIndex).getLibro().getTitulo();
|
||||
case 3:
|
||||
return rows.get(rowIndex).getEstado();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
this.ejemplaresTable = new JTable(this.ejemplaresTableModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user