Agregado informe que muestra los egresos de facturas materia prima

This commit is contained in:
Daniel Cortes
2019-01-16 03:34:52 -03:00
parent 392da6dd9d
commit a5ddd4a826
14 changed files with 991 additions and 256 deletions

View File

@@ -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,

View File

@@ -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",
"",
"DESCRIPCION",
"VALOR"
};
private List<InformeEgresosFacturasMateriaPrimaContent> informe;
private File saveFile;
//Filas donde se almacenaran los totales
private ArrayList<Row> totalRows;
//Filas donde se almacenaran los egresos.
private ArrayList<Row> dataRows;
//Fila que contiene el total final;
private Row totalFinal;
//Rango que corresponde a un dia de egresos;
private ArrayList<Pair<Integer, Integer>> totalRange;
private Workbook wb;
private Sheet sheet;
private CreationHelper createHelper;
private HashMap<String, CellStyle> 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<Integer, Integer> 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<String, CellStyle> 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<String, CellStyle> 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;
}
}

View File

@@ -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;

View File

@@ -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 +
'}';
}
}

View File

@@ -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<InformeLibroDeVentasContent> getInformeMensual(LocalDate date);
public abstract List<InformeEgresosFacturasMateriaPrimaContent> getInformeEgresosFactuasMateriaPrima(LocalDate month);
}

View File

@@ -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<InformeEgresosFacturasMateriaPrimaContent> list;
@Override
public List<InformeEgresosFacturasMateriaPrimaContent> 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);
}
}
}

View File

@@ -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;

View File

@@ -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<InformeLibroDeVentasContent> getInformeMensual(LocalDate date);
}

View File

@@ -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;

View File

@@ -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<L,R> {
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 + "}";
}
}

View File

@@ -3,7 +3,7 @@
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="338" height="356"/>
<xy x="20" y="20" width="419" height="356"/>
</constraints>
<properties/>
<border type="none"/>
@@ -14,9 +14,9 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Informes"/>
<border type="etched" title="Informes Generales"/>
<children>
<component id="4644d" class="javax.swing.JButton" binding="informeMensualButton" default-binding="true">
<component id="4644d" class="javax.swing.JButton" binding="generarLibroVentasButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
@@ -32,13 +32,16 @@
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<border type="etched" title="Egresos"/>
<children>
<hspacer id="faf3b">
<component id="b9812" class="javax.swing.JButton" binding="GenerarEgresosFacturasMateriaPrimaButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<properties>
<text value="Facturas Materia Prima"/>
</properties>
</component>
</children>
</grid>
<grid id="a924" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -61,6 +64,11 @@
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="d7cdc">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>

View File

@@ -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));
}
/**