-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1118,16 +1047,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1155,38 +1074,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1198,7 +1085,6 @@
-
@@ -1213,13 +1099,6 @@
-
-
-
-
-
-
-
@@ -1390,18 +1269,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1419,41 +1286,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1468,12 +1300,264 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index 4cf2969..c53b98a 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/src/danielcortes/xyz/controllers/InformesController.java b/src/danielcortes/xyz/controllers/InformesController.java
index eaac40e..8686b84 100644
--- a/src/danielcortes/xyz/controllers/InformesController.java
+++ b/src/danielcortes/xyz/controllers/InformesController.java
@@ -24,6 +24,7 @@
package danielcortes.xyz.controllers;
+import danielcortes.xyz.informes.InformeEgresosFacturaMateriaPrima;
import danielcortes.xyz.informes.InformeLibroDeVentas;
import danielcortes.xyz.utils.StringUtils;
import danielcortes.xyz.views.MonthSelectDialog;
@@ -47,6 +48,7 @@ public class InformesController {
private void setupViewEvents() {
this.view.getInformeLibroDeVentasButton().addActionListener(e -> generarInformeLibroDeVentasListener());
+ this.view.getGenerarEgresosFacturasMateriaPrimaButton().addActionListener(e -> generarInformeEgresosFacturasMateriaPrima());
}
private void generarInformeLibroDeVentasListener() {
@@ -60,8 +62,27 @@ public class InformesController {
File saveFile = askForFile("Libro " + capitalized);
if (saveFile != null) {
- InformeLibroDeVentas informeLibroDeVentas = new InformeLibroDeVentas(month, saveFile);
- File generatedFile = informeLibroDeVentas.generarInforme();
+ InformeLibroDeVentas informe = new InformeLibroDeVentas(month, saveFile);
+ File generatedFile = informe.generarInforme();
+
+ this.showConfirmation(generatedFile);
+ }
+ }
+ }
+
+ private void generarInformeEgresosFacturasMateriaPrima() {
+ LocalDate month = askForMonth();
+ if (month != null) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM YYYY");
+
+ String formatedName = month.format(formatter);
+ String capitalized = StringUtils.toUpperCase(formatedName);
+
+ File saveFile = askForFile("Egresos Materia Prima " + capitalized);
+
+ if (saveFile != null) {
+ InformeEgresosFacturaMateriaPrima informe = new InformeEgresosFacturaMateriaPrima(month, saveFile);
+ File generatedFile = informe.generarInforme();
this.showConfirmation(generatedFile);
}
@@ -97,7 +118,7 @@ public class InformesController {
private void showConfirmation(File file) {
int result = JOptionPane.showConfirmDialog(
this.view.getContentPanel(),
- "El informe se a generado\n" +
+ "El informes se a generado\n" +
"¿Desea abrirlo?",
"Confirmacion",
JOptionPane.YES_NO_OPTION,
diff --git a/src/danielcortes/xyz/informes/InformeEgresosFacturaMateriaPrima.java b/src/danielcortes/xyz/informes/InformeEgresosFacturaMateriaPrima.java
new file mode 100644
index 0000000..33d8a3d
--- /dev/null
+++ b/src/danielcortes/xyz/informes/InformeEgresosFacturaMateriaPrima.java
@@ -0,0 +1,293 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.informes;
+
+import danielcortes.xyz.models.caja.SQLiteCajaDAO;
+import danielcortes.xyz.models.informes.egresos.InformeEgresosFacturasMateriaPrimaContent;
+import danielcortes.xyz.models.informes.egresos.SQLiteInformeEgresosFacturasMateriaPrimaContentDAO;
+import danielcortes.xyz.utils.Pair;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.PropertyTemplate;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.*;
+
+public class InformeEgresosFacturaMateriaPrima {
+ private final String[] titles = {
+ "FECHA",
+ "N°",
+ "DESCRIPCION",
+ "VALOR"
+ };
+
+ private List informe;
+ private File saveFile;
+
+ //Filas donde se almacenaran los totales
+ private ArrayList totalRows;
+ //Filas donde se almacenaran los egresos.
+ private ArrayList dataRows;
+ //Fila que contiene el total final;
+ private Row totalFinal;
+
+
+ //Rango que corresponde a un dia de egresos;
+ private ArrayList> totalRange;
+ private Workbook wb;
+ private Sheet sheet;
+ private CreationHelper createHelper;
+ private HashMap styles;
+
+ public InformeEgresosFacturaMateriaPrima(LocalDate date, File saveFile) {
+ new SQLiteCajaDAO().createCajasForMonth(date);
+ this.informe = new SQLiteInformeEgresosFacturasMateriaPrimaContentDAO().getInformeEgresosFactuasMateriaPrima(date);
+ this.saveFile = saveFile;
+
+ this.wb = new HSSFWorkbook();
+ this.sheet = wb.createSheet();
+ this.createHelper = wb.getCreationHelper();
+
+ this.totalRows = new ArrayList<>();
+ this.totalRange = new ArrayList<>();
+ this.dataRows = new ArrayList<>();
+
+ this.styles = this.generateStyles();
+ }
+
+ private void fillHeaders() {
+ Row titles = sheet.createRow(0);
+
+ for (int x = 0; x < this.titles.length; x++) {
+ titles.createCell(x).setCellValue(this.titles[x]);
+ }
+ }
+
+ private void fillData() {
+ int rowCounter = 1;
+ int dayStart = rowCounter;
+ int dayEnd;
+
+ for (int informeID = 0; informeID < informe.size(); informeID++) {
+ InformeEgresosFacturasMateriaPrimaContent data = informe.get(informeID);
+ int cellCounter = 0;
+ Row dataRow = sheet.createRow(rowCounter);
+ dataRows.add(dataRow);
+ Date fecha = Date.from(data.getFecha().atStartOfDay(ZoneId.systemDefault()).toInstant());
+
+ dataRow.createCell(cellCounter++).setCellValue(fecha);
+ dataRow.createCell(cellCounter++).setCellValue(data.getNro());
+ dataRow.createCell(cellCounter++).setCellValue(data.getDescripcion());
+ dataRow.createCell(cellCounter).setCellValue(data.getValor());
+
+ if (informeID + 1 >= informe.size() || !data.getFecha().equals(informe.get(informeID + 1).getFecha())) {
+ totalRows.add(sheet.createRow(rowCounter + 1));
+
+ dayEnd = rowCounter;
+ totalRange.add(new Pair<>(dayStart, dayEnd));
+ dayStart = rowCounter + 2;
+ rowCounter++;
+ }
+
+ rowCounter++;
+ }
+ }
+
+ private void fillTotales() {
+ StringBuilder sumTotalFinal = new StringBuilder();
+
+ //Se aprovechara la iteracion para agregar los totales individuales y para construir la suma del total final
+ for (int x = 0; x < totalRows.size(); x++) {
+ Row row = totalRows.get(x);
+ Pair range = totalRange.get(x);
+
+ row.createCell(2).setCellValue("TOTAL DIARIO");
+ row.createCell(3).setCellFormula("SUM(D" + (range.getLeft() + 1) + ":D" + (range.getRight() + 1) + ")");
+
+ sumTotalFinal.append("D").append(row.getRowNum() + 1);
+ if (x + 1 != totalRows.size()) {
+ sumTotalFinal.append("+");
+ } else {
+ this.totalFinal = sheet.createRow(row.getRowNum() + 1);
+ this.totalFinal.createCell(2).setCellValue("TOTAL MENSUAL");
+ this.totalFinal.createCell(3).setCellFormula(sumTotalFinal.toString());
+ }
+ }
+
+
+ }
+
+ private void freezeCells() {
+ this.sheet.createFreezePane(0, 1);
+ }
+
+ private void addBorders() {
+ int rows = this.totalRows.size() + this.dataRows.size() + 1;
+ PropertyTemplate pt = new PropertyTemplate();
+
+ //Bordes Internos
+ pt.drawBorders(new CellRangeAddress(0, rows, 0, 3), BorderStyle.THIN, BorderExtent.ALL);
+
+ //Bordes de los Headers
+ pt.drawBorders(new CellRangeAddress(0, 0, 0, 3), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+ //Bordes de los Totales
+ for (Row row : this.totalRows) {
+ int index = row.getRowNum();
+ pt.drawBorders(new CellRangeAddress(index, index, 0, 3), BorderStyle.NONE, BorderExtent.ALL);
+ pt.drawBorders(new CellRangeAddress(index, index, 0, 3), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ }
+
+ //Borde del Total Final
+ pt.drawBorders(new CellRangeAddress(this.totalFinal.getRowNum(), this.totalFinal.getRowNum(), 0, 3), BorderStyle.NONE, BorderExtent.ALL);
+ pt.drawBorders(new CellRangeAddress(this.totalFinal.getRowNum(), this.totalFinal.getRowNum(), 0, 3), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+ //Borde externo
+ pt.drawBorders(new CellRangeAddress(0, rows, 0, 3), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+ pt.applyBorders(this.sheet);
+ }
+
+ private void setStyles() {
+ //Estilo para el header
+ this.sheet.getRow(0).getCell(0).setCellStyle(this.styles.get("header"));
+ this.sheet.getRow(0).getCell(1).setCellStyle(this.styles.get("header"));
+ this.sheet.getRow(0).getCell(2).setCellStyle(this.styles.get("header"));
+ this.sheet.getRow(0).getCell(3).setCellStyle(this.styles.get("header"));
+
+ //Estilo para el Total Final
+ this.totalFinal.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("gray"));
+ this.totalFinal.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("gray"));
+ this.totalFinal.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("gray"));
+ this.totalFinal.getCell(3).setCellStyle(this.styles.get("total_final"));
+
+ //Estilo para las filas de datos
+ for(Row row: this.dataRows){
+ row.getCell(0).setCellStyle(this.styles.get("date"));
+ row.getCell(1).setCellStyle(this.styles.get("regular"));
+ row.getCell(2).setCellStyle(this.styles.get("regular"));
+ row.getCell(3).setCellStyle(this.styles.get("money"));
+ }
+
+ //Estilo para las filas de totales
+ for(Row row: this.totalRows){
+ row.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("not_so_gray"));
+ row.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("not_so_gray"));
+ row.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("not_so_gray"));
+ row.getCell(3, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("total"));
+ }
+
+
+ //Setea el alto de las filas
+ this.sheet.getRow(0).setHeightInPoints(30);
+ this.totalFinal.setHeightInPoints(20);
+ for(Row row: this.dataRows){
+ row.setHeightInPoints(15);
+ }
+ for(Row row: this.totalRows){
+ row.setHeightInPoints(18);
+ }
+
+
+ //Setea el ancho de las columnas
+ sheet.autoSizeColumn(0);
+ sheet.autoSizeColumn(1);
+ sheet.autoSizeColumn(2);
+ sheet.autoSizeColumn(3);
+ }
+
+ private HashMap generateStyles(){
+ Font font = this.wb.createFont();
+ font.setBold(true);
+ font.setColor(IndexedColors.WHITE.getIndex());
+
+ CellStyle regularStyle = this.wb.createCellStyle();
+
+ CellStyle grayStyle = this.wb.createCellStyle();
+ grayStyle.setFont(font);
+ grayStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+ grayStyle.setFillForegroundColor(IndexedColors.GREY_80_PERCENT.getIndex());
+ grayStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+ CellStyle notSoGrayStyle = this.wb.createCellStyle();
+ notSoGrayStyle.setFont(font);
+ notSoGrayStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+ notSoGrayStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
+ notSoGrayStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+ CellStyle dateStyle = this.wb.createCellStyle();
+ dateStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("dd/mm/yyyy"));
+
+ CellStyle moneyStyle = this.wb.createCellStyle();
+ moneyStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("\"$\"#,##0_);(\"$\"#,##0)"));
+
+ CellStyle headerStyle = this.wb.createCellStyle();
+ headerStyle.cloneStyleFrom(grayStyle);
+ headerStyle.setAlignment(HorizontalAlignment.CENTER);
+
+ CellStyle totalStyle = this.wb.createCellStyle();
+ totalStyle.cloneStyleFrom(notSoGrayStyle);
+ totalStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("\"$\"#,##0_);(\"$\"#,##0)"));
+
+ CellStyle totalFinalStyle = this.wb.createCellStyle();
+ totalFinalStyle.cloneStyleFrom(grayStyle);
+ totalFinalStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("\"$\"#,##0_);(\"$\"#,##0)"));
+
+ HashMap styles = new HashMap<>();
+ styles.put("regular", regularStyle);
+ styles.put("gray", grayStyle);
+ styles.put("not_so_gray", notSoGrayStyle);
+ styles.put("date", dateStyle);
+ styles.put("money", moneyStyle);
+ styles.put("header", headerStyle);
+ styles.put("total", totalStyle);
+ styles.put("total_final", totalFinalStyle);
+
+ return styles;
+ }
+
+ public File generarInforme() {
+ fillHeaders();
+ fillData();
+ fillTotales();
+ freezeCells();
+ setStyles();
+ addBorders();
+
+ try (OutputStream fileOut = new FileOutputStream(this.saveFile)) {
+ wb.write(fileOut);
+ return this.saveFile;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/src/danielcortes/xyz/informes/InformeLibroDeVentas.java b/src/danielcortes/xyz/informes/InformeLibroDeVentas.java
index a426ca3..2d31386 100644
--- a/src/danielcortes/xyz/informes/InformeLibroDeVentas.java
+++ b/src/danielcortes/xyz/informes/InformeLibroDeVentas.java
@@ -25,8 +25,8 @@
package danielcortes.xyz.informes;
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
-import danielcortes.xyz.models.informe.InformeLibroDeVentasContent;
-import danielcortes.xyz.models.informe.SQLiteInformeLibroDeVentasContentDAO;
+import danielcortes.xyz.models.informes.libro_de_ventas.InformeLibroDeVentasContent;
+import danielcortes.xyz.models.informes.libro_de_ventas.SQLiteInformeLibroDeVentasContentDAO;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
diff --git a/src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContent.java b/src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContent.java
new file mode 100644
index 0000000..38d19cf
--- /dev/null
+++ b/src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContent.java
@@ -0,0 +1,76 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.informes.egresos;
+
+import java.time.LocalDate;
+
+public class InformeEgresosFacturasMateriaPrimaContent {
+ private LocalDate fecha;
+ private String nro;
+ private String descripcion;
+ private int valor;
+
+ public LocalDate getFecha() {
+ return fecha;
+ }
+
+ public void setFecha(LocalDate fecha) {
+ this.fecha = fecha;
+ }
+
+ public String getNro() {
+ return nro;
+ }
+
+ public void setNro(String nro) {
+ this.nro = nro;
+ }
+
+ public String getDescripcion() {
+ return descripcion;
+ }
+
+ public void setDescripcion(String descripcion) {
+ this.descripcion = descripcion;
+ }
+
+ public int getValor() {
+ return valor;
+ }
+
+ public void setValor(int valor) {
+ this.valor = valor;
+ }
+
+ @Override
+ public String toString() {
+ return "InformeEgresosFacturasMateriaPrimaContent{" +
+ "fecha=" + fecha +
+ ", nro='" + nro + '\'' +
+ ", descripcion='" + descripcion + '\'' +
+ ", valor=" + valor +
+ '}';
+ }
+}
diff --git a/src/danielcortes/xyz/models/informe/InformeLibroDeVentasContentDAO.java b/src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContentDAO.java
similarity index 72%
rename from src/danielcortes/xyz/models/informe/InformeLibroDeVentasContentDAO.java
rename to src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContentDAO.java
index 545a06e..e1f3519 100644
--- a/src/danielcortes/xyz/models/informe/InformeLibroDeVentasContentDAO.java
+++ b/src/danielcortes/xyz/models/informes/egresos/InformeEgresosFacturasMateriaPrimaContentDAO.java
@@ -22,16 +22,16 @@
* SOFTWARE.
*/
-package danielcortes.xyz.models.informe;
+package danielcortes.xyz.models.informes.egresos;
import java.time.LocalDate;
-import java.util.Collection;
+import java.util.List;
-public abstract class InformeLibroDeVentasContentDAO {
+public abstract class InformeEgresosFacturasMateriaPrimaContentDAO {
/**
- * Genera el contenido del informe mensual
- * @param date fecha que esta dentro del mes en el que se necesita el informe
- * @return Lista con las columnas principales necesarias para el informe
+ * Genera el informe con nombre muy largo
+ * @param month mes sobre el cual se quiere le informe
+ * @return lista del objeto que contiene los datos necesarios para el informe
*/
- public abstract Collection getInformeMensual(LocalDate date);
+ public abstract List getInformeEgresosFactuasMateriaPrima(LocalDate month);
}
diff --git a/src/danielcortes/xyz/models/informes/egresos/SQLiteInformeEgresosFacturasMateriaPrimaContentDAO.java b/src/danielcortes/xyz/models/informes/egresos/SQLiteInformeEgresosFacturasMateriaPrimaContentDAO.java
new file mode 100644
index 0000000..81edae5
--- /dev/null
+++ b/src/danielcortes/xyz/models/informes/egresos/SQLiteInformeEgresosFacturasMateriaPrimaContentDAO.java
@@ -0,0 +1,76 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.informes.egresos;
+
+import danielcortes.xyz.data.SQLiteConnectionHolder;
+import danielcortes.xyz.models.egreso.Egreso;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SQLiteInformeEgresosFacturasMateriaPrimaContentDAO extends InformeEgresosFacturasMateriaPrimaContentDAO {
+ private List list;
+
+ @Override
+ public List getInformeEgresosFactuasMateriaPrima(LocalDate date) {
+ list = new ArrayList<>();
+ try {
+ Connection conn = new SQLiteConnectionHolder().getConnection();
+
+ String query = "select caja.fecha as \"fecha\",\n" +
+ "egresos.nro as \"nro\",\n" +
+ "egresos.descripcion as \"descripcion\",\n" +
+ "egresos.valor as \"valor\"\n" +
+ "from egresos inner join caja on egresos.caja_id = caja.id\n" +
+ "where caja.fecha between date(?) and date(?) and egresos.tipo_egreso_id = 1\n" +
+ "order by caja.fecha\n";
+
+ PreparedStatement ps = conn.prepareStatement(query);
+ ps.setString(1, date.withDayOfMonth(1).toString());
+ ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
+ ResultSet rs = ps.executeQuery();
+ this.fillInforme(rs);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+ private void fillInforme(ResultSet rs) throws SQLException {
+ while (rs.next()) {
+ InformeEgresosFacturasMateriaPrimaContent content = new InformeEgresosFacturasMateriaPrimaContent();
+ content.setFecha(LocalDate.parse(rs.getString("fecha")));
+ content.setDescripcion(rs.getString("descripcion"));
+ content.setNro(rs.getString("nro"));
+ content.setValor(rs.getInt("valor"));
+ list.add(content);
+ }
+ }
+}
diff --git a/src/danielcortes/xyz/models/informe/InformeLibroDeVentasContent.java b/src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContent.java
similarity index 84%
rename from src/danielcortes/xyz/models/informe/InformeLibroDeVentasContent.java
rename to src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContent.java
index df98f7e..2cc8ac9 100644
--- a/src/danielcortes/xyz/models/informe/InformeLibroDeVentasContent.java
+++ b/src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContent.java
@@ -22,7 +22,31 @@
* SOFTWARE.
*/
-package danielcortes.xyz.models.informe;
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.informes.libro_de_ventas;
import java.time.LocalDate;
diff --git a/src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContentDAO.java b/src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContentDAO.java
new file mode 100644
index 0000000..4e232d8
--- /dev/null
+++ b/src/danielcortes/xyz/models/informes/libro_de_ventas/InformeLibroDeVentasContentDAO.java
@@ -0,0 +1,61 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.informes.libro_de_ventas;
+
+import java.time.LocalDate;
+import java.util.Collection;
+
+public abstract class InformeLibroDeVentasContentDAO {
+ /**
+ * Genera el contenido del informes mensual
+ * @param date fecha que esta dentro del mes en el que se necesita el informes
+ * @return Lista con las columnas principales necesarias para el informes
+ */
+ public abstract Collection getInformeMensual(LocalDate date);
+}
diff --git a/src/danielcortes/xyz/models/informe/SQLiteInformeLibroDeVentasContentDAO.java b/src/danielcortes/xyz/models/informes/libro_de_ventas/SQLiteInformeLibroDeVentasContentDAO.java
similarity index 90%
rename from src/danielcortes/xyz/models/informe/SQLiteInformeLibroDeVentasContentDAO.java
rename to src/danielcortes/xyz/models/informes/libro_de_ventas/SQLiteInformeLibroDeVentasContentDAO.java
index 2076642..166b585 100644
--- a/src/danielcortes/xyz/models/informe/SQLiteInformeLibroDeVentasContentDAO.java
+++ b/src/danielcortes/xyz/models/informes/libro_de_ventas/SQLiteInformeLibroDeVentasContentDAO.java
@@ -22,7 +22,31 @@
* SOFTWARE.
*/
-package danielcortes.xyz.models.informe;
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.informes.libro_de_ventas;
import danielcortes.xyz.data.SQLiteConnectionHolder;
import danielcortes.xyz.utils.NaturalOrderComparator;
diff --git a/src/danielcortes/xyz/utils/Pair.java b/src/danielcortes/xyz/utils/Pair.java
new file mode 100644
index 0000000..5b9e79b
--- /dev/null
+++ b/src/danielcortes/xyz/utils/Pair.java
@@ -0,0 +1,59 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018-2019 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.utils;
+
+import java.util.Objects;
+
+public class Pair {
+ private final L left;
+ private final R right;
+
+ public Pair(L left, R right) {
+ this.left = left;
+ this.right = right;
+ }
+
+ public L getLeft() { return left; }
+ public R getRight() { return right; }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Pair, ?> pair = (Pair, ?>) o;
+ return left.equals(pair.left) &&
+ right.equals(pair.right);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(left, right);
+ }
+
+ @Override
+ public String toString() {
+ return "{left=" + left + ", right=" + right + "}";
+ }
+}
\ No newline at end of file
diff --git a/src/danielcortes/xyz/views/InformesView.form b/src/danielcortes/xyz/views/InformesView.form
index 54577d4..45e9fca 100644
--- a/src/danielcortes/xyz/views/InformesView.form
+++ b/src/danielcortes/xyz/views/InformesView.form
@@ -3,7 +3,7 @@
-
+
@@ -14,9 +14,9 @@
-
+
-
+
@@ -32,13 +32,16 @@
-
+
-
+
-
+
-
+
+
+
+
@@ -61,6 +64,11 @@
+
+
+
+
+
diff --git a/src/danielcortes/xyz/views/InformesView.java b/src/danielcortes/xyz/views/InformesView.java
index 8abed20..ab26a6a 100644
--- a/src/danielcortes/xyz/views/InformesView.java
+++ b/src/danielcortes/xyz/views/InformesView.java
@@ -32,15 +32,20 @@ import javax.swing.*;
import java.awt.*;
public class InformesView {
- private JButton informeMensualButton;
+ private JButton generarLibroVentasButton;
private JPanel contentPanel;
+ private JButton GenerarEgresosFacturasMateriaPrimaButton;
public JPanel getContentPanel() {
return contentPanel;
}
public JButton getInformeLibroDeVentasButton() {
- return informeMensualButton;
+ return generarLibroVentasButton;
+ }
+
+ public JButton getGenerarEgresosFacturasMateriaPrimaButton() {
+ return GenerarEgresosFacturasMateriaPrimaButton;
}
{
@@ -63,22 +68,26 @@ public class InformesView {
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Informes"));
- informeMensualButton = new JButton();
- informeMensualButton.setText("Libro de Ventas Mensual");
- panel1.add(informeMensualButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Informes Generales"));
+ generarLibroVentasButton = new JButton();
+ generarLibroVentasButton.setText("Libro de Ventas Mensual");
+ panel1.add(generarLibroVentasButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- final Spacer spacer1 = new Spacer();
- panel2.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
+ panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Egresos"));
+ GenerarEgresosFacturasMateriaPrimaButton = new JButton();
+ GenerarEgresosFacturasMateriaPrimaButton.setText("Facturas Materia Prima");
+ panel2.add(GenerarEgresosFacturasMateriaPrimaButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ final Spacer spacer1 = new Spacer();
+ panel3.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
- panel3.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
+ contentPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer3 = new Spacer();
- contentPanel.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ contentPanel.add(spacer3, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
}
/**