Estaba trabajando en las compras y empeze a documentar :c
This commit is contained in:
@@ -351,19 +351,27 @@ public class LaunchController {
|
||||
* @return <code>JMenu</code> con los <code>MenuItem</code> para acceder a las vistas.
|
||||
*/
|
||||
private JMenu createComprarMenu() {
|
||||
JMenu comprarMenu = new JMenu("Comprar");
|
||||
JMenu comprarMenu = new JMenu("Compra, Venta y Arriendo");
|
||||
|
||||
JMenuItem comprarLibroItem = new JMenuItem("Comprar Libro");
|
||||
JMenuItem venderLibroItem = new JMenuItem("Vender Libro");
|
||||
JMenuItem arrendarLibroItem = new JMenuItem("Arrendar Libro");
|
||||
|
||||
comprarLibroItem.addActionListener(e -> this.showCard(PanelName.COMPRAR_LIBRO));
|
||||
comprarLibroItem.addActionListener(e -> this.showCard(PanelName.COMPRAR_SEARCH));
|
||||
venderLibroItem.addActionListener(e -> this.showCard(PanelName.VENDER_SEARCH));
|
||||
arrendarLibroItem.addActionListener(e -> this.showCard(PanelName.ARRENDAR_SEARCH));
|
||||
|
||||
comprarMenu.add(comprarMenu);
|
||||
comprarMenu.add(comprarLibroItem);
|
||||
comprarMenu.add(venderLibroItem);
|
||||
comprarMenu.add(arrendarLibroItem);
|
||||
|
||||
return comprarMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Muestra la Carta con el nombre entregado Llama al metodo show del controlador de la carta a mostrar
|
||||
* Muestra la Carta con el nombre entregado
|
||||
* <p>
|
||||
* Llama al metodo show del controlador de la carta a mostrar
|
||||
*
|
||||
* @param name <code>PanelName</code> de la Carta que se quiere mostrar.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.danielcortes.controllers.comprar;
|
||||
|
||||
import xyz.danielcortes.repository.CompraRepository;
|
||||
import xyz.danielcortes.views.comprar.ComprarSearchPanel;
|
||||
|
||||
public class ComprarSearchController {
|
||||
|
||||
public ComprarSearchPanel view;
|
||||
private CompraRepository repository;
|
||||
}
|
||||
@@ -2,22 +2,47 @@ package xyz.danielcortes.framework;
|
||||
|
||||
import xyz.danielcortes.controllers.LaunchController;
|
||||
|
||||
/**
|
||||
* Controlador base que debe ser extendido por todos los controladores que se utilizen en la aplicacion
|
||||
*/
|
||||
public abstract class BaseController {
|
||||
|
||||
/**
|
||||
* El <code>LaunchController</code> que ejecuta este controlador
|
||||
*/
|
||||
protected LaunchController parentController;
|
||||
|
||||
/**
|
||||
* @param parentController <code>LaunchController</code> que ejecuta este controlador
|
||||
*/
|
||||
public BaseController(LaunchController parentController) {
|
||||
this.parentController = parentController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>LaunchController</code> que ejecuta este controlador
|
||||
*/
|
||||
public LaunchController getParentController() {
|
||||
return this.parentController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Este metodo sera llamado cada vez que se necesite mostrar la vista que contiene
|
||||
* <p>
|
||||
* Aqui debe prepararse la vista para ser mostrada, procesos como:
|
||||
* <ul>
|
||||
* <li>Actualizar JLists</li>
|
||||
* <li>Actualizar JTables</li>
|
||||
* <li>Limpiar JFields</li>
|
||||
* <li>Llamar a <code>requestFocus()</code> en el componente que necesita tener foco al iniciar</li>
|
||||
* </ul>
|
||||
*/
|
||||
public abstract void show();
|
||||
|
||||
/**
|
||||
* Entrega el <code>BasePanel</code> que maneja el controlador
|
||||
*
|
||||
* @return <code>BasePanel</code>
|
||||
*/
|
||||
public abstract BasePanel getView();
|
||||
}
|
||||
|
||||
@@ -97,5 +97,13 @@ public enum PanelName {
|
||||
CLIENTE_DIRECCION_CREATE,
|
||||
CLIENTE_DIRECCION_UPDATE,
|
||||
|
||||
COMPRAR_LIBRO,
|
||||
COMPRAR_SEARCH,
|
||||
COMPRAR_COMPRAR,
|
||||
|
||||
VENDER_SEARCH,
|
||||
VENDER_VENDER,
|
||||
|
||||
ARRENDAR_SEARCH,
|
||||
ARRENDAR_ARRENDAR,
|
||||
ARRENDAR_RECIBIR,
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ public class Factura {
|
||||
this.precioIVA = precioIVA;
|
||||
}
|
||||
|
||||
public Integer getPrecioBruto() {
|
||||
return this.precioNeto + this.precioIVA;
|
||||
}
|
||||
|
||||
public LocalDate getFechaVenta() {
|
||||
return this.fechaVenta;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package xyz.danielcortes.repository;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.TypedQuery;
|
||||
import xyz.danielcortes.framework.BaseRepository;
|
||||
import xyz.danielcortes.models.Compra;
|
||||
|
||||
public class CompraRepository extends BaseRepository<Compra> {
|
||||
|
||||
public List<Compra> getAll() {
|
||||
TypedQuery<Compra> query = this.em.createQuery("SELECT a FROM Compra a", Compra.class);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public List<Compra> search(String term) {
|
||||
Query query = this.em.createQuery("SELECT c FROM Compra c WHERE "
|
||||
+ "LOWER(c.factura.folio) LIKE :term OR "
|
||||
+ "c.factura.precioNeto LIKE :term OR "
|
||||
+ "c.factura.precioNeto + c.factura.precioIVA LIKE :term OR "
|
||||
+ "LOWER(c.distribuidor.rut) LIKE :term OR "
|
||||
+ "COCOUNT(c.ejemplares.size) LIKE :term"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.comprar.ComprarLibroPanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,42 +0,0 @@
|
||||
package xyz.danielcortes.views.comprar;
|
||||
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
|
||||
public class ComprarLibroPanel extends BasePanel {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
this.$$$setupUI$$$();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getContentPane() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(1, 1, new Insets(20, 20, 20, 20), -1, -1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.comprar.ComprarSearchPanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="1" 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="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<scrollpane id="672e3">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c45fa" class="javax.swing.JTable" binding="table" custom-create="true">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="8ed47" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" 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="11f89" class="javax.swing.JTextField" binding="searchField">
|
||||
<constraints>
|
||||
<grid row="0" column="0" 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="c367f" class="javax.swing.JButton" binding="buscarButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" 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="Buscar"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="b7500" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" 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="dd7c5" class="javax.swing.JButton" binding="comprarButton">
|
||||
<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="Comprar"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5d466" class="javax.swing.JButton" binding="verButton">
|
||||
<constraints>
|
||||
<grid row="0" column="1" 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="Ver Orden de Compra"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,104 @@
|
||||
package xyz.danielcortes.views.comprar;
|
||||
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import xyz.danielcortes.framework.BasePanel;
|
||||
import xyz.danielcortes.framework.BaseTableModel;
|
||||
import xyz.danielcortes.models.Compra;
|
||||
|
||||
public class ComprarSearchPanel extends BasePanel {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField searchField;
|
||||
private JButton buscarButton;
|
||||
private JTable table;
|
||||
private BaseTableModel<Compra> model;
|
||||
private JButton comprarButton;
|
||||
private JButton verButton;
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
this.$$$setupUI$$$();
|
||||
}
|
||||
|
||||
public JTextField getSearchField() {
|
||||
return this.searchField;
|
||||
}
|
||||
|
||||
public JButton getBuscarButton() {
|
||||
return this.buscarButton;
|
||||
}
|
||||
|
||||
public JTable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public BaseTableModel<Compra> getModel() {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
public JButton getComprarButton() {
|
||||
return this.comprarButton;
|
||||
}
|
||||
|
||||
public JButton getVerButton() {
|
||||
return this.verButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getContentPane() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(1, 1, new Insets(20, 20, 20, 20), -1, -1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
this.model = new BaseTableModel<>(
|
||||
new String[]{"Folio Factura", "Precio Neto", "Precio Bruto", "Distribuidor", "Fecha Compra", "Nº Libros Comprados"},
|
||||
(row, rowIndex, colIndex) -> {
|
||||
switch (colIndex) {
|
||||
case 0:
|
||||
return row.get(rowIndex).getFactura().getFolio();
|
||||
case 1:
|
||||
return row.get(rowIndex).getFactura().getPrecioNeto();
|
||||
case 2:
|
||||
return row.get(rowIndex).getFactura().getPrecioBruto();
|
||||
case 3:
|
||||
return row.get(rowIndex).getDistribuidor().getRut();
|
||||
case 4:
|
||||
return row.get(rowIndex).getFactura().getFechaVenta();
|
||||
case 6:
|
||||
return row.get(rowIndex).getEjemplares().size();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
// @formatter:on
|
||||
this.table = new JTable(this.model);
|
||||
this.table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user