diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2fe32d3..081e05b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -12,9 +12,13 @@
+
-
+
+
+
+
@@ -25,6 +29,12 @@
+
+
+
+
+
+
@@ -64,12 +74,36 @@
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -87,8 +121,6 @@
- tipo_id
- getEliminarB
onSelec
timezone
efect
@@ -117,6 +149,8 @@
formula
setS
or
+ s
+ getSub
2018 Daniel Cortes
@@ -137,13 +171,11 @@
@@ -232,7 +266,6 @@
-
@@ -252,6 +285,13 @@
+
+
+
+
+
+
+
@@ -265,27 +305,18 @@
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -299,7 +330,7 @@
-
+
@@ -316,16 +347,19 @@
-
-
-
-
+
+
+
+
+
+
+
@@ -508,7 +542,8 @@
-
+
+
1545280618093
@@ -790,11 +825,18 @@
1546983008762
-
+
+ 1547057968640
+
+
+
+ 1547057968640
+
+
-
+
@@ -807,8 +849,9 @@
+
-
+
@@ -817,17 +860,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -836,10 +879,11 @@
-
-
-
-
+
+
+
+
+
@@ -898,7 +942,6 @@
-
@@ -923,48 +966,14 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -973,7 +982,6 @@
-
@@ -1044,40 +1052,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1239,13 +1213,6 @@
-
-
-
-
-
-
-
@@ -1253,20 +1220,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1418,63 +1371,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1482,20 +1384,220 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/database/sqlite.sql b/database/sqlite.sql
index 83ed8f9..93f35dc 100644
--- a/database/sqlite.sql
+++ b/database/sqlite.sql
@@ -124,3 +124,7 @@ values ('Boletas Fiscales'),
alter table ingresos add column nro_z_inicial text;
alter table ingresos add column nro_z_final text;
+/**
+ Segunda migracion, se necesita un tipo de ingresos de boleta exenta
+ */
+ insert into tipos_ingreso (nombre) values ('Boleta Exenta')
diff --git a/dist/caja.jar b/dist/caja.jar
index 1204264..4ac0eea 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/dist/database.sqlite b/dist/database.sqlite
index 68c8c90..9a25e25 100644
Binary files a/dist/database.sqlite and b/dist/database.sqlite differ
diff --git a/src/danielcortes/xyz/Demo.java b/src/danielcortes/xyz/Demo.java
deleted file mode 100644
index dde90ca..0000000
--- a/src/danielcortes/xyz/Demo.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package danielcortes.xyz;
-
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.FileOutputStream;
-
-/**
- * A weekly timesheet created using Apache POI.
- * Usage:
- * TimesheetDemo -xls|xlsx
- *
- * @author Yegor Kozlov
- */
-public class Demo {
- private static final String[] titles = {
- "Person", "ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
- "Total\nHrs", "Overtime\nHrs", "Regular\nHrs"
- };
-
- private static Object[][] sample_data = {
- {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0},
- {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0},
- };
-
- public static void main(String[] args) throws Exception {
- Workbook wb = new HSSFWorkbook();
-
- Map styles = createStyles(wb);
-
- Sheet sheet = wb.createSheet("Timesheet");
- PrintSetup printSetup = sheet.getPrintSetup();
- printSetup.setLandscape(true);
- sheet.setFitToPage(true);
- sheet.setHorizontallyCenter(true);
-
- //title row
- Row titleRow = sheet.createRow(0);
- titleRow.setHeightInPoints(45);
- Cell titleCell = titleRow.createCell(0);
- titleCell.setCellValue("Weekly Timesheet");
- titleCell.setCellStyle(styles.get("title"));
- sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1"));
-
- //header row
- Row headerRow = sheet.createRow(1);
- headerRow.setHeightInPoints(40);
- Cell headerCell;
- for (int i = 0; i < titles.length; i++) {
- headerCell = headerRow.createCell(i);
- headerCell.setCellValue(titles[i]);
- headerCell.setCellStyle(styles.get("header"));
- }
-
- int rownum = 2;
- for (int i = 0; i < 10; i++) {
- Row row = sheet.createRow(rownum++);
- for (int j = 0; j < titles.length; j++) {
- Cell cell = row.createCell(j);
- if(j == 9){
- //the 10th cell contains sum over week days, e.g. SUM(C3:I3)
- String ref = "C" +rownum+ ":I" + rownum;
- cell.setCellFormula("SUM("+ref+")");
- cell.setCellStyle(styles.get("formula"));
- } else if (j == 11){
- cell.setCellFormula("J" +rownum+ "-K" + rownum);
- cell.setCellStyle(styles.get("formula"));
- } else {
- cell.setCellStyle(styles.get("cell"));
- }
- }
- }
-
- //row with totals below
- Row sumRow = sheet.createRow(rownum++);
- sumRow.setHeightInPoints(35);
- Cell cell;
- cell = sumRow.createCell(0);
- cell.setCellStyle(styles.get("formula"));
- cell = sumRow.createCell(1);
- cell.setCellValue("Total Hrs:");
- cell.setCellStyle(styles.get("formula"));
-
- for (int j = 2; j < 12; j++) {
- cell = sumRow.createCell(j);
- String ref = (char)('A' + j) + "3:" + (char)('A' + j) + "12";
- cell.setCellFormula("SUM(" + ref + ")");
- if(j >= 9) cell.setCellStyle(styles.get("formula_2"));
- else cell.setCellStyle(styles.get("formula"));
- }
- rownum++;
- sumRow = sheet.createRow(rownum++);
- sumRow.setHeightInPoints(25);
- cell = sumRow.createCell(0);
- cell.setCellValue("Total Regular Hours");
- cell.setCellStyle(styles.get("formula"));
- cell = sumRow.createCell(1);
- cell.setCellFormula("L13");
- cell.setCellStyle(styles.get("formula_2"));
- sumRow = sheet.createRow(rownum++);
- sumRow.setHeightInPoints(25);
- cell = sumRow.createCell(0);
- cell.setCellValue("Total Overtime Hours");
- cell.setCellStyle(styles.get("formula"));
- cell = sumRow.createCell(1);
- cell.setCellFormula("K13");
- cell.setCellStyle(styles.get("formula_2"));
-
- //set sample data
- for (int i = 0; i < sample_data.length; i++) {
- Row row = sheet.getRow(2 + i);
- for (int j = 0; j < sample_data[i].length; j++) {
- if(sample_data[i][j] == null) continue;
-
- if(sample_data[i][j] instanceof String) {
- row.getCell(j).setCellValue((String)sample_data[i][j]);
- } else {
- row.getCell(j).setCellValue((Double)sample_data[i][j]);
- }
- }
- }
-
- //finally set column widths, the width is measured in units of 1/256th of a character width
- sheet.setColumnWidth(0, 30*256); //30 characters wide
- for (int i = 2; i < 9; i++) {
- sheet.setColumnWidth(i, 6*256); //6 characters wide
- }
- sheet.setColumnWidth(10, 10*256); //10 characters wide
-
- // Write the output to a file
- String file = "timesheet.xls";
- FileOutputStream out = new FileOutputStream(file);
- wb.write(out);
- out.close();
- }
-
- /**
- * Create a library of cell styles
- */
- private static Map createStyles(Workbook wb){
- Map styles = new HashMap<>();
- CellStyle style;
- Font titleFont = wb.createFont();
- titleFont.setFontHeightInPoints((short)18);
- titleFont.setBold(true);
- style = wb.createCellStyle();
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- style.setFont(titleFont);
- styles.put("title", style);
-
- Font monthFont = wb.createFont();
- monthFont.setFontHeightInPoints((short)11);
- monthFont.setColor(IndexedColors.WHITE.getIndex());
- style = wb.createCellStyle();
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- style.setFont(monthFont);
- style.setWrapText(true);
- styles.put("header", style);
-
- style = wb.createCellStyle();
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setWrapText(true);
- style.setBorderRight(BorderStyle.THIN);
- style.setRightBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderLeft(BorderStyle.THIN);
- style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderTop(BorderStyle.THIN);
- style.setTopBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderBottom(BorderStyle.THIN);
- style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
- styles.put("cell", style);
-
- style = wb.createCellStyle();
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
- styles.put("formula", style);
-
- style = wb.createCellStyle();
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
- styles.put("formula_2", style);
-
- return styles;
- }
-}
diff --git a/src/danielcortes/xyz/Main.java b/src/danielcortes/xyz/Main.java
index 2011031..12d37f5 100644
--- a/src/danielcortes/xyz/Main.java
+++ b/src/danielcortes/xyz/Main.java
@@ -26,7 +26,6 @@ package danielcortes.xyz;
import danielcortes.xyz.controllers.ManagerController;
import danielcortes.xyz.data.Properties;
-import danielcortes.xyz.informes.InformeMensual;
import danielcortes.xyz.models.caja.CajaDAO;
import danielcortes.xyz.models.caja.MysqlCajaDAO;
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
@@ -39,8 +38,6 @@ import danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO;
import danielcortes.xyz.models.egreso.EgresoDAO;
import danielcortes.xyz.models.egreso.MysqlEgresoDAO;
import danielcortes.xyz.models.egreso.SQLiteEgresoDAO;
-import danielcortes.xyz.models.informe.InformeMensualContent;
-import danielcortes.xyz.models.informe.SQLiteInformeMensualContentDAO;
import danielcortes.xyz.models.ingreso.IngresoDAO;
import danielcortes.xyz.models.ingreso.MysqlIngresoDAO;
import danielcortes.xyz.models.ingreso.SQLiteIngresoDAO;
@@ -52,8 +49,6 @@ import danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO;
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
import danielcortes.xyz.views.ManagerView;
import javax.swing.*;
-import java.time.LocalDate;
-import java.util.List;
import java.util.Locale;
public class Main {
@@ -112,5 +107,4 @@ public class Main {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
-
}
diff --git a/src/danielcortes/xyz/informes/InformeMensual.java b/src/danielcortes/xyz/informes/InformeMensual.java
index 8cd4325..83a5755 100644
--- a/src/danielcortes/xyz/informes/InformeMensual.java
+++ b/src/danielcortes/xyz/informes/InformeMensual.java
@@ -24,14 +24,13 @@
package danielcortes.xyz.informes;
-import danielcortes.xyz.models.caja.Caja;
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
-import danielcortes.xyz.models.documentos.Documentos;
-import danielcortes.xyz.models.efectivo.Efectivo;
import danielcortes.xyz.models.informe.InformeMensualContent;
import danielcortes.xyz.models.informe.SQLiteInformeMensualContentDAO;
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;
@@ -41,10 +40,32 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
public class InformeMensual {
- private final String[] titles = {"DIA", "FECHA", "FISCALES", "MANUALES", "FACTURAS", "GUIAS", "TOTAL", "ACUMULADO"};
+ private final String[] titles = {
+ "", "",
+ "BOLETA MANUAL", "", "",
+ "BOLETA FISCAL", "", "", "", "",
+ "BOLETAS EXENTAS", "", "",
+ "SUB",
+ "FACTURA", "", "",
+ "GUIAS", "", "",
+ "ESTADISTICAS"
+ };
+
+ private final String[] subtitles = {
+ "DIA", "FECHA",
+ "INICIAL", "FINAL", "VALOR",
+ "Z DEL", "Z AL", "INCIAL", "FINAL", "VALOR",
+ "INICIAL", "FINAL", "VALOR",
+ "TOTAL",
+ "INICIAL", "FINAL", "VALOR",
+ "INICIAL", "FINAL", "VALOR",
+ "TOTAL", "ACUMULADO", ""
+ };
+
private final String[] dias = {"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"};
private List informe;
@@ -55,13 +76,7 @@ public class InformeMensual {
private CreationHelper createHelper;
private HashMap styles;
-
- private int headerStartRow;
- private int dataStartRow;
- private int columnStart;
- private int totalColumns;
-
- public InformeMensual(LocalDate date, File saveFile){
+ public InformeMensual(LocalDate date, File saveFile) {
new SQLiteCajaDAO().createCajasForMonth(date);
this.informe = new SQLiteInformeMensualContentDAO().getInformeMensual(date);
@@ -70,73 +85,222 @@ public class InformeMensual {
this.wb = new HSSFWorkbook();
this.sheet = wb.createSheet();
this.createHelper = wb.getCreationHelper();
- this.styles = this.generateStyles();
- this.headerStartRow = 1;
- this.columnStart = 1;
- this.dataStartRow = 2;
- this.totalColumns = 7;
+ this.styles = this.generateStyles();
}
- private void fillHeaders(){
- Row headers = sheet.createRow(this.headerStartRow);
- for (int x = this.columnStart; x < titles.length + this.columnStart; x++) {
- headers.createCell(x).setCellValue(titles[x - this.columnStart]);
+ private void fillHeaders() {
+ Row titles = sheet.createRow(0);
+ Row subtitles = sheet.createRow(1);
+
+ for (int x = 0; x < this.titles.length; x++) {
+ titles.createCell(x).setCellValue(this.titles[x]);
+ }
+
+ for (int x = 0; x < this.subtitles.length; x++) {
+ subtitles.createCell(x).setCellValue(this.subtitles[x]);
}
}
- private void fillData(){
- for (int x = this.dataStartRow; x < this.dataStartRow + informe.size(); x++) {
+ private void fillData() {
+ for (int x = 2; x < 2 + informe.size(); x++) {
+ int y = 0;
Row dataRow = sheet.createRow(x);
- InformeMensualContent data = informe.get(x-this.dataStartRow);
+ InformeMensualContent data = informe.get(x - 2);
Date fecha = Date.from(data.getFecha().atStartOfDay(ZoneId.systemDefault()).toInstant());
- dataRow.createCell(this.columnStart).setCellValue(this.dias[data.getDia()]);
- dataRow.createCell(this.columnStart + 1).setCellValue(fecha);
- dataRow.createCell(this.columnStart + 2).setCellValue(data.getFiscales());
- dataRow.createCell(this.columnStart + 3).setCellValue(data.getManuales());
- dataRow.createCell(this.columnStart + 4).setCellValue(data.getFacturas());
- dataRow.createCell(this.columnStart + 5).setCellValue(data.getGuias());
- dataRow.createCell(this.columnStart + 6).setCellValue(data.getTotal());
+ dataRow.createCell(y++).setCellValue(this.dias[data.getDia()]);
+ dataRow.createCell(y++).setCellValue(fecha);
- if(x==this.dataStartRow){
- dataRow.createCell(this.columnStart + 7).setCellFormula(("H"+(x+1)));
- }else{
- dataRow.createCell(this.columnStart + 7).setCellFormula(("I"+(x))+("+")+("H"+(x+1)));
+ dataRow.createCell(y++).setCellValue(data.getManualesInicial());
+ dataRow.createCell(y++).setCellValue(data.getManualesFinal());
+ dataRow.createCell(y++).setCellValue(data.getManuales());
+
+ dataRow.createCell(y++).setCellValue(data.getFiscalesZInicial());
+ dataRow.createCell(y++).setCellValue(data.getFiscalesZFinal());
+ dataRow.createCell(y++).setCellValue(data.getFiscalesInicial());
+ dataRow.createCell(y++).setCellValue(data.getFiscalesFinal());
+ dataRow.createCell(y++).setCellValue(data.getFiscales());
+
+ dataRow.createCell(y++).setCellValue(data.getExentasInicial());
+ dataRow.createCell(y++).setCellValue(data.getExentasFinal());
+ dataRow.createCell(y++).setCellValue(data.getExentas());
+
+ dataRow.createCell(y++).setCellValue(data.getSubTotal());
+
+ dataRow.createCell(y++).setCellValue(data.getFacturasInicial());
+ dataRow.createCell(y++).setCellValue(data.getFacturasFinal());
+ dataRow.createCell(y++).setCellValue(data.getFacturas());
+
+ dataRow.createCell(y++).setCellValue(data.getGuiasInicial());
+ dataRow.createCell(y++).setCellValue(data.getGuiasFinal());
+ dataRow.createCell(y++).setCellValue(data.getGuias());
+
+ dataRow.createCell(y++).setCellValue(data.getTotal());
+
+ if (x == 2) {
+ dataRow.createCell(y).setCellFormula(("U" + (x + 1)));
+ } else {
+ dataRow.createCell(y).setCellFormula(("U" + (x + 1)) + ("+") + ("V" + (x)));
}
}
}
- private void setStyles(){
- this.sheet.getRow(this.headerStartRow).setHeightInPoints(30);
- for(int x = this.columnStart; x <= this.totalColumns + this.columnStart; x++){
- this.sheet.getRow(this.headerStartRow).getCell(x).setCellStyle(this.styles.get("header"));
- sheet.autoSizeColumn(x);
+ private void fillTotales() {
+ int row = 2 + informe.size();
+ Row totalesRow = sheet.createRow(row);
+
+ totalesRow.createCell(0).setCellValue("TOTALES");
+
+ totalesRow.createCell(4).setCellFormula("SUM(E" + 3 + ":E" + row + ")");
+ totalesRow.createCell(9).setCellFormula("SUM(J" + 3 + ":J" + row + ")");
+ totalesRow.createCell(12).setCellFormula("SUM(M" + 3 + ":M" + row + ")");
+ totalesRow.createCell(16).setCellFormula("SUM(Q" + 3 + ":Q" + row + ")");
+ totalesRow.createCell(19).setCellFormula("SUM(T" + 3 + ":T" + row + ")");
+ }
+
+ private void joinCells() {
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 4));
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 5, 9));
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 10, 12));
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 14, 16));
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 17, 19));
+ this.sheet.addMergedRegion(new CellRangeAddress(0, 0, 20, 22));
+
+ }
+
+ private void freezeCells() {
+ this.sheet.createFreezePane(2,2);
+ }
+
+ private void addBorders() {
+ int row = 2 + informe.size();
+ PropertyTemplate pt = new PropertyTemplate();
+
+ //Bordes internos
+ pt.drawBorders(new CellRangeAddress(2, row - 1, 0, 22), BorderStyle.THIN, BorderExtent.ALL);
+
+ //Bordes de los headers
+ pt.drawBorders(new CellRangeAddress(0, 1, 0, 1), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 2, 4), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 5, 9), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 10, 12), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 13, 13), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 14, 16), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 17, 19), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(0, 1, 20, 22), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+ //Bordes que agrupan
+ pt.drawBorders(new CellRangeAddress(2, row, 0, 1), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 2, 4), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 5, 9), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 10, 12), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 13, 13), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 14, 16), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 17, 19), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+ pt.drawBorders(new CellRangeAddress(2, row, 20, 22), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+
+ //Bordes del total
+ pt.drawBorders(new CellRangeAddress(row, row, 0, 22), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
+
+ pt.applyBorders(this.sheet);
+ }
+
+ private void setStyles() {
+ //Estilos para los 2 filas de titulos
+ Iterator cellIterator = this.sheet.getRow(0).cellIterator();
+ while (cellIterator.hasNext()) {
+ Cell cell = cellIterator.next();
+ cell.setCellStyle(this.styles.get("header"));
}
+ cellIterator = this.sheet.getRow(1).cellIterator();
+ while (cellIterator.hasNext()) {
+ Cell cell = cellIterator.next();
+ cell.setCellStyle(this.styles.get("header"));
+ }
- for(int x = this.dataStartRow; x < informe.size() + this.dataStartRow; x++){
+ //Estilos para las celdas de los datos
+ for (int x = 2; x < informe.size() + 2; x++) {
Row row = this.sheet.getRow(x);
- row.getCell(this.columnStart).setCellStyle(this.styles.get("borders"));
- row.getCell(this.columnStart + 1).setCellStyle(this.styles.get("date"));
- row.getCell(this.columnStart + 2).setCellStyle(this.styles.get("money"));
- row.getCell(this.columnStart + 3).setCellStyle(this.styles.get("money"));
- row.getCell(this.columnStart + 4).setCellStyle(this.styles.get("money"));
- row.getCell(this.columnStart + 5).setCellStyle(this.styles.get("money"));
- row.getCell(this.columnStart + 6).setCellStyle(this.styles.get("money"));
- row.getCell(this.columnStart + 7).setCellStyle(this.styles.get("money"));
+ int y = 0;
+
+ //Primeras Celdas
+ row.getCell(y++).setCellStyle(this.styles.get("dia"));
+ row.getCell(y++).setCellStyle(this.styles.get("date"));
+
+ //Boletas Manuales
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Boletas Fiscales
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Boletas Exentas
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Sub Total
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Facturas
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Guias
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("regular"));
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+
+ //Estadisticas
+ row.getCell(y++).setCellStyle(this.styles.get("money"));
+ row.getCell(y).setCellStyle(this.styles.get("money"));
}
- for(int x = this.columnStart; x <= this.totalColumns + this.columnStart; x++){
+
+ //Estilos para los totales del footer
+ Row footerRow = this.sheet.getRow(33);
+ for (int x = 0; x < 23; x++) {
+ footerRow.getCell(x, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellStyle(this.styles.get("footer"));
+ }
+ footerRow.getCell(4).setCellStyle(this.styles.get("footer_money"));
+ footerRow.getCell(9).setCellStyle(this.styles.get("footer_money"));
+ footerRow.getCell(12).setCellStyle(this.styles.get("footer_money"));
+ footerRow.getCell(16).setCellStyle(this.styles.get("footer_money"));
+ footerRow.getCell(19).setCellStyle(this.styles.get("footer_money"));
+
+ //Setea la altura para todas las filas
+ this.sheet.getRow(0).setHeightInPoints(20);
+ this.sheet.getRow(1).setHeightInPoints(30);
+ this.sheet.getRow(33).setHeightInPoints(20);
+
+ for (int x = 2; x < 32; x++) {
+ this.sheet.getRow(x).setHeightInPoints(15);
+ }
+
+ //Coloca el ancho como automatico en todas las columnas
+ for (int x = 0; x <= 23; x++) {
sheet.autoSizeColumn(x);
}
}
- public File generarInforme(){
+ public File generarInforme() {
fillData();
fillHeaders();
+ fillTotales();
+ joinCells();
+ freezeCells();
setStyles();
+ addBorders();
try (OutputStream fileOut = new FileOutputStream(this.saveFile)) {
wb.write(fileOut);
@@ -147,40 +311,50 @@ public class InformeMensual {
return null;
}
+ private HashMap generateStyles() {
+ Font font = this.wb.createFont();
+ font.setBold(true);
+ font.setColor(IndexedColors.WHITE.getIndex());
- private HashMap generateStyles(){
- CellStyle bordersStyle = this.wb.createCellStyle();
- bordersStyle.setBorderBottom(BorderStyle.THIN);
- bordersStyle.setBorderTop(BorderStyle.THIN);
- bordersStyle.setBorderLeft(BorderStyle.THIN);
- bordersStyle.setBorderRight(BorderStyle.THIN);
+ CellStyle regularStyle = this.wb.createCellStyle();
+
+ CellStyle grayStyle = this.wb.createCellStyle();
+ grayStyle.setFont(font);
+ grayStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
+ grayStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+ CellStyle diaStyle = this.wb.createCellStyle();
+ diaStyle.cloneStyleFrom(grayStyle);
CellStyle dateStyle = this.wb.createCellStyle();
- dateStyle.cloneStyleFrom(bordersStyle);
+ dateStyle.cloneStyleFrom(grayStyle);
dateStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("dd/mm/yyyy"));
CellStyle moneyStyle = this.wb.createCellStyle();
- moneyStyle.cloneStyleFrom(bordersStyle);
moneyStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("\"$\"#,##0_);(\"$\"#,##0)"));
- Font headerFont = this.wb.createFont();
- headerFont.setColor(IndexedColors.WHITE.getIndex());
-
CellStyle headerStyle = this.wb.createCellStyle();
- headerStyle.cloneStyleFrom(bordersStyle);
- headerStyle.setFont(headerFont);
+ headerStyle.cloneStyleFrom(grayStyle);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
- headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
- headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ headerStyle.setAlignment(HorizontalAlignment.CENTER);
+
+ CellStyle footerStyle = this.wb.createCellStyle();
+ footerStyle.cloneStyleFrom(grayStyle);
+ footerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+
+ CellStyle footerMoneyStyle = this.wb.createCellStyle();
+ footerMoneyStyle.cloneStyleFrom(footerStyle);
+ footerMoneyStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("\"$\"#,##0_);(\"$\"#,##0)"));
HashMap styles = new HashMap<>();
+ styles.put("regular", regularStyle);
styles.put("date", dateStyle);
+ styles.put("dia", diaStyle);
styles.put("money", moneyStyle);
styles.put("header", headerStyle);
- styles.put("borders", bordersStyle);
+ styles.put("footer", footerStyle);
+ styles.put("footer_money", footerMoneyStyle);
return styles;
}
-
-
}
diff --git a/src/danielcortes/xyz/models/informe/InformeMensualContent.java b/src/danielcortes/xyz/models/informe/InformeMensualContent.java
index 1249c71..2027cf9 100644
--- a/src/danielcortes/xyz/models/informe/InformeMensualContent.java
+++ b/src/danielcortes/xyz/models/informe/InformeMensualContent.java
@@ -29,14 +29,28 @@ import java.time.LocalDate;
public class InformeMensualContent {
private int dia;
private LocalDate fecha;
- private int fiscales;
+ private String manualesInicial;
+ private String manualesFinal;
private int manuales;
+ private String fiscalesZInicial;
+ private String fiscalesZFinal;
+ private String fiscalesInicial;
+ private String fiscalesFinal;
+ private int fiscales;
+ private String exentasInicial;
+ private String exentasFinal;
+ private int exentas;
+ private int subTotal;
+ private String facturasInicial;
+ private String facturasFinal;
private int facturas;
+ private String guiasInicial;
+ private String guiasFinal;
private int guias;
private int total;
public int getDia() {
- return this.dia;
+ return dia;
}
public void setDia(int dia) {
@@ -51,12 +65,20 @@ public class InformeMensualContent {
this.fecha = fecha;
}
- public int getFiscales() {
- return fiscales;
+ public String getManualesInicial() {
+ return manualesInicial;
}
- public void setFiscales(int fiscales) {
- this.fiscales = fiscales;
+ public void setManualesInicial(String manualesInicial) {
+ this.manualesInicial = manualesInicial;
+ }
+
+ public String getManualesFinal() {
+ return manualesFinal;
+ }
+
+ public void setManualesFinal(String manualesFinal) {
+ this.manualesFinal = manualesFinal;
}
public int getManuales() {
@@ -67,6 +89,94 @@ public class InformeMensualContent {
this.manuales = manuales;
}
+ public String getFiscalesZInicial() {
+ return fiscalesZInicial;
+ }
+
+ public void setFiscalesZInicial(String fiscalesZInicial) {
+ this.fiscalesZInicial = fiscalesZInicial;
+ }
+
+ public String getFiscalesZFinal() {
+ return fiscalesZFinal;
+ }
+
+ public void setFiscalesZFinal(String fiscalesZFinal) {
+ this.fiscalesZFinal = fiscalesZFinal;
+ }
+
+ public String getFiscalesInicial() {
+ return fiscalesInicial;
+ }
+
+ public void setFiscalesInicial(String fiscalesInicial) {
+ this.fiscalesInicial = fiscalesInicial;
+ }
+
+ public String getFiscalesFinal() {
+ return fiscalesFinal;
+ }
+
+ public void setFiscalesFinal(String fiscalesFinal) {
+ this.fiscalesFinal = fiscalesFinal;
+ }
+
+ public int getFiscales() {
+ return fiscales;
+ }
+
+ public void setFiscales(int fiscales) {
+ this.fiscales = fiscales;
+ }
+
+ public String getExentasInicial() {
+ return exentasInicial;
+ }
+
+ public void setExentasInicial(String exentasInicial) {
+ this.exentasInicial = exentasInicial;
+ }
+
+ public String getExentasFinal() {
+ return exentasFinal;
+ }
+
+ public void setExentasFinal(String exentasFinal) {
+ this.exentasFinal = exentasFinal;
+ }
+
+ public int getExentas() {
+ return exentas;
+ }
+
+ public void setExentas(int exentas) {
+ this.exentas = exentas;
+ }
+
+ public int getSubTotal() {
+ return subTotal;
+ }
+
+ public void setSubTotal(int sub_total) {
+ this.subTotal = sub_total;
+ }
+
+ public String getFacturasInicial() {
+ return facturasInicial;
+ }
+
+ public void setFacturasInicial(String facturasInicial) {
+ this.facturasInicial = facturasInicial;
+ }
+
+ public String getFacturasFinal() {
+ return facturasFinal;
+ }
+
+ public void setFacturasFinal(String facturasFinal) {
+ this.facturasFinal = facturasFinal;
+ }
+
public int getFacturas() {
return facturas;
}
@@ -75,6 +185,22 @@ public class InformeMensualContent {
this.facturas = facturas;
}
+ public String getGuiasInicial() {
+ return guiasInicial;
+ }
+
+ public void setGuiasInicial(String guiasInicial) {
+ this.guiasInicial = guiasInicial;
+ }
+
+ public String getGuiasFinal() {
+ return guiasFinal;
+ }
+
+ public void setGuiasFinal(String guiasFinal) {
+ this.guiasFinal = guiasFinal;
+ }
+
public int getGuias() {
return guias;
}
@@ -96,9 +222,17 @@ public class InformeMensualContent {
return "InformeMensualContent{" +
"dia=" + dia +
", fecha=" + fecha +
+ ", fiscalesInicial='" + fiscalesInicial + '\'' +
+ ", fiscalesFinal='" + fiscalesFinal + '\'' +
", fiscales=" + fiscales +
+ ", manualesInicial='" + manualesInicial + '\'' +
+ ", manualesFinal='" + manualesFinal + '\'' +
", manuales=" + manuales +
+ ", facturasInicial='" + facturasInicial + '\'' +
+ ", facturasFinal='" + facturasFinal + '\'' +
", facturas=" + facturas +
+ ", guiasInicial='" + guiasInicial + '\'' +
+ ", guiasFinal='" + guiasFinal + '\'' +
", guias=" + guias +
", total=" + total +
'}';
diff --git a/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java b/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
index ed58b83..38aefa7 100644
--- a/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
+++ b/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
@@ -40,17 +40,34 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
ArrayList list = new ArrayList<>();
try {
Connection conn = new SQLiteConnectionHolder().getConnection();
- String query = "select strftime(\"%w\", caja.fecha) \"dia\"," +
- "caja.fecha \"fecha\"," +
- "sum(case when ingresos.tipo_ingreso_id = 1 then ingresos.valor else 0 end) as \"fiscales\"," +
- "sum(case when ingresos.tipo_ingreso_id = 2 then ingresos.valor else 0 end) as \"manuales\"," +
- "sum(case when ingresos.tipo_ingreso_id = 3 then ingresos.valor else 0 end) as \"facturas\"," +
- "sum(case when ingresos.tipo_ingreso_id = 4 then ingresos.valor else 0 end) as \"guias\"," +
- "sum(case when ingresos.valor not null then ingresos.valor else 0 end) \"total\" " +
- "from caja left join ingresos on (caja.id = ingresos.caja_id) " +
- "where caja.fecha between date(?) and date(?) " +
- "group by caja.fecha " +
- "order by caja.fecha ";
+ String query =
+ "select\n" +
+ "strftime(\"%w\", caja.fecha) as \"dia\",\n" +
+ "caja.fecha as \"fecha\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 2 and ingresos.valor > 0 then ingresos.nro_inicial else 0 end) as \"manuales_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 2 and ingresos.valor > 0 then ingresos.nro_final else 0 end) as \"manuales_final\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id = 2 then ingresos.valor else 0 end) as \"manuales\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 1 and ingresos.valor > 0 then ingresos.nro_inicial else 0 end) as \"fiscales_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 1 and ingresos.valor > 0 then ingresos.nro_final else 0 end) as \"fiscales_final\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 1 and ingresos.valor > 0 then ingresos.nro_z_inicial else 0 end) as \"fiscales_z_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 1 and ingresos.valor > 0 then ingresos.nro_z_final else 0 end) as \"fiscales_z_final\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id = 1 then ingresos.valor else 0 end) as \"fiscales\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 5 and ingresos.valor > 0 then ingresos.nro_inicial else 0 end) as \"exentas_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 5 and ingresos.valor > 0 then ingresos.nro_final else 0 end) as \"exentas_final\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id = 5 then ingresos.valor else 0 end) as \"exentas\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id in (2, 1, 5) then ingresos.valor else 0 end ) as \"sub_total\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 3 and ingresos.valor > 0 then ingresos.nro_inicial else 0 end) as \"facturas_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 3 and ingresos.valor > 0 then ingresos.nro_final else 0 end) as \"facturas_final\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id = 3 then ingresos.valor else 0 end) as \"facturas\",\n" +
+ "min(case when ingresos.tipo_ingreso_id = 4 and ingresos.valor > 0 then ingresos.nro_inicial else 0 end) as \"guias_inicial\",\n" +
+ "max(case when ingresos.tipo_ingreso_id = 4 and ingresos.valor > 0 then ingresos.nro_final else 0 end) as \"guias_final\",\n" +
+ "sum(case when ingresos.tipo_ingreso_id = 4 then ingresos.valor else 0 end) as \"guias\",\n" +
+ "sum(case when ingresos.valor not null then ingresos.valor else 0 end) as \"total\"\n" +
+ "from caja\n" +
+ "left join ingresos on (caja.id = ingresos.caja_id)\n" +
+ "where caja.fecha between date(?) and date(?)\n" +
+ "group by caja.fecha\n" +
+ "order by caja.fecha\n";
PreparedStatement ps = conn.prepareStatement(query);
@@ -63,9 +80,24 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
InformeMensualContent informeMensualContent = new InformeMensualContent();
informeMensualContent.setDia(rs.getInt("dia"));
informeMensualContent.setFecha(LocalDate.parse(rs.getString("fecha")));
- informeMensualContent.setFiscales(rs.getInt("fiscales"));
+ informeMensualContent.setManualesInicial(rs.getString("manuales_inicial"));
+ informeMensualContent.setManualesFinal(rs.getString("manuales_final"));
informeMensualContent.setManuales(rs.getInt("manuales"));
+ informeMensualContent.setFiscalesZInicial(rs.getString("fiscales_z_inicial"));
+ informeMensualContent.setFiscalesZFinal(rs.getString("fiscales_z_final"));
+ informeMensualContent.setFiscalesInicial(rs.getString("fiscales_inicial"));
+ informeMensualContent.setFiscalesFinal(rs.getString("fiscales_final"));
+ informeMensualContent.setFiscales(rs.getInt("fiscales"));
+ informeMensualContent.setExentasInicial(rs.getString("exentas_inicial"));
+ informeMensualContent.setExentasFinal(rs.getString("exentas_final"));
+ informeMensualContent.setExentas(rs.getInt("exentas"));
+ informeMensualContent.setSubTotal(rs.getInt("sub_total"));
+ informeMensualContent.setFiscales(rs.getInt("fiscales"));
+ informeMensualContent.setFacturasInicial(rs.getString("facturas_inicial"));
+ informeMensualContent.setFacturasFinal(rs.getString("facturas_final"));
informeMensualContent.setFacturas(rs.getInt("facturas"));
+ informeMensualContent.setGuiasInicial(rs.getString("guias_inicial"));
+ informeMensualContent.setGuiasFinal(rs.getString("guias_final"));
informeMensualContent.setGuias(rs.getInt("guias"));
informeMensualContent.setTotal(rs.getInt("total"));
|