Advertisement
LaCaraDeLaVerga

Reportespresenter

Dec 17th, 2020
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.11 KB | None | 0 0
  1.  
  2. package presentacion;
  3.  
  4. import java.awt.event.ActionEvent;
  5. import java.util.Date;
  6. import java.util.List;
  7.  
  8. import business_logic.FacturasController;
  9. import business_logic.ReportesController;
  10. import presentacion.views.gerente.PanelReportes;
  11. import presentacion.views.gerente.ReporteAutosVendidosFormView;
  12. import presentacion.views.gerente.ReporteEgresoDiarioFormView;
  13. import presentacion.views.gerente.ReporteIngresoDiarioInputFormView;
  14. import presentacion.views.utils.IngresosReport;
  15. import presentacion.views.utils.ReporteViewImpl;
  16. import presentacion.views.utils.VentasReport;
  17.  
  18. public class ReportesPresenter {
  19.  
  20.     private PanelReportes view;
  21.     private ReporteAutosVendidosFormView reporteAutosVendidosFormView;
  22.     private ReporteIngresoDiarioInputFormView reporteIngresoDiarioInputFormView;
  23.     private ReporteEgresoDiarioFormView reporteEgresoDiarioFormView;
  24.  
  25.     private FacturasController facturasController;
  26.     private ReportesController reportesController;
  27.  
  28.     public ReportesPresenter(FacturasController facturasController, ReportesController reportesController) {
  29.         this.view = PanelReportes.getInstance();
  30.         this.reporteAutosVendidosFormView = ReporteAutosVendidosFormView.getInstance();
  31.         this.reporteIngresoDiarioInputFormView = ReporteIngresoDiarioInputFormView.getInstance();
  32.         this.reporteEgresoDiarioFormView = ReporteEgresoDiarioFormView.getInstance();
  33.         this.facturasController = facturasController;
  34.         this.reportesController = reportesController;
  35.        
  36.         this.view.setActionDisplayReporteAutosVendidos((a) -> onDisplayReporteAutosVendidos(a));
  37.         this.reporteAutosVendidosFormView.setActionGenerarReporte((a) -> generarReporteAutosVendidos());
  38.  
  39.         this.view.setActionDisplayIngresosDiarios((a) -> onDisplayIngresosDiarios(a));
  40.         this.reporteIngresoDiarioInputFormView.setActionGenerarReporte((a) -> generarReporteIngresos());
  41.  
  42.         this.view.setActionDisplayEgresosDiarios((a) -> onDisplayEgresosDiarios(a));
  43.         this.reporteEgresoDiarioFormView.setActionGenerarReporte((a) -> generarReporteEgresos());
  44.     }
  45.  
  46.     private void onDisplayIngresosDiarios(ActionEvent e) {
  47.         ReporteIngresoDiarioInputFormView.getInstance().clearData();
  48.         ReporteIngresoDiarioInputFormView.getInstance().display();
  49.     }
  50.  
  51.     private void onDisplayEgresosDiarios(ActionEvent e) {
  52.         ReporteEgresoDiarioFormView.getInstance().clearData();
  53.         ReporteEgresoDiarioFormView.getInstance().display();
  54.     }
  55.  
  56.     private void onDisplayReporteAutosVendidos(ActionEvent e) {
  57.         ReporteAutosVendidosFormView.getInstance().clearData();
  58.         ReporteAutosVendidosFormView.getInstance().display();
  59.     }
  60.  
  61.     private void generarReporteAutosVendidos() {
  62.         Date fechaDesde = reporteAutosVendidosFormView.getFechaDesde();
  63.         Date fechaHasta = reporteAutosVendidosFormView.getFechaHasta();
  64.  
  65.         if (fechaDesde == null || fechaHasta == null)
  66.             return;
  67.  
  68.         List<VentasReport> autosVendidos = reportesController.readAutosVendidos(fechaDesde, fechaHasta);
  69.         ReporteViewImpl reporte = new ReporteViewImpl();
  70.         reporte.setDataVentas(autosVendidos);
  71.         reporte.open();
  72.     }
  73.  
  74.     private void generarReporteIngresos() {
  75.         Date fechaDesde = reporteIngresoDiarioInputFormView.getFechaDesde();
  76.         Date fechaHasta = reporteIngresoDiarioInputFormView.getFechaHasta();
  77.        
  78.         if (fechaDesde == null || fechaHasta == null)
  79.             return;
  80.  
  81.         ReporteViewImpl reporte = new ReporteViewImpl();
  82.         List<IngresosReport> ingresos = reportesController.readIngresos(fechaDesde, fechaHasta);
  83.         System.out.println(ingresos.toString());
  84.         reporte.setDataIngresos(ingresos);
  85.         reporte.open();
  86.     }
  87.     //TODO en este metodo en lugar de recolectarse en la lista de ingresosReport facturas y ventas de vehiculos se
  88.     //se buscaran compraVehiculo y compraRepuesto
  89.     private void generarReporteEgresos() {
  90.         Date fechaDesde = reporteEgresoDiarioFormView.getFechaDesde();
  91.         Date fechaHasta = reporteEgresoDiarioFormView.getFechaHasta();
  92.        
  93.         if (fechaDesde == null || fechaHasta == null)
  94.             return;
  95.  
  96.         ReporteViewImpl reporte = new ReporteViewImpl();
  97.         List<IngresosReport> ingresos = reportesController.readEgresos(fechaDesde, fechaHasta);
  98.         System.out.println(ingresos.toString());
  99.         reporte.setDataEgresos(ingresos);
  100.         reporte.open();
  101.     }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement