diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c5777e1..9b47cef 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,16 +2,16 @@
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -25,104 +25,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Mapº
+ parameter
+ param
+ subre
+
+
@@ -150,41 +72,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -198,16 +85,58 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -228,98 +157,78 @@
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
@@ -337,17 +246,20 @@
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
@@ -601,7 +513,91 @@
1519003053166
-
+
+ 1519360983968
+
+
+
+ 1519360983968
+
+
+ 1519394536023
+
+
+
+ 1519394536023
+
+
+ 1519400203711
+
+
+
+ 1519400203711
+
+
+ 1519496176173
+
+
+
+ 1519496176174
+
+
+ 1519572233342
+
+
+
+ 1519572233342
+
+
+ 1519572386910
+
+
+
+ 1519572386910
+
+
+ 1519678445707
+
+
+
+ 1519678445707
+
+
+ 1519709522010
+
+
+
+ 1519709522010
+
+
+ 1519710312225
+
+
+
+ 1519710312225
+
+
+ 1519710875340
+
+
+
+ 1519710875340
+
+
+ 1519773867311
+
+
+
+ 1519773867311
+
+
+ 1519918523585
+
+
+
+ 1519918523586
+
+
@@ -622,15 +618,14 @@
-
+
-
+
-
-
+
@@ -643,8 +638,12 @@
+
+
+
+
@@ -658,7 +657,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -671,426 +681,367 @@
-
+
-
-
-
+
+
+
+
+
-
+
-
-
-
+
+
-
-
+
-
-
+
+
-
-
-
-
-
+
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
+
-
-
-
+
+
-
-
-
-
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
-
+
-
-
-
+
+
-
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..023e20c
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+encoding//src/application/reports/ControlStock.jrxml=UTF-8
+encoding//src/application/reports/DatosOrganizacion.jrxml=UTF-8
+encoding//src/application/reports/DetalleLiquidacion.jrxml=UTF-8
+encoding//src/application/reports/ReciboSueldo.jrxml=UTF-8
+encoding//src/application/reports/RecibosPorLiquidacion.jrxml=UTF-8
+encoding//target/classes/application/reports/DatosOrganizacion.jrxml=UTF-8
diff --git a/LogiservStudio.iml b/LogiservStudio.iml
index 8e67c96..8a0e148 100644
--- a/LogiservStudio.iml
+++ b/LogiservStudio.iml
@@ -19,7 +19,6 @@
-
@@ -31,5 +30,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e4c4524..c09fe95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,5 +56,10 @@
commons-codec
1.11
+
+ net.sf.jasperreports
+ jasperreports
+ 6.5.1
+
\ No newline at end of file
diff --git a/src/application/Main.java b/src/application/Main.java
index e1446f3..383b6ab 100644
--- a/src/application/Main.java
+++ b/src/application/Main.java
@@ -1,14 +1,16 @@
package application;
-import application.view.*;
-import java.io.IOException;
import application.database.JDBCConnection;
+import application.view.LoginController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
+import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
+import java.io.IOException;
+
public class Main extends Application {
private Stage primaryStage;
private BorderPane rootLayout;
@@ -17,6 +19,9 @@ public class Main extends Application {
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Logiserv Studio");
+ // Set the application icon.
+ this.primaryStage.getIcons().add(new Image("resources/logiserv-icon.png"));
+
JDBCConnection.getInstanceConnection();
initRootLayout();
}
diff --git a/src/application/comunes/Alerta.java b/src/application/comunes/Alerta.java
index f39e9be..2eb9150 100644
--- a/src/application/comunes/Alerta.java
+++ b/src/application/comunes/Alerta.java
@@ -11,7 +11,7 @@ protected Alerta(){
}
public static void alertaInfo(String titulo, String contenido){
- Alert alert = new Alert(Alert.AlertType.WARNING);
+ Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(titulo);
alert.setContentText(contenido);
alert.initStyle(StageStyle.UNDECORATED);
@@ -19,7 +19,7 @@ public static void alertaInfo(String titulo, String contenido){
}
public static void alertaInfo(String titulo, String header, String contenido){
- Alert alert = new Alert(Alert.AlertType.WARNING);
+ Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(titulo);
alert.setHeaderText(header);
alert.setContentText(contenido);
diff --git a/src/application/model/calculo/Acoplado.java b/src/application/model/calculo/Acoplado.java
index 9e9fada..56d9d0b 100644
--- a/src/application/model/calculo/Acoplado.java
+++ b/src/application/model/calculo/Acoplado.java
@@ -9,6 +9,19 @@ public class Acoplado {
private IntegerProperty id;
private StringProperty marca;
private StringProperty patente;
+ private StringProperty chasisNumero;
+
+ public String getChasisNumero() {
+ return chasisNumero.get();
+ }
+
+ public StringProperty chasisNumeroProperty() {
+ return chasisNumero;
+ }
+
+ public void setChasisNumero(String chasisNumero) {
+ this.chasisNumero.set(chasisNumero);
+ }
public int getId() {
return id.get();
@@ -46,13 +59,14 @@ public void setPatente(String patente) {
this.patente.set(patente);
}
- public Acoplado(Integer id, String marca, String patente) {
+ public Acoplado(Integer id, String marca, String patente, String chasisNumero) {
this.id = new SimpleIntegerProperty(id);
this.marca = new SimpleStringProperty(marca);
this.patente = new SimpleStringProperty(patente);
+ this.chasisNumero = new SimpleStringProperty(chasisNumero);
}
public Acoplado() {
- this(0,null,null);
+ this(0,null,null,null);
}
}
diff --git a/src/application/model/calculo/Camion.java b/src/application/model/calculo/Camion.java
index 745b95c..1c911be 100644
--- a/src/application/model/calculo/Camion.java
+++ b/src/application/model/calculo/Camion.java
@@ -10,6 +10,32 @@ public class Camion {
private StringProperty marca;
private StringProperty modelo;
private StringProperty patente;
+ private StringProperty motor;
+ private StringProperty chasis;
+
+ public String getMotor() {
+ return motor.get();
+ }
+
+ public StringProperty motorProperty() {
+ return motor;
+ }
+
+ public void setMotor(String motor) {
+ this.motor.set(motor);
+ }
+
+ public String getChasis() {
+ return chasis.get();
+ }
+
+ public StringProperty chasisProperty() {
+ return chasis;
+ }
+
+ public void setChasis(String chasis) {
+ this.chasis.set(chasis);
+ }
public int getId() {
return id.get();
@@ -59,14 +85,16 @@ public void setPatente(String patente) {
this.patente.set(patente);
}
- public Camion(Integer id, String marca, String modelo, String patente) {
+ public Camion(Integer id, String marca, String modelo, String patente, String motor, String chasis) {
this.id = new SimpleIntegerProperty(id);
this.marca = new SimpleStringProperty(marca);
this.modelo = new SimpleStringProperty(modelo);
this.patente = new SimpleStringProperty(patente);
+ this.motor = new SimpleStringProperty(motor);
+ this.chasis = new SimpleStringProperty(chasis);
}
public Camion() {
- this(0,null,null,null);
+ this(0,null,null,null, null,null);
}
}
diff --git a/src/application/model/calculo/Ingenio.java b/src/application/model/calculo/Ingenio.java
index a773c07..415e6d1 100644
--- a/src/application/model/calculo/Ingenio.java
+++ b/src/application/model/calculo/Ingenio.java
@@ -97,4 +97,8 @@ public Ingenio() {
this(0,0.0,0.0,null,0.0,0.0);
}
+ @Override
+ public String toString() {
+ return getNombre();
+ }
}
diff --git a/src/application/model/compra/DetalleCompra.java b/src/application/model/compra/DetalleCompra.java
index 01fddf2..d1fe351 100644
--- a/src/application/model/compra/DetalleCompra.java
+++ b/src/application/model/compra/DetalleCompra.java
@@ -4,8 +4,6 @@
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
-import javafx.beans.property.SimpleStringProperty;
-import javafx.beans.property.StringProperty;
public class DetalleCompra {
diff --git a/src/application/model/compra/FacturaCompra.java b/src/application/model/compra/FacturaCompra.java
index b6edc0b..2d11eab 100644
--- a/src/application/model/compra/FacturaCompra.java
+++ b/src/application/model/compra/FacturaCompra.java
@@ -1,11 +1,6 @@
package application.model.compra;
-import javafx.beans.property.DoubleProperty;
-import javafx.beans.property.IntegerProperty;
-import javafx.beans.property.SimpleDoubleProperty;
-import javafx.beans.property.SimpleIntegerProperty;
-import javafx.beans.property.SimpleStringProperty;
-import javafx.beans.property.StringProperty;
+ import javafx.beans.property.*;
public class FacturaCompra {
diff --git a/src/application/model/info/CategoriaEmpleado.java b/src/application/model/info/CategoriaEmpleado.java
index 919b252..48123f8 100644
--- a/src/application/model/info/CategoriaEmpleado.java
+++ b/src/application/model/info/CategoriaEmpleado.java
@@ -1,6 +1,9 @@
package application.model.info;
-import javafx.beans.property.*;
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
import javafx.scene.control.CheckBox;
public class CategoriaEmpleado {
diff --git a/src/application/model/info/Domicilio.java b/src/application/model/info/Domicilio.java
index 51e8403..eef2564 100644
--- a/src/application/model/info/Domicilio.java
+++ b/src/application/model/info/Domicilio.java
@@ -5,7 +5,6 @@
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
-import application.repository.info.LocalidadRepository;
public class Domicilio {
diff --git a/src/application/model/info/Empleado.java b/src/application/model/info/Empleado.java
index b905f10..79a126c 100644
--- a/src/application/model/info/Empleado.java
+++ b/src/application/model/info/Empleado.java
@@ -5,7 +5,6 @@
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
-import application.repository.info.DomicilioRepository;
public class Empleado {
diff --git a/src/application/model/sueldo/ConceptoCalculado.java b/src/application/model/sueldo/ConceptoCalculado.java
index 6b2e636..3411647 100644
--- a/src/application/model/sueldo/ConceptoCalculado.java
+++ b/src/application/model/sueldo/ConceptoCalculado.java
@@ -46,4 +46,11 @@ private void calcularMontoCalculado(){
break;
}
}
+
+ @Override
+ public String toString() {
+ return "ConceptoCalculado{" +
+ "montoCalculado=" + montoCalculado + "\n"+ super.toString()+
+ '}';
+ }
}
diff --git a/src/application/model/sueldo/ConceptoSueldo.java b/src/application/model/sueldo/ConceptoSueldo.java
index 7f5957b..618b480 100644
--- a/src/application/model/sueldo/ConceptoSueldo.java
+++ b/src/application/model/sueldo/ConceptoSueldo.java
@@ -107,4 +107,16 @@ public ConceptoSueldo(){
this(0, null, 0f, null, null, 1.0);
}
+ @Override
+ public String toString() {
+ return "ConceptoSueldo{" +
+ "idConceptoSueldo=" + idConceptoSueldo +
+ ", descripcion=" + descripcion +
+ ", cantidad=" + cantidad +
+ ", tipoConcepto=" + tipoConcepto +
+ ", tipoCantidad=" + tipoCantidad +
+ ", select=" + select +
+ ", factor=" + factor +
+ '}';
+ }
}
diff --git a/src/application/model/sueldo/Liquidaciones.java b/src/application/model/sueldo/Liquidacion.java
similarity index 79%
rename from src/application/model/sueldo/Liquidaciones.java
rename to src/application/model/sueldo/Liquidacion.java
index eebf045..f2b1ed6 100644
--- a/src/application/model/sueldo/Liquidaciones.java
+++ b/src/application/model/sueldo/Liquidacion.java
@@ -2,22 +2,24 @@
import javafx.beans.property.*;
+import java.util.ArrayList;
import java.util.List;
-public class Liquidaciones {
+public class Liquidacion {
private IntegerProperty id;
private StringProperty fechaLiquidacion;
private DoubleProperty totalHaberesRemunerativos;
private DoubleProperty totalHaberesNoRemunerativos;
private DoubleProperty totalRetenciones;
+ private List liquidacionesEmpleados = new ArrayList<>();
- public Liquidaciones() {
+ public Liquidacion() {
this(0,null,0.0,
0.0,0.0);
}
- public Liquidaciones(Integer id, String fechaLiquidacion, Double totalHaberesRemunerativos, Double totalHaberesNoRemunerativos,
- Double totalRetenciones) {
+ public Liquidacion(Integer id, String fechaLiquidacion, Double totalHaberesRemunerativos, Double totalHaberesNoRemunerativos,
+ Double totalRetenciones) {
this.id = new SimpleIntegerProperty(id);
this.fechaLiquidacion = new SimpleStringProperty(fechaLiquidacion);
@@ -88,4 +90,11 @@ public void setTotalRetenciones(double totalRetenciones) {
this.totalRetenciones.set(totalRetenciones);
}
+ public List getLiquidacionesEmpleados() {
+ return liquidacionesEmpleados;
+ }
+
+ public void setLiquidacionesEmpleados(List liquidacionesEmpleados) {
+ this.liquidacionesEmpleados = liquidacionesEmpleados;
+ }
}
\ No newline at end of file
diff --git a/src/application/model/sueldo/LiquidacionEmpleado.java b/src/application/model/sueldo/LiquidacionEmpleado.java
index f46078c..278c393 100644
--- a/src/application/model/sueldo/LiquidacionEmpleado.java
+++ b/src/application/model/sueldo/LiquidacionEmpleado.java
@@ -2,7 +2,6 @@
import application.model.info.Empleado;
import javafx.beans.property.*;
-import javafx.collections.ObservableList;
import java.util.List;
diff --git a/src/application/model/venta/Cliente.java b/src/application/model/venta/Cliente.java
index 8a06eb4..e8409c0 100644
--- a/src/application/model/venta/Cliente.java
+++ b/src/application/model/venta/Cliente.java
@@ -1,7 +1,6 @@
package application.model.venta;
import application.model.info.Domicilio;
-import application.model.info.Localidad;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
diff --git a/src/application/model/venta/FacturaVenta.java b/src/application/model/venta/FacturaVenta.java
index e3101c7..e05cd97 100644
--- a/src/application/model/venta/FacturaVenta.java
+++ b/src/application/model/venta/FacturaVenta.java
@@ -116,16 +116,17 @@ public void setOrganizacion(Organizacion organizacion) {
public FacturaVenta(Integer idFacturaVenta, String cuit, String nombreEmpresa,
- String fechaEmision, String nombreCliente, String cuitCliente) {
+ String fechaEmision, String nombreCliente, String cuitCliente, Double montoTotal) {
this.idFacturaVenta = new SimpleIntegerProperty(idFacturaVenta);
this.cuit = new SimpleStringProperty(cuit);
this.nombreEmpresa = new SimpleStringProperty(nombreEmpresa);
this.fechaEmision = new SimpleStringProperty(fechaEmision);
this.nombreCliente = new SimpleStringProperty(nombreCliente);
this.cuitCliente = new SimpleStringProperty(cuitCliente);
+ this.montoFactura = new SimpleDoubleProperty(montoTotal);
}
public FacturaVenta() {
- this(0,null,null,null,null,null);
+ this(0,null,null,null,null,null,0.0);
}
-}
+}
\ No newline at end of file
diff --git a/src/application/model/venta/Viaje.java b/src/application/model/venta/Viaje.java
index 733bd04..e292b31 100644
--- a/src/application/model/venta/Viaje.java
+++ b/src/application/model/venta/Viaje.java
@@ -7,8 +7,6 @@
import javafx.beans.property.*;
import javafx.scene.control.CheckBox;
-import java.math.BigDecimal;
-
public class Viaje {
private IntegerProperty idRemito;
@@ -228,6 +226,7 @@ public Viaje(Integer idRemito, String fecha, String horaEntrada,
this.ingenioDestino = new SimpleStringProperty(ingenioDestino);
this.camionNombre = new SimpleStringProperty(camionNombre);
this.facturaVenta = new SimpleStringProperty(facturaVenta);
+ this.monto = new SimpleDoubleProperty();
this.conductor = conductor;
this.ingenio = new Ingenio();
this.conductor = new Empleado();
@@ -241,5 +240,6 @@ public Viaje() {
this.setDistanciaRecorrida("0");
this.setBruto(0);
this.setTara(0);
+ this.setMonto(0);
}
}
\ No newline at end of file
diff --git a/src/application/reports/ControlStock.jasper b/src/application/reports/ControlStock.jasper
new file mode 100644
index 0000000..c7bc03c
Binary files /dev/null and b/src/application/reports/ControlStock.jasper differ
diff --git a/src/application/reports/ControlStock.jrxml b/src/application/reports/ControlStock.jrxml
new file mode 100644
index 0000000..009e861
--- /dev/null
+++ b/src/application/reports/ControlStock.jrxml
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/DatosOrganizacion.jasper b/src/application/reports/DatosOrganizacion.jasper
new file mode 100644
index 0000000..b2030c7
Binary files /dev/null and b/src/application/reports/DatosOrganizacion.jasper differ
diff --git a/src/application/reports/DatosOrganizacion.jrxml b/src/application/reports/DatosOrganizacion.jrxml
new file mode 100644
index 0000000..8ade43b
--- /dev/null
+++ b/src/application/reports/DatosOrganizacion.jrxml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/DetalleLiquidacion.jasper b/src/application/reports/DetalleLiquidacion.jasper
new file mode 100644
index 0000000..0320b87
Binary files /dev/null and b/src/application/reports/DetalleLiquidacion.jasper differ
diff --git a/src/application/reports/DetalleLiquidacion.jrxml b/src/application/reports/DetalleLiquidacion.jrxml
new file mode 100644
index 0000000..bc38d99
--- /dev/null
+++ b/src/application/reports/DetalleLiquidacion.jrxml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/FacturaA.jasper b/src/application/reports/FacturaA.jasper
new file mode 100644
index 0000000..3475116
Binary files /dev/null and b/src/application/reports/FacturaA.jasper differ
diff --git a/src/application/reports/FacturaA.jrxml b/src/application/reports/FacturaA.jrxml
new file mode 100644
index 0000000..6ad79f0
--- /dev/null
+++ b/src/application/reports/FacturaA.jrxml
@@ -0,0 +1,441 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/ReciboSueldo.jasper b/src/application/reports/ReciboSueldo.jasper
new file mode 100644
index 0000000..0962157
Binary files /dev/null and b/src/application/reports/ReciboSueldo.jasper differ
diff --git a/src/application/reports/ReciboSueldo.jrxml b/src/application/reports/ReciboSueldo.jrxml
new file mode 100644
index 0000000..5889816
--- /dev/null
+++ b/src/application/reports/ReciboSueldo.jrxml
@@ -0,0 +1,234 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jasper b/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jasper
new file mode 100644
index 0000000..9a5e969
Binary files /dev/null and b/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jasper differ
diff --git a/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jrxml b/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jrxml
new file mode 100644
index 0000000..1721c20
--- /dev/null
+++ b/src/application/reports/TodosLosRecibosDeUnaLiquidacion.jrxml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/reports/classes/AbstractJasperReports.java b/src/application/reports/classes/AbstractJasperReports.java
new file mode 100644
index 0000000..9b0ed25
--- /dev/null
+++ b/src/application/reports/classes/AbstractJasperReports.java
@@ -0,0 +1,56 @@
+package application.reports.classes;
+
+import application.database.JDBCConnection;
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JasperFillManager;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+import net.sf.jasperreports.engine.util.JRLoader;
+
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class AbstractJasperReports {
+ private static JasperReport report;
+ private static JasperPrint reportFilled;
+ private static JasperFX viewer;
+ public static void createReport(String path){
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ report = (JasperReport) JRLoader.loadObjectFromFile(path);
+ reportFilled = JasperFillManager.fillReport(report,null, connection);
+ }catch (JRException e){
+ e.printStackTrace();
+ }
+ }
+ public static void createReport(String path,String nombreParametro, int id){
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ report = (JasperReport) JRLoader.loadObjectFromFile(path);
+ Map parameter = new HashMap<>();
+ parameter.put(nombreParametro,id);
+ reportFilled = JasperFillManager.fillReport(report, parameter, connection);
+ }catch (JRException e){
+ e.printStackTrace();
+ }
+
+ }
+ public static void createReport(String path,String nombreParametro, int id, String nombreParamete2, double value){
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ report = (JasperReport) JRLoader.loadObjectFromFile(path);
+ Map parameter = new HashMap<>();
+ parameter.put(nombreParametro,id);
+ parameter.put(nombreParamete2, value);
+ reportFilled = JasperFillManager.fillReport(report, parameter, connection);
+ }catch (JRException e){
+ e.printStackTrace();
+ }
+
+ }
+ public static void showViewer(){
+ viewer = new JasperFX(reportFilled);
+ viewer.show();
+ }
+}
diff --git a/src/application/reports/classes/JasperFX.java b/src/application/reports/classes/JasperFX.java
new file mode 100644
index 0000000..f8789d2
--- /dev/null
+++ b/src/application/reports/classes/JasperFX.java
@@ -0,0 +1,360 @@
+package application.reports.classes;
+
+import javafx.animation.AnimationTimer;
+import javafx.collections.FXCollections;
+import javafx.embed.swing.SwingFXUtils;
+import javafx.geometry.Orientation;
+import javafx.geometry.Pos;
+import javafx.geometry.VPos;
+import javafx.scene.Scene;
+import javafx.scene.canvas.Canvas;
+import javafx.scene.canvas.GraphicsContext;
+import javafx.scene.control.Button;
+import javafx.scene.control.*;
+import javafx.scene.image.WritableImage;
+import javafx.scene.layout.*;
+import javafx.scene.text.Text;
+import javafx.stage.*;
+import javafx.stage.Window;
+import net.sf.jasperreports.engine.*;
+import net.sf.jasperreports.engine.export.JRGraphics2DExporter;
+import net.sf.jasperreports.export.SimpleExporterInput;
+import net.sf.jasperreports.export.SimpleGraphics2DExporterOutput;
+import net.sf.jasperreports.export.SimpleGraphics2DReportConfiguration;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.util.Arrays;
+
+
+public class JasperFX {
+
+ private static final int WIDTH = 800;
+ private static final int HEIGHT = 600;
+
+ private final int RESOLUTION;
+ private final JasperPrint print;
+ private final Canvas canvas;
+ private final ComboBox cbxZoom;
+ private final ScrollBar sbHorizontal;
+ private final ScrollBar sbVertical;
+ private final JasperReportsContext jasperReportsContext;
+
+ private JRGraphics2DExporter exporter;
+ private Page pages;
+ private boolean loaded;
+ private Stage stage;
+
+ private AnimationTimer timer;
+ private long lastTimerCall;
+
+ public JasperFX(JasperPrint print) {
+ this.print = print;
+ this.canvas = new Canvas();
+ this.cbxZoom = new ComboBox<>();
+ this.sbHorizontal = new ScrollBar();
+ this.sbVertical = new ScrollBar();
+ this.loaded = false;
+ this.jasperReportsContext = DefaultJasperReportsContext.getInstance();
+
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ RESOLUTION = toolkit.getScreenResolution();
+ }
+
+ public void show() {
+ this.show(WIDTH, HEIGHT, null, Modality.NONE, StageStyle.DECORATED);
+ }
+
+ public void show(int width, int height, StageStyle style) {
+ this.show(width, height, null, Modality.NONE, style);
+ }
+
+ public void show(int width, int height, final Window owner, Modality modality, StageStyle style) {
+ pages = new Page(print.getPages().size() - 1, 0, 0);
+ Scene scene = createScene(pages, width, height);
+
+ stage = new Stage();
+ stage.setScene(scene);
+ stage.setTitle("Jasper ViewerFX");
+ stage.setOnShown(s -> showFirstPage());
+ stage.initOwner(owner);
+ stage.initModality(modality);
+ stage.initStyle(style);
+ stage.sizeToScene();
+ stage.show();
+ }
+
+ private Scene createScene(Page page, int width, int height) {
+ VBox vbxRoot = new VBox();
+
+ Region topShadow = new Region();
+ topShadow.setStyle("-fx-background-color: linear-gradient(from 100% 0% to 100% 100%, gray, transparent);");
+ topShadow.setMaxSize(Double.MAX_VALUE, 5);
+
+ cbxZoom.setMaxWidth(100);
+ cbxZoom.setEditable(true);
+ cbxZoom.setItems(FXCollections.observableArrayList(50, 75, 100, 125, 150, 175, 200, 250, 400, 800));
+ cbxZoom.getSelectionModel().select(2);
+ cbxZoom.getSelectionModel().selectedItemProperty().addListener((p, o, z) -> showPage(page.getActual()));
+ cbxZoom.setConverter(new ZoomConverter());
+ cbxZoom.getEditor().setContextMenu(new ContextMenu());
+ cbxZoom.getEditor().setOnKeyTyped(k -> {
+ if (!Character.isDigit(k.getCharacter().charAt(0))) {
+ k.consume();
+ }
+ });
+
+ sbVertical.setOrientation(Orientation.VERTICAL);
+
+ sbVertical.heightProperty().addListener((p, o, n) -> handleResize());
+ sbHorizontal.widthProperty().addListener((p, o, n) -> handleResize());
+
+ sbHorizontal.valueProperty().addListener((p, o, n) -> handleResize() /*renderPage(page.getActual())*/);
+ sbVertical.valueProperty().addListener((p, o, n) -> handleResize() /*renderPage(page.getActual())*/);
+
+ GridPane scrollPane = new GridPane();
+ scrollPane.add(sbHorizontal, 0, 1);
+ scrollPane.add(sbVertical, 1, 0);
+ scrollPane.add(canvas, 0, 0);
+ scrollPane.add(topShadow, 0, 0);
+
+ GridPane.setHgrow(sbVertical, Priority.NEVER);
+ GridPane.setVgrow(sbHorizontal, Priority.NEVER);
+
+ ColumnConstraints cc = new ColumnConstraints();
+ cc.setHgrow(Priority.ALWAYS);
+ cc.setMinWidth(0.0);
+
+ scrollPane.getColumnConstraints().add(cc);
+
+ RowConstraints rc = new RowConstraints();
+ rc.setValignment(VPos.TOP);
+ rc.setVgrow(Priority.ALWAYS);
+ rc.setMinHeight(0.0);
+
+ scrollPane.getRowConstraints().add(rc);
+
+ VBox.setVgrow(scrollPane, Priority.ALWAYS);
+
+ canvas.heightProperty().bind(sbVertical.heightProperty());
+ canvas.widthProperty().bind(sbHorizontal.widthProperty());
+
+ Button btnNext = new Button("Siguiente");
+ Button btnPrev = new Button("Anterior");
+ Button btnLast = new Button("Ultimo");
+ Button btnFirst = new Button("Primero");
+ Button btnSave = new Button("Guardar");
+ Button btnPrint = new Button("Imprimir");
+
+ btnPrint.setOnAction(ae -> printReport());
+ btnSave.setOnAction(ae -> saveReport());
+
+ btnNext.setOnAction((ae) -> showPage(nextPage()));
+ btnPrev.setOnAction((ae) -> showPage(prevPage()));
+ btnLast.setOnAction((ae) -> showPage(lastPage()));
+ btnFirst.setOnAction((ae) -> showPage(firstPage()));
+
+ btnFirst.getStyleClass().add("left-pill");
+ btnNext.getStyleClass().add("center-pill");
+ btnLast.getStyleClass().add("right-pill");
+ btnPrev.getStyleClass().add("center-pill");
+
+/* btnFirst.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ btnNext.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ btnLast.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ btnPrev.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ btnSave.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ btnPrint.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);*/
+
+ btnPrint.setTooltip(new Tooltip("Imprimir"));
+ btnSave.setTooltip(new Tooltip("Guardar"));
+
+ btnFirst.disableProperty().bind(page.firstPageProperty());
+ btnPrev.disableProperty().bind(page.firstPageProperty());
+ btnLast.disableProperty().bind(page.lastPageProperty());
+ btnNext.disableProperty().bind(page.lastPageProperty());
+
+ Text pageInfo = new Text("0 / 0");
+ pageInfo.textProperty().bind(page.actualPageProperty()
+ .asString().concat(" / ").concat(page.getLast() + 1));
+
+ HBox navBar = new HBox(btnFirst, btnPrev, btnNext, btnLast);
+ navBar.setAlignment(Pos.CENTER);
+
+ ToolBar hbxToolBar = new ToolBar(btnSave, btnPrint, new Separator(),
+ navBar, new Separator(), pageInfo, new Separator(), cbxZoom);
+
+ vbxRoot.getChildren().addAll(hbxToolBar, scrollPane);
+
+ return new Scene(vbxRoot, width, height);
+ }
+
+ private void saveReport() {
+ FileChooser fileChooser = new FileChooser();
+ fileChooser.setInitialFileName("Reporte.pdf");
+ fileChooser.setTitle("Guardar Reporte");
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PDF Document", Arrays.asList("*.pdf", "*.PDF")));
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("DOCX Document", Arrays.asList("*.docx", "*.DOCX")));
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("XLSX Document", Arrays.asList("*.xlsx", "*.XLSX")));
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("HTML Document", Arrays.asList("*.html", "*.HTML")));
+
+ File file = fileChooser.showSaveDialog(stage);
+
+ if (fileChooser.getSelectedExtensionFilter() != null && fileChooser.getSelectedExtensionFilter().getExtensions() != null) {
+ java.util.List selectedExtension = fileChooser.getSelectedExtensionFilter().getExtensions();
+ try {
+ if (selectedExtension.contains("*.pdf")) {
+ JasperExportManager.exportReportToPdfFile(print, file.getAbsolutePath());
+ } else if (selectedExtension.contains("*.html")) {
+ JasperExportManager.exportReportToHtmlFile(print, file.getAbsolutePath());
+ } else if (selectedExtension.contains("*.docx")) {
+ ReportExporter.docx(print, file.getAbsolutePath());
+ } else if (selectedExtension.contains("*.xlsx")) {
+ ReportExporter.xlsx(print, file.getAbsolutePath());
+ }
+ } catch (JRException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void printReport() {
+ try {
+ JasperPrintManager.printReport(print, true);
+ } catch (JRException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private int nextPage() {
+ return pages.moveNext().getActual();
+ }
+
+ private int prevPage() {
+ return pages.movePrev().getActual();
+ }
+
+ private int lastPage() {
+ return pages.moveLast().getActual();
+ }
+
+ private int firstPage() {
+ return pages.moveFirst().getActual();
+ }
+
+ private float getZoom() {
+ Integer zoom = cbxZoom.getSelectionModel().getSelectedItem();
+ return (zoom / 100.0f) * RESOLUTION / 72.0f;
+ }
+
+ private void showFirstPage() {
+ updateScrollSize(print, 0, getZoom());
+ renderPage(0);
+ loaded = true;
+ }
+
+ private void showPage(int page) {
+ sbVertical.setValue(0);
+ sbHorizontal.setValue(0);
+
+ updateScrollSize(print, page, getZoom());
+ renderPage(page);
+ }
+
+ private void handleResize() {
+ if (loaded) {
+ lastTimerCall = System.nanoTime();
+ if (timer == null) {
+ timer = new AnimationTimer() {
+ @Override
+ public void handle(long now) {
+ if (now > lastTimerCall + 2_500_000l /*30_000_000l*/) {
+ updateScrollSize(print, pages.getActual(), getZoom());
+ renderPage(pages.getActual());
+ timer.stop();
+ }
+ }
+ };
+ }
+ timer.start();
+ }
+ }
+
+ private void updateScrollSize(JasperPrint printer, int page, float zoom) {
+ PrintPageFormat pageFormat = printer.getPageFormat(page);
+
+ int image_width = (int) (pageFormat.getPageWidth() * zoom);
+ int image_height = (int) (pageFormat.getPageHeight() * zoom);
+
+ int canvas_height = (int) canvas.getHeight();
+ int canvas_width = (int) canvas.getWidth();
+
+ double maxv = image_height - canvas_height;
+ double visv = maxv - (maxv * (maxv / canvas_height));
+
+ sbVertical.setMax(maxv);
+ sbVertical.setVisibleAmount(visv);
+
+ double maxh = image_width - canvas_width;
+ double vish = maxh - (maxh * (maxh / canvas_width));
+
+ sbHorizontal.setMax(maxh);
+ sbHorizontal.setVisibleAmount(vish);
+ }
+
+ private void renderPage(int actual) {
+ try {
+ float zoomRatio = getZoom();
+
+ PrintPageFormat pageFormat = print.getPageFormat(actual);
+
+ int image_width = (int) (pageFormat.getPageWidth() * zoomRatio);
+ int image_height = (int) (pageFormat.getPageHeight() * zoomRatio);
+ int ch = (int) canvas.getHeight(), cw = (int) canvas.getWidth();
+ int xpos = cw > image_width ? (cw / 2) - (image_width / 2) : 0;
+ int ypos = ch > image_height ? (ch / 2) - (image_height / 2) : 0;
+
+ BufferedImage bimage = getImage(print, actual, zoomRatio);
+ WritableImage wimage = SwingFXUtils.toFXImage(bimage, null);
+
+ GraphicsContext gc = canvas.getGraphicsContext2D();
+ gc.clearRect(0, 0, cw, ch);
+ gc.drawImage(wimage, xpos, ypos);
+
+ } catch (JRException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private BufferedImage getImage(JasperPrint jasperPrint, int pageIndex, float zoom) throws JRException {
+ int canvas_width =(int) canvas.getWidth();
+ int canvas_height =(int) canvas.getHeight();
+
+ BufferedImage pageImage = new BufferedImage(canvas_width, canvas_height, BufferedImage.TYPE_INT_ARGB);
+
+ if (exporter == null) {
+ exporter = new JRGraphics2DExporter(jasperReportsContext);
+ exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
+ }
+
+ int offsetx = (int) sbHorizontal.getValue();
+ int offsety = (int) sbVertical.getValue();
+
+ SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput();
+ output.setGraphics2D((Graphics2D) pageImage.getGraphics());
+ output.getGraphics2D().translate(-offsetx, -offsety);
+
+ exporter.setExporterOutput(output);
+
+ SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration();
+ configuration.setPageIndex(pageIndex);
+ configuration.setZoomRatio(zoom);
+
+ exporter.setConfiguration(configuration);
+ exporter.exportReport();
+
+ return pageImage;
+ }
+
+}
diff --git a/src/application/reports/classes/Page.java b/src/application/reports/classes/Page.java
new file mode 100644
index 0000000..35b07c4
--- /dev/null
+++ b/src/application/reports/classes/Page.java
@@ -0,0 +1,92 @@
+package application.reports.classes;
+
+import javafx.beans.property.ReadOnlyBooleanProperty;
+import javafx.beans.property.ReadOnlyBooleanWrapper;
+import javafx.beans.property.ReadOnlyIntegerProperty;
+import javafx.beans.property.ReadOnlyIntegerWrapper;
+
+public class Page {
+ private int last, first, actual;
+
+ private final ReadOnlyIntegerWrapper actualPage;
+ private final ReadOnlyBooleanWrapper firstPage;
+ private final ReadOnlyBooleanWrapper lastPage;
+
+ public ReadOnlyBooleanProperty lastPageProperty() {
+ return lastPage.getReadOnlyProperty();
+ }
+
+ public Page(int last, int first, int actual) {
+ this.last = last;
+ this.first = first;
+ this.actual = actual;
+ this.actualPage = new ReadOnlyIntegerWrapper();
+ this.lastPage = new ReadOnlyBooleanWrapper();
+ this.firstPage = new ReadOnlyBooleanWrapper();
+ this.updateInfoPage(actual);
+ }
+
+ private void updateInfoPage(int page){
+ actualPage.set(page + 1);
+ firstPage.set(page == first);
+ lastPage.set(page == last);
+ actual = page;
+ }
+
+ public Page moveNext() {
+ updateInfoPage(actual < last ? actual + 1 : last);
+ return this;
+ }
+
+ public Page movePrev() {
+ updateInfoPage(actual > first ? actual - 1 : first);
+ return this;
+ }
+
+ public Page moveLast(){
+ updateInfoPage(last);
+ return this;
+ }
+
+ public Page moveFirst(){
+ updateInfoPage(first);
+ return this;
+ }
+
+ public Page MoveTo(int page){
+ updateInfoPage(page < first ? first : page > last ? last : page);
+ return this;
+ }
+
+ public int getLast() {
+ return last;
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public int getActual() {
+ return actual;
+ }
+
+ public int getActualPage() {
+ return actualPage.get();
+ }
+
+ public ReadOnlyIntegerProperty actualPageProperty() {
+ return actualPage.getReadOnlyProperty();
+ }
+
+ public boolean getFirstPage() {
+ return firstPage.get();
+ }
+
+ public ReadOnlyBooleanProperty firstPageProperty() {
+ return firstPage.getReadOnlyProperty();
+ }
+
+ public boolean getLastPage() {
+ return lastPage.get();
+ }
+}
diff --git a/src/application/reports/classes/ReportExporter.java b/src/application/reports/classes/ReportExporter.java
new file mode 100644
index 0000000..d4f21a6
--- /dev/null
+++ b/src/application/reports/classes/ReportExporter.java
@@ -0,0 +1,54 @@
+package application.reports.classes;
+
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.export.JRRtfExporter;
+import net.sf.jasperreports.engine.export.oasis.JROdtExporter;
+import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;
+import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;
+import net.sf.jasperreports.export.SimpleExporterInput;
+import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
+import net.sf.jasperreports.export.SimpleWriterExporterOutput;
+import net.sf.jasperreports.export.SimpleXlsxReportConfiguration;
+
+public class ReportExporter {
+ public static void docx(JasperPrint print, String file) throws JRException {
+ JRDocxExporter exporter = new JRDocxExporter();
+
+ exporter.setExporterInput(new SimpleExporterInput(print));
+ exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
+
+ exporter.exportReport();
+ }
+
+ public static void xlsx(JasperPrint print, String file) throws JRException {
+ JRXlsxExporter exporter = new JRXlsxExporter();
+
+ exporter.setExporterInput(new SimpleExporterInput(print));
+ exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
+ SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
+ configuration.setOnePagePerSheet(false);
+ exporter.setConfiguration(configuration);
+
+ exporter.exportReport();
+ }
+
+ public static void rtf(JasperPrint print, String file) throws JRException{
+ JRRtfExporter exporter = new JRRtfExporter();
+
+ exporter.setExporterInput(new SimpleExporterInput(print));
+ exporter.setExporterOutput(new SimpleWriterExporterOutput(file));
+
+ exporter.exportReport();
+ }
+
+ public static void odt(JasperPrint print, String file) throws JRException {
+ JROdtExporter exporter = new JROdtExporter();
+
+ exporter.setExporterInput(new SimpleExporterInput(print));
+ exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
+
+ exporter.exportReport();
+ }
+
+}
diff --git a/src/application/reports/classes/ZoomConverter.java b/src/application/reports/classes/ZoomConverter.java
new file mode 100644
index 0000000..7b27846
--- /dev/null
+++ b/src/application/reports/classes/ZoomConverter.java
@@ -0,0 +1,24 @@
+package application.reports.classes;
+
+import javafx.util.StringConverter;
+
+public class ZoomConverter extends StringConverter {
+ @Override
+ public String toString(Integer object) {
+ return object.toString() + " %";
+ }
+
+ @Override
+ public Integer fromString(String string) {
+ String zoom = string.split("%")[0];
+ if(zoom.isEmpty()){
+ return 100;
+ }else {
+ try {
+ return Integer.parseInt(zoom.trim());
+ }catch (NumberFormatException nfe){
+ return 100;
+ }
+ }
+ }
+}
diff --git a/src/application/repository/calculo/AcopladoRepository.java b/src/application/repository/calculo/AcopladoRepository.java
index 7ce0ec1..0266fc0 100644
--- a/src/application/repository/calculo/AcopladoRepository.java
+++ b/src/application/repository/calculo/AcopladoRepository.java
@@ -22,9 +22,8 @@ public void save(Acoplado acoplado){
preparedStatement.setString(1,null);
preparedStatement.setString(2, acoplado.getMarca());
preparedStatement.setString(3, acoplado.getPatente());
- preparedStatement.setString(4, null);
+ preparedStatement.setString(4, acoplado.getChasisNumero());
preparedStatement.executeUpdate();
- preparedStatement.close();
String cuerpoMsj = "Acoplado \n Marca: " + acoplado.getMarca() + "\nPatente: "+acoplado.getPatente() +"\nagregado correctamente.\n";
Alerta.alertaInfo("Acoplados",cuerpoMsj);
} catch (SQLException e) {
@@ -37,16 +36,16 @@ public void update(Acoplado acoplado){
try {
connection = JDBCConnection.getInstanceConnection();
preparedStatement= connection.prepareStatement("UPDATE ACOPLADO " +
- "SET Marca=?, Patente=?" +
+ "SET Marca=?, Patente=?, ChasisNumero=?" +
"WHERE idAcoplado=?");
preparedStatement.setString(1, acoplado.getMarca());
preparedStatement.setString(2, acoplado.getPatente());
- preparedStatement.setInt(3, acoplado.getId());
+ preparedStatement.setString(3, acoplado.getChasisNumero());
+ preparedStatement.setInt(4, acoplado.getId());
preparedStatement.executeUpdate();
- preparedStatement.close();
String headerMsj="Actualización: Acoplado actualizado";
String cuerpoMsj = "Acoplado: \n\tMarca: " + acoplado.getMarca() + "\n\tPatente: " +
- acoplado.getPatente()+ "modificado correctamente.";
+ acoplado.getPatente()+ "modificado correctamente.";
Alerta.alertaInfo("Acoplados", headerMsj, cuerpoMsj);
} catch (SQLException e) {
e.printStackTrace();
@@ -60,7 +59,6 @@ public void delete(Acoplado acoplado){
"DELETE FROM ACOPLADO WHERE idAcoplado=?");
preparedStatement.setInt(1, acoplado.getId());
preparedStatement.execute();
- preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -77,28 +75,16 @@ public ObservableList view(){
acoplado.setId(resultSet.getInt(1));
acoplado.setMarca(resultSet.getString(2));
acoplado.setPatente(resultSet.getString(3));
+ acoplado.setChasisNumero(resultSet.getString(4));
list.add(acoplado);
}
- preparedStatement.close();
- resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
- public void search(Acoplado acoplado){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM ACOPLADO where idAcoplado=?");
- preparedStatement.setInt(1,acoplado.getId());
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
public Acoplado getAcopladoById(int idAcoplado){
Acoplado acoplado = new Acoplado();
@@ -111,14 +97,13 @@ public Acoplado getAcopladoById(int idAcoplado){
acoplado.setId(resultSet.getInt("idAcoplado"));
acoplado.setMarca(resultSet.getString("Marca"));
acoplado.setPatente(resultSet.getString("Patente"));
+ acoplado.setChasisNumero(resultSet.getString("ChasisNumero"));
}
} catch (SQLException e) {
e.printStackTrace();
}
-
return acoplado;
-
}
-}
+}
\ No newline at end of file
diff --git a/src/application/repository/calculo/CamionRepository.java b/src/application/repository/calculo/CamionRepository.java
index 0947202..7a7496f 100644
--- a/src/application/repository/calculo/CamionRepository.java
+++ b/src/application/repository/calculo/CamionRepository.java
@@ -23,8 +23,8 @@ public void save(Camion camion){
preparedStatement.setString(2,camion.getMarca());
preparedStatement.setString(3,camion.getModelo());
preparedStatement.setString(4,camion.getPatente());
- preparedStatement.setString(5, null);
- preparedStatement.setString(6, null);
+ preparedStatement.setString(5, camion.getMotor());
+ preparedStatement.setString(6, camion.getChasis());
preparedStatement.execute();
String cuerpoMsj = "Camión: " + camion.getMarca() + " agregado correctamente.\n";
Alerta.alertaInfo("Camiones",cuerpoMsj);
@@ -37,12 +37,14 @@ public void update(Camion camion){
connection = JDBCConnection.getInstanceConnection();
preparedStatement= connection.prepareStatement("" +
"UPDATE CAMION " +
- "SET Marca=?, Modelo=?, Patente=? " +
+ "SET Marca=?, Modelo=?, Patente=?, MotorNumero=?, ChasisNumero=? " +
"WHERE idCamion=?");
preparedStatement.setString(1,camion.getMarca());
preparedStatement.setString(2,camion.getModelo());
preparedStatement.setString(3,camion.getPatente());
- preparedStatement.setInt(4,camion.getId());
+ preparedStatement.setString(4, camion.getMotor());
+ preparedStatement.setString(5, camion.getChasis());
+ preparedStatement.setInt(6,camion.getId());
preparedStatement.execute();
String headerMsj="Actualización: Camión actualizado";
String cuerpoMsj = "Camión: " + camion.getMarca() + " modificado correctamente.";
@@ -76,6 +78,8 @@ public ObservableList view(){
camion.setMarca(resultSet.getString(2));
camion.setModelo(resultSet.getString(3));
camion.setPatente(resultSet.getString(4));
+ camion.setMotor(resultSet.getString(5));
+ camion.setChasis(resultSet.getString(6));
list.add(camion);
}
@@ -84,17 +88,6 @@ public ObservableList view(){
}
return list;
}
- public void search(Camion camion){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM CAMION where idCamion=?");
- preparedStatement.setInt(1,camion.getId());
- preparedStatement.execute();
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- }
public Camion getCamionById(int idCamion){
Camion camion = new Camion();
@@ -108,12 +101,12 @@ public Camion getCamionById(int idCamion){
camion.setMarca(resultSet.getString("Marca"));
camion.setModelo(resultSet.getString("Modelo"));
camion.setPatente(resultSet.getString("PATENTE"));
+ camion.setMotor(resultSet.getString("MotorNumero"));
+ camion.setChasis(resultSet.getString("ChasisNumero"));
}
} catch (SQLException e) {
e.printStackTrace();
}
-
return camion;
-
}
}
diff --git a/src/application/repository/calculo/FincaRepository.java b/src/application/repository/calculo/FincaRepository.java
index 5725bbc..52394d4 100644
--- a/src/application/repository/calculo/FincaRepository.java
+++ b/src/application/repository/calculo/FincaRepository.java
@@ -6,7 +6,6 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import java.awt.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
diff --git a/src/application/repository/calculo/OrigenDestinoRepository.java b/src/application/repository/calculo/OrigenDestinoRepository.java
index 92688ba..3702f20 100644
--- a/src/application/repository/calculo/OrigenDestinoRepository.java
+++ b/src/application/repository/calculo/OrigenDestinoRepository.java
@@ -134,4 +134,50 @@ public int getIdByFincaIngenio(int idFinca, int idIngenio){
return idOrigenDestino;
}
+
+ public ObservableList viewByIngenio(int idIngenio) {
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("" +
+ " SELECT o.idOrigen_Destino, f.nombre, i.nombre, o.distanciakm " +
+ "FROM origen_destino AS o, finca AS f, ingenio AS i " +
+ "WHERE o.FINCA_idFinca = f.idfinca AND o.INGENIO_idIngenio = i.idIngenio AND i.idIngenio=?");
+ preparedStatement.setInt(1, idIngenio);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ OrigenDestino origenDestino = new OrigenDestino();
+ origenDestino.setIdOrigenDestino(resultSet.getInt(1));
+ origenDestino.setNombreFinca(resultSet.getString(2));
+ origenDestino.setNombreIngenio(resultSet.getString(3));
+ origenDestino.setDistanciaKM(resultSet.getFloat(4));
+ list.add(origenDestino);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return list;
+
+ }
+ public boolean isDuplicated(int idIngenio, int idFinca) {
+ boolean isDuplicated = false;
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("" +
+ " SELECT FINCA_idFinca, INGENIO_idIngenio FROM origen_destino " +
+ "WHERE FINCA_idFinca=? AND INGENIO_idIngenio =?");
+ preparedStatement.setInt(1, idFinca);
+ preparedStatement.setInt(2, idIngenio);
+ resultSet = preparedStatement.executeQuery();
+ if (resultSet.absolute(1)){
+ isDuplicated=true;
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return isDuplicated;
+
+ }
}
diff --git a/src/application/repository/compra/ArticuloRepository.java b/src/application/repository/compra/ArticuloRepository.java
index 8153925..ba156fd 100644
--- a/src/application/repository/compra/ArticuloRepository.java
+++ b/src/application/repository/compra/ArticuloRepository.java
@@ -4,11 +4,13 @@
import application.database.JDBCConnection;
import application.model.compra.Articulo;
import application.model.compra.CategoriaArticulo;
-import com.sun.corba.se.impl.encoding.TypeCodeInputStream;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
public class ArticuloRepository {
Connection connection;
diff --git a/src/application/repository/compra/CategoriaArticuloRepository.java b/src/application/repository/compra/CategoriaArticuloRepository.java
index 6c2d048..b53565f 100644
--- a/src/application/repository/compra/CategoriaArticuloRepository.java
+++ b/src/application/repository/compra/CategoriaArticuloRepository.java
@@ -6,8 +6,10 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
public class CategoriaArticuloRepository {
diff --git a/src/application/repository/compra/FacturaCompraRepository.java b/src/application/repository/compra/FacturaCompraRepository.java
index 529606b..bd56bdb 100644
--- a/src/application/repository/compra/FacturaCompraRepository.java
+++ b/src/application/repository/compra/FacturaCompraRepository.java
@@ -4,7 +4,6 @@
import application.database.JDBCConnection;
import application.model.compra.FacturaCompra;
import application.model.compra.Proveedor;
-import com.sun.org.apache.regexp.internal.RE;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -99,6 +98,5 @@ public int getLastID() {
}
return lastIdFactura;
}
-//TODO: hacer un metodo para obtener facturas en un rango de fechas? o bien ¿utilizar un procedimiento?
}
diff --git a/src/application/repository/info/CategoriaEmpleadoRepository.java b/src/application/repository/info/CategoriaEmpleadoRepository.java
index bc37672..1c00e29 100644
--- a/src/application/repository/info/CategoriaEmpleadoRepository.java
+++ b/src/application/repository/info/CategoriaEmpleadoRepository.java
@@ -1,15 +1,15 @@
- package application.repository.info;
+ package application.repository.info;
- import application.comunes.Alerta;
- import application.database.JDBCConnection;
-import application.model.info.CategoriaEmpleado;
+ import application.comunes.Alerta;
+ import application.database.JDBCConnection;
+ import application.model.info.CategoriaEmpleado;
import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
+ import javafx.collections.ObservableList;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
+ import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
public class CategoriaEmpleadoRepository {
Connection connection;
@@ -82,25 +82,24 @@ public ObservableList view(){
return list;
}
-
- public CategoriaEmpleado search(int idCategoriaEmpleado){
- CategoriaEmpleado categoriaEmpleado = new CategoriaEmpleado();
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM CATEGORIA_EMPLEADO where idCategoriaEmpleado=?");
- preparedStatement.setInt(1, idCategoriaEmpleado);
- if(resultSet.next()){
- categoriaEmpleado.setIdCategoriaEmpleado(idCategoriaEmpleado);
- categoriaEmpleado.setNombre(resultSet.getString("NombreCategoria"));
- }
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ public CategoriaEmpleado search(int idCategoriaEmpleado){
+ CategoriaEmpleado categoriaEmpleado = new CategoriaEmpleado();
-
- return categoriaEmpleado;
- }
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT * FROM CATEGORIA_EMPLEADO where idCategoriaEmpleado=?");
+ preparedStatement.setInt(1, idCategoriaEmpleado);
+ resultSet = preparedStatement.executeQuery();
+ if(resultSet.next()){
+ categoriaEmpleado.setIdCategoriaEmpleado(idCategoriaEmpleado);
+ categoriaEmpleado.setNombre(resultSet.getString("NombreCategoria"));
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+
+ return categoriaEmpleado;
+ }
}
\ No newline at end of file
diff --git a/src/application/repository/info/DomicilioRepository.java b/src/application/repository/info/DomicilioRepository.java
index d0d753f..69ec7f1 100644
--- a/src/application/repository/info/DomicilioRepository.java
+++ b/src/application/repository/info/DomicilioRepository.java
@@ -1,15 +1,15 @@
package application.repository.info;
- import application.comunes.Alerta;
- import application.database.JDBCConnection;
- import application.model.info.Domicilio;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
+ import application.comunes.Alerta;
+ import application.database.JDBCConnection;
+ import application.model.info.Domicilio;
+ import javafx.collections.FXCollections;
+ import javafx.collections.ObservableList;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
+ import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
public class DomicilioRepository {
Connection connection;
diff --git a/src/application/repository/info/EmpleadoRepository.java b/src/application/repository/info/EmpleadoRepository.java
index 9b0e3f5..bea9d01 100644
--- a/src/application/repository/info/EmpleadoRepository.java
+++ b/src/application/repository/info/EmpleadoRepository.java
@@ -1,25 +1,20 @@
package application.repository.info;
import application.comunes.Alerta;
+import application.database.JDBCConnection;
import application.model.info.*;
+import com.ibm.icu.impl.duration.impl.DataRecord;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import application.database.JDBCConnection;
+import java.sql.*;
public class EmpleadoRepository {
Connection connection;
PreparedStatement preparedStatement;
ResultSet resultSet;
- private int lastID;
- public ObservableList buscarEmpleados(){
+ public ObservableList buscarEmpleados(){
ObservableList empleados = FXCollections.observableArrayList();
try {
connection = JDBCConnection.getInstanceConnection();
@@ -33,7 +28,7 @@ public ObservableList buscarEmpleados(){
" AND e.FechaBaja IS null " + //aqui traemos a los empleados cuya fecha de baja no fue ingresada
" AND l.PROVINCIA_idProvincia=p.idProvincia");
resultSet = preparedStatement.executeQuery();
-
+
while(resultSet.next()){
Empleado empleado = new Empleado();
empleado.setIdEmpleado(resultSet.getInt(1));
@@ -48,7 +43,7 @@ public ObservableList buscarEmpleados(){
resultSet.getString(9), resultSet.getString(10)));
empleados.add(empleado);
}
- } catch (SQLException e) {
+ } catch (SQLException e) {
e.printStackTrace();
}
return empleados;
@@ -60,17 +55,17 @@ public ObservableList buscarEmpleados(){
*/
public void logicDelete(Empleado empleado){
try {
- Connection connection = JDBCConnection.getInstanceConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(
- "UPDATE EMPLEADO SET FechaBaja=? where idEmpleado=?");
+ Connection connection = JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(
+ "UPDATE EMPLEADO SET FechaBaja=? where idEmpleado=?");
preparedStatement.setString(1, empleado.getFechaBaja());
preparedStatement.setInt(2, empleado.getIdEmpleado());
- preparedStatement.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ preparedStatement.executeUpdate();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
}
-
+
public void edit(Empleado empleado){
try {
connection = JDBCConnection.getInstanceConnection();
@@ -94,79 +89,79 @@ public void edit(Empleado empleado){
e.printStackTrace();
}
}
-
+
public static Empleado buscarEmpleadoById(Integer id){
-
+
Empleado empleado = new Empleado();
Statement statement = null;
ResultSet resultSet = null;
-
+
try {
statement = JDBCConnection.getInstanceConnection().createStatement();
resultSet = statement.executeQuery("SELECT * FROM EMPLEADO e, CATEGORIA_EMPLEADO c, DOMICILIO d "
+ "WHERE e.CATEGORIA_EMPLEADO_idCategoriaEmpleado = c.idCategoriaEmpleado "
+ "AND e.DOMICILIO_idDomicilio = d.idDomicilio "
- + "AND e.idEmpleado="+id);
+ + "AND e.idEmpleado="+id);
if(resultSet.next())
{
- empleado.setNombre(resultSet.getString("Nombre"));
- empleado.setApellido(resultSet.getString("Apellido"));
+ empleado.setNombre(resultSet.getString("Nombre"));
+ empleado.setApellido(resultSet.getString("Apellido"));
}
-
- }catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return empleado;
+
+ }catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- public ObservableList getEmpleadosByCategoriaEmpleado(int idCategoria){
- ObservableList list = FXCollections.observableArrayList();
- try {
- Connection connection= JDBCConnection.getInstanceConnection();
- PreparedStatement preparedStatement=connection.prepareStatement("select idEmpleado, " +
- "Apellido, Nombre " +
- "from Empleado " +
- "where CATEGORIA_EMPLEADO_idCategoriaEmpleado = ?" +
- " AND FechaBaja IS null");
- preparedStatement.setInt(1,idCategoria);
- ResultSet resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Empleado empleado = new Empleado();
- empleado.setIdEmpleado(resultSet.getInt(1));
- empleado.setApellido(resultSet.getString(2));
- empleado.setNombre(resultSet.getString(3));
- list.add(empleado);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ return empleado;
+ }
- return list;
+ public ObservableList getEmpleadosByCategoriaEmpleado(int idCategoria){
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ Connection connection= JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement=connection.prepareStatement("select idEmpleado, " +
+ "Apellido, Nombre " +
+ "from Empleado " +
+ "where CATEGORIA_EMPLEADO_idCategoriaEmpleado = ?" +
+ " AND FechaBaja IS null");
+ preparedStatement.setInt(1,idCategoria);
+ ResultSet resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Empleado empleado = new Empleado();
+ empleado.setIdEmpleado(resultSet.getInt(1));
+ empleado.setApellido(resultSet.getString(2));
+ empleado.setNombre(resultSet.getString(3));
+ list.add(empleado);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
}
+
+ return list;
+ }
/**
* @Isa: El empleado siempre se guarda con una fecha de baja null
*/
- public void save(Empleado empleado){
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement= connection.prepareStatement("INSERT INTO EMPLEADO VALUES(?,?,?,?,?,?,LAST_INSERT_ID(),?,?)");
- preparedStatement.setString(1,null);
- preparedStatement.setString(2, empleado.getCuit());
- preparedStatement.setInt(3, empleado.getCategoriaEmpleado().getIdCategoriaEmpleado());
- preparedStatement.setString(4, empleado.getNombre());
- preparedStatement.setString(5, empleado.getApellido());
- preparedStatement.setString(6, empleado.getNacimiento());
- preparedStatement.setString(7, empleado.getFechaAlta());
- preparedStatement.setString(8, null); //fecha de baja
- preparedStatement.executeUpdate();
- String cuerpoMsj = "Empleado " + empleado.getNombre() + " agregado correctamente.\n";
- Alerta.alertaInfo("Empleados",cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
+ public void save(Empleado empleado){
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement= connection.prepareStatement("INSERT INTO EMPLEADO VALUES(?,?,?,?,?,?,LAST_INSERT_ID(),?,?)");
+ preparedStatement.setString(1,null);
+ preparedStatement.setString(2, empleado.getCuit());
+ preparedStatement.setInt(3, empleado.getCategoriaEmpleado().getIdCategoriaEmpleado());
+ preparedStatement.setString(4, empleado.getNombre());
+ preparedStatement.setString(5, empleado.getApellido());
+ preparedStatement.setString(6, empleado.getNacimiento());
+ preparedStatement.setString(7, empleado.getFechaAlta());
+ preparedStatement.setString(8, null); //fecha de baja
+ preparedStatement.executeUpdate();
+ String cuerpoMsj = "Empleado " + empleado.getNombre() + " agregado correctamente.\n";
+ Alerta.alertaInfo("Empleados",cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
public ObservableList buscarEmpleadosDadosDeBaja(){
ObservableList empleados = FXCollections.observableArrayList();
try {
@@ -202,19 +197,68 @@ public ObservableList buscarEmpleadosDadosDeBaja(){
}
return empleados;
}
+ public Empleado getEmpleadoById(int idEmpleado){
+ Empleado empleado = new Empleado();
+ try {
+ Connection connection= JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement =connection.prepareStatement("\tSELECT idEmpleado, CUIT, Nombre, Apellido, FechaNacimiento,\n" +
+ "\t\tCATEGORIA_EMPLEADO_idCategoriaEmpleado, NombreCategoria\n" +
+ "\t\t\t\t\t FROM EMPLEADO, CATEGORIA_EMPLEADO \n" +
+ "\t\t\t\t\t WHERE idEmpleado=? \n" +
+ "\t\t\t\t\t AND CATEGORIA_EMPLEADO_idCategoriaEmpleado = idCategoriaEmpleado");
+ preparedStatement.setInt(1,idEmpleado);
+ ResultSet resultSet = preparedStatement.executeQuery();
+ if (resultSet.next()){
+ empleado.setIdEmpleado(resultSet.getInt(1));
+ empleado.setCuit(resultSet.getString(2));
+ empleado.setNombre(resultSet.getString(3));
+ empleado.setApellido(resultSet.getString(4));
+ empleado.setNacimiento(resultSet.getString(5));
+ empleado.setCategoriaEmpleado(new CategoriaEmpleado(resultSet.getInt(6), resultSet.getString(7)));
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return empleado;
+ }
- public int getLastID() {
+ public int getLastID() {
int lastId=0;
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT MAX(idEmpleado) FROM EMPLEADO");
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next())
- lastId= resultSet.getInt(1);
- return lastId;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return lastId;
- }
-}
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT MAX(idEmpleado) FROM EMPLEADO");
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next())
+ lastId= resultSet.getInt(1);
+ return lastId;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return lastId;
+ }
+ public ObservableList getConductores(){
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ Connection connection= JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement=connection.prepareStatement("SELECT idEmpleado, Apellido, Nombre \n" +
+ "\t\tFROM Empleado INNER JOIN categoria_empleado \n" +
+ "\t\t\tON CATEGORIA_EMPLEADO_idCategoriaEmpleado = idCategoriaEmpleado\n" +
+ "\t\tWHERE nombreCategoria like 'con%'\n" +
+ "\t\t\tAND FechaBaja is null;");
+
+ ResultSet resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Empleado empleado = new Empleado();
+ empleado.setIdEmpleado(resultSet.getInt(1));
+ empleado.setApellido(resultSet.getString(2));
+ empleado.setNombre(resultSet.getString(3));
+ list.add(empleado);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return list;
+ }
+
+}
\ No newline at end of file
diff --git a/src/application/repository/info/FamiliarRepository.java b/src/application/repository/info/FamiliarRepository.java
index ac28ea5..355986b 100644
--- a/src/application/repository/info/FamiliarRepository.java
+++ b/src/application/repository/info/FamiliarRepository.java
@@ -3,7 +3,6 @@
import application.comunes.Alerta;
import application.database.JDBCConnection;
import application.model.info.Familiar;
-import com.sun.org.apache.bcel.internal.generic.FADD;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
diff --git a/src/application/repository/info/LocalidadRepository.java b/src/application/repository/info/LocalidadRepository.java
index 9d7945c..5f4f61f 100644
--- a/src/application/repository/info/LocalidadRepository.java
+++ b/src/application/repository/info/LocalidadRepository.java
@@ -1,16 +1,16 @@
package application.repository.info;
- import application.comunes.Alerta;
- import application.database.JDBCConnection;
- import application.model.info.Localidad;
- import application.model.info.Provincia;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
-
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
+ import application.comunes.Alerta;
+ import application.database.JDBCConnection;
+ import application.model.info.Localidad;
+ import application.model.info.Provincia;
+ import javafx.collections.FXCollections;
+ import javafx.collections.ObservableList;
+
+ import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
public class LocalidadRepository {
Connection connection;
@@ -43,7 +43,6 @@ public void update(Localidad localidad, int idProvincia){
preparedStatement.setInt(2,idProvincia);
preparedStatement.setInt(3,localidad.getIdLocalidad());
preparedStatement.close();
- connection.close();
String headerMsj="Actualización: localidad actualizada";
String cuerpoMsj = "Localidad: " + localidad.getNombre() + " modificado correctamente.";
Alerta.alertaInfo("Localidad", headerMsj, cuerpoMsj);
@@ -59,7 +58,6 @@ public void delete(Localidad localidad){
preparedStatement.setInt(1, localidad.getIdLocalidad());
preparedStatement.executeUpdate();
preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -85,15 +83,14 @@ public ObservableList view(int idProvincia){
return list;
}
- public ObservableList view2(int idProvincia){
+ public ObservableList localidadesDeTucuman(){
ObservableList list = FXCollections.observableArrayList();
try {
connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM LOCALIDAD WHERE PROVINCIA_idProvincia = ?");
- preparedStatement.setInt(1,idProvincia);
+ preparedStatement=connection.prepareStatement("SELECT idLocalidad, NombreLocalidad " +
+ "FROM LOCALIDAD, PROVINCIA where PROVINCIA_idProvincia = idProvincia AND NombreProvincia like 'tuc%';");
resultSet = preparedStatement.executeQuery();
-
while (resultSet.next()){
Localidad localidad = new Localidad();
localidad.setIdLocalidad(resultSet.getInt("idLocalidad"));
diff --git a/src/application/repository/info/ProvinciaRepository.java b/src/application/repository/info/ProvinciaRepository.java
index b5265a5..1c9d622 100644
--- a/src/application/repository/info/ProvinciaRepository.java
+++ b/src/application/repository/info/ProvinciaRepository.java
@@ -1,15 +1,14 @@
package application.repository.info;
- import application.comunes.Alerta;
- import application.database.JDBCConnection;
- import application.model.info.Provincia;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
+ import application.database.JDBCConnection;
+ import application.model.info.Provincia;
+ import javafx.collections.FXCollections;
+ import javafx.collections.ObservableList;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
+ import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
public class ProvinciaRepository {
Connection connection;
diff --git a/src/application/repository/info/UsuarioRepository.java b/src/application/repository/info/UsuarioRepository.java
index 4b08e62..9579534 100644
--- a/src/application/repository/info/UsuarioRepository.java
+++ b/src/application/repository/info/UsuarioRepository.java
@@ -1,15 +1,15 @@
package application.repository.info;
+import application.comunes.Alerta;
+import application.database.JDBCConnection;
import application.model.info.Empleado;
-import javafx.beans.property.StringProperty;
+import application.model.info.Usuario;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import javax.swing.undo.UndoableEditSupport;
import java.sql.*;
-import application.database.JDBCConnection;
-import application.model.info.Usuario;
-
public class UsuarioRepository {
Connection connection;
PreparedStatement preparedStatement;
@@ -23,24 +23,25 @@ public static ObservableList buscarUsuarios(){
try {
statement = JDBCConnection.getInstanceConnection().createStatement();
- resultSet = statement.executeQuery("select * from USUARIO");
-
+ resultSet = statement.executeQuery("SELECT idUsuario, NombreUsuario, Password, idEmpleado, Nombre, Apellido " +
+ "FROM USUARIO INNER JOIN EMPLEADO " +
+ "ON Empleado_idEmpleado=idEmpleado");
+
while(resultSet.next()){
- Usuario usuario = new Usuario();
- usuario.setIdUsuario(resultSet.getInt("idUsuario"));
- usuario.setNombre_usuario(resultSet.getString("NombreUsuario"));
- usuario.setPassword(resultSet.getString("Password"));
- usuario.setEmpleado(new Empleado());
- usuario.getEmpleado().setIdEmpleado(resultSet.getInt("Empleado_idEmpleado"));
- usuarios.add(usuario);
+ Usuario usuario = new Usuario();
+ usuario.setIdUsuario(resultSet.getInt(1));
+ usuario.setNombre_usuario(resultSet.getString(2));
+ usuario.setPassword(resultSet.getString(3));
+ usuario.setEmpleado(new Empleado());
+ usuario.getEmpleado().setIdEmpleado(resultSet.getInt(4));
+ usuario.getEmpleado().setNombre(resultSet.getString(5));
+ usuario.getEmpleado().setApellido(resultSet.getString(6));
+ usuarios.add(usuario);
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
-
return usuarios;
-
}
public void create(Usuario usuario){
@@ -59,19 +60,20 @@ public void create(Usuario usuario){
}
}
- public static void edit(Usuario usuario, int idEmpleado){
+ public static void edit(Usuario usuario){
PreparedStatement preparedstatement;
-
try {
preparedstatement = JDBCConnection.getInstanceConnection().prepareStatement(
- "UPDATE USUARIO SET NombreUsuario=?, Password=?, Empleado_idEmpleado=? WHERE idUsuario=?)");
+ "UPDATE USUARIO SET NombreUsuario=?, Password=MD5(?), Empleado_idEmpleado=? WHERE idUsuario=?");
preparedstatement.setString(1, usuario.getNombre_usuario());
preparedstatement.setString(2, usuario.getPassword());
- preparedstatement.setInt(3, idEmpleado);
+ preparedstatement.setInt(3, usuario.getEmpleado().getIdEmpleado());
preparedstatement.setInt(4, usuario.getIdUsuario());
preparedstatement.executeUpdate();
+ String headerMsj="Actualización: usuario actualizado";
+ String cuerpoMsj = "Usuario: " + usuario.getNombre_usuario() + " modificado correctamente.";
+ Alerta.alertaInfo("Usuarios", headerMsj, cuerpoMsj);
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
@@ -85,11 +87,7 @@ public static void delete(Usuario usuario){
"DELETE FROM USUARIO WHERE idUsuario=?");
preparedstatement.setInt(1, usuario.getIdUsuario());
preparedstatement.executeUpdate();
- preparedstatement.close();
-
-
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
diff --git a/src/application/repository/sueldo/DetalleLiquidacionEmpleadoRepository.java b/src/application/repository/sueldo/DetalleLiquidacionEmpleadoRepository.java
index c9feec9..f391e1a 100644
--- a/src/application/repository/sueldo/DetalleLiquidacionEmpleadoRepository.java
+++ b/src/application/repository/sueldo/DetalleLiquidacionEmpleadoRepository.java
@@ -26,8 +26,6 @@ public void save(DetalleLiquidacionEmpleado detalleLiquidacionEmpleado){
// preparedStatement.setInt(4, detalleLiquidacionEmpleado.getIdCodigoConcepto());
preparedStatement.setDouble(5, detalleLiquidacionEmpleado.getMonto());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
@@ -49,8 +47,6 @@ public void update(DetalleLiquidacionEmpleado detalleLiquidacionEmpleado){
preparedStatement.setDouble(4,detalleLiquidacionEmpleado.getMonto());
preparedStatement.setInt(5, detalleLiquidacionEmpleado.getIdDetalleLiquidacionEmpleado());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -62,7 +58,6 @@ public void delete(DetalleLiquidacionEmpleado detalleLiquidacionEmpleado){
preparedStatement= connection.prepareStatement("DELETE FROM detalle_liquidacion_empleado WHERE idDetalleLiquidacionEmpleado=?");
preparedStatement.setInt(1,detalleLiquidacionEmpleado.getIdDetalleLiquidacionEmpleado());
preparedStatement.executeUpdate();
- preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -83,12 +78,9 @@ public ObservableList view(){
detalleLiquidacionEmpleado.setMonto(resultSet.getDouble(5));
list.add(detalleLiquidacionEmpleado);
}
- preparedStatement.close();
- resultSet.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
-}
+}
\ No newline at end of file
diff --git a/src/application/repository/sueldo/LiquidacionEmpleadoRepository.java b/src/application/repository/sueldo/LiquidacionEmpleadoRepository.java
index ce45b87..140e886 100644
--- a/src/application/repository/sueldo/LiquidacionEmpleadoRepository.java
+++ b/src/application/repository/sueldo/LiquidacionEmpleadoRepository.java
@@ -1,7 +1,11 @@
package application.repository.sueldo;
import application.database.JDBCConnection;
+import application.model.info.CategoriaEmpleado;
+import application.model.info.Empleado;
import application.model.sueldo.LiquidacionEmpleado;
+import application.repository.info.EmpleadoRepository;
+import application.view.venta.cruds.EmitirFacturaController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -9,6 +13,8 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
public class LiquidacionEmpleadoRepository {
Connection connection;
@@ -29,8 +35,6 @@ public void save(LiquidacionEmpleado liquidacionEmpleado){
// preparedStatement.setInt(8, liquidacionEmpleado.getIdPeriodoLiquidacion());
// preparedStatement.setInt(9,liquidacionEmpleado.getIdEmpleado());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -47,15 +51,12 @@ public void update(LiquidacionEmpleado liquidacionEmpleado){
preparedStatement.setString(1,liquidacionEmpleado.getFechaLiquidacion());
preparedStatement.setDouble(2,liquidacionEmpleado.getImporteNeto());
preparedStatement.setDouble(3,liquidacionEmpleado.getTotalHaberesRemunerativos());
- preparedStatement.setDouble(4,liquidacionEmpleado.getTotalHaberesNoRemunerativos());
preparedStatement.setDouble(5,liquidacionEmpleado.getTotalRetenciones());
preparedStatement.setDouble(6,liquidacionEmpleado.getTotalBruto());
// preparedStatement.setInt(7,liquidacionEmpleado.setIdPeriodoLiquidacion());
// preparedStatement.setInt(8,liquidacionEmpleado.setIdEmpleado());
preparedStatement.setInt(9,liquidacionEmpleado.getId());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -66,8 +67,6 @@ public void delete(LiquidacionEmpleado liquidacionEmpleado){
preparedStatement=connection.prepareStatement("DELETE FROM LIQUIDACION_EMPLEADO WHERE idLiquidacionEmpleado=?");
preparedStatement.setInt(1,liquidacionEmpleado.getId());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -92,12 +91,69 @@ public ObservableList view(){
list.add(liquidacionEmpleado);
}
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
-}
+ /**
+ * Busca LiquidacionEmpleado a partir de un idLiquidacion
+ *
+ * @param idLiquidacion
+ * @return ObservableList
+ */
+ public ObservableList getLiqEmpleadoByIdLiq(int idLiquidacion){
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("SELECT idLiquidacionEmpleado, fecha_liquidacion, importe_neto, total_haberes_remunerativos, \n" +
+ "\ttotal_haberes_no_remunerativos, total_retenciones, total_bruto, EMPLEADO_idEmpleado, CUIT,\n" +
+ "\tCATEGORIA_EMPLEADO_idCategoriaEmpleado, NombreCategoria, Nombre, Apellido, FechaNacimiento, inicio_periodo, fin_periodo \n" +
+ "\t\t\t\t\tFROM LIQUIDACION_EMPLEADO INNER JOIN EMPLEADO INNER JOIN CATEGORIA_EMPLEADO\n" +
+ "\t\t\t\t\tON CATEGORIA_EMPLEADO_idCategoriaEmpleado = idCategoriaEmpleado AND \n" +
+ "\t\t\t\t\tEMPLEADO_idEmpleado = idEmpleado \n" +
+ "\t\t\t\t\tWHERE LIQUIDACION_idLIQUIDACION = ?");
+ preparedStatement.setInt(1, idLiquidacion);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ LiquidacionEmpleado liquidacionEmpleado = new LiquidacionEmpleado();
+ liquidacionEmpleado.setId(resultSet.getInt("idLiquidacionEmpleado"));
+ liquidacionEmpleado.setFechaLiquidacion(resultSet.getString("fecha_liquidacion"));
+ liquidacionEmpleado.setImporteNeto(resultSet.getDouble("importe_neto"));
+ liquidacionEmpleado.setTotalHaberesRemunerativos(resultSet.getDouble("total_haberes_remunerativos"));
+ liquidacionEmpleado.setTotalHaberesNoRemunerativos(resultSet.getDouble("total_haberes_no_remunerativos"));
+ liquidacionEmpleado.setTotalRetenciones(resultSet.getDouble("total_retenciones"));
+ liquidacionEmpleado.setTotalBruto(resultSet.getDouble("total_bruto"));
+ liquidacionEmpleado.setEmpleado(new Empleado(
+ resultSet.getInt("EMPLEADO_idEmpleado"),
+ resultSet.getString("Nombre"),
+ resultSet.getString("Apellido"),
+ resultSet.getString("CUIT"),
+ resultSet.getString("FechaNacimiento"),
+ null,
+ new CategoriaEmpleado(resultSet.getInt("CATEGORIA_EMPLEADO_idCategoriaEmpleado"),
+ resultSet.getString("NombreCategoria")),
+ null,
+ null
+ ));
+ liquidacionEmpleado.setInicioPeriodo(resultSet.getString("inicio_periodo"));
+ liquidacionEmpleado.setFinPeriodo(resultSet.getString("fin_periodo"));
+ list.add(liquidacionEmpleado);
+ /* System.out.println("-----------------------------------------------------------\n" +
+ "id: " + liquidacionEmpleado.getId() + "\n neto: " + liquidacionEmpleado.getImporteNeto()
+ + "\n fecha: " +liquidacionEmpleado.getFechaLiquidacion() + "\n THR: " + liquidacionEmpleado.getTotalHaberesRemunerativos()
+ + "\n THNR: " +liquidacionEmpleado.getTotalHaberesNoRemunerativos() + "\n TR: " + liquidacionEmpleado.getTotalRetenciones()
+ + "\n bruto: " + liquidacionEmpleado.getTotalBruto()
+ + "\nEmpleado: " + liquidacionEmpleado.getEmpleado()
+ + "\n\t categoria: " + liquidacionEmpleado.getEmpleado().getCategoriaEmpleado().getNombre()
+ + "\n inicio: " + liquidacionEmpleado.getInicioPeriodo() + " - fin: " + liquidacionEmpleado.getFinPeriodo()
+ );*/
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+}
\ No newline at end of file
diff --git a/src/application/repository/sueldo/LiquidacionRepository.java b/src/application/repository/sueldo/LiquidacionRepository.java
new file mode 100644
index 0000000..0cb0cb1
--- /dev/null
+++ b/src/application/repository/sueldo/LiquidacionRepository.java
@@ -0,0 +1,167 @@
+package application.repository.sueldo;
+
+import java.math.BigDecimal;
+import java.sql.*;
+
+import application.database.JDBCConnection;
+import application.model.info.Empleado;
+import application.model.sueldo.ConceptoCalculado;
+import application.model.sueldo.DetalleLiquidacionEmpleado;
+import application.model.sueldo.LiquidacionEmpleado;
+import application.model.sueldo.Liquidacion;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+public class LiquidacionRepository {
+
+ Connection connection;
+ PreparedStatement preparedStatement;
+ ResultSet resultSet;
+
+ public static ObservableList buscarLiquidaciones(){
+
+
+ ObservableList liquidaciones = FXCollections.observableArrayList();
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = JDBCConnection.getInstanceConnection().createStatement();
+ resultSet = statement.executeQuery("SELECT * FROM LIQUIDACION");
+ while(resultSet.next()){
+ Liquidacion liquidacion = new Liquidacion();
+ liquidacion.setId(resultSet.getInt("idLIQUIDACION"));
+ liquidacion.setTotalHaberesRemunerativos(resultSet.getDouble("total_haberes_remunerativos"));
+ liquidacion.setTotalHaberesNoRemunerativos(resultSet.getDouble("total_haberes_no_remunerativos"));
+ liquidacion.setTotalRetenciones(resultSet.getDouble("total_retenciones"));
+ liquidacion.setFechaLiquidacion(resultSet.getString("timestamp"));
+ liquidaciones.add(liquidacion);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return liquidaciones;
+
+ }
+
+ /**
+ * Crea una liquidacion
+ * @return Liquidacion creada
+ */
+ public Liquidacion newLiquidacion(Liquidacion liquidacion){
+
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO LIQUIDACION (timestamp, total_haberes_remunerativos, " +
+ "total_haberes_no_remunerativos, total_retenciones ) VALUES (NOW(), ? , ?, ?);");
+ preparedStatement.setDouble(1,liquidacion.getTotalHaberesRemunerativos());
+ preparedStatement.setDouble(2,liquidacion.getTotalHaberesNoRemunerativos());
+ preparedStatement.setDouble(3,liquidacion.getTotalRetenciones());
+ preparedStatement.executeUpdate();
+ System.out.println("SQL LIQUIDACION INSERT: " + preparedStatement);
+ resultSet = preparedStatement.executeQuery("SELECT idLiquidacion, timestamp " +
+ "FROM LIQUIDACION " +
+ "WHERE idLiquidacion = LAST_INSERT_ID();");
+ if (resultSet.next()){
+ liquidacion.setId(resultSet.getInt("idLiquidacion"));
+ liquidacion.setFechaLiquidacion(resultSet.getString("timestamp"));
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //crear una liquidacion_empleado por cada empleado, es asociado a una liquidacion
+ for (LiquidacionEmpleado liquidacionEmpleado : liquidacion.getLiquidacionesEmpleados()){
+
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO LIQUIDACION_EMPLEADO " +
+ "(importe_neto,total_haberes_remunerativos, total_haberes_no_remunerativos,total_retenciones, " +
+ "total_bruto, EMPLEADO_idEmpleado, inicio_periodo, fin_periodo, LIQUIDACION_idLiquidacion, " +
+ "fecha_liquidacion)" +
+ " VALUES (?,?,?,?,?,?,?,?,?,NOW());");
+ preparedStatement.setDouble(1,liquidacionEmpleado.getImporteNeto());
+ preparedStatement.setDouble(2,liquidacionEmpleado.getTotalHaberesRemunerativos());
+ preparedStatement.setDouble(3,liquidacionEmpleado.getTotalHaberesNoRemunerativos());
+ preparedStatement.setDouble(4,liquidacionEmpleado.getTotalRetenciones());
+ preparedStatement.setDouble(5,liquidacionEmpleado.getTotalBruto());
+ preparedStatement.setInt(6,liquidacionEmpleado.getEmpleado().getIdEmpleado());
+ preparedStatement.setString(7,liquidacionEmpleado.getInicioPeriodo());
+ preparedStatement.setString(8,liquidacionEmpleado.getFinPeriodo());
+ preparedStatement.setInt(9,liquidacion.getId());
+ preparedStatement.executeUpdate();
+ resultSet = preparedStatement.executeQuery("SELECT LAST_INSERT_ID()");
+ if (resultSet.next()){
+ liquidacionEmpleado.setId(resultSet.getInt(1));
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //grabacion de detalle_liquidacion, es decir ConceptoCalculado
+ for (ConceptoCalculado conceptoCalculado : liquidacionEmpleado.getConceptosLiquidados()){
+ try {
+ Connection connection = JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("INSERT INTO DETALLE_LIQUIDACION_EMPLEADO " +
+ "(cantidad,monto,LiquidacionEmpleado_idLiquidacionEmpleado,CONCEPTO_SUELDO_idCodigoConcepto)" +
+ " VALUES (?,?,?,?);");
+ preparedStatement.setDouble(1,conceptoCalculado.getFactor());
+ preparedStatement.setDouble(2,conceptoCalculado.getMontoCalculado());
+ preparedStatement.setInt(3,liquidacionEmpleado.getId());
+ preparedStatement.setInt(4,conceptoCalculado.getIdConceptoSueldo());//todo funcionara???
+ System.out.println("SQL CONCEPTO CALCULADO: " + preparedStatement);
+ preparedStatement.executeUpdate();
+ // resultSet = preparedStatement.executeQuery("SELECT LAST_INSERT_ID()");
+ //if (resultSet.next()){
+ // conceptoCalculado.setId(resultSet.getInt(1));
+ // conceptoCalculado.setIdConceptoSueldo();
+ // }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ return liquidacion;
+ }
+
+ public ObservableList getEmpleadosLiquidadosByidLiquidacion(int idLIQUIDACION){
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT EMPLEADO.idEmpleado, EMPLEADO.Apellido, EMPLEADO.Nombre, " +
+ " CATEGORIA_EMPLEADO.NombreCategoria, LIQUIDACION_EMPLEADO.total_haberes_remunerativos, " +
+ "LIQUIDACION_EMPLEADO.total_haberes_no_remunerativos, LIQUIDACION_EMPLEADO.total_retenciones " +
+ " FROM LIQUIDACION_EMPLEADO" +
+ " INNER JOIN" +
+ " EMPLEADO ON EMPLEADO.idEmpleado = LIQUIDACION_EMPLEADO.EMPLEADO_idEmpleado" +
+ " INNER JOIN" +
+ " CATEGORIA_EMPLEADO ON CATEGORIA_EMPLEADO.idCategoriaEmpleado = EMPLEADO.CATEGORIA_EMPLEADO_idCategoriaEmpleado" +
+ " WHERE" +
+ " LIQUIDACION_EMPLEADO.idLiquidacionEmpleado like ?");
+ preparedStatement.setInt(1, idLIQUIDACION);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ LiquidacionEmpleado empleadosLiquidados = new LiquidacionEmpleado();
+ Empleado empleado = new Empleado();
+ empleado.setIdEmpleado(resultSet.getInt(1));
+ empleado.setApellido(resultSet.getString(2));
+ empleado.setNombre(resultSet.getString(3));
+// empleado.setCategoria(resultSet.getString(4));
+ empleadosLiquidados.setEmpleado(empleado);
+ empleadosLiquidados.setTotalHaberesRemunerativos(resultSet.getDouble(5));
+ empleadosLiquidados.setTotalHaberesNoRemunerativos(resultSet.getDouble(6));
+ empleadosLiquidados.setTotalRetenciones(resultSet.getDouble(7));
+ list.add(empleadosLiquidados);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+}
\ No newline at end of file
diff --git a/src/application/repository/sueldo/LiquidacionesRepository.java b/src/application/repository/sueldo/LiquidacionesRepository.java
deleted file mode 100644
index 38577ec..0000000
--- a/src/application/repository/sueldo/LiquidacionesRepository.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package application.repository.sueldo;
-
-import java.sql.*;
-import java.text.SimpleDateFormat;
-
-import application.database.JDBCConnection;
-import application.model.info.CategoriaEmpleado;
-import application.model.info.Empleado;
-import application.model.sueldo.ConceptoSueldo;
-import application.model.sueldo.LiquidacionEmpleado;
-import application.model.sueldo.Liquidaciones;
-import application.model.venta.Viaje;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-
-public class LiquidacionesRepository {
-
- Connection connection;
- PreparedStatement preparedStatement;
- ResultSet resultSet;
-
- public static ObservableList buscarLiquidaciones(){
-
-
- ObservableList liquidaciones = FXCollections.observableArrayList();
- Statement statement = null;
- ResultSet resultSet = null;
- try {
- statement = JDBCConnection.getInstanceConnection().createStatement();
- resultSet = statement.executeQuery("SELECT * FROM LIQUIDACION");
- while(resultSet.next()){
- Liquidaciones liquidacion = new Liquidaciones();
- liquidacion.setId(resultSet.getInt("idLIQUIDACION"));
- liquidacion.setTotalHaberesRemunerativos(resultSet.getDouble("total_haberes_remunerativos"));
- liquidacion.setTotalHaberesNoRemunerativos(resultSet.getDouble("total_haberes_no_remunerativos"));
- liquidacion.setTotalRetenciones(resultSet.getDouble("total_retenciones"));
- liquidacion.setFechaLiquidacion(resultSet.getString("timestamp"));
- liquidaciones.add(liquidacion);
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return liquidaciones;
-
- }
-
- public ObservableList getEmpleadosLiquidadosByidLiquidacion(int idLIQUIDACION){
- ObservableList list = FXCollections.observableArrayList();
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT EMPLEADO.idEmpleado, EMPLEADO.Apellido, EMPLEADO.Nombre, " +
- " CATEGORIA_EMPLEADO.NombreCategoria, LIQUIDACION_EMPLEADO.total_haberes_remunerativos, " +
- "LIQUIDACION_EMPLEADO.total_haberes_no_remunerativos, LIQUIDACION_EMPLEADO.total_retenciones " +
- " FROM LIQUIDACION_EMPLEADO\n" +
- " INNER JOIN\n" +
- " EMPLEADO ON EMPLEADO.idEmpleado = LIQUIDACION_EMPLEADO.EMPLEADO_idEmpleado\n" +
- " INNER JOIN\n" +
- " CATEGORIA_EMPLEADO ON CATEGORIA_EMPLEADO.idCategoriaEmpleado = EMPLEADO.CATEGORIA_EMPLEADO_idCategoriaEmpleado\n" +
- " WHERE\n" +
- " LIQUIDACION_EMPLEADO.idLiquidacionEmpleado like ?");
- preparedStatement.setInt(1, idLIQUIDACION);
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- LiquidacionEmpleado empleadosLiquidados = new LiquidacionEmpleado();
- Empleado empleado = new Empleado();
- empleado.setIdEmpleado(resultSet.getInt(1));
- empleado.setApellido(resultSet.getString(2));
- empleado.setNombre(resultSet.getString(3));
-// empleado.setCategoria(resultSet.getString(4));
- empleadosLiquidados.setEmpleado(empleado);
- empleadosLiquidados.setTotalHaberesRemunerativos(resultSet.getDouble(5));
- empleadosLiquidados.setTotalHaberesNoRemunerativos(resultSet.getDouble(6));
- empleadosLiquidados.setTotalRetenciones(resultSet.getDouble(7));
- list.add(empleadosLiquidados);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return list;
- }
-
-}
diff --git a/src/application/repository/sueldo/LiquidarSueldoRepository.java b/src/application/repository/sueldo/LiquidarSueldoRepository.java
index 7386af7..4a6fd50 100644
--- a/src/application/repository/sueldo/LiquidarSueldoRepository.java
+++ b/src/application/repository/sueldo/LiquidarSueldoRepository.java
@@ -1,15 +1,13 @@
package application.repository.sueldo;
+import application.database.JDBCConnection;
+import application.model.info.Empleado;
+import application.model.venta.Viaje;
+
import java.sql.Connection;
-import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.text.SimpleDateFormat;
-
-import application.database.JDBCConnection;
-import application.model.info.Empleado;
-import application.model.venta.Viaje;
public class LiquidarSueldoRepository {
diff --git a/src/application/repository/sueldo/ReciboSueldoRepository.java b/src/application/repository/sueldo/ReciboSueldoRepository.java
index 71fe032..068845d 100644
--- a/src/application/repository/sueldo/ReciboSueldoRepository.java
+++ b/src/application/repository/sueldo/ReciboSueldoRepository.java
@@ -23,8 +23,6 @@ public void save(ReciboSueldo reciboSueldo){
preparedStatement.setDouble(3,reciboSueldo.getTotalNeto());
// preparedStatement.setInt(4,reciboSueldo.getIdLiquidacionEmpleado());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -41,8 +39,6 @@ public void update(ReciboSueldo reciboSueldo){
// preparedStatement.setInt(3,reciboSueldo.getIdLiquidacionEmpleado());
preparedStatement.setInt(4, reciboSueldo.getIdRecibo());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -53,8 +49,6 @@ public void delete(ReciboSueldo reciboSueldo){
preparedStatement=connection.prepareStatement("DELETE FROM RECIBO_SUELDO WHERE idRECIBO_SUELDO=?");
preparedStatement.setInt(1,reciboSueldo.getIdRecibo());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -74,8 +68,6 @@ public ObservableList view(){
list.add(reciboSueldo);
}
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
@@ -87,8 +79,6 @@ public void search(ReciboSueldo reciboSueldo){
preparedStatement=connection.prepareStatement("SELECT * FROM RECIBO_SUELDO WHERE idRECIBO_SUELDO=?");
preparedStatement.setInt(1,reciboSueldo.getIdRecibo());
preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
diff --git a/src/application/repository/sueldo/TipoLiquidacionRepository.java b/src/application/repository/sueldo/TipoLiquidacionRepository.java
index 414dcc1..6941d5a 100644
--- a/src/application/repository/sueldo/TipoLiquidacionRepository.java
+++ b/src/application/repository/sueldo/TipoLiquidacionRepository.java
@@ -1,8 +1,6 @@
package application.repository.sueldo;
-import application.comunes.Alerta;
import application.database.JDBCConnection;
-import application.model.calculo.Finca;
import application.model.info.CategoriaEmpleado;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
diff --git a/src/application/repository/venta/FacturaVentaRepository.java b/src/application/repository/venta/FacturaVentaRepository.java
index 55d04a3..b52677e 100644
--- a/src/application/repository/venta/FacturaVentaRepository.java
+++ b/src/application/repository/venta/FacturaVentaRepository.java
@@ -1,188 +1,202 @@
- package application.repository.venta;
-
- import application.comunes.Alerta;
- import application.comunes.Calculo;
- import application.database.JDBCConnection;
- import application.model.venta.Cliente;
- import application.model.venta.FacturaVenta;
- import application.model.venta.Organizacion;
- import application.model.venta.Viaje;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
-
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.List;
-
- public class FacturaVentaRepository {
- ClienteRepository clienteRepository = new ClienteRepository();
- OrganizacionRepository organizacionRepository = new OrganizacionRepository();
- Connection connection;
- PreparedStatement preparedStatement;
- ResultSet resultSet;
-
- public void save(FacturaVenta facturaVenta, int idCliente){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("INSERT INTO FACTURA_VENTA (NombreEmpre, CUIT, FechaEmision, CLIENTE_idCliente ) "
- + "values(?,?,?,?)");
- preparedStatement.setString(1,facturaVenta.getNombreEmpresa());
- preparedStatement.setString(2, facturaVenta.getCuit());
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- try {
- preparedStatement.setDate(3, (java.sql.Date) dateFormat.parse(facturaVenta.getFechaEmision()));
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- preparedStatement.setInt(4, idCliente);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- String cuerpoMsj = "Factura Venta " + facturaVenta.getIdFacturaVenta()+ " agregada correctamente.\n";
- Alerta.alertaInfo("Facturas de Venta",cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
-
- }
- public void update(FacturaVenta facturaVenta, int idCliente){
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement= connection.prepareStatement("" +
- "UPDATE CLIENTE " +
- "SET NombreEmpresa=?, CUIT=?, FechaEmision=?, CLIENTE_idCliente=? " +
- "WHERE idFACTURA_VENTA=?");
- preparedStatement.setString(1,facturaVenta.getNombreEmpresa());
- preparedStatement.setString(2,facturaVenta.getCuit());
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- try {
- preparedStatement.setDate(3, (java.sql.Date) dateFormat.parse(facturaVenta.getFechaEmision()));
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- preparedStatement.setInt(4, idCliente);
- preparedStatement.setInt(5, facturaVenta.getIdFacturaVenta());
- preparedStatement.close();
- String headerMsj="Actualización: Factura venta actualizada";
- String cuerpoMsj = "Factura Venta: " + facturaVenta.getIdFacturaVenta() + " modificada correctamente.";
- Alerta.alertaInfo("Factura Venta", headerMsj, cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public void delete(FacturaVenta facturaVenta){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement(
- "DELETE FROM FACTURA_VENTA WHERE idFACTURA_VENTA=?");
- preparedStatement.setInt(1, facturaVenta.getIdFacturaVenta());
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public ObservableList view(){
-
- ObservableList list = FXCollections.observableArrayList();
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM FACTURA_VENTA INNER JOIN CLIENTE "
- + "WHERE idCliente = CLIENTE_idCliente");
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- FacturaVenta facturaVenta = new FacturaVenta();
- facturaVenta.setIdFacturaVenta(resultSet.getInt("idFACTURA_VENTA"));
- facturaVenta.setFechaEmision(resultSet.getString("FechaEmision"));
- Cliente cliente = clienteRepository.getClienteById(resultSet.getInt("CLIENTE_idCLIENTE"));
- facturaVenta.setCliente(cliente);
- Organizacion organizacion = organizacionRepository.getOrganizacionById(resultSet.getInt("ORGANIZACION_idORGANIZACION"));
- facturaVenta.setOrganizacion(organizacion);
- list.add(facturaVenta);
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- return list;
- }
- public void search(FacturaVenta facturaVenta){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM FACTURA_VENTA where idFACTURA_VENTA=?");
- preparedStatement.setInt(1,facturaVenta.getIdFacturaVenta());
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- }
-
- public void emitirFactura(List viajesALiquidar, int idCliente, int idOrg) {//TODO: Escribir este metodo en la clase que corresponda
- //primero ingresar la factura
-
+package application.repository.venta;
+
+import application.comunes.Alerta;
+import application.comunes.Calculo;
+import application.database.JDBCConnection;
+import application.model.venta.Cliente;
+import application.model.venta.FacturaVenta;
+import application.model.venta.Organizacion;
+import application.model.venta.Viaje;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+public class FacturaVentaRepository {
+ ClienteRepository clienteRepository = new ClienteRepository();
+ OrganizacionRepository organizacionRepository = new OrganizacionRepository();
+ Connection connection;
+ PreparedStatement preparedStatement;
+ ResultSet resultSet;
+
+ public void save(FacturaVenta facturaVenta, int idCliente){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("INSERT INTO FACTURA_VENTA (NombreEmpre, CUIT, FechaEmision, CLIENTE_idCliente ) "
+ + "values(?,?,?,?)");
+ preparedStatement.setString(1,facturaVenta.getNombreEmpresa());
+ preparedStatement.setString(2, facturaVenta.getCuit());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("INSERT INTO FACTURA_VENTA" +
- " (FechaEmision,CLIENTE_idCLIENTE,ORGANIZACION_idORGANIZACION) " +
- "VALUES (curdate(), ?, ?);");
- preparedStatement.setInt(1, idCliente);
- preparedStatement.setInt(2, idOrg);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
+ preparedStatement.setDate(3, (java.sql.Date) dateFormat.parse(facturaVenta.getFechaEmision()));
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
}
-
- //luego obtener el idFactura recientemente ingresado
- int idFactura = 0;
-
+ preparedStatement.setInt(4, idCliente);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ String cuerpoMsj = "Factura Venta " + facturaVenta.getIdFacturaVenta()+ " agregada correctamente.\n";
+ Alerta.alertaInfo("Facturas de Venta",cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+ public void update(FacturaVenta facturaVenta, int idCliente){
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement= connection.prepareStatement("" +
+ "UPDATE CLIENTE " +
+ "SET NombreEmpresa=?, CUIT=?, FechaEmision=?, CLIENTE_idCliente=? " +
+ "WHERE idFACTURA_VENTA=?");
+ preparedStatement.setString(1,facturaVenta.getNombreEmpresa());
+ preparedStatement.setString(2,facturaVenta.getCuit());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ try {
+ preparedStatement.setDate(3, (java.sql.Date) dateFormat.parse(facturaVenta.getFechaEmision()));
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ preparedStatement.setInt(4, idCliente);
+ preparedStatement.setInt(5, facturaVenta.getIdFacturaVenta());
+ preparedStatement.close();
+ String headerMsj="Actualización: Factura venta actualizada";
+ String cuerpoMsj = "Factura Venta: " + facturaVenta.getIdFacturaVenta() + " modificada correctamente.";
+ Alerta.alertaInfo("Factura Venta", headerMsj, cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ public void delete(FacturaVenta facturaVenta){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement(
+ "DELETE FROM FACTURA_VENTA WHERE idFACTURA_VENTA=?");
+ preparedStatement.setInt(1, facturaVenta.getIdFacturaVenta());
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ public ObservableList view(){
+
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT * FROM FACTURA_VENTA INNER JOIN CLIENTE "
+ + "WHERE idCliente = CLIENTE_idCliente");
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ FacturaVenta facturaVenta = new FacturaVenta();
+ facturaVenta.setIdFacturaVenta(resultSet.getInt("idFACTURA_VENTA"));
+ facturaVenta.setFechaEmision(resultSet.getString("FechaEmision"));
+ Cliente cliente = clienteRepository.getClienteById(resultSet.getInt("CLIENTE_idCLIENTE"));
+ facturaVenta.setCliente(cliente);
+ Organizacion organizacion = organizacionRepository.getOrganizacionById(resultSet.getInt("ORGANIZACION_idORGANIZACION"));
+ facturaVenta.setOrganizacion(organizacion);
+ setTotalMonto(facturaVenta);
+ list.add(facturaVenta);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return list;
+ }
+
+ public void setTotalMonto(FacturaVenta facturaVenta){
+
+ try {
+ Connection con = JDBCConnection.getInstanceConnection();
+ PreparedStatement pS = con.prepareStatement("SELECT SUM(monto) FROM linea_viaje WHERE FACTURA_VENTA_idFACTURA_VENTA=?;");
+ pS.setInt(1, facturaVenta.getIdFacturaVenta());
+ ResultSet result = pS.executeQuery();
+ if (result.next()) facturaVenta.setMontoFactura(result.getDouble(1));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void search(FacturaVenta facturaVenta){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT * FROM FACTURA_VENTA where idFACTURA_VENTA=?");
+ preparedStatement.setInt(1,facturaVenta.getIdFacturaVenta());
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void emitirFactura(List viajesALiquidar, int idCliente, int idOrg) {//TODO: Escribir este metodo en la clase que corresponda
+ //primero ingresar la factura
+
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("INSERT INTO FACTURA_VENTA" +
+ " (FechaEmision,CLIENTE_idCLIENTE,ORGANIZACION_idORGANIZACION) " +
+ "VALUES (curdate(), ?, ?);");
+ preparedStatement.setInt(1, idCliente);
+ preparedStatement.setInt(2, idOrg);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ //luego obtener el idFactura recientemente ingresado
+ int idFactura = 0;
+
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("select last_insert_id();");
+ resultSet = preparedStatement.executeQuery();
+ if (resultSet.next()) idFactura = resultSet.getInt(1);
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ //Ahora a crear por una Linea de Viaje por cada Viaje de la colección
+
+ for (Viaje viajeaLiquidar : viajesALiquidar) {
+ Calculo calculo = new Calculo();
+ double pesoNeto = calculo.calcularPesoNeto(viajeaLiquidar.getBruto(), viajeaLiquidar.getTara());
+
+ double monto = calculo.calcularMonto(Double.parseDouble(viajeaLiquidar.getDistanciaRecorrida()),pesoNeto,
+ viajeaLiquidar.getIngenio().getTarifa(), viajeaLiquidar.getIngenio().getArranque());
try {
connection = JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("select last_insert_id();");
- resultSet = preparedStatement.executeQuery();
- if (resultSet.next()) idFactura = resultSet.getInt(1);
+ preparedStatement = connection.prepareStatement("INSERT INTO LINEA_VIAJE (monto," +
+ " FACTURA_VENTA_idFACTURA_VENTA, VIAJE_idRemito) VALUES (?,?,?);");
+ preparedStatement.setDouble(1, monto);
+ preparedStatement.setInt(2, idFactura);
+ preparedStatement.setInt(3, viajeaLiquidar.getIdRemito() );
+ preparedStatement.executeUpdate();
+ //if (resultSet.next()) idFactura = resultSet.getInt(1);
preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
}
-
- //Ahora a crear por una Linea de Viaje por cada Viaje de la colección
-
- for (Viaje viajeaLiquidar : viajesALiquidar) {
- Calculo calculo = new Calculo();
- double pesoNeto = calculo.calcularPesoNeto(viajeaLiquidar.getBruto(), viajeaLiquidar.getTara());
-
- double monto = calculo.calcularMonto(Double.parseDouble(viajeaLiquidar.getDistanciaRecorrida()),pesoNeto,
- viajeaLiquidar.getIngenio().getTarifa(), viajeaLiquidar.getIngenio().getArranque());
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("INSERT INTO LINEA_VIAJE (monto," +
- " FACTURA_VENTA_idFACTURA_VENTA, VIAJE_idRemito) VALUES (?,?,?);");
- preparedStatement.setDouble(1, monto);
- preparedStatement.setInt(2, idFactura);
- preparedStatement.setInt(3, viajeaLiquidar.getIdRemito() );
- preparedStatement.executeUpdate();
- //if (resultSet.next()) idFactura = resultSet.getInt(1);
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
+ }
- }
+ }
- }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/application/repository/venta/OrganizacionRepository.java b/src/application/repository/venta/OrganizacionRepository.java
index 3b7d826..d8548bc 100644
--- a/src/application/repository/venta/OrganizacionRepository.java
+++ b/src/application/repository/venta/OrganizacionRepository.java
@@ -60,9 +60,6 @@ public void update(Organizacion organizacion){
// preparedStatement.setString(4, organizacion.getTelefono());
preparedStatement.setInt(7, organizacion.getIdOrganizacion());
preparedStatement.executeUpdate();
- String headerMsj="Actualización: datos de la organizacion actualizados";
- String cuerpoMsj = "Organizacion: " + organizacion.getNombreOrg() + " modificado correctamente.";
- Alerta.alertaInfo("Organización", headerMsj, cuerpoMsj);
} catch (SQLException e) {
e.printStackTrace();
}
@@ -92,7 +89,7 @@ public ObservableList view(){
Organizacion organizacion = new Organizacion();
organizacion.setIdOrganizacion(resultSet.getInt("idORGANIZACION"));
organizacion.setNombreOrg(resultSet.getString("Nombre"));
- Empleado apoderado = empleadoRepository.getEmpleadoById(resultSet.getInt("APODERADO_idEmpleado"));
+ Empleado apoderado = empleadoRepository.buscarEmpleadoById(resultSet.getInt("APODERADO_idEmpleado"));
organizacion.setApoderadoOrg(apoderado);
Domicilio domicilio = domicilioRepository.getDomicilioById(resultSet.getInt("DOMICILIO_idDomicilio"));
organizacion.setDomicilioOrg(domicilio);
diff --git a/src/application/repository/venta/ViajeRepository.java b/src/application/repository/venta/ViajeRepository.java
index a923643..87e4b5d 100644
--- a/src/application/repository/venta/ViajeRepository.java
+++ b/src/application/repository/venta/ViajeRepository.java
@@ -1,448 +1,457 @@
- package application.repository.venta;
-
- import application.comunes.Alerta;
- import application.comunes.Calculo;
- import application.database.JDBCConnection;
- import application.model.calculo.Camion;
- import application.model.calculo.Finca;
- import application.model.calculo.Ingenio;
- import application.model.info.Empleado;
- import application.model.venta.Viaje;
- import application.repository.calculo.CamionRepository;
- import application.repository.calculo.FincaRepository;
- import application.repository.calculo.IngenioRepository;
- import application.repository.info.EmpleadoRepository;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
-
- import java.math.BigDecimal;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.List;
-
- public class ViajeRepository {
- Connection connection;
- PreparedStatement preparedStatement;
- ResultSet resultSet;
- FincaRepository fincaRepository = new FincaRepository();
- IngenioRepository ingenioRepository = new IngenioRepository();
- EmpleadoRepository empleadoRepository = new EmpleadoRepository();
- CamionRepository camionRepository = new CamionRepository();
-
- public void save(Viaje viaje, int idOrigenDestino, int idEmpleado, int idCamion, int idFacturaVenta){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("INSERT INTO VIAJE (Fecha, HoraEntrada, Bruto, Tara,"
- + "Origen_Destino_idOrigen_Destino, Empleado_idEmpleado, CAMION_idCamion, FACTURA_VENTA_idFACTURA_VENTA)"
- + " values(?,?,?,?,?,?,?,?)");
- try {
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- preparedStatement.setDate(1, (java.sql.Date) dateFormat.parse(viaje.getFecha()));
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- DateFormat formatter = new SimpleDateFormat("HH:mm");
- java.sql.Time horaEntrada;
- horaEntrada = new java.sql.Time(formatter.parse(viaje.getHoraEntrada()).getTime());
- preparedStatement.setTime(2, horaEntrada);
-
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- preparedStatement.setDouble(3, viaje.getBruto());
- preparedStatement.setDouble(4, viaje.getTara());
- preparedStatement.setInt(5, idOrigenDestino);
- preparedStatement.setInt(6, idEmpleado);
- preparedStatement.setInt(7, idCamion);
- preparedStatement.setInt(8, idFacturaVenta);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- connection.close();
- String cuerpoMsj = "Provincia " + viaje.getIdRemito()+ " agregado correctamente.\n";
- Alerta.alertaInfo("Viajes",cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
-
- }
-
- public void save2(Viaje viaje, int idOrigenDestino){
+package application.repository.venta;
+
+import application.comunes.Alerta;
+import application.comunes.Calculo;
+import application.database.JDBCConnection;
+import application.model.calculo.Camion;
+import application.model.calculo.Finca;
+import application.model.calculo.Ingenio;
+import application.model.info.Empleado;
+import application.model.venta.Viaje;
+import application.repository.calculo.CamionRepository;
+import application.repository.calculo.FincaRepository;
+import application.repository.calculo.IngenioRepository;
+import application.repository.info.EmpleadoRepository;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import java.math.BigDecimal;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+public class ViajeRepository {
+ Connection connection;
+ PreparedStatement preparedStatement;
+ ResultSet resultSet;
+ FincaRepository fincaRepository = new FincaRepository();
+ IngenioRepository ingenioRepository = new IngenioRepository();
+ EmpleadoRepository empleadoRepository = new EmpleadoRepository();
+ CamionRepository camionRepository = new CamionRepository();
+
+ public void save(Viaje viaje, int idOrigenDestino, int idEmpleado, int idCamion, int idFacturaVenta){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("INSERT INTO VIAJE (Fecha, HoraEntrada, Bruto, Tara,"
+ + "Origen_Destino_idOrigen_Destino, Empleado_idEmpleado, CAMION_idCamion, FACTURA_VENTA_idFACTURA_VENTA)"
+ + " values(?,?,?,?,?,?,?,?)");
+ try {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ preparedStatement.setDate(1, (java.sql.Date) dateFormat.parse(viaje.getFecha()));
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("INSERT INTO VIAJE (Fecha, HoraEntrada, Bruto, Tara,"
- + "Origen_Destino_idOrigen_Destino, Empleado_idEmpleado, CAMION_idCamion)"
- + " values(?,?,?,?,?,?,?);");
- preparedStatement.setString(1, viaje.getFecha());
- preparedStatement.setString(2, viaje.getHoraEntrada());
- preparedStatement.setDouble(3, viaje.getBruto());
- preparedStatement.setDouble(4, viaje.getTara());
- preparedStatement.setInt(5, idOrigenDestino);
- preparedStatement.setInt(6, viaje.getConductor().getIdEmpleado());
- preparedStatement.setInt(7, viaje.getCamion().getId());
- preparedStatement.executeUpdate();
- preparedStatement.close();
- String cuerpoMsj = "Viaje " + viaje.getIdRemito()+ " agregado correctamente.\n";
- Alerta.alertaInfo("Viajes",cuerpoMsj);
- } catch (SQLException e) {
+ DateFormat formatter = new SimpleDateFormat("HH:mm");
+ java.sql.Time horaEntrada;
+ horaEntrada = new java.sql.Time(formatter.parse(viaje.getHoraEntrada()).getTime());
+ preparedStatement.setTime(2, horaEntrada);
+
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
}
+ preparedStatement.setDouble(3, viaje.getBruto());
+ preparedStatement.setDouble(4, viaje.getTara());
+ preparedStatement.setInt(5, idOrigenDestino);
+ preparedStatement.setInt(6, idEmpleado);
+ preparedStatement.setInt(7, idCamion);
+ preparedStatement.setInt(8, idFacturaVenta);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ String cuerpoMsj = "Provincia " + viaje.getIdRemito()+ " agregado correctamente.\n";
+ Alerta.alertaInfo("Viajes",cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void save2(Viaje viaje, int idOrigenDestino){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("INSERT INTO VIAJE (Fecha, HoraEntrada, Bruto, Tara,"
+ + "Origen_Destino_idOrigen_Destino, Empleado_idEmpleado, CAMION_idCamion)"
+ + " values(?,?,?,?,?,?,?);");
+ preparedStatement.setString(1, viaje.getFecha());
+ preparedStatement.setString(2, viaje.getHoraEntrada());
+ preparedStatement.setDouble(3, viaje.getBruto());
+ preparedStatement.setDouble(4, viaje.getTara());
+ preparedStatement.setInt(5, idOrigenDestino);
+ preparedStatement.setInt(6, viaje.getConductor().getIdEmpleado());
+ preparedStatement.setInt(7, viaje.getCamion().getId());
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ String cuerpoMsj = "Viaje " + viaje.getIdRemito()+ " agregado correctamente.\n";
+ Alerta.alertaInfo("Viajes",cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- public void update2(Viaje viaje, int idOrigenDestino){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("UPDATE VIAJE SET Fecha=?, HoraEntrada=?, Bruto=?," +
- " Tara=?, Origen_Destino_idOrigen_Destino=?, Empleado_idEmpleado=?, CAMION_idCamion=?" +
- " WHERE idRemito=?;");
- preparedStatement.setString(1, viaje.getFecha());
- preparedStatement.setString(2, viaje.getHoraEntrada());
- preparedStatement.setDouble(3, viaje.getBruto());
- preparedStatement.setDouble(4, viaje.getTara());
- preparedStatement.setInt(5, idOrigenDestino);
- preparedStatement.setInt(6, viaje.getConductor().getIdEmpleado());
- preparedStatement.setInt(7, viaje.getCamion().getId());
- preparedStatement.setInt(8,viaje.getIdRemito());
- System.out.println("UPDATE VIAJE QUERY: " + preparedStatement);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- String cuerpoMsj = "Viaje " + viaje.getIdRemito()+ " agregado correctamente.\n";
- Alerta.alertaInfo("Viajes",cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ }
+ public void update2(Viaje viaje, int idOrigenDestino){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("UPDATE VIAJE SET Fecha=?, HoraEntrada=?, Bruto=?," +
+ " Tara=?, Origen_Destino_idOrigen_Destino=?, Empleado_idEmpleado=?, CAMION_idCamion=?" +
+ " WHERE idRemito=?;");
+ preparedStatement.setString(1, viaje.getFecha());
+ preparedStatement.setString(2, viaje.getHoraEntrada());
+ preparedStatement.setDouble(3, viaje.getBruto());
+ preparedStatement.setDouble(4, viaje.getTara());
+ preparedStatement.setInt(5, idOrigenDestino);
+ preparedStatement.setInt(6, viaje.getConductor().getIdEmpleado());
+ preparedStatement.setInt(7, viaje.getCamion().getId());
+ preparedStatement.setInt(8,viaje.getIdRemito());
+ System.out.println("UPDATE VIAJE QUERY: " + preparedStatement);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ String cuerpoMsj = "Viaje " + viaje.getIdRemito()+ " agregado correctamente.\n";
+ Alerta.alertaInfo("Viajes",cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- public void update(Viaje viaje, int idOrigenDestino, int idEmpleado, int idCamion, int idFacturaVenta){
- try {
- connection = JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement("UPDATE VIAJE SET Fecha=?, HoraEntrada=?, Bruto=?, Tara=?,"
- + "Origen_Destino_idOrigen_Destino=?, Empleado_idEmpleado=?, CAMION_idCamion=?, FACTURA_VENTA_idFACTURA_VENTA=?"
- + "WHERE idRemito=?");
- try {
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- preparedStatement.setDate(1, (java.sql.Date) dateFormat.parse(viaje.getFecha()));
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- DateFormat formatter = new SimpleDateFormat("HH:mm");
- java.sql.Time horaEntrada;
- horaEntrada = new java.sql.Time(formatter.parse(viaje.getHoraEntrada()).getTime());
- preparedStatement.setTime(2, horaEntrada);
-
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- preparedStatement.setDouble(3, viaje.getBruto());
- preparedStatement.setDouble(4, viaje.getTara());
- preparedStatement.setInt(5, idOrigenDestino);
- preparedStatement.setInt(6, idEmpleado);
- preparedStatement.setInt(7, idCamion);
- preparedStatement.setInt(8, idFacturaVenta);
- preparedStatement.setInt(9, viaje.getIdRemito());
- preparedStatement.close();
- connection.close();
- String headerMsj="Actualización: Provincia actualizado";
- String cuerpoMsj = "Provincia: " + viaje.getIdRemito() + " modificado correctamente.";
- Alerta.alertaInfo("Provincia", headerMsj, cuerpoMsj);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public void delete(Viaje viaje){
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement = connection.prepareStatement(
- "DELETE FROM VIAJE WHERE idRemito=?");
- preparedStatement.setInt(1, viaje.getIdRemito());
- preparedStatement.executeUpdate();
- preparedStatement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public ObservableList view(){
-
- ObservableList list = FXCollections.observableArrayList();
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
- " v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion, od.DistanciaKM, od.FINCA_idFinca, " +
- "od.INGENIO_idIngenio FROM VIAJE v " +
- "INNER JOIN ORIGEN_DESTINO od ON Origen_Destino_idOrigen_Destino= od.idOrigen_Destino;");
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Viaje viaje = new Viaje();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setFecha(resultSet.getDate("Fecha").toString());
- viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setTara(resultSet.getDouble("Tara"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
- Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
- viaje.setFinca(finca);
- Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
- viaje.setIngenio(ingenio);
- Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
-// Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
-// viaje.setConductor(conductor);
- viaje.setCamion(camion);
- list.add(viaje);
- System.out.printf("Viaje agregado%n" +
- "idRemito: %s %n" +
- "Fecha : %s %n" +
- "Bruto : %s %n" +
- "Tara : %s %n",
- viaje.getIdRemito(),
- viaje.getFecha(),
- viaje.getBruto(),
- viaje.getTara());
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- return list;
- }
-
- public ObservableList getViajesSinLiquidar(){
-
- ObservableList list = FXCollections.observableArrayList();
+
+
+ }
+ public void update(Viaje viaje, int idOrigenDestino, int idEmpleado, int idCamion, int idFacturaVenta){
+ try {
+ connection = JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement("UPDATE VIAJE SET Fecha=?, HoraEntrada=?, Bruto=?, Tara=?,"
+ + "Origen_Destino_idOrigen_Destino=?, Empleado_idEmpleado=?, CAMION_idCamion=?, FACTURA_VENTA_idFACTURA_VENTA=?"
+ + "WHERE idRemito=?");
try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
- " v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion, od.DistanciaKM, od.FINCA_idFinca, " +
- "od.INGENIO_idIngenio FROM VIAJE v INNER JOIN ORIGEN_DESTINO od ON " +
- "Origen_Destino_idOrigen_Destino= od.idOrigen_Destino " +
- "LEFT JOIN LINEA_VIAJE lv ON v.idRemito = lv.VIAJE_idRemito WHERE lv.idLINEA_VIAJE IS NULL;");
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Viaje viaje = new Viaje();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setFecha(resultSet.getDate("Fecha").toString());
- viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setTara(resultSet.getDouble("Tara"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
- Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
- viaje.setFinca(finca);
- Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
- viaje.setIngenio(ingenio);
- Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
- Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
- viaje.setConductor(conductor);
- viaje.setCamion(camion);
- list.add(viaje);
- System.out.printf("Viaje agregado%n" +
- "idRemito: %s %n" +
- "Fecha : %s %n" +
- "Bruto : %s %n" +
- "Tara : %s %n",
- viaje.getIdRemito(),
- viaje.getFecha(),
- viaje.getBruto(),
- viaje.getTara());
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ preparedStatement.setDate(1, (java.sql.Date) dateFormat.parse(viaje.getFecha()));
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
}
-
- return list;
- }
-
- public Viaje search(int idViaje){
- Viaje viaje = new Viaje();
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT * FROM VIAJE INNER JOIN"
- + "FROM VIAJE v, ORIGEN_DESTINO o, EMPLEADO e, CAMION c, FACTURA_VENTA f"
- + "WHERE v.Origen_Destino_idOrigen_Destino = o.idOrigen_Destino"
- + "AND v.Empleado_idEmpleado = e.idEmpleado"
- + "AND v.Camion_idCamion = c.idCamion"
- + "AND v.FACTURA_VENTA_idFactura_VENTA = f.idFactura_Venta"
- + "AND v.idRemito=?");
- preparedStatement.setInt(1,idViaje);
- resultSet = preparedStatement.executeQuery();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setCamionNombre(resultSet.getString("Marca") + " " + resultSet.getString("Modelo") );
- viaje.setFecha(resultSet.getString("Fecha"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
-
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return viaje;
- }
-
- public ObservableList getViajesByIdFactura(int idFactura){
- ObservableList list = FXCollections.observableArrayList();
-
try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
- " v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion, od.DistanciaKM, od.FINCA_idFinca," +
- " od.INGENIO_idIngenio FROM VIAJE v INNER JOIN ORIGEN_DESTINO od " +
- "ON Origen_Destino_idOrigen_Destino= od.idOrigen_Destino " +
- "WHERE FACTURA_VENTA_idFACTURA_VENTA=?;");//TODO cambiar esto cuando se actualice la base de datos
- preparedStatement.setInt(1 ,idFactura);
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Viaje viaje = new Viaje();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setFecha(resultSet.getDate("Fecha").toString());
- viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setTara(resultSet.getDouble("Tara"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
- Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
- viaje.setFinca(finca);
- Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
- viaje.setIngenio(ingenio);
- Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
-// Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
-// viaje.setConductor(conductor);
- viaje.setCamion(camion);
- list.add(viaje);
- System.out.printf("Viaje agregado%n" +
- "idRemito: %s %n" +
- "Fecha : %s %n" +
- "Bruto : %s %n" +
- "Tara : %s %n",
- viaje.getIdRemito(),
- viaje.getFecha(),
- viaje.getBruto(),
- viaje.getTara());
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
+ DateFormat formatter = new SimpleDateFormat("HH:mm");
+ java.sql.Time horaEntrada;
+ horaEntrada = new java.sql.Time(formatter.parse(viaje.getHoraEntrada()).getTime());
+ preparedStatement.setTime(2, horaEntrada);
+
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
}
+ preparedStatement.setDouble(3, viaje.getBruto());
+ preparedStatement.setDouble(4, viaje.getTara());
+ preparedStatement.setInt(5, idOrigenDestino);
+ preparedStatement.setInt(6, idEmpleado);
+ preparedStatement.setInt(7, idCamion);
+ preparedStatement.setInt(8, idFacturaVenta);
+ preparedStatement.setInt(9, viaje.getIdRemito());
+ preparedStatement.close();
+ String headerMsj="Actualización: Provincia actualizado";
+ String cuerpoMsj = "Provincia: " + viaje.getIdRemito() + " modificado correctamente.";
+ Alerta.alertaInfo("Provincia", headerMsj, cuerpoMsj);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ public void delete(Viaje viaje){
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement = connection.prepareStatement(
+ "DELETE FROM VIAJE WHERE idRemito=?");
+ preparedStatement.setInt(1, viaje.getIdRemito());
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ public ObservableList view(){
- return list;
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
+ " v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion, od.DistanciaKM, od.FINCA_idFinca, " +
+ "od.INGENIO_idIngenio FROM VIAJE v " +
+ "INNER JOIN ORIGEN_DESTINO od ON Origen_Destino_idOrigen_Destino= od.idOrigen_Destino;");
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Viaje viaje = new Viaje();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setFecha(resultSet.getDate("Fecha").toString());
+ viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setTara(resultSet.getDouble("Tara"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+ Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
+ viaje.setFinca(finca);
+ Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
+ viaje.setIngenio(ingenio);
+ Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
+ Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
+ viaje.setConductor(conductor);
+ viaje.setCamion(camion);
+ list.add(viaje);
+ System.out.printf("Viaje agregado%n" +
+ "idRemito: %s %n" +
+ "Fecha : %s %n" +
+ "Bruto : %s %n" +
+ "Tara : %s %n",
+ viaje.getIdRemito(),
+ viaje.getFecha(),
+ viaje.getBruto(),
+ viaje.getTara());
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- public ObservableList getViajesByIdIngenio(int idIngenio){
- ObservableList list = FXCollections.observableArrayList();
+ return list;
+ }
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto, v.Tara," +
- " od.DistanciaKM, v.Origen_Destino_idOrigen_Destino, v.Empleado_idEmpleado, v.CAMION_idCamion, " +
- "od.FINCA_idFinca, od.INGENIO_idIngenio FROM VIAJE v INNER JOIN ORIGEN_DESTINO od ON od.idOrigen_Destino = " +
- "v.Origen_Destino_idOrigen_Destino WHERE od.INGENIO_idIngenio = ?;");
- preparedStatement.setInt(1 ,idIngenio);
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Viaje viaje = new Viaje();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setFecha(resultSet.getDate("Fecha").toString());
- viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setTara(resultSet.getDouble("Tara"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
- Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
- viaje.setFinca(finca);
- Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
- viaje.setIngenio(ingenio);
- Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
- Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
- viaje.setConductor(conductor);
- viaje.setCamion(camion);
- list.add(viaje);
- System.out.printf("Viaje agregado%n" +
- "idRemito: %s %n" +
- "Fecha : %s %n" +
- "Bruto : %s %n" +
- "Tara : %s %n",
- viaje.getIdRemito(),
- viaje.getFecha(),
- viaje.getBruto(),
- viaje.getTara());
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
- e.printStackTrace();
+ //todo devolver monto viaje
+ public ObservableList getViajesSinLiquidar(){
+
+ ObservableList list = FXCollections.observableArrayList();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
+ " v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion, od.DistanciaKM, od.FINCA_idFinca, " +
+ "od.INGENIO_idIngenio FROM VIAJE v INNER JOIN ORIGEN_DESTINO od ON " +
+ "Origen_Destino_idOrigen_Destino= od.idOrigen_Destino " +
+ "LEFT JOIN LINEA_VIAJE lv ON v.idRemito = lv.VIAJE_idRemito WHERE lv.idLINEA_VIAJE IS NULL;");
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Viaje viaje = new Viaje();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setFecha(resultSet.getDate("Fecha").toString());
+ viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setTara(resultSet.getDouble("Tara"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+ Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
+ viaje.setFinca(finca);
+ Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
+ viaje.setIngenio(ingenio);
+ Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
+ Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
+ viaje.setConductor(conductor);
+ viaje.setCamion(camion);
+ setMontoViaje(viaje);
+ list.add(viaje);
+ System.out.printf("Viaje agregado%n" +
+ "idRemito: %s %n" +
+ "Fecha : %s %n" +
+ "Bruto : %s %n" +
+ "Tara : %s %n",
+ viaje.getIdRemito(),
+ viaje.getFecha(),
+ viaje.getBruto(),
+ viaje.getTara());
}
+ preparedStatement.close();
+ resultSet.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return list;
+ }
+
+ public void setMontoViaje(Viaje viaje){
+
+ BigDecimal distancia = BigDecimal.valueOf(Double.valueOf(viaje.getDistanciaRecorrida()));
+ BigDecimal bruto = BigDecimal.valueOf(Double.valueOf(viaje.getBruto()));
+ BigDecimal tara = BigDecimal.valueOf(Double.valueOf(viaje.getTara()));
+ BigDecimal pesoNeto = bruto.subtract(tara);
+ BigDecimal precioKm = BigDecimal.valueOf(viaje.getIngenio().getTarifa());//todo cambiar metodo p/ cambiar ingenio automat...
+ BigDecimal arranque = BigDecimal.valueOf(viaje.getIngenio().getArranque());
+ BigDecimal precioUnitario = distancia.multiply(precioKm).add(arranque);
+ BigDecimal montoViaje = precioUnitario.multiply(pesoNeto).multiply(BigDecimal.valueOf(0.001));
+ viaje.setMonto(montoViaje.doubleValue());
+ }
+
+ public Viaje search(int idViaje){
+ Viaje viaje = new Viaje();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT * FROM VIAJE INNER JOIN"
+ + "FROM VIAJE v, ORIGEN_DESTINO o, EMPLEADO e, CAMION c, FACTURA_VENTA f"
+ + "WHERE v.Origen_Destino_idOrigen_Destino = o.idOrigen_Destino"
+ + "AND v.Empleado_idEmpleado = e.idEmpleado"
+ + "AND v.Camion_idCamion = c.idCamion"
+ + "AND v.FACTURA_VENTA_idFactura_VENTA = f.idFactura_Venta"
+ + "AND v.idRemito=?");
+ preparedStatement.setInt(1,idViaje);
+ resultSet = preparedStatement.executeQuery();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setCamionNombre(resultSet.getString("Marca") + " " + resultSet.getString("Modelo") );
+ viaje.setFecha(resultSet.getString("Fecha"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return viaje;
+ }
+
+ public ObservableList getViajesByIdFactura(int idFactura){
+ ObservableList list = FXCollections.observableArrayList();
- return list;
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT lv.monto, lv.FACTURA_VENTA_idFACTURA_VENTA, lv.VIAJE_idRemito," +
+ " v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto, v.Tara, v.Empleado_idEmpleado, v.CAMION_idCamion," +
+ " od.DistanciaKM, od.FINCA_idFinca, od.INGENIO_idIngenio" +
+ " FROM LINEA_VIAJE lv" +
+ " INNER JOIN VIAJE v ON v.idRemito = lv.VIAJE_idRemito" +
+ " INNER JOIN ORIGEN_DESTINO od ON od.idOrigen_Destino = v.Origen_Destino_idOrigen_Destino" +
+ " INNER JOIN FACTURA_VENTA fv ON fv.idFACTURA_VENTA = lv.FACTURA_VENTA_idFACTURA_VENTA" +
+ " WHERE fv.idFACTURA_VENTA = ?;");
+ preparedStatement.setInt(1 ,idFactura);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Viaje viaje = new Viaje();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setFecha(resultSet.getDate("Fecha").toString());
+ viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setTara(resultSet.getDouble("Tara"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+ viaje.setMonto(resultSet.getDouble("monto"));
+ Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
+ viaje.setFinca(finca);
+ Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
+ viaje.setIngenio(ingenio);
+ Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
+ Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
+ viaje.setConductor(conductor);
+ viaje.setCamion(camion);
+ list.add(viaje);
+ System.out.printf("Viaje agregado%n" +
+ "idRemito: %s %n" +
+ "Fecha : %s %n" +
+ "Bruto : %s %n" +
+ "Tara : %s %n",
+ viaje.getIdRemito(),
+ viaje.getFecha(),
+ viaje.getBruto(),
+ viaje.getTara());
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- /**
- * Devuelve una lista de todos lo viajes de un determinado Ingenio
- * que no han sido liquidados en alguna facturación
- *
- * @param idIngenio Identificador del Ingenio
- * @return Devuelve una Lista de Viajes de ese Ingenio que no fueron liquidados
- */
+ return list;
+ }
- public ObservableList getViajesSinLiqByIngenioId(int idIngenio){
- ObservableList list = FXCollections.observableArrayList();
+ public ObservableList getViajesByIdIngenio(int idIngenio){
+ ObservableList list = FXCollections.observableArrayList();
- try {
- connection= JDBCConnection.getInstanceConnection();
- preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
- " v.Tara, od.DistanciaKM, v.Origen_Destino_idOrigen_Destino, v.Empleado_idEmpleado, " +
- "v.CAMION_idCamion, od.FINCA_idFinca, od.INGENIO_idIngenio FROM VIAJE v " +
- "INNER JOIN ORIGEN_DESTINO od ON od.idOrigen_Destino = v.Origen_Destino_idOrigen_Destino " +
- "LEFT JOIN LINEA_VIAJE lv ON v.idRemito = lv.VIAJE_idRemito " +
- "WHERE lv.idLINEA_VIAJE IS NULL AND od.INGENIO_idIngenio = ?;");
- preparedStatement.setInt(1 ,idIngenio);
- resultSet = preparedStatement.executeQuery();
- while (resultSet.next()){
- Viaje viaje = new Viaje();
- viaje.setIdRemito(resultSet.getInt("idRemito"));
- viaje.setFecha(resultSet.getDate("Fecha").toString());
- viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
- viaje.setBruto(resultSet.getDouble("Bruto"));
- viaje.setTara(resultSet.getDouble("Tara"));
- viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
- Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
- viaje.setFinca(finca);
- Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
- viaje.setIngenio(ingenio);
- Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
- Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
- viaje.setConductor(conductor);
- viaje.setCamion(camion);
- list.add(viaje);
- System.out.printf("Viaje agregado%n" +
- "idRemito: %s %n" +
- "Fecha : %s %n" +
- "Bruto : %s %n" +
- "Tara : %s %n",
- viaje.getIdRemito(),
- viaje.getFecha(),
- viaje.getBruto(),
- viaje.getTara());
- }
- preparedStatement.close();
- resultSet.close();
- } catch (SQLException e) {
- e.printStackTrace();
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto, v.Tara," +
+ " od.DistanciaKM, v.Origen_Destino_idOrigen_Destino, v.Empleado_idEmpleado, v.CAMION_idCamion, " +
+ "od.FINCA_idFinca, od.INGENIO_idIngenio FROM VIAJE v INNER JOIN ORIGEN_DESTINO od ON od.idOrigen_Destino = " +
+ "v.Origen_Destino_idOrigen_Destino WHERE od.INGENIO_idIngenio = ?;");
+ preparedStatement.setInt(1 ,idIngenio);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Viaje viaje = new Viaje();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setFecha(resultSet.getDate("Fecha").toString());
+ viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setTara(resultSet.getDouble("Tara"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+ Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
+ viaje.setFinca(finca);
+ Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
+ viaje.setIngenio(ingenio);
+ Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
+ Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
+ viaje.setConductor(conductor);
+ viaje.setCamion(camion);
+ list.add(viaje);
+ System.out.printf("Viaje agregado%n" +
+ "idRemito: %s %n" +
+ "Fecha : %s %n" +
+ "Bruto : %s %n" +
+ "Tara : %s %n",
+ viaje.getIdRemito(),
+ viaje.getFecha(),
+ viaje.getBruto(),
+ viaje.getTara());
}
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
- return list;
+ return list;
+ }
+
+ /**
+ * Devuelve una lista de todos lo viajes de un determinado Ingenio
+ * que no han sido liquidados en alguna facturación
+ *
+ * @param idIngenio Identificador del Ingenio
+ * @return Devuelve una Lista de Viajes de ese Ingenio que no fueron liquidados
+ */
+
+ public ObservableList getViajesSinLiqByIngenioId(int idIngenio){
+ ObservableList list = FXCollections.observableArrayList();
+
+ try {
+ connection= JDBCConnection.getInstanceConnection();
+ preparedStatement=connection.prepareStatement("SELECT v.idRemito, v.Fecha, v.HoraEntrada, v.Bruto," +
+ " v.Tara, od.DistanciaKM, v.Origen_Destino_idOrigen_Destino, v.Empleado_idEmpleado, " +
+ "v.CAMION_idCamion, od.FINCA_idFinca, od.INGENIO_idIngenio FROM VIAJE v " +
+ "INNER JOIN ORIGEN_DESTINO od ON od.idOrigen_Destino = v.Origen_Destino_idOrigen_Destino " +
+ "LEFT JOIN LINEA_VIAJE lv ON v.idRemito = lv.VIAJE_idRemito " +
+ "WHERE lv.idLINEA_VIAJE IS NULL AND od.INGENIO_idIngenio = ?;");
+ preparedStatement.setInt(1 ,idIngenio);
+ resultSet = preparedStatement.executeQuery();
+ while (resultSet.next()){
+ Viaje viaje = new Viaje();
+ viaje.setIdRemito(resultSet.getInt("idRemito"));
+ viaje.setFecha(resultSet.getDate("Fecha").toString());
+ viaje.setHoraEntrada(resultSet.getTime("HoraEntrada").toString());
+ viaje.setBruto(resultSet.getDouble("Bruto"));
+ viaje.setTara(resultSet.getDouble("Tara"));
+ viaje.setDistanciaRecorrida(resultSet.getString("DistanciaKM"));
+ Finca finca = fincaRepository.getFincaById(resultSet.getInt("FINCA_idFinca"));
+ viaje.setFinca(finca);
+ Ingenio ingenio = ingenioRepository.getIngenioById(resultSet.getInt("INGENIO_idIngenio"));
+ viaje.setIngenio(ingenio);
+ Camion camion = camionRepository.getCamionById(resultSet.getInt("CAMION_idCamion"));
+ Empleado conductor = empleadoRepository.getEmpleadoById(resultSet.getInt("EMPLEADO_idEmpleado"));
+ viaje.setConductor(conductor);
+ viaje.setCamion(camion);
+ list.add(viaje);
+ System.out.printf("Viaje agregado%n" +
+ "idRemito: %s %n" +
+ "Fecha : %s %n" +
+ "Bruto : %s %n" +
+ "Tara : %s %n",
+ viaje.getIdRemito(),
+ viaje.getFecha(),
+ viaje.getBruto(),
+ viaje.getTara());
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
}
+ return list;
}
+
+}
\ No newline at end of file
diff --git a/src/application/view/Login.fxml b/src/application/view/Login.fxml
index 5ac3771..189439e 100644
--- a/src/application/view/Login.fxml
+++ b/src/application/view/Login.fxml
@@ -1,12 +1,13 @@
+
-
+
@@ -14,39 +15,39 @@
-
+
diff --git a/src/application/view/LoginController.java b/src/application/view/LoginController.java
index a3241ed..e6b1f64 100644
--- a/src/application/view/LoginController.java
+++ b/src/application/view/LoginController.java
@@ -1,7 +1,6 @@
package application.view;
import application.Main;
-import application.model.compra.Proveedor;
import application.model.info.Usuario;
import application.repository.info.UsuarioRepository;
import javafx.beans.binding.BooleanBinding;
@@ -13,20 +12,16 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
-import javafx.scene.layout.AnchorPane;
-import javafx.scene.layout.BorderPane;
-import javafx.stage.Modality;
-import javafx.stage.Stage;
-import javafx.stage.StageStyle;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class LoginController implements Initializable {
@FXML
@@ -39,6 +34,8 @@ public class LoginController implements Initializable {
private Hyperlink hlCrateAccount;
@FXML
private Label errorLoginLabel;
+ @FXML
+ private ImageView logo;
private String nombreUsuario;
private String password;
@@ -47,6 +44,9 @@ public class LoginController implements Initializable {
UsuarioRepository usuarioRepository = new UsuarioRepository();
public void initialize(URL url, ResourceBundle rb) {
+ File file = new File("src/resources/logiserv-icon.png");
+ Image image = new Image(file.toURI().toString());
+ logo.setImage(image);
BooleanBinding boolenBinding = usuarioField.textProperty().isEmpty()
.or(passwordField.textProperty().isEmpty());
btnLogin.disableProperty().bind(boolenBinding);
@@ -61,7 +61,8 @@ private void hlCreateAnAccount(){
private void btnLogin(ActionEvent event){
nombreUsuario = usuarioField.getText();
password = passwordField.getText();
-
+ usuario.setNombre_usuario(nombreUsuario);
+ usuario.setPassword(password);
String passMD5 = usuario.encryptMD5(password);
boolean okLogin = usuarioRepository.login(nombreUsuario,passMD5);
@@ -76,7 +77,11 @@ private void btnLogin(ActionEvent event){
Parent parent = loader.getRoot();
Stage adminPanelStage = new Stage();
adminPanelStage.setTitle("LogiServ app - usuario: " + nombreUsuario + " conectado.");
+ adminPanelStage.setWidth(1100);
+// adminPanelStage.setMaximized(true);
PrincipalController controller = loader.getController();
+ controller.setUserOn(usuario);
+ controller.setPrimaryStage(adminPanelStage);
controller.setRootLayout(root);
controller.setHome();
// Show the scene containing the root layout.
diff --git a/src/application/view/Principal.fxml b/src/application/view/Principal.fxml
index 4eae6f6..c458787 100644
--- a/src/application/view/Principal.fxml
+++ b/src/application/view/Principal.fxml
@@ -1,41 +1,11 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -136,4 +106,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/view/PrincipalController.java b/src/application/view/PrincipalController.java
index 7a5ccd6..9213a3c 100644
--- a/src/application/view/PrincipalController.java
+++ b/src/application/view/PrincipalController.java
@@ -1,31 +1,33 @@
package application.view;
-import java.io.IOException;
-
-import application.model.venta.Organizacion;
-import application.view.inicio.HomeController;
-import application.view.calculo.InfoFincaController;
-import application.view.calculo.InfoIngenioController;
-import application.view.calculo.InfoOrigenDestinoController;
+import application.Main;
+import application.model.info.Usuario;
+import application.view.calculo.*;
import application.view.compra.*;
import application.view.info.*;
-import application.view.calculo.CargarCamionController;
+import application.view.inicio.HomeController;
import application.view.inicio.OrganizacionController;
import application.view.sueldo.ConceptosSalarialesController;
import application.view.sueldo.LiquidacionesController;
import application.view.venta.AdministrarViajesController;
-import application.view.calculo.CargarAcopladoController;
import application.view.venta.FacturacionController;
import application.view.venta.VentaClienteController;
import javafx.fxml.FXML;
-import application.Main;
import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
import javafx.scene.control.Accordion;
+import javafx.scene.control.Hyperlink;
+import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
+import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
+import javafx.stage.Modality;
import javafx.stage.Stage;
+import javax.swing.text.Style;
+import java.io.IOException;
+
public class PrincipalController {
private Stage primaryStage;
@@ -34,13 +36,62 @@ public class PrincipalController {
private Accordion modulosAccordion;
@FXML
private TitledPane inicioTitledPane;
- public void setRootLayout(BorderPane root){
+ @FXML
+ private Label usuarioLabel;
+ @FXML
+ private Hyperlink cerrarSesion;
+
+ private Usuario userOn;
+
+ @FXML
+ private void handleCerrarSesion(){
+ try {
+ // Load the fxml file and create a new stage for the popup dialog.
+ FXMLLoader loader = new FXMLLoader();
+ loader.setLocation(Main.class.getResource("view/Login.fxml"));
+ BorderPane page = loader.load();
+
+ // Create the dialog Stage.
+ Stage dialogStage = new Stage();
+ dialogStage.setTitle("Acceso a LogiServ App");
+ dialogStage.initModality(Modality.WINDOW_MODAL);
+ Scene scene = new Scene(page);
+ dialogStage.setScene(scene);
+
+
+ LoginController controller = loader.getController();
+
+
+ // Show the dialog and wait until the user closes it
+ dialogStage.show();
+
+ //Cierro la ventana de login
+ Stage stage = (Stage) primaryStage.getScene().getWindow();
+ stage.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+
+
+ public void setUserOn(Usuario userOn) {
+ this.userOn = userOn;
+ usuarioLabel.setText(userOn.getNombre_usuario());
+ }
+
+ public void setRootLayout(BorderPane root){
this.rootLayout = root;
+
}
public void setPrimaryStage(Stage primary){
this.primaryStage = primary;
- }
+ this.primaryStage.getIcons().add(new Image("resources/logiserv-icon.png"));
+
+ }
//---------------MODULO VENTAS------------------------//
@@ -417,6 +468,7 @@ private void showUsuarioOverview() {
AdministrarUsuariosController usercontroller = loaderusuario.getController();
usercontroller.setOwner(primaryStage);
usercontroller.buscarUsuarios();
+ usercontroller.setUserSesion(userOn);
} catch (IOException e) {
e.printStackTrace();
diff --git a/src/application/view/Register.fxml b/src/application/view/Register.fxml
index 35c0423..18c9496 100644
--- a/src/application/view/Register.fxml
+++ b/src/application/view/Register.fxml
@@ -1,27 +1,14 @@
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
@@ -50,7 +37,7 @@
-
+
@@ -82,8 +69,8 @@
-
-
+
+
diff --git a/src/application/view/RegisterController.java b/src/application/view/RegisterController.java
index 190eff9..b5a3efc 100644
--- a/src/application/view/RegisterController.java
+++ b/src/application/view/RegisterController.java
@@ -2,22 +2,10 @@
import application.Main;
import application.comunes.Alerta;
-import application.model.compra.Articulo;
-import application.model.compra.DetalleCompra;
-import application.model.compra.FacturaCompra;
-import application.model.compra.Proveedor;
import application.model.info.*;
-import application.repository.compra.ArticuloRepository;
-import application.repository.compra.DetalleCompraRepository;
-import application.repository.compra.FacturaCompraRepository;
-import application.repository.compra.ProveedorRepository;
import application.repository.info.*;
-import application.view.compra.ArticulosController;
-import application.view.compra.ProveedoresController;
import application.view.info.InfoCategoriaEmpleadoController;
import javafx.beans.binding.BooleanBinding;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
@@ -35,6 +23,10 @@
import java.util.ResourceBundle;
public class RegisterController implements Initializable {
+ public Hyperlink getHlLogin() {
+ return hlLogin;
+ }
+
@FXML
private Hyperlink hlLogin;
@FXML
@@ -62,7 +54,6 @@ public class RegisterController implements Initializable {
@FXML
private Button registrarButton;
- private Stage owner;
private Stage dialogStage;
private CategoriaEmpleadoRepository categoriaEmpleadoRepository = new CategoriaEmpleadoRepository();
@@ -123,9 +114,7 @@ public void initialize(URL location, ResourceBundle resources) {
registrarButton.disableProperty().bind(boolenBinding);
cargarCategorias();
cargarLocalidades();
- }
- public void setOwner(Stage owner){
- this.owner = owner;
+
}
public void setDialogStage(Stage dialogStage) {
@@ -175,8 +164,7 @@ private void cargarCategorias() {
categoriaEmpleadoComboBox.setItems(categoriaEmpleadoRepository.view());
}
private void cargarLocalidades() {
- int idTucuman = 23; //hardcode id tucuman
- localidadComboBox.setItems(localidadRepository.view(idTucuman));
+ localidadComboBox.setItems(localidadRepository.localidadesDeTucuman());
}
@FXML
diff --git a/src/application/view/calculo/CargarAcoplado.fxml b/src/application/view/calculo/CargarAcoplado.fxml
index e6dda41..16b2b57 100644
--- a/src/application/view/calculo/CargarAcoplado.fxml
+++ b/src/application/view/calculo/CargarAcoplado.fxml
@@ -2,55 +2,42 @@
-
-
-
-
-
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/calculo/CargarAcopladoController.java b/src/application/view/calculo/CargarAcopladoController.java
index 1fb62c1..716b75d 100644
--- a/src/application/view/calculo/CargarAcopladoController.java
+++ b/src/application/view/calculo/CargarAcopladoController.java
@@ -31,11 +31,11 @@ public class CargarAcopladoController {
@FXML
private TableView acopladoTableView;
@FXML
- private TableColumn idAcopladoTableColumn;
- @FXML
private TableColumn marcaTableColumn;
@FXML
private TableColumn patenteTableColumn;
+ @FXML
+ private TableColumn chasisColumn;
private Stage owner;
private ObservableList acopladoData = FXCollections.observableArrayList();
@@ -47,7 +47,7 @@ public class CargarAcopladoController {
*/
@FXML
private void initialize(){
- idAcopladoTableColumn.setCellValueFactory(cellData -> cellData.getValue().idProperty().asString());
+ chasisColumn.setCellValueFactory(cellData -> cellData.getValue().chasisNumeroProperty());
marcaTableColumn.setCellValueFactory(cellData -> cellData.getValue().marcaProperty());
patenteTableColumn.setCellValueFactory(cellData -> cellData.getValue().patenteProperty());
@@ -58,7 +58,7 @@ public void handleNewAcoplado(){
Acoplado tempAcoplado = new Acoplado();
boolean okClicked = this.showAcopladoEdit(tempAcoplado,true);
if(okClicked)
- acopladoData.add(tempAcoplado);
+ buscarAcoplados();
}
diff --git a/src/application/view/calculo/CargarCamion.fxml b/src/application/view/calculo/CargarCamion.fxml
index 7ca92c7..aa7de98 100644
--- a/src/application/view/calculo/CargarCamion.fxml
+++ b/src/application/view/calculo/CargarCamion.fxml
@@ -2,53 +2,44 @@
-
-
-
-
-
+
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/calculo/CargarCamionController.java b/src/application/view/calculo/CargarCamionController.java
index 6eb7737..2e7e866 100644
--- a/src/application/view/calculo/CargarCamionController.java
+++ b/src/application/view/calculo/CargarCamionController.java
@@ -31,13 +31,15 @@ public class CargarCamionController {
@FXML
private TableView camionTableView;
@FXML
- private TableColumn idCamionTableColumn;
- @FXML
private TableColumn marcaTableColumn;
@FXML
private TableColumn modeloTableColumn;
@FXML
private TableColumn patenteTableColumn;
+ @FXML
+ private TableColumn motorColumn;
+ @FXML
+ private TableColumn chasisColumn;
private Stage owner;
private ObservableList camionData = FXCollections.observableArrayList();
@@ -49,11 +51,11 @@ public class CargarCamionController {
*/
@FXML
private void initialize(){
- idCamionTableColumn.setCellValueFactory(cellData -> cellData.getValue().idProperty().asString());
marcaTableColumn.setCellValueFactory(cellData -> cellData.getValue().marcaProperty());
modeloTableColumn.setCellValueFactory(cellData -> cellData.getValue().modeloProperty());
patenteTableColumn.setCellValueFactory(cellData -> cellData.getValue().patenteProperty());
-
+ motorColumn.setCellValueFactory(cellData -> cellData.getValue().motorProperty());
+ chasisColumn.setCellValueFactory(cellData -> cellData.getValue().chasisProperty());
}
@FXML
@@ -61,7 +63,7 @@ public void handleNewCamion(){
Camion tempCamion = new Camion();
boolean okClicked = this.showCamionEdit(tempCamion,true);
if(okClicked)
- camionData.add(tempCamion);
+ buscarCamiones();
}
diff --git a/src/application/view/calculo/InfoFinca.fxml b/src/application/view/calculo/InfoFinca.fxml
index 38333a7..5ff61c8 100644
--- a/src/application/view/calculo/InfoFinca.fxml
+++ b/src/application/view/calculo/InfoFinca.fxml
@@ -1,44 +1,32 @@
-
-
-
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/calculo/InfoIngenio.fxml b/src/application/view/calculo/InfoIngenio.fxml
index 3fd5305..6ee9aa9 100644
--- a/src/application/view/calculo/InfoIngenio.fxml
+++ b/src/application/view/calculo/InfoIngenio.fxml
@@ -1,53 +1,40 @@
-
-
-
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/calculo/InfoIngenioController.java b/src/application/view/calculo/InfoIngenioController.java
index 155fddc..5f9bfe0 100644
--- a/src/application/view/calculo/InfoIngenioController.java
+++ b/src/application/view/calculo/InfoIngenioController.java
@@ -12,7 +12,10 @@
import javafx.fxml.Initializable;
import javafx.scene.Group;
import javafx.scene.Scene;
-import javafx.scene.control.*;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
diff --git a/src/application/view/calculo/InfoOrigenDestino.fxml b/src/application/view/calculo/InfoOrigenDestino.fxml
index d20355c..0d55973 100644
--- a/src/application/view/calculo/InfoOrigenDestino.fxml
+++ b/src/application/view/calculo/InfoOrigenDestino.fxml
@@ -1,54 +1,41 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/application/view/calculo/InfoOrigenDestinoController.java b/src/application/view/calculo/InfoOrigenDestinoController.java
index dd5c6f0..ee3f8b7 100644
--- a/src/application/view/calculo/InfoOrigenDestinoController.java
+++ b/src/application/view/calculo/InfoOrigenDestinoController.java
@@ -2,6 +2,7 @@
import application.Main;
import application.comunes.Alerta;
+import application.model.calculo.Ingenio;
import application.model.calculo.OrigenDestino;
import application.repository.calculo.FincaRepository;
import application.repository.calculo.IngenioRepository;
@@ -35,15 +36,13 @@ public class InfoOrigenDestinoController implements Initializable {
@FXML
private TableColumn distanciaColumn;
@FXML
- private TextField buscarPorIngenioField;
+ private ComboBox buscarPorIngenioComboBox;
@FXML
private Button newButton;
@FXML
private Button editButton;
@FXML
private Button eliminarButton;
- @FXML
- private Button searchButton;
private Stage owner;
@@ -132,6 +131,7 @@ private boolean showEdit(OrigenDestino distancia, boolean b) {
}
@Override
public void initialize(URL location, ResourceBundle resources) {
+ cargarIngenioComboBox();
idColumn.setCellValueFactory(cellData -> cellData.getValue().idOrigenDestinoProperty().asString());
ingenioColumn.setCellValueFactory(cellData -> cellData.getValue().nombreIngenioProperty());
fincaColumn.setCellValueFactory(cellData -> cellData.getValue().nombreFincaProperty());
@@ -139,8 +139,16 @@ public void initialize(URL location, ResourceBundle resources) {
}
+ private void cargarIngenioComboBox() {
+ buscarPorIngenioComboBox.setItems(ingenioRepository.view());
+ }
+
public void buscarDistancias(){
this.distancias = distanciasRepository.view();
tableView.setItems(distancias);
+ if (!buscarPorIngenioComboBox.getSelectionModel().isEmpty()){
+ distancias = distanciasRepository.viewByIngenio(buscarPorIngenioComboBox.getSelectionModel().getSelectedItem().getIdIngenio());
+ tableView.setItems(distancias);
+ }
}
}
\ No newline at end of file
diff --git a/src/application/view/calculo/cruds/AcopladoEdit.fxml b/src/application/view/calculo/cruds/AcopladoEdit.fxml
index d1fb6ac..d83eb28 100644
--- a/src/application/view/calculo/cruds/AcopladoEdit.fxml
+++ b/src/application/view/calculo/cruds/AcopladoEdit.fxml
@@ -2,20 +2,22 @@
-
+
-
+
-
+
-
+
+
+
@@ -25,11 +27,13 @@
+
+
-
+
diff --git a/src/application/view/calculo/cruds/AcopladoEditController.java b/src/application/view/calculo/cruds/AcopladoEditController.java
index bc61b55..4e2c6f0 100644
--- a/src/application/view/calculo/cruds/AcopladoEditController.java
+++ b/src/application/view/calculo/cruds/AcopladoEditController.java
@@ -14,6 +14,8 @@ public class AcopladoEditController {
private TextField marcaField;
@FXML
private TextField patenteField;
+ @FXML
+ private TextField chasisField;
@FXML
private Button btnOk;
@@ -37,6 +39,7 @@ public void handleOk(){
if (isInputValid()){
acoplado.setMarca(marcaField.getText());
acoplado.setPatente(patenteField.getText());
+ acoplado.setChasisNumero(chasisField.getText());
if (isNew){
repository.save(acoplado);
}else {
@@ -57,8 +60,11 @@ public void setDialogStage(Stage dialogStage) {
public void setAcoplado(Acoplado acoplado){
this.acoplado = acoplado;
- marcaField.setText(acoplado.getMarca());
- patenteField.setText(acoplado.getPatente());
+ if (!isNew){
+ marcaField.setText(acoplado.getMarca());
+ patenteField.setText(acoplado.getPatente());
+ chasisField.setText(acoplado.getChasisNumero());
+ }
}
public boolean isOkClicked(){
return okClicked;
@@ -72,6 +78,9 @@ private boolean isInputValid() {
if (patenteField.getText() == null || patenteField.getText().length() == 0 || patenteField.getText().length() > 6 ) {
errorMessage += "Patente no Ingresado correctamente (6 digitos).\n";
}
+ if (chasisField.getText() == null || chasisField.getText().length() == 0) {
+ errorMessage += "Chasis no ingresado correctamente (17 digitos).\n";
+ }
if (errorMessage.length() == 0) {
return true;
} else {
diff --git a/src/application/view/calculo/cruds/CamionEdit.fxml b/src/application/view/calculo/cruds/CamionEdit.fxml
index 59c2b5d..b26f986 100644
--- a/src/application/view/calculo/cruds/CamionEdit.fxml
+++ b/src/application/view/calculo/cruds/CamionEdit.fxml
@@ -2,15 +2,15 @@
-
+
-
+
-
+
-
+
@@ -18,6 +18,10 @@
+
+
+
+
@@ -31,9 +35,13 @@
+
+
+
+
-
+
diff --git a/src/application/view/calculo/cruds/CamionEditController.java b/src/application/view/calculo/cruds/CamionEditController.java
index b22e53c..81d7910 100644
--- a/src/application/view/calculo/cruds/CamionEditController.java
+++ b/src/application/view/calculo/cruds/CamionEditController.java
@@ -16,6 +16,10 @@ public class CamionEditController {
private TextField modeloField;
@FXML
private TextField patenteField;
+ @FXML
+ private TextField motorField;
+ @FXML
+ private TextField chasisField;
@FXML
private Button btnOk;
@@ -40,6 +44,8 @@ public void handleOk(){
camion.setMarca(marcaField.getText());
camion.setModelo(modeloField.getText());
camion.setPatente(patenteField.getText());
+ camion.setMotor(motorField.getText());
+ camion.setChasis(chasisField.getText());
if (isNew){
repository.save(camion);
}else {
@@ -60,9 +66,13 @@ public void setDialogStage(Stage dialogStage) {
public void setCamion(Camion camion){
this.camion = camion;
- marcaField.setText(camion.getMarca());
- modeloField.setText(camion.getModelo());
- patenteField.setText(camion.getPatente());
+ if (!isNew){
+ marcaField.setText(camion.getMarca());
+ modeloField.setText(camion.getModelo());
+ patenteField.setText(camion.getPatente());
+ motorField.setText(camion.getMotor());
+ chasisField.setText(camion.getChasis());
+ }
}
public boolean isOkClicked(){
return okClicked;
@@ -70,15 +80,16 @@ public boolean isOkClicked(){
private boolean isInputValid() {
String errorMessage = "";
- if (marcaField.getText() == null || marcaField.getText().length() == 0) {
+ if (marcaField.getText() == null || marcaField.getText().length() == 0)
errorMessage += "Marca no Ingresada\n";
- }
- if (modeloField.getText() == null || modeloField.getText().length() == 0) {
+ if (modeloField.getText() == null || modeloField.getText().length() == 0)
errorMessage += "Modelo no Ingresado\n";
- }
- if (patenteField.getText() == null || patenteField.getText().length() == 0 || patenteField.getText().length() > 6 ) {
+ if (patenteField.getText() == null || patenteField.getText().length() == 0 || patenteField.getText().length() > 6 )
errorMessage += "Patente no Ingresado correctamente (6 digitos).\n";
- }
+ if (motorField.getText() == null || motorField.getText().length() == 0 || motorField.getText().length() > 17 )
+ errorMessage += "numero de motor no Ingresado correctamente (17 digitos).\n";
+ if (chasisField.getText() == null || chasisField.getText().length() == 0 || chasisField.getText().length() > 17 )
+ errorMessage += "numero de chasis no Ingresado correctamente (17 digitos).\n";
if (errorMessage.length() == 0) {
return true;
} else {
diff --git a/src/application/view/calculo/cruds/DistanciasEdit.fxml b/src/application/view/calculo/cruds/DistanciasEdit.fxml
index 9493ef6..b3b464b 100644
--- a/src/application/view/calculo/cruds/DistanciasEdit.fxml
+++ b/src/application/view/calculo/cruds/DistanciasEdit.fxml
@@ -3,20 +3,10 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -40,7 +30,12 @@
-
+
+
+
+
+
+
diff --git a/src/application/view/calculo/cruds/FincaEdit.fxml b/src/application/view/calculo/cruds/FincaEdit.fxml
index 566d10b..72c067e 100644
--- a/src/application/view/calculo/cruds/FincaEdit.fxml
+++ b/src/application/view/calculo/cruds/FincaEdit.fxml
@@ -1,13 +1,10 @@
-
-
-
-
-
-
+
+
+
diff --git a/src/application/view/calculo/cruds/FincaEditController.java b/src/application/view/calculo/cruds/FincaEditController.java
index a7bd272..b819078 100644
--- a/src/application/view/calculo/cruds/FincaEditController.java
+++ b/src/application/view/calculo/cruds/FincaEditController.java
@@ -97,7 +97,7 @@ private boolean isInputValid() {
@Override
public void initialize(URL location, ResourceBundle resources) {
WebEngine engine = webView.getEngine();
- String url = "https://www.google.com";
+ String url = "https://www.google.com.ar/maps";
engine.load(url);
}
diff --git a/src/application/view/calculo/cruds/IngenioEdit.fxml b/src/application/view/calculo/cruds/IngenioEdit.fxml
index 5e01253..3142c2e 100644
--- a/src/application/view/calculo/cruds/IngenioEdit.fxml
+++ b/src/application/view/calculo/cruds/IngenioEdit.fxml
@@ -1,13 +1,10 @@
-
-
-
-
-
-
+
+
+
diff --git a/src/application/view/calculo/cruds/IngenioEditController.java b/src/application/view/calculo/cruds/IngenioEditController.java
index eb63ace..e2f0323 100644
--- a/src/application/view/calculo/cruds/IngenioEditController.java
+++ b/src/application/view/calculo/cruds/IngenioEditController.java
@@ -10,12 +10,11 @@
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
+import org.apache.commons.lang3.math.NumberUtils;
import java.net.URL;
import java.util.ResourceBundle;
-import org.apache.commons.lang3.math.NumberUtils;
-
public class IngenioEditController implements Initializable {
@FXML
private TextField nombreTextField;
@@ -113,7 +112,7 @@ private boolean isInputValid() {
@Override
public void initialize(URL location, ResourceBundle resources) {
WebEngine engine = webView.getEngine();
- String url = "https://www.google.com";
+ String url = "https://www.google.com.ar/maps";
engine.load(url);
}
diff --git a/src/application/view/compra/Articulos.fxml b/src/application/view/compra/Articulos.fxml
index 4ae97f5..68a5dea 100644
--- a/src/application/view/compra/Articulos.fxml
+++ b/src/application/view/compra/Articulos.fxml
@@ -2,47 +2,40 @@
-
-
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/src/application/view/compra/ArticulosController.java b/src/application/view/compra/ArticulosController.java
index 952edd6..0bd7e71 100644
--- a/src/application/view/compra/ArticulosController.java
+++ b/src/application/view/compra/ArticulosController.java
@@ -27,8 +27,6 @@ public class ArticulosController {
@FXML
private Button buttonUpdate;
@FXML
- private Button buttonDelete;
- @FXML
private TableView articuloTableView;
@FXML
private TableColumn marcaTableColumn;
@@ -71,19 +69,6 @@ public void handleUpdate(){
}
- @FXML
- public void handleDelete(){
- Articulo articulo = articuloTableView.getSelectionModel().getSelectedItem();
- Optional resultado = Alerta.alertaConfirmacion("Eliminar Artículo",
- null, "¿Desea eliminar el artículo seleccionado?");
- if (resultado.isPresent() && resultado.get()==ButtonType.OK){
- articuloTableView.getItems().remove(
- articuloTableView.getSelectionModel().getSelectedIndex());
- articuloRepository.delete(articulo.getIdArticulo());
- }else
- Alerta.alertaError("Seleccionar Artículo", "Por favor seleccione un artículo en la tabla.");
-
- }
public boolean showEdit(Articulo articulo, boolean tipo) {
try {
// Load the fxml file and create a new stage for the popup dialog.
diff --git a/src/application/view/compra/CategoriaArticuloController.java b/src/application/view/compra/CategoriaArticuloController.java
index fd7f579..cabca9d 100644
--- a/src/application/view/compra/CategoriaArticuloController.java
+++ b/src/application/view/compra/CategoriaArticuloController.java
@@ -11,7 +11,10 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Scene;
-import javafx.scene.control.*;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
import javafx.stage.Modality;
import javafx.stage.Stage;
diff --git a/src/application/view/compra/CategoriaArticulos.fxml b/src/application/view/compra/CategoriaArticulos.fxml
index 0553335..d942faf 100644
--- a/src/application/view/compra/CategoriaArticulos.fxml
+++ b/src/application/view/compra/CategoriaArticulos.fxml
@@ -1,48 +1,38 @@
-
-
+
-
-
-
-
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/compra/CompraCompras.fxml b/src/application/view/compra/CompraCompras.fxml
index a4e5cb6..7ceed00 100644
--- a/src/application/view/compra/CompraCompras.fxml
+++ b/src/application/view/compra/CompraCompras.fxml
@@ -1,62 +1,47 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/compra/ControlStock.fxml b/src/application/view/compra/ControlStock.fxml
index 2f84ed8..7721ff9 100644
--- a/src/application/view/compra/ControlStock.fxml
+++ b/src/application/view/compra/ControlStock.fxml
@@ -1,55 +1,39 @@
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/src/application/view/compra/ControlStockController.java b/src/application/view/compra/ControlStockController.java
index bd71a27..4609247 100644
--- a/src/application/view/compra/ControlStockController.java
+++ b/src/application/view/compra/ControlStockController.java
@@ -4,9 +4,9 @@
import application.comunes.Alerta;
import application.model.compra.Articulo;
import application.model.compra.CategoriaArticulo;
+import application.reports.classes.AbstractJasperReports;
import application.repository.compra.ArticuloRepository;
import application.repository.compra.CategoriaArticuloRepository;
-import application.view.compra.cruds.ArticuloEditController;
import application.view.compra.cruds.StockEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -15,13 +15,15 @@
import javafx.fxml.Initializable;
import javafx.scene.Group;
import javafx.scene.Scene;
-import javafx.scene.control.*;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
-import java.util.Optional;
import java.util.ResourceBundle;
public class ControlStockController implements Initializable{
@@ -118,6 +120,7 @@ private void filtrarCategoria(){
}
@FXML
private void generarReporteStock(){
- //todo: hacer reporte de stock
+ AbstractJasperReports.createReport("src\\application\\reports\\ControlStock.jasper");
+ AbstractJasperReports.showViewer();
}
}
diff --git a/src/application/view/compra/Proveedores.fxml b/src/application/view/compra/Proveedores.fxml
index 4891ef5..1e3625f 100644
--- a/src/application/view/compra/Proveedores.fxml
+++ b/src/application/view/compra/Proveedores.fxml
@@ -1,49 +1,43 @@
-
-
+
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/compra/cruds/ArticuloEdit.fxml b/src/application/view/compra/cruds/ArticuloEdit.fxml
index e2696e7..f27924f 100644
--- a/src/application/view/compra/cruds/ArticuloEdit.fxml
+++ b/src/application/view/compra/cruds/ArticuloEdit.fxml
@@ -1,18 +1,12 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -24,16 +18,19 @@
-
-
-
+
+
+
+
+
+
+
-
@@ -45,7 +42,7 @@
-
+
diff --git a/src/application/view/compra/cruds/ArticuloEditController.java b/src/application/view/compra/cruds/ArticuloEditController.java
index dd22136..1089b68 100644
--- a/src/application/view/compra/cruds/ArticuloEditController.java
+++ b/src/application/view/compra/cruds/ArticuloEditController.java
@@ -107,17 +107,17 @@ public void handleCancel(){
public boolean isInputValid() {
String errorMessage = "";
if (marcaTextField.getText() == null || marcaTextField.getText().length() == 0) {
- errorMessage += "No valid brand name!\n";
+ errorMessage += "No se ingresó una marca válida\n";
}
if (modeloTextField.getText() == null || modeloTextField.getText().length() == 0) {
- errorMessage += "No valid model name!\n";
+ errorMessage += "No se ingresó un modelo válido\n";
}
if (descripcionTextArea.getText() == null || descripcionTextArea.getText().length() == 0) {
- errorMessage += "No valid description!\n";
+ errorMessage += "No se ingresó una descripción válida\n";
+ }
+ if (categoriaComboBox.getSelectionModel().isEmpty()) {
+ errorMessage += "No se seleccionó una categoria correctamente.\n";
}
- /* if (categoriaComboBox.is == null || modeloTextField.getText().length() == 0) {
- errorMessage += "No valid model name!\n";
- }*/
if (errorMessage.length() == 0) {
return true;
} else {
diff --git a/src/application/view/compra/cruds/CategoriaArticuloEdit.fxml b/src/application/view/compra/cruds/CategoriaArticuloEdit.fxml
index 075363f..07dc347 100644
--- a/src/application/view/compra/cruds/CategoriaArticuloEdit.fxml
+++ b/src/application/view/compra/cruds/CategoriaArticuloEdit.fxml
@@ -1,12 +1,9 @@
-
-
-
-
-
+
+
@@ -28,7 +25,7 @@
-
+
diff --git a/src/application/view/compra/cruds/FacturaEdit.fxml b/src/application/view/compra/cruds/FacturaEdit.fxml
index 4459afc..98d7467 100644
--- a/src/application/view/compra/cruds/FacturaEdit.fxml
+++ b/src/application/view/compra/cruds/FacturaEdit.fxml
@@ -1,27 +1,16 @@
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
@@ -59,10 +48,10 @@
-
+
-
+
@@ -101,8 +90,8 @@
-
-
+
+
diff --git a/src/application/view/compra/cruds/FacturaEditController.java b/src/application/view/compra/cruds/FacturaEditController.java
index 71a6dbe..72e93e0 100644
--- a/src/application/view/compra/cruds/FacturaEditController.java
+++ b/src/application/view/compra/cruds/FacturaEditController.java
@@ -22,7 +22,6 @@
import java.net.URL;
import java.time.LocalDate;
import java.time.ZoneId;
-import java.util.ConcurrentModificationException;
import java.util.Date;
import java.util.ResourceBundle;
@@ -331,4 +330,9 @@ public boolean isFieldsSetted() {
isFieldsSetted=true;
return isFieldsSetted;
}
+
+ @FXML
+ private void handleAddArticuleOnEnter(){
+ handleNewLine();
+ }
}
diff --git a/src/application/view/compra/cruds/ProveedorEdit.fxml b/src/application/view/compra/cruds/ProveedorEdit.fxml
index 852e59e..b48199d 100644
--- a/src/application/view/compra/cruds/ProveedorEdit.fxml
+++ b/src/application/view/compra/cruds/ProveedorEdit.fxml
@@ -1,12 +1,9 @@
-
-
-
-
-
+
+
diff --git a/src/application/view/compra/cruds/ProveedorEditController.java b/src/application/view/compra/cruds/ProveedorEditController.java
index b5c97e0..ba6d9e9 100644
--- a/src/application/view/compra/cruds/ProveedorEditController.java
+++ b/src/application/view/compra/cruds/ProveedorEditController.java
@@ -5,9 +5,9 @@
import application.model.info.Domicilio;
import application.model.info.Localidad;
import application.model.info.Provincia;
+import application.repository.compra.ProveedorRepository;
import application.repository.info.DomicilioRepository;
import application.repository.info.LocalidadRepository;
-import application.repository.compra.ProveedorRepository;
import application.repository.info.ProvinciaRepository;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
diff --git a/src/application/view/compra/cruds/StockEdit.fxml b/src/application/view/compra/cruds/StockEdit.fxml
index e3c3a88..222a8d9 100644
--- a/src/application/view/compra/cruds/StockEdit.fxml
+++ b/src/application/view/compra/cruds/StockEdit.fxml
@@ -1,29 +1,33 @@
+
+
+
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -39,7 +43,6 @@
-
diff --git a/src/application/view/compra/cruds/StockEditController.java b/src/application/view/compra/cruds/StockEditController.java
index 4ff8c06..72550f3 100644
--- a/src/application/view/compra/cruds/StockEditController.java
+++ b/src/application/view/compra/cruds/StockEditController.java
@@ -1,23 +1,16 @@
package application.view.compra.cruds;
-import application.Main;
import application.comunes.Alerta;
import application.model.compra.Articulo;
-import application.model.compra.CategoriaArticulo;
import application.repository.compra.ArticuloRepository;
-import application.repository.compra.CategoriaArticuloRepository;
-import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
-import javafx.scene.Group;
-import javafx.scene.Scene;
-import javafx.scene.control.*;
-import javafx.stage.Modality;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
import javafx.stage.Stage;
import org.apache.commons.lang3.math.NumberUtils;
-import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
diff --git a/src/application/view/css/theme.css b/src/application/view/css/theme.css
new file mode 100644
index 0000000..3c2fe7f
--- /dev/null
+++ b/src/application/view/css/theme.css
@@ -0,0 +1,440 @@
+/*
+* FLATBEE by KarlTheBee´
+* An javafx css style for a smooth & flat user interface
+* Website : github.com/karlthebee/flatbee
+* Mail : karlthebee@gmail.com
+*
+* Version 1.0.0
+*
+* The license is pretty much a CC-BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/).
+* In simple (non legal) english :
+* you can modify and distribute it, ship in in your application,
+* but not use/sell it commercially.
+* And you have to give credits,
+* like "FlatBee theme by karlthebee (https://github.com/karlthebee/flatbee)"
+*/
+
+/*
+ * These are values you can edit safely.
+ The "color" is your main color (in this case greenish)
+ */
+* {
+ -color : #2ecc71;
+ -white : #efefef;
+ -gray : #dfdfdf;
+ -darkGray : derive(-gray,-20%);
+ -black : #444444dd;
+ -abort : #e74c3c;
+}
+
+.root{
+ -fx-background-color : -white;
+ -fx-fill-width : true;
+ -fx-color : -color;
+ -fx-fill-height : true;
+ -fx-font-family: 'Segoe UI';
+ /* remove the ugly focus shade */
+ -fx-focus-color : transparent;
+ -fx-faint-focus-color: transparent;
+}
+
+#flatbee-tiny{
+ -fx-font-size : 8.0;
+}
+
+#flatbee-small{
+ -fx-font-size : 10.0;
+}
+
+#flatbee-medium{
+ -fx-font-size : 12.0;
+}
+
+#flatbee-large{
+ -fx-font-size : 18.0;
+}
+
+#flatbee-xlarge{
+ -fx-font-size : 24.0;
+}
+
+#flatbee-xxlarge{
+ -fx-font-size : 32.0;
+ -fx-font-weight: bold;
+}
+
+#flatbee-xxxlarge{
+ -fx-font-size : 40.0;
+ -fx-font-weight: bold;
+}
+
+#flatbee-jumbo{
+ -fx-font-size : 48.0;
+ -fx-font-weight: bold;
+}
+
+#flatbee-card{
+ -fx-spacing : 12.0;
+ -fx-padding : 10;
+ -fx-hgap : 10;
+ -fx-vgap : 10;
+ -fx-background-color : -white;
+ -fx-effect : dropshadow(two-pass-box,-black,10,0,0,0);
+}
+
+#flatbee-container{
+ -fx-spacing : 12.0;
+ -fx-padding : 10;
+ -fx-hgap : 10;
+ -fx-vgap : 10;
+}
+
+#flatbee-panel{
+ -fx-padding : 10;
+}
+
+/*
+ * **********
+ * LABELS
+ * **********
+*/
+.label{
+ -fx-text-fill : -black;
+ }
+
+/*
+ * **********
+ * BUTTONS
+ * **********
+ *
+ */
+.button {
+ -fx-background-color : -gray,-gray,-gray,-gray;
+}
+.button:default{
+ -fx-background-color : -color;
+}
+.button:cancel{
+ -fx-background-color : -abort;
+}
+
+.button:focused {
+ -fx-color : -darkGray;
+ -fx-background-color : -darkGray;
+ -fx-focus-color : -darkGray;
+}
+.button:hover {
+ -fx-color: -darkGray;
+ -fx-inner-border : -darkGray;
+ -fx-body-color : -darkGray;
+}
+
+.button:armed {
+ -fx-color: -white;
+}
+
+
+.toggle-button{
+ -fx-background-color : -gray;
+}
+
+.toggle-button:selected{
+ -fx-background-color : -darkGray;
+}
+
+.menu-button{
+ -fx-background-color : -gray;
+}
+
+.split-menu-button{
+ -fx-background-color : -gray;
+}
+
+.split-menu-button>*.label{
+ -fx-background-color : -gray;
+}
+
+.split-menu-button>*.arrow-button{
+ -fx-background-color : -gray;
+}
+
+
+/*
+ * **********
+ * PROGRESSBAR
+ * **********
+ *
+ */
+.progress-indicator {
+ -fx-indeterminate-segment-count : 12;
+ -fx-progress-color : -color;
+ -fx-spin-enabled : true;
+}
+
+.progress-bar>*.bar{
+ -fx-background-color : -color;
+ }
+
+.progress-bar>*.track{
+ -fx-background-color : -gray;
+ }
+
+.progress-bar:determinate>*.determinate-indicator>*.track{
+ -fx-background-color : -gray;
+ }
+
+.progress-bar:determinate>*.determinate-indicator>*.indicator{
+ -fx-background-color : -gray;
+ }
+
+ /*
+ * **********
+ * DATE PICKER
+ * **********
+ *
+ */
+.date-picker{
+ -fx-background-color : -white,-gray,gray;
+}
+
+.date-picker>*.arrow-button{
+ -fx-background-color : -white,-gray,-gray;
+}
+
+ .date-picker>*.arrow-button>*.arrow{
+ -fx-background-color : -darkGray, -black;
+}
+/*
+ * **********
+ * SLIDER
+ * **********
+ *
+ */
+ .slider>*.track{
+ -fx-background-color : -gray;
+ }
+.slider>*.axis:bottom{
+ -fx-tick-label-font-family : 'Segoe UI';
+}
+
+.slider>*.thumb{
+ -fx-background-color : -color;
+}
+
+/*
+ * **********
+ * COMBOBOX
+ * **********
+ *
+ */
+.combo-box {
+ -fx-background-color : -gray;
+}
+
+.check-box>*.box{
+ -fx-background-color : -color;
+}
+
+
+/*
+ * **********
+ * TABPANE
+ * **********
+ *
+ */
+ .tab-pane>*.tab-header-area{
+ -fx-padding : 0,0,0,0;
+ }
+.tab-pane>*.tab-header-area>*.headers-region>*.tab:selected:top{
+ -fx-padding : 6,6,6,6;
+ -fx-text-fill : -white;
+ -fx-background-color : -color;
+}
+.tab-pane>*.tab-header-area>*.headers-region>*.tab:selected>*.tab-container>*.tab-label{
+ -fx-font-size : 13.0;
+ -fx-font-weight: bold;
+}
+
+.tab-pane>*.tab-header-area>*.headers-region>*.tab:top{
+ -fx-padding : 4,4,4,4;
+ -fx-text-fill : -white;
+ -fx-background-color : -white;
+}
+
+.tab-pane>*.tab-header-area>*.control-buttons-tab>*.container>*.tab-down-button{
+ -fx-background-color : -white;
+}
+
+.tab-pane>*.tab-header-area>*.control-buttons-tab>*.container>*.tab-down-button>*.arrow{
+ -fx-background-color : -darkGray;
+}
+
+
+/*
+ * **********
+ * MENU
+ * **********
+ *
+ */
+.menu-bar{
+ -fx-background-color : -gray;
+}
+
+
+/*
+ * **********
+ * Checkbox
+ * **********
+ *
+ */
+ .check-box>*.box{
+ -fx-background-color : -gray;
+ }
+
+ .check-box:selected>*.box>*.mark{
+ -fx-background-color : -black;
+ }
+.check-box:indeterminate>*.box>*.mark{
+ -fx-background-color : -black;
+ }
+
+
+ /*
+ * **********
+ * RADIO BUTTONS
+ * **********
+ *
+ */
+ .radio-button>*.radio{
+ -fx-background-color : -gray;
+ }
+
+ .radio-button:selected>*.radio>*.dot{
+ -fx-background-color : -black;
+ }
+
+/*
+ * **********
+ * Text fields / inputs
+ * **********
+ *
+ */
+.text-field{
+ -fx-highlight-fill : -color;
+ -fx-highlight-text-fill : -white;
+}
+
+.text-area{
+ -fx-highlight-fill : -color;
+ -fx-highlight-text-fill : -white;
+}
+
+.spinner>*.increment-arrow-button{
+ -fx-background-color : -gray;
+}
+
+.spinner>*.decrement-arrow-button{
+ -fx-background-color : -gray;
+}
+/*
+ * **********
+ * Titled Pane
+ * **********
+ *
+ */
+
+.first-titled-pane:expanded>*.title{
+ -fx-background-color : -color;
+}
+
+.titled-pane:expanded>*.title{
+ -fx-background-color : -color;
+}
+
+.titled-pane:collapsed>*.title{
+ -fx-background-color : -gray;
+}
+
+.titled-pane*>*.title>*.arrow-button>*.arrow{
+ -fx-background-color : -black;
+}
+
+/*
+ * **********
+ * Table
+ * **********
+ *
+ */
+.table-view:row-selection{
+ -fx-background-color : -gray;
+}
+
+.table-view:row-selection>*.column-header-background{
+ -fx-background-color : -white;
+}
+
+.table-view>*.column-resize-line{
+ -fx-background-color : -black;
+}
+
+.table-view>*.column-header-background>*.nested-column-header>*.table-column{
+ -fx-background-color : -darkGray, -white;
+}
+
+.table-view>*.column-header-background>*.filler{
+ -fx-background-color : -darkGray, -gray;
+}
+
+.table-view>*.column-header-background>*.show-hide-columns-button{
+ -fx-background-color : -gray;
+}
+
+
+.tree-table-view:row-selection{
+ -fx-background-color : -gray;
+}
+
+.tree-table-view:row-selection>*.column-header-background{
+ -fx-background-color : -white;
+}
+
+.tree-table-view>*.column-resize-line{
+ -fx-background-color : -black;
+}
+
+.tree-table-view>*.column-header-background>*.nested-column-header>*.table-column{
+ -fx-background-color : -darkGray, -white;
+}
+
+.tree-table-view>*.column-header-background>*.filler{
+ -fx-background-color : -darkGray, -gray;
+}
+
+.tree-table-view>*.column-header-background>*.show-hide-columns-button{
+ -fx-background-color : -gray;
+}
+
+
+/*
+ * **********
+ * Color picker
+ * **********
+ *
+ */
+.color-picker{
+ -fx-background-color : -gray;
+}
+
+/*
+ * **********
+ * Scroll pane
+ * **********
+ *
+ */
+.scroll-pane>*.scroll-bar{
+ -fx-background-color : -gray;
+}
+
+.scroll-pane>*.scroll-bar>*.thumb{
+ -fx-background-color : -color;
+}
diff --git a/src/application/view/info/AdministrarEmpleados.fxml b/src/application/view/info/AdministrarEmpleados.fxml
index 32b098a..6213b4c 100644
--- a/src/application/view/info/AdministrarEmpleados.fxml
+++ b/src/application/view/info/AdministrarEmpleados.fxml
@@ -1,58 +1,46 @@
-
-
+
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/info/AdministrarEmpleadosController.java b/src/application/view/info/AdministrarEmpleadosController.java
index 0677b1e..716879a 100644
--- a/src/application/view/info/AdministrarEmpleadosController.java
+++ b/src/application/view/info/AdministrarEmpleadosController.java
@@ -1,32 +1,29 @@
package application.view.info;
-import java.io.IOException;
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
-import java.util.Optional;
-
+import application.Main;
import application.comunes.Alerta;
-import application.model.info.CategoriaEmpleado;
-import application.view.info.cruds.CategoriaEmpleadoEditController;
+import application.model.info.Empleado;
+import application.repository.info.EmpleadoRepository;
import application.view.info.cruds.EmpleadoEditDialogController;
-import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.control.TableColumn;
-import javafx.scene.control.TableView;
-import application.Main;
-import application.model.info.Empleado;
-import application.repository.info.EmpleadoRepository;
+
+import java.io.IOException;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.Date;
+import java.util.Optional;
public class AdministrarEmpleadosController {
diff --git a/src/application/view/info/AdministrarUsuarios.fxml b/src/application/view/info/AdministrarUsuarios.fxml
index df81a41..1386257 100644
--- a/src/application/view/info/AdministrarUsuarios.fxml
+++ b/src/application/view/info/AdministrarUsuarios.fxml
@@ -1,49 +1,40 @@
+
+
+
-
-
-
-
+
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/info/AdministrarUsuariosController.java b/src/application/view/info/AdministrarUsuariosController.java
index 6d64c2e..64ae69b 100644
--- a/src/application/view/info/AdministrarUsuariosController.java
+++ b/src/application/view/info/AdministrarUsuariosController.java
@@ -1,24 +1,29 @@
package application.view.info;
-import application.view.info.cruds.UsuarioEditDialogController;
+import application.Main;
+import application.comunes.Alerta;
+import application.model.info.Usuario;
+import application.repository.info.UsuarioRepository;
+import application.view.LoginController;
+import application.view.RegisterController;
+import application.view.info.cruds.UsuarioEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
+import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
+import javafx.scene.control.Alert.AlertType;
+import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
-import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
-
-import application.Main;
-import application.model.info.Usuario;
-import application.repository.info.UsuarioRepository;
+import java.util.Optional;
public class AdministrarUsuariosController {
@@ -34,7 +39,8 @@ public class AdministrarUsuariosController {
private ObservableList usuarioData = FXCollections.observableArrayList();
Stage owner;
-
+ private Usuario userSesion;
+
public void buscarUsuarios(){
this.usuarioData = UsuarioRepository.buscarUsuarios();
usuarioTable.setItems(usuarioData);
@@ -49,27 +55,55 @@ private void initialize(){
@FXML
private void handleDeleteUsuario(){
- int selectedIndex = usuarioTable.getSelectionModel().getSelectedIndex();
- if(selectedIndex >= 0){
- usuarioTable.getItems().remove(selectedIndex);
- } else {
- Alert alert = new Alert(AlertType.WARNING);
- alert.setTitle("Seleccionar Usuario");
- alert.setHeaderText(null);
- alert.setContentText("Por favor selecciona un usuario en la tabla");
- alert.showAndWait();
+ Usuario selectedItem = usuarioTable.getSelectionModel().getSelectedItem();
+ Optional resultado = Alerta.alertaConfirmacion("Eliminar usuario",
+ null,"¿Desea eliminar el usuario seleccionado?");
+ if (!selectedItem.getNombre_usuario().matches(userSesion.getNombre_usuario())){
+ if (resultado.isPresent() && resultado.get()==ButtonType.OK){
+ usuarioTable.getItems().remove(
+ usuarioTable.getSelectionModel().getSelectedIndex());
+ UsuarioRepository.delete(selectedItem);
+ }
+
+ }else {
+ Alerta.alertaError("Seleccionar usuario", "Por favor seleccione un usuario válido en la tabla." +
+ "\n (No se puede borrar la cuenta actual).");
}
}
@FXML
private void handleNewUsuario() {
- Usuario tempUsuario = new Usuario();
- boolean okClicked = this.showUsuarioEditDialog(tempUsuario);
- if (okClicked) {
- usuarioData.add(tempUsuario);
+ loadRegistration();
+ }
+
+ private void loadRegistration() {
+ try {
+ // Load the fxml file and create a new stage for the popup dialog.
+ FXMLLoader loader = new FXMLLoader();
+ loader.setLocation(Main.class.getResource("view/Register.fxml"));
+ Group page = loader.load();
+
+ // Create the dialog Stage.
+ Stage dialogStage = new Stage();
+ dialogStage.setTitle("Nuevo usuario");
+ dialogStage.initModality(Modality.WINDOW_MODAL);
+ Scene scene = new Scene(page);
+ dialogStage.setScene(scene);
+
+
+ RegisterController controller = loader.getController();
+ controller.setDialogStage(dialogStage);
+ controller.getHlLogin().setVisible(false);
+
+
+
+ // Show the dialog and wait until the user closes it
+ dialogStage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
-
+
public void setOwner(Stage owner){
this.owner = owner;
@@ -96,7 +130,7 @@ public boolean showUsuarioEditDialog(Usuario usuario) {
try {
// Load the fxml file and create a new stage for the popup dialog.
FXMLLoader loader = new FXMLLoader();
- loader.setLocation(Main.class.getResource("view/info/cruds/EditarUsuarioDialog.fxml"));
+ loader.setLocation(Main.class.getResource("view/info/cruds/UsuarioEdit.fxml"));
AnchorPane page = (AnchorPane) loader.load();
// Create the dialog Stage.
@@ -108,7 +142,7 @@ public boolean showUsuarioEditDialog(Usuario usuario) {
dialogStage.setScene(scene);
// Set the person into the controller.
- UsuarioEditDialogController controller = loader.getController();
+ UsuarioEditController controller = loader.getController();
controller.setDialogStage(dialogStage);
controller.setUsuario(usuario);
@@ -121,7 +155,9 @@ public boolean showUsuarioEditDialog(Usuario usuario) {
return false;
}
}
-
-
-
+
+
+ public void setUserSesion(Usuario userSesion) {
+ this.userSesion = userSesion;
+ }
}
\ No newline at end of file
diff --git a/src/application/view/info/Desempleados.fxml b/src/application/view/info/Desempleados.fxml
index e3841d1..dca2646 100644
--- a/src/application/view/info/Desempleados.fxml
+++ b/src/application/view/info/Desempleados.fxml
@@ -1,46 +1,32 @@
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/info/DesempleadosController.java b/src/application/view/info/DesempleadosController.java
index 68804f9..0696941 100644
--- a/src/application/view/info/DesempleadosController.java
+++ b/src/application/view/info/DesempleadosController.java
@@ -1,30 +1,14 @@
package application.view.info;
-import application.Main;
-import application.comunes.Alerta;
import application.model.info.Empleado;
import application.repository.info.EmpleadoRepository;
-import application.view.info.cruds.EmpleadoEditDialogController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Scene;
-import javafx.scene.control.Alert;
-import javafx.scene.control.Alert.AlertType;
-import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
-import javafx.scene.layout.AnchorPane;
-import javafx.stage.Modality;
import javafx.stage.Stage;
-import java.io.IOException;
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
-import java.util.Optional;
-
public class DesempleadosController {
@FXML
diff --git a/src/application/view/info/GrupoFamiliar.fxml b/src/application/view/info/GrupoFamiliar.fxml
index 5a460f1..a5ab0e2 100644
--- a/src/application/view/info/GrupoFamiliar.fxml
+++ b/src/application/view/info/GrupoFamiliar.fxml
@@ -1,17 +1,10 @@
-
-
-
-
-
-
-
-
-
+
+
-
+
diff --git a/src/application/view/info/GrupoFamiliarController.java b/src/application/view/info/GrupoFamiliarController.java
index 5b3aa42..d368512 100644
--- a/src/application/view/info/GrupoFamiliarController.java
+++ b/src/application/view/info/GrupoFamiliarController.java
@@ -6,7 +6,6 @@
import application.model.info.Familiar;
import application.repository.info.EmpleadoRepository;
import application.repository.info.FamiliarRepository;
-import application.view.compra.cruds.FacturaEditController;
import application.view.info.cruds.FamiliarEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
diff --git a/src/application/view/info/InfoCategoriaEmpleado.fxml b/src/application/view/info/InfoCategoriaEmpleado.fxml
index 534f878..d8e6b1a 100644
--- a/src/application/view/info/InfoCategoriaEmpleado.fxml
+++ b/src/application/view/info/InfoCategoriaEmpleado.fxml
@@ -1,48 +1,35 @@
-
-
+
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/info/InfoCategoriaEmpleadoController.java b/src/application/view/info/InfoCategoriaEmpleadoController.java
index bf51172..ecc126e 100644
--- a/src/application/view/info/InfoCategoriaEmpleadoController.java
+++ b/src/application/view/info/InfoCategoriaEmpleadoController.java
@@ -1,5 +1,10 @@
package application.view.info;
+import application.Main;
+import application.comunes.Alerta;
+import application.model.info.CategoriaEmpleado;
+import application.repository.info.CategoriaEmpleadoRepository;
+import application.view.info.cruds.CategoriaEmpleadoEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@@ -16,12 +21,6 @@
import java.io.IOException;
import java.util.Optional;
-import application.Main;
-import application.comunes.Alerta;
-import application.model.info.CategoriaEmpleado;
-import application.repository.info.CategoriaEmpleadoRepository;
-import application.view.info.cruds.CategoriaEmpleadoEditController;
-
public class InfoCategoriaEmpleadoController {
@FXML
diff --git a/src/application/view/info/InfoDomicilio.fxml b/src/application/view/info/InfoDomicilio.fxml
deleted file mode 100644
index 33061ca..0000000
--- a/src/application/view/info/InfoDomicilio.fxml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/application/view/info/cruds/CategoriaEmpleadoEdit.fxml b/src/application/view/info/cruds/CategoriaEmpleadoEdit.fxml
index 3059e52..d5d9dba 100644
--- a/src/application/view/info/cruds/CategoriaEmpleadoEdit.fxml
+++ b/src/application/view/info/cruds/CategoriaEmpleadoEdit.fxml
@@ -1,12 +1,11 @@
-
-
+
+
+
-
-
-
+
diff --git a/src/application/view/info/cruds/CategoriaEmpleadoEditController.java b/src/application/view/info/cruds/CategoriaEmpleadoEditController.java
index 94ed7dc..676c614 100644
--- a/src/application/view/info/cruds/CategoriaEmpleadoEditController.java
+++ b/src/application/view/info/cruds/CategoriaEmpleadoEditController.java
@@ -1,7 +1,6 @@
package application.view.info.cruds;
import application.comunes.Alerta;
-import application.model.compra.CategoriaArticulo;
import application.model.info.CategoriaEmpleado;
import application.repository.info.CategoriaEmpleadoRepository;
import javafx.fxml.FXML;
@@ -66,7 +65,7 @@ private boolean isInputValid() {
String errorMessage = "";
if (nombreCategoriaField.getText() == null || nombreCategoriaField.getText().length() == 0) {
- errorMessage += "No valid Category name!\n";
+ errorMessage += "No se ingresó una categoria válida\n";
}
if (errorMessage.length() == 0) {
return true;
diff --git a/src/application/view/info/cruds/EditarEmpleadoDialog.fxml b/src/application/view/info/cruds/EditarEmpleadoDialog.fxml
index 3eea071..85d3ab1 100644
--- a/src/application/view/info/cruds/EditarEmpleadoDialog.fxml
+++ b/src/application/view/info/cruds/EditarEmpleadoDialog.fxml
@@ -1,19 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
@@ -52,7 +44,7 @@
-
+
@@ -65,7 +57,6 @@
-
diff --git a/src/application/view/info/cruds/EditarUsuarioDialog.fxml b/src/application/view/info/cruds/EditarUsuarioDialog.fxml
deleted file mode 100644
index fbe2882..0000000
--- a/src/application/view/info/cruds/EditarUsuarioDialog.fxml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/application/view/info/cruds/EmpleadoEditDialogController.java b/src/application/view/info/cruds/EmpleadoEditDialogController.java
index ffb6bb9..7fae6e4 100644
--- a/src/application/view/info/cruds/EmpleadoEditDialogController.java
+++ b/src/application/view/info/cruds/EmpleadoEditDialogController.java
@@ -1,35 +1,16 @@
package application.view.info.cruds;
-import application.view.info.GrupoFamiliarController;
+import application.model.info.*;
+import application.repository.info.*;
import application.view.info.InfoCategoriaEmpleadoController;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.scene.control.Alert;
-import javafx.scene.control.TextField;
+import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
-import javafx.scene.control.Button;
-import javafx.scene.control.ComboBox;
-import javafx.scene.control.DatePicker;
import javafx.stage.Stage;
import java.time.LocalDate;
import java.time.ZoneId;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
-import java.time.format.DateTimeFormatter;
-
-import application.model.info.CategoriaEmpleado;
-import application.model.info.Domicilio;
-import application.model.info.Empleado;
-import application.model.info.Localidad;
-import application.model.info.Provincia;
-import application.repository.info.CategoriaEmpleadoRepository;
-import application.repository.info.DomicilioRepository;
-import application.repository.info.EmpleadoRepository;
-import application.repository.info.LocalidadRepository;
-import application.repository.info.ProvinciaRepository;
public class EmpleadoEditDialogController {
@@ -55,8 +36,7 @@ public class EmpleadoEditDialogController {
private ComboBox localidadComboBox;
@FXML
private Button aceptarButton;
- @FXML
- private Button familiarButton;
+
private boolean isNew;
private EmpleadoRepository empleadoRepository = new EmpleadoRepository();
private CategoriaEmpleadoRepository categoriaEmpleadoRepository = new CategoriaEmpleadoRepository();
@@ -109,10 +89,8 @@ public void setDialogStage(Stage dialogStage) {
}
public void setPerson(Empleado empleado) {
- familiarButton.setDisable(true);
this.empleado = empleado;
if (!isNew){
- familiarButton.setDisable(false);
nombreField.setText(empleado.getNombre());
apellidoField.setText(empleado.getApellido());
cuitField.setText(empleado.getCuit());
@@ -177,10 +155,10 @@ private boolean isInputValid() {
String errorMessage = "";
if (nombreField.getText() == null || nombreField.getText().length() == 0) {
- errorMessage += "No valid first name!\n";
+ errorMessage += "No se ingresó un nombre válido\n";
}
if (apellidoField.getText() == null || apellidoField.getText().length() == 0) {
- errorMessage += "No valid last name!\n";
+ errorMessage += "No se ingresó un apellido válido\n";
}
if (errorMessage.length() == 0) {
@@ -188,7 +166,7 @@ private boolean isInputValid() {
} else {
// Show the error message.
Alert alert = new Alert(AlertType.ERROR);
- alert.setTitle("Datos Invalidos");
+ alert.setTitle("Datos Inválidos");
alert.setHeaderText(null);
alert.setContentText(errorMessage);
alert.showAndWait();
@@ -202,10 +180,7 @@ private void handleNewCategoriaEmpleado(){
controller.showCategoriaEmpleadoEdit(new CategoriaEmpleado(), true);
setCategoriaComboBox();
}
- @FXML
- private void mostrarFamiliares(){
- //todo: hacer metodo
- }
+
private void ponerFechaAlta(){
java.util.Date input = new Date();
diff --git a/src/application/view/info/cruds/FamiliarEdit.fxml b/src/application/view/info/cruds/FamiliarEdit.fxml
index 686a63f..b5d9c39 100644
--- a/src/application/view/info/cruds/FamiliarEdit.fxml
+++ b/src/application/view/info/cruds/FamiliarEdit.fxml
@@ -1,22 +1,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/application/view/info/cruds/FamiliarEditController.java b/src/application/view/info/cruds/FamiliarEditController.java
index 8c4b97d..987a6f6 100644
--- a/src/application/view/info/cruds/FamiliarEditController.java
+++ b/src/application/view/info/cruds/FamiliarEditController.java
@@ -1,27 +1,15 @@
package application.view.info.cruds;
-import application.Main;
import application.comunes.Alerta;
-import application.model.compra.Articulo;
-import application.model.compra.CategoriaArticulo;
-import application.model.compra.FacturaCompra;
import application.model.info.Familiar;
-import application.repository.compra.ArticuloRepository;
-import application.repository.compra.CategoriaArticuloRepository;
import application.repository.info.FamiliarRepository;
-import application.view.compra.cruds.CategoriaArticuloEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
-import javafx.scene.Group;
-import javafx.scene.Scene;
import javafx.scene.control.*;
-import javafx.stage.Modality;
import javafx.stage.Stage;
-import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.ResourceBundle;
diff --git a/src/application/view/info/cruds/UsuarioEdit.fxml b/src/application/view/info/cruds/UsuarioEdit.fxml
new file mode 100644
index 0000000..81485ef
--- /dev/null
+++ b/src/application/view/info/cruds/UsuarioEdit.fxml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/view/info/cruds/UsuarioEditController.java b/src/application/view/info/cruds/UsuarioEditController.java
new file mode 100644
index 0000000..4425673
--- /dev/null
+++ b/src/application/view/info/cruds/UsuarioEditController.java
@@ -0,0 +1,148 @@
+package application.view.info.cruds;
+
+import application.model.info.Empleado;
+import application.model.info.Usuario;
+import application.repository.info.EmpleadoRepository;
+import application.repository.info.UsuarioRepository;
+import javafx.beans.property.StringProperty;
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.*;
+import javafx.scene.control.Alert.AlertType;
+import javafx.stage.Stage;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+public class UsuarioEditController implements Initializable{
+
+ @FXML
+ private TextField usuarioField;
+ @FXML
+ private PasswordField passwordField;
+ @FXML
+ private PasswordField newPasswordField;
+ @FXML
+ private PasswordField reNewPasswordField;
+ @FXML
+ private ComboBox empleadoComboBox;
+
+ @FXML
+ private Button aceptarButton;
+
+ private Stage dialogStage;
+ private Usuario usuario;
+ private boolean okClicked = false;
+
+ EmpleadoRepository empleadoRepository = new EmpleadoRepository();
+ private ObservableList empleadoList = empleadoRepository.buscarEmpleados();
+ UsuarioRepository usuarioRepository = new UsuarioRepository();
+ /**
+ * Sets the stage of this dialog.
+ *
+ * @param dialogStage
+ */
+ public void setDialogStage(Stage dialogStage) {
+ this.dialogStage = dialogStage;
+ }
+
+ public void setUsuario(Usuario usuario) {
+ this.usuario = usuario;
+ usuarioField.setText(usuario.getNombre_usuario());
+ empleadoComboBox.getSelectionModel().select(usuario.getEmpleado());
+ }
+
+
+ public boolean isOkClicked(){
+ return okClicked;
+ }
+
+
+ @FXML
+ private void handleOk() {
+ if (isInputValid()){
+ usuario.setPassword(newPasswordField.getText());
+ usuario.setEmpleado(empleadoComboBox.getValue());
+ usuarioRepository.edit(usuario);
+ dialogStage.close();
+ }
+
+ }
+
+ @FXML
+ private void handleCancel() {
+ dialogStage.close();
+ }
+
+
+
+
+ private boolean isInputValid() {
+ String errorMessage = "";
+ if (usuarioField.getText() == null || usuarioField.getText().length() == 0)
+ errorMessage += "No se ingresó un usuario válido\n";
+ if (passwordField.getText() == null || passwordField.getText().length() == 0)
+ errorMessage += "No se ingresó una contraseña válida\n";
+ if (!passMatch())
+ errorMessage += "La contraseña nueva no coincide, por favor ingreselas correctamente.\n";
+ if (!isDiferentPassword())
+ errorMessage += "La contraseña nueva es identica a la antigua.\n";
+ if (!isCorrectPassword())
+ errorMessage += "Contraseña incorrecta";
+
+ if (errorMessage.length() == 0) {
+ return true;
+ } else {
+ // Show the error message.
+ Alert alert = new Alert(AlertType.ERROR);
+ alert.setTitle("Datos Inválidos");
+ alert.setHeaderText(null);
+ alert.setContentText(errorMessage);
+ alert.showAndWait();
+ return false;
+ }
+ }
+
+ @Override
+ public void initialize(URL location, ResourceBundle resources) {
+ cargarComboBoxEmpleados();
+
+ }
+
+ private void cargarComboBoxEmpleados() {
+ empleadoComboBox.setItems(empleadoRepository.buscarEmpleados());
+ }
+
+ private boolean passMatch() {
+ boolean passMatch;
+ String password = newPasswordField.getText();
+ String rePass = reNewPasswordField.getText();
+ if (password.matches(rePass)) {
+ passMatch = true;
+ } else {
+ passMatch = false;
+ }
+ return passMatch;
+ }
+ private boolean isDiferentPassword(){
+ boolean isDiferent;
+ String oldPassword = passwordField.getText();
+ String newPassword = newPasswordField.getText();
+
+ if (oldPassword.matches(newPassword))
+ isDiferent = false;
+ else
+ isDiferent = true;
+
+ return isDiferent;
+ }
+
+ private boolean isCorrectPassword(){
+ String passMD5 = usuario.encryptMD5(passwordField.getText());
+ boolean okLogin = usuarioRepository.login(usuario.getNombre_usuario(), passMD5);
+ System.out.println("Login: " + okLogin);
+ return okLogin;
+ }
+
+}
diff --git a/src/application/view/info/cruds/UsuarioEditDialogController.java b/src/application/view/info/cruds/UsuarioEditDialogController.java
deleted file mode 100644
index 87d1f4f..0000000
--- a/src/application/view/info/cruds/UsuarioEditDialogController.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package application.view.info.cruds;
-
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-import javafx.fxml.FXML;
-import javafx.scene.control.Alert;
-import javafx.scene.control.TextField;
-import javafx.scene.control.Alert.AlertType;
-import javafx.scene.control.Button;
-import javafx.scene.control.ChoiceBox;
-import javafx.scene.control.TableColumn;
-import javafx.scene.control.TableView;
-import javafx.stage.Stage;
-import application.model.info.Usuario;
-import application.repository.info.EmpleadoRepository;
-import application.repository.info.UsuarioRepository;
-import application.model.info.Empleado;
-
-public class UsuarioEditDialogController {
-
- @FXML
- private TextField usuarioField;
- @FXML
- private TextField passwordField;
- @FXML
- private TableView empleadoTable;
- @FXML
- private TableColumn nombreColumn;
- @FXML
- private TableColumn apellidoColumn;
- @FXML
- private TableColumn cuitColumn;
- @FXML
- private Button aceptarButton;
-
- private Stage dialogStage;
- private Usuario usuario;
- private boolean okClicked = false;
-
- EmpleadoRepository empleadoRepository = new EmpleadoRepository();
- private ObservableList empleadoList = empleadoRepository.buscarEmpleados();
-
- @FXML
- private void initialize(){
- empleadoTable.setItems(empleadoList);
- nombreColumn.setCellValueFactory(cellData -> cellData.getValue().nombreProperty());
- apellidoColumn.setCellValueFactory(cellData -> cellData.getValue().apellidoProperty());
- //TODO cuitColumn.setCellValueFactory(cellData -> cellData.getValue().);
-
- }
-UsuarioRepository usuarioRepository = new UsuarioRepository();
- /**
- * Sets the stage of this dialog.
- *
- * @param dialogStage
- */
- public void setDialogStage(Stage dialogStage) {
- this.dialogStage = dialogStage;
- }
-
- public void setUsuario(Usuario usuario) {
- this.usuario = usuario;
-
- usuarioField.setText(usuario.getNombre_usuario());
- passwordField.setText(usuario.getPassword());
-
-
- }
-
-
- public boolean isOkClicked(){
- return okClicked;
- }
-
-
- @FXML
- private void handleOk() {
- Empleado empleado = empleadoTable.getSelectionModel().getSelectedItem();
- if (isInputValid() && empleado != null ) {
- usuario.setNombre_usuario(usuarioField.getText());
- usuario.setPassword(passwordField.getText());
- usuario.setEmpleado(empleado);
- usuarioRepository.create(usuario);
- okClicked = true;
- dialogStage.close();
- }else {
- // Nothing selected.
- Alert alert = new Alert(AlertType.WARNING);
- alert.setTitle("Verifique los datos");
- alert.setHeaderText(null);
- alert.setContentText("Alguno de los datos ingresados es incorrecto o no selecciono un empleado");
- alert.showAndWait();
- }
- }
-
- @FXML
- private void handleCancel() {
- dialogStage.close();
- }
-
-
-
-
- private boolean isInputValid() {
- String errorMessage = "";
-
- if (usuarioField.getText() == null || usuarioField.getText().length() == 0) {
- errorMessage += "No valid user name!\n";
- }
- if (passwordField.getText() == null || passwordField.getText().length() == 0) {
- errorMessage += "No valid password!\n";
- }
-
- if (errorMessage.length() == 0) {
- return true;
- } else {
- // Show the error message.
- Alert alert = new Alert(AlertType.ERROR);
- alert.setTitle("Datos Invalidos");
- alert.setHeaderText(null);
- alert.setContentText(errorMessage);
- alert.showAndWait();
-
- return false;
- }
- }
-
-}
diff --git a/src/application/view/inicio/Home.fxml b/src/application/view/inicio/Home.fxml
index 6b2c619..a9eb27a 100644
--- a/src/application/view/inicio/Home.fxml
+++ b/src/application/view/inicio/Home.fxml
@@ -1,13 +1,9 @@
-
-
-
-
-
-
+
+
-
+
diff --git a/src/application/view/inicio/HomeController.java b/src/application/view/inicio/HomeController.java
index f91037a..40ec9b9 100644
--- a/src/application/view/inicio/HomeController.java
+++ b/src/application/view/inicio/HomeController.java
@@ -32,7 +32,7 @@ public void setOwner(Stage owner){
@Override
public void initialize(URL location, ResourceBundle resources) {
- File file = new File("src/img/cañasprincipal.jpg");
+ File file = new File("src/resources/cañasprincipal.jpg");
Image image = new Image(file.toURI().toString());
imageView.setImage(image);
}
diff --git a/src/application/view/inicio/Organizacion.fxml b/src/application/view/inicio/Organizacion.fxml
index 913c761..a7a6e85 100644
--- a/src/application/view/inicio/Organizacion.fxml
+++ b/src/application/view/inicio/Organizacion.fxml
@@ -1,20 +1,20 @@
-
-
-
+
+
+
-
+
-
+
@@ -23,16 +23,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -41,7 +32,7 @@
-
+
@@ -50,16 +41,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -69,5 +51,6 @@
+
diff --git a/src/application/view/inicio/OrganizacionController.java b/src/application/view/inicio/OrganizacionController.java
index 565b3ba..469fbcc 100644
--- a/src/application/view/inicio/OrganizacionController.java
+++ b/src/application/view/inicio/OrganizacionController.java
@@ -11,9 +11,12 @@
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
import javafx.stage.Modality;
import javafx.stage.Stage;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
@@ -24,15 +27,13 @@ public class OrganizacionController implements Initializable{
@FXML
private Label cuitOrganizacionLabel;
@FXML
- private Label razonSocialOrganizacionLabel;
- @FXML
private Label apoderadoOrganizacionLabel;
@FXML
private Label domicilioOrganizacionLabel;
@FXML
- private Label telefonoOrganizacionLabel;
- @FXML
private Button actualizarDatosOrganizacionLabel;
+ @FXML
+ private ImageView imagenCamion;
Organizacion organizacion = new Organizacion();
OrganizacionRepository repository = new OrganizacionRepository();
@@ -44,6 +45,9 @@ public void setOwner(Stage owner) {
@Override
public void initialize(URL location, ResourceBundle resources) {
+ File file = new File("src/resources/volks.png");
+ Image image = new Image(file.toURI().toString());
+ imagenCamion.setImage(image);
cargarDatosOrganizacion();
}
@@ -60,6 +64,7 @@ private void cargarDatosOrganizacion() {
@FXML
public void handleNew(){
handleEdit(organizacion);
+ cargarDatosOrganizacion();
}
private void handleEdit(Organizacion organizacion){
diff --git a/src/application/view/inicio/crud/OrganizacionEdit.fxml b/src/application/view/inicio/crud/OrganizacionEdit.fxml
index 915eeb4..32aa3dc 100644
--- a/src/application/view/inicio/crud/OrganizacionEdit.fxml
+++ b/src/application/view/inicio/crud/OrganizacionEdit.fxml
@@ -1,35 +1,31 @@
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -48,13 +44,9 @@
-
-
-
-
-
+
diff --git a/src/application/view/inicio/crud/OrganizacionEditController.java b/src/application/view/inicio/crud/OrganizacionEditController.java
index e728326..5cf5615 100644
--- a/src/application/view/inicio/crud/OrganizacionEditController.java
+++ b/src/application/view/inicio/crud/OrganizacionEditController.java
@@ -1,23 +1,16 @@
package application.view.inicio.crud;
import application.comunes.Alerta;
-import application.model.compra.Proveedor;
-import application.model.info.Domicilio;
import application.model.info.Empleado;
import application.model.info.Localidad;
-import application.model.info.Provincia;
import application.model.venta.Organizacion;
-import application.repository.compra.ProveedorRepository;
-import application.repository.info.DomicilioRepository;
import application.repository.info.EmpleadoRepository;
import application.repository.info.LocalidadRepository;
-import application.repository.info.ProvinciaRepository;
import application.repository.venta.OrganizacionRepository;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
-import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
@@ -31,8 +24,6 @@ public class OrganizacionEditController implements Initializable{
@FXML
private TextField cuitTextField;
@FXML
- private TextField razonSocialField;
- @FXML
private ComboBox apoderadoComboBox;
@FXML
private TextField domicilioCalleField;
@@ -41,8 +32,6 @@ public class OrganizacionEditController implements Initializable{
@FXML
private ComboBox localidadComboBox;
@FXML
- private TextField telefonoField;
- @FXML
private Button btnOk;
@FXML
private Button btnCancel;
@@ -82,28 +71,31 @@ public boolean isOkClicked(){
}
private boolean isInputValid() {
- /*String errorMessage = "";
+ String errorMessage = "";
if (nombreTextField.getText() == null || nombreTextField.getText().length() == 0) {
- errorMessage += "No valid supplier name!\n";
+ errorMessage += "Nombre de la organización no ingresado.\n";
}
if(cuitTextField.getText()==null || cuitTextField.getText().length() == 0){
- errorMessage += "No valid CUIT \n";
+ errorMessage += "CUIT de la organización no ingresado correctamente.\n";
}
+ if (!apoderadoComboBox.getSelectionModel().isEmpty())
+ errorMessage += "Apoderado no seleccionado.\n";
if(domicilioCalleField.getText()==null || domicilioCalleField.getText().length() == 0){
- errorMessage += "No valid street name\n";
+ errorMessage += "Calle no ingresada correctamente.\n";
}
if(domicilioNumeroField.getText()==null || domicilioNumeroField.getText().length() == 0){
- errorMessage += "No valid street number \n";
+ errorMessage += "Número no ingresado correctamente. \n";
}
+ if (!localidadComboBox.getSelectionModel().isEmpty())
+ errorMessage += "Localidad no seleccionada.";
if (errorMessage.length() == 0) {
return true;
} else {
Alerta.alertaError("Datos inválidos", errorMessage);
return false;
- }*/
- return true;
+ }
}
@FXML
diff --git a/src/application/view/sueldo/ConceptosSalariales.fxml b/src/application/view/sueldo/ConceptosSalariales.fxml
index e31d553..083c338 100644
--- a/src/application/view/sueldo/ConceptosSalariales.fxml
+++ b/src/application/view/sueldo/ConceptosSalariales.fxml
@@ -1,58 +1,38 @@
-
-
-
-
-
-
-
-
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/sueldo/ConceptosSalarialesController.java b/src/application/view/sueldo/ConceptosSalarialesController.java
index f13e8a9..42ff978 100644
--- a/src/application/view/sueldo/ConceptosSalarialesController.java
+++ b/src/application/view/sueldo/ConceptosSalarialesController.java
@@ -3,8 +3,8 @@
import application.Main;
import application.comunes.Alerta;
import application.model.sueldo.ConceptoSueldo;
-import application.repository.sueldo.TipoLiquidacionRepository;
import application.repository.sueldo.ConceptoSueldoRepository;
+import application.repository.sueldo.TipoLiquidacionRepository;
import application.view.sueldo.cruds.ConceptoEditController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
diff --git a/src/application/view/sueldo/Liquidaciones.fxml b/src/application/view/sueldo/Liquidaciones.fxml
index 80800ae..e77da08 100644
--- a/src/application/view/sueldo/Liquidaciones.fxml
+++ b/src/application/view/sueldo/Liquidaciones.fxml
@@ -2,85 +2,55 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/application/view/sueldo/LiquidacionesController.java b/src/application/view/sueldo/LiquidacionesController.java
index d27c37c..2dab61c 100644
--- a/src/application/view/sueldo/LiquidacionesController.java
+++ b/src/application/view/sueldo/LiquidacionesController.java
@@ -1,10 +1,12 @@
package application.view.sueldo;
import application.Main;
-import application.model.info.Empleado;
import application.model.sueldo.LiquidacionEmpleado;
-import application.model.sueldo.Liquidaciones;
-import application.repository.sueldo.LiquidacionesRepository;
+import application.model.sueldo.Liquidacion;
+import application.reports.classes.AbstractJasperReports;
+import application.repository.sueldo.LiquidacionEmpleadoRepository;
+import application.repository.sueldo.LiquidacionRepository;
+import application.view.sueldo.cruds.LiquidacionSueldoController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@@ -24,23 +26,25 @@
public class LiquidacionesController implements Initializable{
+
+
//Declaracion de la tabla y columnas de la clase Liquidaciones
@FXML
- private TableView liquidacionTable;
+ private TableView liquidacionTable;
@FXML
- private TableColumn idLiquidacion;
+ private TableColumn idLiquidacion;
@FXML
- private TableColumn fechaColumn;
+ private TableColumn fechaColumn;
@FXML
- private TableColumn hrColumn;
+ private TableColumn hrColumn;
@FXML
- private TableColumn hnrColumn;
+ private TableColumn hnrColumn;
@FXML
- private TableColumn retencionesColumn;
+ private TableColumn retencionesColumn;
//Declaracion de la tabla y columnas de la clase LiquidacionEmpleado
@FXML
- private TableView empleadosTable;
+ private TableView liqEmpleadosTable;
@FXML
private TableColumn legajoColumn;
@FXML
@@ -58,33 +62,31 @@ public class LiquidacionesController implements Initializable{
@FXML
private Button nuevaLiquidacionButton;
@FXML
- private Button reportesButton;
-
-
-
-
+ private Button imprimirRecibos;
+ @FXML
+ private Button imprimirReciboDeEmpleado;
private Stage owner;
-
- private ObservableList liquidacion = FXCollections.observableArrayList();
-
- private ObservableList empleados = FXCollections.observableArrayList();
-
- private LiquidacionesRepository liquidacionesRepository = new LiquidacionesRepository();
-
- private ObservableList empleadosLiquidados = FXCollections.observableArrayList();
+ private ObservableList liquidacionesEmpleado = FXCollections.observableArrayList();
+ private LiquidacionEmpleadoRepository liquidacionEmpleadoRepository = new LiquidacionEmpleadoRepository();
public void setOwner(Stage owner){
this.owner = owner;
}
- private ObservableList liquidaciones = FXCollections.observableArrayList();
+ private ObservableList liquidaciones = FXCollections.observableArrayList();
public void buscarLiquidaciones(){
- this.liquidaciones = LiquidacionesRepository.buscarLiquidaciones();
+ this.liquidaciones = LiquidacionRepository.buscarLiquidaciones();
liquidacionTable.setItems(liquidaciones);
}
+ private void buscarLiquidacionesEmpleado(int idLiquidacion){
+ this.liquidacionesEmpleado = liquidacionEmpleadoRepository.getLiqEmpleadoByIdLiq(idLiquidacion);
+ if (!liquidacionesEmpleado.isEmpty())
+ liqEmpleadosTable.setItems(liquidacionesEmpleado);
+ }
+
@Override
public void initialize(URL location, ResourceBundle resources) {
buscarLiquidaciones();
@@ -94,10 +96,16 @@ public void initialize(URL location, ResourceBundle resources) {
hnrColumn.setCellValueFactory(cellData -> cellData.getValue().totalHaberesNoRemunerativosProperty().asString());
retencionesColumn.setCellValueFactory(cellData -> cellData.getValue().totalRetencionesProperty().asString());
+ liquidacionTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
+ if (newSelection != null) {
+ buscarLiquidacionesEmpleado(liquidacionTable.getSelectionModel().getSelectedItem().getId());
+ }
+ });
+
legajoColumn.setCellValueFactory(cellData -> cellData.getValue().getEmpleado().idEmpleadoProperty().asString());
apellidoColumn.setCellValueFactory(cellData -> cellData.getValue().getEmpleado().apellidoProperty());
nombreColumn.setCellValueFactory(cellData -> cellData.getValue().getEmpleado().nombreProperty());
-// categoriaColumn.setCellValueFactory(cellData -> cellData.getValue().getEmpleado().categoriaProperty());
+ categoriaColumn.setCellValueFactory(cellData -> cellData.getValue().getEmpleado().getCategoriaEmpleado().nombreProperty());
hrEmpleadoColumn.setCellValueFactory(cellData -> cellData.getValue().totalHaberesRemunerativosProperty().asString());
hnrEmpleadoColumn.setCellValueFactory(cellData -> cellData.getValue().totalHaberesNoRemunerativosProperty().asString());
retencionesEmpleadoColumn.setCellValueFactory(cellData -> cellData.getValue().totalRetencionesProperty().asString());
@@ -121,7 +129,8 @@ private void handleNew(){
Scene scene = new Scene(page);
dialogStage.setScene(scene);
-
+ LiquidacionSueldoController controller = loader.getController();
+ controller.setOwner(dialogStage);
// Show the dialog and wait until the user closes it
dialogStage.showAndWait();
@@ -132,17 +141,22 @@ private void handleNew(){
}
@FXML
- public void cargarEmpleadosLiquidados(){
- if (liquidacionTable.getSelectionModel().getSelectedItem() != null){
- empleadosLiquidados = liquidacionesRepository.getEmpleadosLiquidadosByidLiquidacion(liquidacionTable.getSelectionModel().getSelectedItem().getId());
- empleadosTable.setItems(empleadosLiquidados);
- }
+ private void handleImprimirRecibos(){
+ int idLiquidacion = liquidacionTable.getSelectionModel().getSelectedItem().getId();
+ System.out.println("se imprimieron recibos de sueldo "+ idLiquidacion);
+ AbstractJasperReports.createReport("src\\application\\reports\\TodosLosRecibosDeUnaLiquidacion.jasper",
+ "idLiquidacion", idLiquidacion);
+ AbstractJasperReports.showViewer();
}
-// @FXML
-// private void cargarLiquidaciones(){
-// if (liquidacionTable.getSelectionModel().getSelectedItem() != null){
-//
-// }
-// }
+
+ @FXML
+ private void handleImprimirReciboSueldo(){
+ if (!liqEmpleadosTable.getSelectionModel().isEmpty()){
+ LiquidacionEmpleado empleadoLiquidado = liqEmpleadosTable.getSelectionModel().getSelectedItem();
+ AbstractJasperReports.createReport("src\\application\\reports\\ReciboSueldo.jasper",
+ "idLiquidacion", empleadoLiquidado.getId());
+ AbstractJasperReports.showViewer();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/application/view/sueldo/cruds/ConceptoEdit.fxml b/src/application/view/sueldo/cruds/ConceptoEdit.fxml
index de7b423..27968af 100644
--- a/src/application/view/sueldo/cruds/ConceptoEdit.fxml
+++ b/src/application/view/sueldo/cruds/ConceptoEdit.fxml
@@ -1,20 +1,9 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/application/view/sueldo/cruds/ConceptoEditController.java b/src/application/view/sueldo/cruds/ConceptoEditController.java
index b85c7fe..7be8bbb 100644
--- a/src/application/view/sueldo/cruds/ConceptoEditController.java
+++ b/src/application/view/sueldo/cruds/ConceptoEditController.java
@@ -5,8 +5,8 @@
import application.model.info.CategoriaEmpleado;
import application.model.sueldo.ConceptoSueldo;
import application.repository.info.CategoriaEmpleadoRepository;
-import application.repository.sueldo.TipoLiquidacionRepository;
import application.repository.sueldo.ConceptoSueldoRepository;
+import application.repository.sueldo.TipoLiquidacionRepository;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@@ -168,9 +168,7 @@ public void initialize(URL location, ResourceBundle resources) {
}
private void cargarCategorias(){
- //todo: hacer que cuando se seleccione esta fila se guarden todas las categorias.
categorias = categoriaEmpleadoRepository.view();
- categorias.add(new CategoriaEmpleado(0, "Todos"));
categoriaEmpleadoTableView.setItems(categorias);
}
private void setComboBox(){
diff --git a/src/application/view/sueldo/cruds/LiquidacionSueldo.fxml b/src/application/view/sueldo/cruds/LiquidacionSueldo.fxml
index 4134479..e730277 100644
--- a/src/application/view/sueldo/cruds/LiquidacionSueldo.fxml
+++ b/src/application/view/sueldo/cruds/LiquidacionSueldo.fxml
@@ -3,20 +3,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -100,8 +88,8 @@
-
-
+
+
diff --git a/src/application/view/sueldo/cruds/LiquidacionSueldoController.java b/src/application/view/sueldo/cruds/LiquidacionSueldoController.java
index e7e1164..b26df96 100644
--- a/src/application/view/sueldo/cruds/LiquidacionSueldoController.java
+++ b/src/application/view/sueldo/cruds/LiquidacionSueldoController.java
@@ -1,13 +1,16 @@
package application.view.sueldo.cruds;
+import application.comunes.Alerta;
import application.model.info.CategoriaEmpleado;
import application.model.info.Empleado;
import application.model.sueldo.ConceptoCalculado;
import application.model.sueldo.ConceptoSueldo;
+import application.model.sueldo.Liquidacion;
import application.model.sueldo.LiquidacionEmpleado;
import application.repository.info.CategoriaEmpleadoRepository;
import application.repository.sueldo.ConceptoSueldoRepository;
import application.repository.info.EmpleadoRepository;
+import application.repository.sueldo.LiquidacionRepository;
import application.view.sueldo.EmpleadoALiquidar;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -16,12 +19,15 @@
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
+import org.joda.time.DateTime;
import javax.xml.soap.Text;
import java.math.BigDecimal;
import java.net.URL;
import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.*;
public class LiquidacionSueldoController implements Initializable {
@@ -55,7 +61,6 @@ public class LiquidacionSueldoController implements Initializable {
@FXML
private TableView novedadesTableView;
- // @FXML
@FXML
private TableColumn codigoColumn;
@FXML
@@ -80,8 +85,10 @@ public class LiquidacionSueldoController implements Initializable {
private Button cancelButton;
private Stage owner;
+ private boolean isNew;
private CategoriaEmpleadoRepository categoriaEmpleadoRepository = new CategoriaEmpleadoRepository();
private EmpleadoRepository empleadoRepository = new EmpleadoRepository();
+ private LiquidacionRepository liquidacionRepository = new LiquidacionRepository();
private ConceptoSueldoRepository conceptoSueldoRepository=new ConceptoSueldoRepository();
private ObservableList categorias = FXCollections.observableArrayList();
private ObservableList empleados = FXCollections.observableArrayList();
@@ -92,7 +99,6 @@ public void setOwner(Stage owner){
this.owner = owner;
}
-
@Override
public void initialize(URL location, ResourceBundle resources) {
novedadesTableView.setPlaceholder(new Label("No hay novedades para mostrar"));
@@ -169,10 +175,10 @@ private void agregarEmpleadoALiquidar(){
private void agregarTodos(){
if(!totalEmpleadoTableView.getItems().isEmpty())
- for(Empleado empleado : totalEmpleadoTableView.getItems()) {
- liquidarEmpleadoTableView.getItems().add(empleado);
- liquidarEmpleados.add(new EmpleadoALiquidar(empleado));
- }
+ for(Empleado empleado : totalEmpleadoTableView.getItems()) {
+ liquidarEmpleadoTableView.getItems().add(empleado);
+ liquidarEmpleados.add(new EmpleadoALiquidar(empleado));
+ }
cargarTablaEmpleados();
}
@@ -182,7 +188,7 @@ private void quitarEmpleadoALiquidar(){
if(liquidarEmpleadoTableView.getSelectionModel().getSelectedItem() != null) {
System.out.println("ID EMPLEADO A LIQUIDAR: " + liquidarEmpleadoTableView.getSelectionModel().getSelectedItem().getIdEmpleado());
removeEmpleadoALiquidarById(liquidarEmpleadoTableView.getSelectionModel().getSelectedItem().getIdEmpleado());
- liquidarEmpleadoTableView.getItems().remove(liquidarEmpleadoTableView.getSelectionModel().getSelectedItem());
+ liquidarEmpleadoTableView.getItems().remove(liquidarEmpleadoTableView.getSelectionModel().getSelectedItem());
}
cargarTablaEmpleados();
novedadesTableView.getItems().clear();
@@ -207,7 +213,7 @@ private void quitarTodos(){
@FXML
private void cargarNovedades(){
- if (liquidarEmpleadoTableView.getSelectionModel().getSelectedItem() != null)
+ if (liquidarEmpleadoTableView.getSelectionModel().getSelectedItem() != null)
novedadesTableView.setItems(liquidarEmpleados.get(getEmpleadoALiquidarById(
liquidarEmpleadoTableView.getSelectionModel().getSelectedItem().getIdEmpleado())).getConceptos());
@@ -220,7 +226,7 @@ private void cargarFactor(){
.getFactor()));
liquidarEmpleados.get(getEmpleadoALiquidarById(liquidarEmpleadoTableView.getSelectionModel().
getSelectedItem().getIdEmpleado())).getConceptos().get(novedadesTableView.getItems().indexOf(
- novedadesTableView.getSelectionModel().getSelectedItem())).setSelect(novedadesTableView.
+ novedadesTableView.getSelectionModel().getSelectedItem())).setSelect(novedadesTableView.
getSelectionModel().getSelectedItem().getSelect().isSelected());
}
@@ -256,6 +262,9 @@ private void removeEmpleadoALiquidarById(int idEmpleadoALiquidar){
@FXML
private void liquidarEmpleados(){
separarConceptosByTipoConcepto();
+ //crea un nuevo row de Liquidacion
+ Liquidacion liquidacion = new Liquidacion();
+
//Liquidacion de Empleados
for (EmpleadoALiquidar empleadoALiquidar : liquidarEmpleados)
{
@@ -267,8 +276,8 @@ private void liquidarEmpleados(){
System.out.println("%nCONCEPTOS A LIQUIDAR%n%n");
for (ConceptoSueldo conceptoSueldo : empleadoALiquidar.getRemunerativos())
System.out.printf("CONCEPTO REMUNERATIVO: %s%n" +
- " CANTIDAD: %f%n" +
- " FACTOR : %f%n", conceptoSueldo.getDescripcion(),conceptoSueldo.getCantidad(),
+ " CANTIDAD: %f%n" +
+ " FACTOR : %f%n", conceptoSueldo.getDescripcion(),conceptoSueldo.getCantidad(),
conceptoSueldo.getFactor());
for (ConceptoSueldo conceptoSueldo : empleadoALiquidar.getNoRemunerativos())
System.out.printf("CONCEPTO NO REMUNERATIVO: %s%n" +
@@ -337,6 +346,11 @@ private void liquidarEmpleados(){
liquidacionEmpleado.setTotalHaberesRemunerativos(totalRemunerativos);
liquidacionEmpleado.setTotalHaberesNoRemunerativos(totalNoRemunerativos);
liquidacionEmpleado.setTotalRetenciones(totalRetenciones);
+ liquidacionEmpleado.setEmpleado(empleadoALiquidar.getEmpleado());
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-d");
+ liquidacionEmpleado.setInicioPeriodo(desdeDatePicker.getValue().format(formatter));
+ liquidacionEmpleado.setFinPeriodo(hastaDatePicker.getValue().format(formatter));
+ liquidacionEmpleado.setFechaLiquidacion(LocalDateTime.now().format(formatter));
BigDecimal totalBruto = BigDecimal.valueOf(totalRemunerativos).add(BigDecimal.valueOf(totalNoRemunerativos));
@@ -347,21 +361,43 @@ private void liquidarEmpleados(){
liquidacionEmpleado.setImporteNeto(importeNeto.doubleValue());
+ liquidacionEmpleado.setConceptosLiquidados(remCalculados);
+ liquidacionEmpleado.getConceptosLiquidados().addAll(noRemCalculados);
+ liquidacionEmpleado.getConceptosLiquidados().addAll(retCalculados);
+
System.out.printf("%n%n------- Liquidación Empleado :%s %s ------- %n ", empleadoALiquidar.getEmpleado().getNombre(),
empleadoALiquidar.getEmpleado().getApellido());
System.out.println("TOTAL HABERES REMUNERATIVOS: " + liquidacionEmpleado.getTotalHaberesRemunerativos());
System.out.printf("Total haberes remunerativos : $ %f%n" +
- "Total haberes no remunerativos: $ %f%n" +
- "Total retenciones : $ %f%n" +
- "------------------------------------%n" +
- "Total Bruto : $ %f%n" +
- "Importe Neto : $ %f%n" +
- "------------------------------------%n",
- liquidacionEmpleado.getTotalHaberesRemunerativos(), liquidacionEmpleado.getTotalHaberesNoRemunerativos(),
- liquidacionEmpleado.getTotalRetenciones(), liquidacionEmpleado.getTotalBruto(), liquidacionEmpleado.getImporteNeto());
+ "Total haberes no remunerativos: $ %f%n" +
+ "Total retenciones : $ %f%n" +
+ "------------------------------------%n" +
+ "Total Bruto : $ %f%n" +
+ "Importe Neto : $ %f%n" +
+ "------------------------------------%n",
+ liquidacionEmpleado.getTotalHaberesRemunerativos(), liquidacionEmpleado.getTotalHaberesNoRemunerativos(),
+ liquidacionEmpleado.getTotalRetenciones(), liquidacionEmpleado.getTotalBruto(), liquidacionEmpleado.getImporteNeto());
+
+ //Agregar LiquidacionEmpleado a Liquidacion
+ liquidacion.getLiquidacionesEmpleados().add(liquidacionEmpleado);
+ }
+
+ //calcular total de liquidacion empleado
+ Double totalHaberesRemunerativos = 0.0;
+ Double totalHaberesNoRemunerativos = 0.0;
+ Double totalRetenciones = 0.0;
+ for (LiquidacionEmpleado liquidacionEmpleado : liquidacion.getLiquidacionesEmpleados()) {
+ totalHaberesRemunerativos += liquidacionEmpleado.getTotalHaberesRemunerativos();
+ totalHaberesNoRemunerativos += liquidacionEmpleado.getTotalHaberesNoRemunerativos();
+ totalRetenciones += liquidacionEmpleado.getTotalRetenciones();
}
+ liquidacion.setTotalHaberesRemunerativos(totalHaberesRemunerativos.doubleValue());
+ liquidacion.setTotalHaberesNoRemunerativos(totalHaberesNoRemunerativos.doubleValue());
+ liquidacion.setTotalRetenciones(totalRetenciones.doubleValue());
+ //Grabar los datos en la base de datos
+ liquidacionRepository.newLiquidacion(liquidacion);
}
private void separarConceptosByTipoConcepto(){
@@ -397,6 +433,47 @@ private void separarConceptosByTipoConcepto(){
}
}
+ private boolean validarFechas(){
+ boolean isOkDates = false;
+ if (desdeDatePicker.getValue() != null || hastaDatePicker.getValue() != null){
+ java.util.Date input = new Date();
+ LocalDate actual = input.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+ if ( desdeDatePicker.getValue().compareTo(hastaDatePicker.getValue()) <= 0 &&
+ hastaDatePicker.getValue().compareTo(actual) <= 0){
+ isOkDates =true;
+ }
+ }
+ return isOkDates;
+ }
+
+ private boolean isInputValid() {
+ String errorMessage = "";
+ if (novedadesTableView.getItems().isEmpty())
+ errorMessage += "No se selecciono ningun empleado a liquidar";
+ if (!validarFechas())
+ errorMessage += "\nFechas inválidas: \n Las fechas ingresadas no pueden superar a la fecha actual \n Fecha Desde debe ser menor a Fecha Hasta";
+ if (errorMessage.length() == 0) {
+ return true;
+ } else {
+ Alerta.alertaError("Datos inválidos", errorMessage);
+ return false;
+ }
+ }
+ @FXML
+ public void handleOk(){
+ //Valida que las fechas se ingresen correctamente
+ if (isInputValid()) {
+ liquidarEmpleados();
+ owner.close();
+ }
+
+ }
+ @FXML
+ public void handleCancel(){
+ owner.close();
+ }
+
+
-}
+}
\ No newline at end of file
diff --git a/src/application/view/venta/AdministrarViajes.fxml b/src/application/view/venta/AdministrarViajes.fxml
index bccda56..0f664c4 100644
--- a/src/application/view/venta/AdministrarViajes.fxml
+++ b/src/application/view/venta/AdministrarViajes.fxml
@@ -1,65 +1,56 @@
-
-
-
-
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
-
+
diff --git a/src/application/view/venta/AdministrarViajesController.java b/src/application/view/venta/AdministrarViajesController.java
index d96972e..e17eb17 100644
--- a/src/application/view/venta/AdministrarViajesController.java
+++ b/src/application/view/venta/AdministrarViajesController.java
@@ -10,7 +10,6 @@
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
-import javafx.scene.Group;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
diff --git a/src/application/view/venta/Facturacion.fxml b/src/application/view/venta/Facturacion.fxml
index 9bee12c..ef403b4 100644
--- a/src/application/view/venta/Facturacion.fxml
+++ b/src/application/view/venta/Facturacion.fxml
@@ -8,7 +8,7 @@
-
+
@@ -48,13 +48,14 @@
-
+
-
+
+
diff --git a/src/application/view/venta/FacturacionController.java b/src/application/view/venta/FacturacionController.java
index c2eef2c..65f4e3f 100644
--- a/src/application/view/venta/FacturacionController.java
+++ b/src/application/view/venta/FacturacionController.java
@@ -1,9 +1,9 @@
package application.view.venta;
import application.Main;
-import application.comunes.Alerta;
import application.model.venta.FacturaVenta;
import application.model.venta.Viaje;
+import application.reports.classes.AbstractJasperReports;
import application.repository.venta.FacturaVentaRepository;
import application.repository.venta.ViajeRepository;
import application.view.venta.cruds.EmitirFacturaController;
@@ -11,7 +11,6 @@
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
-import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
@@ -81,7 +80,14 @@ public void initialize() {
idFacturacion.setCellValueFactory(cellData -> cellData.getValue().idFacturaVentaProperty().asString());
fechaColumn.setCellValueFactory(cellData -> cellData.getValue().fechaEmisionProperty());
clienteColumn.setCellValueFactory(cellData -> cellData.getValue().getCliente().nombreProperty());
- //montoTotal.setCellValueFactory(cellData -> cellData.getValue().montoFacturaProperty().asString());//TODO: inicializar este dato
+ montoTotal.setCellValueFactory(cellData -> cellData.getValue().montoFacturaProperty().asString());
+
+ facturacionesTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
+ if (newSelection != null) {
+ cargarViajes();
+ }
+ });
+
fincaColumn.setCellValueFactory(cellData -> cellData.getValue().getFinca().nombreProperty());
ingenioColumn.setCellValueFactory(cellData -> cellData.getValue().getIngenio().nombreProperty());
@@ -94,7 +100,7 @@ public void initialize() {
@FXML
private void handleNew() {
- this.showEdit();
+ this.showEdit();
}
@@ -108,7 +114,7 @@ private boolean showEdit() {
// Create the dialog Stage.
Stage dialogStage = new Stage();
- dialogStage.setTitle("Nuevo cliente");
+ dialogStage.setTitle("Nuevo Factura");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(owner);
Scene scene = new Scene(page);
@@ -143,5 +149,14 @@ public void cargarViajes() {
viajeTableView.setItems(viajes);
}
}
+ @FXML
+ private void handleImprimirFactura(){
+ if (!facturacionesTable.getSelectionModel().isEmpty()){
+ FacturaVenta selectedItem = facturacionesTable.getSelectionModel().getSelectedItem();
+ AbstractJasperReports.createReport("src\\application\\reports\\FacturaA.jasper",
+ "idFactura", selectedItem.getIdFacturaVenta(), "importeTotal", selectedItem.getMontoFactura());
+ AbstractJasperReports.showViewer();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/application/view/venta/VentaCliente.fxml b/src/application/view/venta/VentaCliente.fxml
index a5643a8..89f07d4 100644
--- a/src/application/view/venta/VentaCliente.fxml
+++ b/src/application/view/venta/VentaCliente.fxml
@@ -1,56 +1,40 @@
-
-
-
-
-
-
-
-
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
+
diff --git a/src/application/view/venta/cruds/ClienteEdit.fxml b/src/application/view/venta/cruds/ClienteEdit.fxml
index 463b12e..3499f89 100644
--- a/src/application/view/venta/cruds/ClienteEdit.fxml
+++ b/src/application/view/venta/cruds/ClienteEdit.fxml
@@ -1,12 +1,9 @@
-
-
-
-
-
+
+
diff --git a/src/application/view/venta/cruds/ClienteEditController.java b/src/application/view/venta/cruds/ClienteEditController.java
index 1efdfcc..c0692f2 100644
--- a/src/application/view/venta/cruds/ClienteEditController.java
+++ b/src/application/view/venta/cruds/ClienteEditController.java
@@ -1,7 +1,6 @@
package application.view.venta.cruds;
import application.comunes.Alerta;
-import application.model.compra.Proveedor;
import application.model.info.Domicilio;
import application.model.info.Localidad;
import application.model.info.Provincia;
diff --git a/src/application/view/venta/cruds/EmitirFactura.fxml b/src/application/view/venta/cruds/EmitirFactura.fxml
index 4f7b62f..f5528a2 100644
--- a/src/application/view/venta/cruds/EmitirFactura.fxml
+++ b/src/application/view/venta/cruds/EmitirFactura.fxml
@@ -1,17 +1,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/application/view/venta/cruds/EmitirFacturaController.java b/src/application/view/venta/cruds/EmitirFacturaController.java
index 1e4d917..e9da5cd 100644
--- a/src/application/view/venta/cruds/EmitirFacturaController.java
+++ b/src/application/view/venta/cruds/EmitirFacturaController.java
@@ -93,7 +93,7 @@ public void initialize(){
apellidoConductorColumn.setCellValueFactory(cellData -> cellData.getValue().getConductor().apellidoProperty());
fincaColumn.setCellValueFactory(cellData -> cellData.getValue().getFinca().nombreProperty());
ingenioColumn.setCellValueFactory(cellData -> cellData.getValue().getIngenio().nombreProperty());
- //montoColumn.setCellValueFactory(cellData -> cellData.getValue().montoProperty().asString());
+ montoColumn.setCellValueFactory(cellData -> cellData.getValue().montoProperty().asString());
checkColumn.setCellValueFactory(new PropertyValueFactory("select"));
checkColumn.setStyle( "-fx-alignment: CENTER;");
@@ -136,10 +136,10 @@ public void setViajeTableViewByIngenio(){
if (ingenioComboBox.getSelectionModel().getSelectedItem() == "Todos"){
buscarViajes();
}else{
- viajeData = viajeRepository.getViajesSinLiqByIngenioId
- (ingenioData.get(ingenioComboBox.getSelectionModel().getSelectedIndex()).getIdIngenio());
- viajeTableView.setItems(viajeData);
- }
+ viajeData = viajeRepository.getViajesSinLiqByIngenioId
+ (ingenioData.get(ingenioComboBox.getSelectionModel().getSelectedIndex()).getIdIngenio());
+ viajeTableView.setItems(viajeData);
+ }
}
@@ -151,7 +151,7 @@ public void handleOk(){
dialogStage.close();
okClicked = true;
}
- }
+ }
@FXML
private void handleCancel(){
diff --git a/src/application/view/venta/cruds/ViajeEdit.fxml b/src/application/view/venta/cruds/ViajeEdit.fxml
index cb06f29..88bf701 100644
--- a/src/application/view/venta/cruds/ViajeEdit.fxml
+++ b/src/application/view/venta/cruds/ViajeEdit.fxml
@@ -1,28 +1,30 @@
-
-
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
@@ -32,13 +34,13 @@
-
+
-
+
-
+
@@ -52,7 +54,7 @@
-
+
@@ -69,7 +71,7 @@
-
+
@@ -79,7 +81,7 @@
-
+
@@ -87,13 +89,13 @@
-
+
-
+
diff --git a/src/application/view/venta/cruds/ViajeEditController.java b/src/application/view/venta/cruds/ViajeEditController.java
index aef8b20..800cdff 100644
--- a/src/application/view/venta/cruds/ViajeEditController.java
+++ b/src/application/view/venta/cruds/ViajeEditController.java
@@ -16,15 +16,13 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.stage.Stage;
import javafx.scene.control.*;
+import javafx.stage.Stage;
-import javax.xml.crypto.dom.DOMCryptoContext;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
-import java.util.function.BiFunction;
public class ViajeEditController {
@@ -52,7 +50,7 @@ public class ViajeEditController {
@FXML
private TextField brutoTextField;
@FXML
- private ComboBox conductorCombo;
+ private ComboBox conductorCombo;
@FXML
private ComboBox camionCombo;
@FXML
@@ -79,7 +77,7 @@ public class ViajeEditController {
private ObservableList conductorData = FXCollections.observableArrayList();
private ObservableList camionData = FXCollections.observableArrayList();
- List conductoresList = conductorRepository.getEmpleadosByCategoriaEmpleado(2);// todo Hardcodeado
+ List conductoresList = conductorRepository.getConductores();
List fincasList = fincaRepository.view();
List ingeniosList = ingenioRepository.view();
List camionList = camionRepository.view();
@@ -142,10 +140,8 @@ public void setIngenioTabla(){
public void setConductorComboBox(){
- ObservableList conList = FXCollections.observableArrayList();
- conductorData = conductorRepository.getEmpleadosByCategoriaEmpleado(2);
- for (Empleado conductor : conductoresList) conList.add(conductor.getNombre() + " " + conductor.getApellido());
- conductorCombo.setItems(conList);
+ conductorData = conductorRepository.getConductores();
+ conductorCombo.setItems(conductorData);
}
private void setCamionComboBox(){
diff --git "a/src/img/ca\303\261asprincipal.jpg" "b/src/resources/ca\303\261asprincipal.jpg"
similarity index 100%
rename from "src/img/ca\303\261asprincipal.jpg"
rename to "src/resources/ca\303\261asprincipal.jpg"
diff --git a/src/resources/logiserv-icon.png b/src/resources/logiserv-icon.png
new file mode 100644
index 0000000..1a79cd9
Binary files /dev/null and b/src/resources/logiserv-icon.png differ
diff --git a/src/resources/pie_factura_datos_CAE.jpeg b/src/resources/pie_factura_datos_CAE.jpeg
new file mode 100644
index 0000000..1db97c4
Binary files /dev/null and b/src/resources/pie_factura_datos_CAE.jpeg differ
diff --git a/src/resources/volks.png b/src/resources/volks.png
new file mode 100644
index 0000000..7632cbb
Binary files /dev/null and b/src/resources/volks.png differ