Merge branch 'logging-commenting' into cleaning
This commit is contained in:
BIN
dist/Programa Caja.jar
vendored
BIN
dist/Programa Caja.jar
vendored
Binary file not shown.
@@ -1,20 +1,16 @@
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.data.Configuration;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.informes.InformeEstadoResultado;
|
||||
import danielcortes.xyz.models.estado_resultado.EstadoResultado;
|
||||
import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO;
|
||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||
import danielcortes.xyz.utils.StringUtils;
|
||||
import danielcortes.xyz.utils.SaveFile;
|
||||
import danielcortes.xyz.views.EstadoResultadoView;
|
||||
import danielcortes.xyz.views.dialogs.InformeGeneratedConfirmation;
|
||||
import danielcortes.xyz.views.dialogs.XLSFileChooser;
|
||||
import danielcortes.xyz.views.listeners.FocusLostListener;
|
||||
import java.nio.file.Path;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Optional;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class EstadoResultadoController extends BaseController {
|
||||
|
||||
@@ -121,20 +117,8 @@ public class EstadoResultadoController extends BaseController {
|
||||
}
|
||||
|
||||
private void exportarListener() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM yyyy");
|
||||
String formatedName = mes.format(formatter);
|
||||
String capitalized = StringUtils.capitalize(formatedName);
|
||||
|
||||
Path saveFile = new XLSFileChooser(
|
||||
Configuration.get("base_save_directory") + "Estado Resultado " + capitalized).execute();
|
||||
|
||||
if (saveFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InformeEstadoResultado estadoResultado = new InformeEstadoResultado(this.mes, saveFile);
|
||||
estadoResultado.generarInforme();
|
||||
new InformeGeneratedConfirmation(saveFile).execute();
|
||||
Workbook wb = new InformeEstadoResultado(this.mes).generarInforme();
|
||||
SaveFile.saveToTempFileAndOpen(wb, "estado_resultado");
|
||||
}
|
||||
|
||||
private void updateMonth() {
|
||||
|
||||
@@ -24,20 +24,16 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.data.Configuration;
|
||||
import danielcortes.xyz.informes.InformeEgresosToExcel;
|
||||
import danielcortes.xyz.informes.InformeLibroDeVentasToExcel;
|
||||
import danielcortes.xyz.informes.InformeResumenArqueo;
|
||||
import danielcortes.xyz.informes.InformeResumenArqueoToExcel;
|
||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||
import danielcortes.xyz.utils.SaveFile;
|
||||
import danielcortes.xyz.utils.StringUtils;
|
||||
import danielcortes.xyz.views.InformesSideBar;
|
||||
import danielcortes.xyz.views.dialogs.InformeGeneratedConfirmation;
|
||||
import danielcortes.xyz.views.dialogs.MonthSelectDialog;
|
||||
import danielcortes.xyz.views.dialogs.TipoEgresoSelectDialog;
|
||||
import danielcortes.xyz.views.dialogs.XLSFileChooser;
|
||||
import java.nio.file.Path;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class InformesSideBarController {
|
||||
@@ -58,6 +54,8 @@ public class InformesSideBarController {
|
||||
.addActionListener(e -> generarInformeLibroDeVentasListener());
|
||||
this.view.getGenerarEgresosFacturasMateriaPrimaButton()
|
||||
.addActionListener(e -> generarInformeEgresosListener());
|
||||
this.view.getGenerarResumenArqueoButton()
|
||||
.addActionListener(e -> generarInformeResumenArqueoListener());
|
||||
}
|
||||
|
||||
private void generarInformeLibroDeVentasListener() {
|
||||
@@ -66,23 +64,10 @@ public class InformesSideBarController {
|
||||
return;
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM yyyy");
|
||||
String formatedName = month.format(formatter);
|
||||
String capitalized = StringUtils.capitalize(formatedName);
|
||||
|
||||
Path saveFile = new XLSFileChooser(
|
||||
Configuration.get("base_save_directory") + "Libro " + capitalized).execute();
|
||||
|
||||
if (saveFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InformeLibroDeVentasToExcel informe = new InformeLibroDeVentasToExcel(month, saveFile);
|
||||
InformeLibroDeVentasToExcel informe = new InformeLibroDeVentasToExcel(month);
|
||||
Workbook wb = informe.generarInforme();
|
||||
|
||||
SaveFile.save(wb, saveFile);
|
||||
|
||||
new InformeGeneratedConfirmation(saveFile).execute();
|
||||
SaveFile.saveToTempFileAndOpen(wb, "libro_de_ventas");
|
||||
}
|
||||
|
||||
private void generarInformeEgresosListener() {
|
||||
@@ -96,20 +81,22 @@ public class InformesSideBarController {
|
||||
return;
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM yyyy");
|
||||
String formatedMonth = month.format(formatter);
|
||||
InformeEgresosToExcel informe = new InformeEgresosToExcel(tipoEgreso, month);
|
||||
Workbook wb = informe.generarInforme();
|
||||
|
||||
Path saveFile = new XLSFileChooser(
|
||||
"Informe Egresos - " + tipoEgreso.getNombre() + " - " + StringUtils
|
||||
.capitalize(formatedMonth)).execute();
|
||||
if (saveFile == null) {
|
||||
SaveFile.saveToTempFileAndOpen(wb, "informe_egresos");
|
||||
}
|
||||
|
||||
private void generarInformeResumenArqueoListener() {
|
||||
YearMonth mes = new MonthSelectDialog().execute();
|
||||
if (mes == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InformeEgresosToExcel informe = new InformeEgresosToExcel(tipoEgreso, month);
|
||||
Workbook wb = informe.generarInforme();
|
||||
SaveFile.save(wb, saveFile);
|
||||
InformeResumenArqueo informe = InformeResumenArqueo.generate(mes);
|
||||
Workbook wb = new InformeResumenArqueoToExcel(informe).generarInforme();
|
||||
|
||||
new InformeGeneratedConfirmation(saveFile).execute();
|
||||
SaveFile.saveToTempFileAndOpen(wb, "resumen_arqueo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.estado_resultado.EstadoResultado;
|
||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||
import danielcortes.xyz.utils.StringUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,7 +36,6 @@ public class InformeEstadoResultado {
|
||||
private ArrayList<Row> resumenGeneralRows;
|
||||
|
||||
private YearMonth mes;
|
||||
private Path saveFile;
|
||||
|
||||
private EstadoResultado estadoResultado;
|
||||
|
||||
@@ -49,9 +44,8 @@ public class InformeEstadoResultado {
|
||||
private CreationHelper createHelper;
|
||||
private HashMap<String, CellStyle> styles;
|
||||
|
||||
public InformeEstadoResultado(YearMonth mes, Path saveFile) {
|
||||
public InformeEstadoResultado(YearMonth mes) {
|
||||
this.mes = mes;
|
||||
this.saveFile = saveFile;
|
||||
|
||||
this.estadoResultado = DAOManager.getEstadoResultadoDAO().getByMonth(this.mes).orElse(EstadoResultado.EMPTY);
|
||||
|
||||
@@ -422,7 +416,7 @@ public class InformeEstadoResultado {
|
||||
pt.applyBorders(this.sheet);
|
||||
}
|
||||
|
||||
public void generarInforme() {
|
||||
public Workbook generarInforme() {
|
||||
fillTitle();
|
||||
fillVentaData();
|
||||
fillGastosOperacionalesData();
|
||||
@@ -432,11 +426,7 @@ public class InformeEstadoResultado {
|
||||
setStyles();
|
||||
addBorders();
|
||||
|
||||
try (OutputStream fileOut = Files.newOutputStream(this.saveFile)) {
|
||||
wb.write(fileOut);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return wb;
|
||||
}
|
||||
|
||||
private HashMap<String, CellStyle> generateStyles() {
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package danielcortes.xyz.informes;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
@@ -89,7 +88,7 @@ public class InformeLibroDeVentasToExcel {
|
||||
private CreationHelper createHelper;
|
||||
private HashMap<String, CellStyle> styles;
|
||||
|
||||
public InformeLibroDeVentasToExcel(YearMonth mes, Path saveFile) {
|
||||
public InformeLibroDeVentasToExcel(YearMonth mes) {
|
||||
this.mes = mes;
|
||||
this.informe = InformeLibroDeVentas.generate(mes);
|
||||
|
||||
|
||||
89
src/danielcortes/xyz/informes/InformeResumenArqueo.java
Normal file
89
src/danielcortes/xyz/informes/InformeResumenArqueo.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package danielcortes.xyz.informes;
|
||||
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.caja.CajaDAO;
|
||||
import danielcortes.xyz.models.documentos.Documentos;
|
||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class InformeResumenArqueo {
|
||||
|
||||
private HashMap<LocalDate, ResumenArqueo> informe;
|
||||
private YearMonth mes;
|
||||
|
||||
private InformeResumenArqueo(){}
|
||||
|
||||
public ResumenArqueo get(LocalDate localDate) {
|
||||
return informe.get(localDate);
|
||||
}
|
||||
|
||||
private void put(LocalDate localDate, ResumenArqueo resumenArqueo) {
|
||||
informe.put(localDate, resumenArqueo);
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return informe.size();
|
||||
}
|
||||
|
||||
public YearMonth getMes(){
|
||||
return mes;
|
||||
}
|
||||
|
||||
public static InformeResumenArqueo generate(YearMonth mes){
|
||||
InformeResumenArqueo informeResumenArqueo = new InformeResumenArqueo();
|
||||
informeResumenArqueo.informe = new HashMap<>();
|
||||
informeResumenArqueo.mes = mes;
|
||||
|
||||
LocalDate currentDate = mes.atDay(1);
|
||||
LocalDate endDatePlusOne = mes.atEndOfMonth().plusDays(1);
|
||||
|
||||
CajaDAO cajaDAO = DAOManager.getCajaDAO();
|
||||
EfectivoDAO efectivoDAO = DAOManager.getEfectivoDAO();
|
||||
EgresoDAO egresoDAO = DAOManager.getEgresoDAO();
|
||||
IngresoDAO ingresoDAO = DAOManager.getIngresoDAO();
|
||||
DocumentosDAO documentosDAO = DAOManager.getDocumentosDAO();
|
||||
|
||||
while (currentDate.isBefore(endDatePlusOne)) {
|
||||
ResumenArqueo resumenArqueo = new ResumenArqueo();
|
||||
Caja caja = cajaDAO.getByFecha(currentDate).orElse(Caja.EMPTY);
|
||||
Documentos documentos = documentosDAO.getByCaja(caja).orElse(Documentos.EMPTY);
|
||||
|
||||
int efectivo = efectivoDAO.getTotalEfectivo(caja);
|
||||
int cheques = documentos.getCheques();
|
||||
int tarjetasCredito = documentos.getTarjetas();
|
||||
int retiros = documentos.getRetiros();
|
||||
int egresos = egresoDAO.getTotalEgreso(caja);
|
||||
int debeRendir = ingresoDAO.getTotalIngreso(caja);
|
||||
|
||||
resumenArqueo.setEfectivo(efectivo);
|
||||
resumenArqueo.setCheques(cheques);
|
||||
resumenArqueo.setTarjetaCredito(tarjetasCredito);
|
||||
resumenArqueo.setRetiros(retiros);
|
||||
resumenArqueo.setEgresos(egresos);
|
||||
resumenArqueo.setDebeRendir(debeRendir);
|
||||
|
||||
informeResumenArqueo.put(currentDate, resumenArqueo);
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
|
||||
return informeResumenArqueo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(LocalDate localDate: informe.keySet()){
|
||||
sb.append(localDate);
|
||||
sb.append(":");
|
||||
sb.append(informe.get(localDate));
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
224
src/danielcortes/xyz/informes/InformeResumenArqueoToExcel.java
Normal file
224
src/danielcortes/xyz/informes/InformeResumenArqueoToExcel.java
Normal file
@@ -0,0 +1,224 @@
|
||||
package danielcortes.xyz.informes;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.BorderExtent;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.CreationHelper;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.PropertyTemplate;
|
||||
|
||||
public class InformeResumenArqueoToExcel {
|
||||
|
||||
private final String[] dias = {
|
||||
"LUNES", "MARTES", "MIERCOLES", "JUEVES", "VIERNES", "SABADO", "DOMINGO"
|
||||
};
|
||||
private InformeResumenArqueo informe;
|
||||
|
||||
private Row titles;
|
||||
private ArrayList<Row> dataRow;
|
||||
private Row totalesRow;
|
||||
|
||||
private Workbook wb;
|
||||
private Sheet sheet;
|
||||
private CreationHelper createHelper;
|
||||
private HashMap<String, CellStyle> styles;
|
||||
|
||||
public InformeResumenArqueoToExcel(InformeResumenArqueo informe) {
|
||||
this.informe = informe;
|
||||
this.wb = new HSSFWorkbook();
|
||||
this.sheet = wb.createSheet();
|
||||
this.createHelper = wb.getCreationHelper();
|
||||
|
||||
this.dataRow = new ArrayList<>();
|
||||
|
||||
this.styles = this.generateStyles();
|
||||
}
|
||||
|
||||
private void fillHeaders() {
|
||||
this.titles = sheet.createRow(0);
|
||||
int currentCell = 0;
|
||||
this.titles.createCell(currentCell++).setCellValue("Dia");
|
||||
this.titles.createCell(currentCell++).setCellValue("Fecha");
|
||||
this.titles.createCell(currentCell++).setCellValue("Efectivo");
|
||||
this.titles.createCell(currentCell++).setCellValue("Cheques");
|
||||
this.titles.createCell(currentCell++).setCellValue("T Credito");
|
||||
this.titles.createCell(currentCell++).setCellValue("Retiros");
|
||||
this.titles.createCell(currentCell++).setCellValue("Egresos");
|
||||
this.titles.createCell(currentCell++).setCellValue("Rendido");
|
||||
this.titles.createCell(currentCell++).setCellValue("Debe Rendir");
|
||||
this.titles.createCell(currentCell).setCellValue("Diferencia");
|
||||
}
|
||||
|
||||
private void fillData() {
|
||||
int currentRow = 1;
|
||||
|
||||
LocalDate currentDay = this.informe.getMes().atDay(1);
|
||||
LocalDate endDayPlusOne = this.informe.getMes().atEndOfMonth().plusDays(1);
|
||||
|
||||
while (currentDay.isBefore(endDayPlusOne)) {
|
||||
int currentCell = 0;
|
||||
|
||||
Row row = sheet.createRow(currentRow++);
|
||||
ResumenArqueo informe = this.informe.get(currentDay);
|
||||
|
||||
row.createCell(currentCell++).setCellValue(this.dias[currentDay.getDayOfWeek().getValue()-1]);
|
||||
Date fecha = Date.from(currentDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
row.createCell(currentCell++).setCellValue(fecha);
|
||||
row.createCell(currentCell++).setCellValue(informe.getEfectivo());
|
||||
row.createCell(currentCell++).setCellValue(informe.getCheques());
|
||||
row.createCell(currentCell++).setCellValue(informe.getTarjetaCredito());
|
||||
row.createCell(currentCell++).setCellValue(informe.getRetiros());
|
||||
row.createCell(currentCell++).setCellValue(informe.getEgresos());
|
||||
row.createCell(currentCell++).setCellFormula("SUM(C" + currentRow + ":G" + currentRow + ")");
|
||||
row.createCell(currentCell++).setCellValue(informe.getDebeRendir());
|
||||
row.createCell(currentCell++).setCellFormula("H" + currentRow + "-I" + currentRow);
|
||||
|
||||
dataRow.add(row);
|
||||
currentDay = currentDay.plusDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillTotal() {
|
||||
int lastRow = dataRow.size() + 1;
|
||||
int currentRow = dataRow.size() + 1;
|
||||
int currentCell = 0;
|
||||
totalesRow = sheet.createRow(currentRow);
|
||||
|
||||
totalesRow.createCell(currentCell++).setCellValue("Totales");
|
||||
totalesRow.createCell(currentCell++);
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(C2:C" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(D2:D" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(E2:E" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(F2:F" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(G2:G" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(H2:H" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(I2:I" + lastRow + ")");
|
||||
totalesRow.createCell(currentCell++).setCellFormula("SUM(J2:J" + lastRow + ")");
|
||||
}
|
||||
|
||||
private void setStyles() {
|
||||
this.titles.cellIterator().forEachRemaining(
|
||||
(cell) -> cell.setCellStyle(this.styles.get("header"))
|
||||
);
|
||||
|
||||
this.totalesRow.cellIterator().forEachRemaining(
|
||||
(cell) -> cell.setCellStyle(this.styles.get("total"))
|
||||
);
|
||||
|
||||
for(Row row: this.dataRow){
|
||||
int currentCell = 0;
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("not_so_gray"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("date"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
row.getCell(currentCell++).setCellStyle(this.styles.get("money"));
|
||||
}
|
||||
|
||||
for(int x = 0; x < 10; x++){
|
||||
this.sheet.autoSizeColumn(x);
|
||||
}
|
||||
|
||||
for(int x = 0; x < dataRow.size() + 2; x++) {
|
||||
this.sheet.getRow(x).setHeightInPoints(15);
|
||||
}
|
||||
}
|
||||
|
||||
private void addBorders() {
|
||||
int size = dataRow.size() + 2;
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
pt.drawBorders(new CellRangeAddress(0, size - 1, 0, 9), BorderStyle.THIN, BorderExtent.ALL);
|
||||
pt.applyBorders(this.sheet);
|
||||
}
|
||||
|
||||
private void freezeCells() {
|
||||
this.sheet.createFreezePane(2, 1);
|
||||
}
|
||||
|
||||
public Workbook generarInforme() {
|
||||
fillHeaders();
|
||||
fillData();
|
||||
fillTotal();
|
||||
setStyles();
|
||||
addBorders();
|
||||
freezeCells();
|
||||
|
||||
return this.wb;
|
||||
}
|
||||
|
||||
public 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_50_PERCENT.getIndex());
|
||||
notSoGrayStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
CellStyle dateStyle = this.wb.createCellStyle();
|
||||
dateStyle.cloneStyleFrom(notSoGrayStyle);
|
||||
dateStyle.setDataFormat(this.createHelper.createDataFormat().getFormat("dd/mm/yyyy"));
|
||||
|
||||
CellStyle moneyStyle = this.wb.createCellStyle();
|
||||
moneyStyle
|
||||
.setDataFormat(
|
||||
this.createHelper.createDataFormat().getFormat("[$$-340A]#,##0;[RED][$$-340A] -#,##0"));
|
||||
|
||||
CellStyle headerStyle = this.wb.createCellStyle();
|
||||
headerStyle.cloneStyleFrom(notSoGrayStyle);
|
||||
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
|
||||
CellStyle totalStyle = this.wb.createCellStyle();
|
||||
totalStyle.cloneStyleFrom(notSoGrayStyle);
|
||||
totalStyle
|
||||
.setDataFormat(
|
||||
this.createHelper.createDataFormat().getFormat("[$$-340A]#,##0;[RED][$$-340A] -#,##0"));
|
||||
|
||||
CellStyle totalFinalStyle = this.wb.createCellStyle();
|
||||
totalFinalStyle.cloneStyleFrom(notSoGrayStyle);
|
||||
totalFinalStyle
|
||||
.setDataFormat(
|
||||
this.createHelper.createDataFormat().getFormat("[$$-340A]#,##0;[RED][$$-340A] -#,##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;
|
||||
}
|
||||
|
||||
}
|
||||
70
src/danielcortes/xyz/informes/ResumenArqueo.java
Normal file
70
src/danielcortes/xyz/informes/ResumenArqueo.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package danielcortes.xyz.informes;
|
||||
|
||||
public class ResumenArqueo {
|
||||
private int efectivo;
|
||||
private int cheques;
|
||||
private int tarjetaCredito;
|
||||
private int retiros;
|
||||
private int egresos;
|
||||
private int debeRendir;
|
||||
|
||||
public int getEfectivo() {
|
||||
return efectivo;
|
||||
}
|
||||
|
||||
public void setEfectivo(int efectivo) {
|
||||
this.efectivo = efectivo;
|
||||
}
|
||||
|
||||
public int getCheques() {
|
||||
return cheques;
|
||||
}
|
||||
|
||||
public void setCheques(int cheques) {
|
||||
this.cheques = cheques;
|
||||
}
|
||||
|
||||
public int getTarjetaCredito() {
|
||||
return tarjetaCredito;
|
||||
}
|
||||
|
||||
public void setTarjetaCredito(int tarjetaCredito) {
|
||||
this.tarjetaCredito = tarjetaCredito;
|
||||
}
|
||||
|
||||
public int getRetiros() {
|
||||
return retiros;
|
||||
}
|
||||
|
||||
public void setRetiros(int retiros) {
|
||||
this.retiros = retiros;
|
||||
}
|
||||
|
||||
public int getEgresos() {
|
||||
return egresos;
|
||||
}
|
||||
|
||||
public void setEgresos(int egresos) {
|
||||
this.egresos = egresos;
|
||||
}
|
||||
|
||||
public int getDebeRendir() {
|
||||
return debeRendir;
|
||||
}
|
||||
|
||||
public void setDebeRendir(int debeRendir) {
|
||||
this.debeRendir = debeRendir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResumenArqueo{" +
|
||||
"efectivo=" + efectivo +
|
||||
", cheques=" + cheques +
|
||||
", tarjetaCredito=" + tarjetaCredito +
|
||||
", retiros=" + retiros +
|
||||
", egresos=" + egresos +
|
||||
", debeRendir=" + debeRendir +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,10 @@ import java.util.Optional;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Objeto DAO que realiza las querys y mapeos necesarios del objeto Caja
|
||||
* En especifico esta implementacion se comunica con la base de datos SQLite
|
||||
*/
|
||||
public class SQLiteCajaDAO implements CajaDAO {
|
||||
private static final Logger LOGGER = LogManager.getLogger(SQLiteCajaDAO.class);
|
||||
private SQLiteConnectionHolder connectionHolder;
|
||||
@@ -44,8 +48,14 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
this.connectionHolder = new SQLiteConnectionHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todas las instancias de Caja en la base de datos, las cuales mapea al objeto
|
||||
* Caja y devuelve una lista con todos estos
|
||||
* @return Una lista con todas las instancias de Caja en la base de datos
|
||||
*/
|
||||
@Override
|
||||
public List<Caja> getAll() {
|
||||
LOGGER.info("Se intentara conseguir todas las Cajas");
|
||||
List<Caja> cajaList = new ArrayList<>();
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
String query = "select * from caja";
|
||||
@@ -63,12 +73,20 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar obtener todas las Cajas", e);
|
||||
}
|
||||
|
||||
LOGGER.trace("Se encontraron " + cajaList.size() + " cajas");
|
||||
return cajaList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene una instancia de Caja desde la base de datos
|
||||
* @param id el id de la fila de Caja en la base de datos
|
||||
* @return Un optional conteniendo la caja y el cual puede estar vacio, dado que no es 100% seguro que el id
|
||||
* entregado sea valido o exista en la base de datos
|
||||
*/
|
||||
@Override
|
||||
public Optional<Caja> getById(int id) {
|
||||
LOGGER.info("Se intentara conseguir una Caja con el id " + id);
|
||||
Caja caja = null;
|
||||
String query = "select * from caja where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -86,11 +104,19 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir la caja con id " + id, e);
|
||||
}
|
||||
LOGGER.trace("La caja que se consigio es " + caja);
|
||||
return Optional.ofNullable(caja);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una instancia de caja dada su fecha.
|
||||
* @param fecha Fecha a la cual corresponde la caja
|
||||
* @return Un optional conteniendo la caja y el cual puede estar vacio, dado que no es 100%
|
||||
* seguro que la fecha entregada corresponda a una caja en la base de datos
|
||||
*/
|
||||
@Override
|
||||
public Optional<Caja> getByFecha(LocalDate fecha) {
|
||||
LOGGER.info("Se intentara conseguir la caja con fecha " + fecha);
|
||||
Caja caja = null;
|
||||
String query = "select * from caja where fecha = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -108,11 +134,17 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir la caja con fecha " + fecha, e);
|
||||
}
|
||||
LOGGER.trace("Se consiguio la caja " + caja);
|
||||
return Optional.ofNullable(caja);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta en la base de datos una instancia de Caja nueva.
|
||||
* @param caja La caja a insertar, una vez que ocurra, se le otorgara un id.
|
||||
*/
|
||||
@Override
|
||||
public void insert(Caja caja) {
|
||||
LOGGER.info("Se intentara insertar la caja " + caja);
|
||||
String query = "insert into caja (fecha, fondo) values (?, ?)";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -131,10 +163,16 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar insertar la caja " + caja, e);
|
||||
}
|
||||
LOGGER.trace("Se inserto al caja " + caja);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualiza una caja existente en la base de datos
|
||||
* @param caja La caja a actualizar.
|
||||
*/
|
||||
@Override
|
||||
public void update(Caja caja) {
|
||||
LOGGER.info("Se intentara actualizar la caja " + caja);
|
||||
String query = "update caja set fecha = ?, fondo = ? where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -146,5 +184,6 @@ public class SQLiteCajaDAO implements CajaDAO {
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar actualizar la caja " + caja, e);
|
||||
}
|
||||
LOGGER.trace("Se actualizo la caja " + caja);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SQLiteCalculoFondoDAO implements CalculoFondoDAO {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
ps.setInt(1, caja.getId());
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
while (rs.next()) {
|
||||
CalculoFondo calculoFondo = new CalculoFondo();
|
||||
|
||||
calculoFondo.setId(rs.getInt("id"));
|
||||
|
||||
@@ -35,16 +35,28 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Objeto DAO que realiza las querys y mapeos necesarios del objecto Documentos
|
||||
* En especifico esta implementacion se comunica con la base de datos SQLite
|
||||
*/
|
||||
public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
private static final Logger LOGGER = LogManager.getLogger(SQLiteDocumentosDAO.class);
|
||||
private ConnectionHolder connectionHolder;
|
||||
|
||||
public SQLiteDocumentosDAO() {
|
||||
this.connectionHolder = new SQLiteConnectionHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todas las instancias de Documentos que existen en la base de datos
|
||||
* @return Una lista con los Documentos
|
||||
*/
|
||||
@Override
|
||||
public List<Documentos> getAll() {
|
||||
LOGGER.info("Se intentaran conseguir todos los Documentos");
|
||||
List<Documentos> documentosList = new ArrayList<>();
|
||||
String query = "select * from documentos";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -67,12 +79,21 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir todos los Documentos de la base de datos", e);
|
||||
}
|
||||
LOGGER.trace("Se consiguieron " + documentosList.size() + " Documentos");
|
||||
return documentosList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene un Documento dado su id en la base de datos
|
||||
* @param id el id de la fila del documento en la base de datos
|
||||
* @return Un optional que contiene el documento que puede ser vacio, dado que no es
|
||||
* 100% seguro que el id entregado sea valido o exista en la base de datos.
|
||||
*/
|
||||
@Override
|
||||
public Optional<Documentos> getById(int id) {
|
||||
LOGGER.info("Se intentara conseguir el Documentos con id " + id);
|
||||
Documentos documentos = null;
|
||||
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -95,15 +116,25 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir el Documentos con id " + id, e);
|
||||
}
|
||||
LOGGER.trace("Se consiguio el Documentos " + documentos);
|
||||
return Optional.ofNullable(documentos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el Documentos que esta relacionado con la Caja
|
||||
* @param caja caja con la cual esta relacionado el Documentos
|
||||
* @return Un optional que contiene el Documentos el cual puede ser vacio, dado que no
|
||||
* es 100% seguro que exista un Documentos con esa caja.
|
||||
*/
|
||||
@Override
|
||||
public Optional<Documentos> getByCaja(Caja caja) {
|
||||
LOGGER.info("Se intentara conseguir el Documentos de la caja " + caja);
|
||||
Documentos documentos = null;
|
||||
|
||||
if (Caja.EMPTY == caja) {
|
||||
LOGGER.trace("La caja entregada era Caja.EMPTY");
|
||||
return Optional.ofNullable(documentos);
|
||||
}
|
||||
|
||||
@@ -123,14 +154,25 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir el documentos de la caja " + caja, e);
|
||||
}
|
||||
|
||||
LOGGER.trace("Se consiguio el Documentos " + documentos);
|
||||
return Optional.ofNullable(documentos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene la suma de los documentos pertenecientes a una caja
|
||||
* @param caja caja a la que pertenecen los documentos que se sumaran
|
||||
* @return Un int con la suma obtenida, en caso que la caja entregada sea igual a
|
||||
* Caja.EMPTY se retornara 0, al igual que si no existe ningun documentos para la caja
|
||||
*/
|
||||
@Override
|
||||
public int getTotalDocumentos(Caja caja) {
|
||||
LOGGER.info("Se intentara conseguir el total de Documentos de la caja " + caja);
|
||||
int total = 0;
|
||||
if (Caja.EMPTY == caja) {
|
||||
LOGGER.trace("La caja entregada era Caja.EMPTY");
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -145,12 +187,19 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir la suma de los documentos de la caja " + caja);
|
||||
}
|
||||
LOGGER.trace("La suma obtenida es " + total);
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta en la base de datos una instancia de Documentos nuevo
|
||||
* @param documentos Documentos a insertar, una vez que ocurra se le otorgara un id
|
||||
*/
|
||||
@Override
|
||||
public void insert(Documentos documentos) {
|
||||
LOGGER.info("Se intentara insertar un nuevo documentos " + documentos);
|
||||
String query = "insert into documentos (cheques, tarjetas, retiros, caja_id) values (?,?,?,?)";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -169,11 +218,20 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar insertar el documentos " + documentos);
|
||||
}
|
||||
LOGGER.trace("Se inserto el documentos " + documentos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta un documentos por default, teniendo los campos cheques, tarjetas y retiros
|
||||
* siendo 0.
|
||||
* @param documentos Instancia de documentos la cual se guardara con esas caracteristicas
|
||||
* Solo se tomara el objecto caja para obtener el id de esta y asociarlo en la base de datos
|
||||
*/
|
||||
@Override
|
||||
public void insertDefault(Documentos documentos) {
|
||||
LOGGER.info("Se intentara insertar el documento default " + documentos);
|
||||
String query = "insert into documentos (cheques, tarjetas, retiros, caja_id) values (0,0,0,?)";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -187,11 +245,18 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar insertar el documento por default " + documentos, e);
|
||||
}
|
||||
LOGGER.trace("Se inserto el documento por default " + documentos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualiza un Documentos existente en la base de datos
|
||||
* @param documentos el documentos a actualizar
|
||||
*/
|
||||
@Override
|
||||
public void update(Documentos documentos) {
|
||||
LOGGER.info("Se intentara actualizar el documentos " + documentos);
|
||||
String query = "update documentos set tarjetas = ?, cheques = ?, retiros = ?, caja_id = ? where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -203,18 +268,26 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al actualizar el documentos " + documentos, e);
|
||||
}
|
||||
LOGGER.trace("Se actualizo el documentos " + documentos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina un Documentos existente en la base de datos
|
||||
* @param documentos El documentos a eliminar
|
||||
*/
|
||||
@Override
|
||||
public void delete(Documentos documentos) {
|
||||
LOGGER.info("Se intentara eliminar el documentos " + documentos);
|
||||
String query = "delete from documentos where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
ps.setInt(1, documentos.getId());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al eliminar el documentos " + documentos, e);
|
||||
}
|
||||
LOGGER.trace("Se elimino el documentos " + documentos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,16 +36,28 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Objeto DAO que realiza las querys y mapeos necesarios del objeto Efectivo
|
||||
* En especifico esta implementacion se comunica con la base de datos SQLite
|
||||
*/
|
||||
public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
private static final Logger LOGGER = LogManager.getLogger(SQLiteEfectivoDAO.class);
|
||||
private ConnectionHolder connectionHolder;
|
||||
|
||||
public SQLiteEfectivoDAO() {
|
||||
this.connectionHolder = new SQLiteConnectionHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todas las instancias de Efectivo que existen en la base de datos
|
||||
* @return una lista de Efectivo
|
||||
*/
|
||||
@Override
|
||||
public List<Efectivo> getAll() {
|
||||
LOGGER.info("Se intentara conseguir todas los Efectivo");
|
||||
List<Efectivo> efectivoList = new ArrayList<>();
|
||||
String query = "select * from efectivos";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -75,13 +87,22 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Erro al intentar conseguir todos los Efectivo", e);
|
||||
}
|
||||
|
||||
LOGGER.trace("Se consiguieron " + efectivoList.size() + " Efectivo");
|
||||
return efectivoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene un Efectivo dado su id en la base de datos
|
||||
* @param id el id de la fila del efectivo en la base de datos
|
||||
* @return un optional que contiene el efectivo y puede estar vacio, dado que no es
|
||||
* 100% seguro que el id entregado sea valido o exista en la base de datos.
|
||||
*/
|
||||
@Override
|
||||
public Optional<Efectivo> getById(int id) {
|
||||
LOGGER.info("Se intentara conseguir un Efectivo con id " + id);
|
||||
Efectivo efectivo = null;
|
||||
String query = "select * from efectivos where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
@@ -110,15 +131,25 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir un Efectivo con id " + id);
|
||||
}
|
||||
|
||||
LOGGER.trace("Se consiguio el efectivo " + efectivo);
|
||||
return Optional.ofNullable(efectivo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene un Efectivo perteneciente a una caja
|
||||
* @param caja Caja a la cual pertenece el efectivo requerido
|
||||
* @return Un optional que contiene el efectivo y puede estar vacio, dado que no es 100%
|
||||
* seguro que la exista un efectivo para la caja. Ademas la caja puede ser Caja.EMPTY
|
||||
* en ese caso siempre se retornara un Optional.empty().
|
||||
*/
|
||||
@Override
|
||||
public Optional<Efectivo> getByCaja(Caja caja) {
|
||||
LOGGER.info("Se intentara conseguir un Efectivo perteneciente a la caja " + caja);
|
||||
Efectivo efectivo = null;
|
||||
if (Caja.EMPTY == caja) {
|
||||
LOGGER.trace("La caja entregada era Caja.EMPTY");
|
||||
return Optional.ofNullable(efectivo);
|
||||
}
|
||||
|
||||
@@ -144,15 +175,26 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir un Efectivo perteneciente a la caja " + caja );
|
||||
}
|
||||
|
||||
LOGGER.trace("Se obtuvo el efectivo " + efectivo);
|
||||
return Optional.ofNullable(efectivo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene la suma de los efectivos pertenecientes una caja
|
||||
* @param caja Caja a la cual pertenece los efectivos a sumar
|
||||
* @return Un int con la suma obtenida, en caso que la caja sea igual a Caja.EMPTY
|
||||
* simplemente se retoranara 0, al igual que cuando no exista ningun efectivo para esa caja
|
||||
*/
|
||||
@Override
|
||||
public int getTotalEfectivo(Caja caja) {
|
||||
LOGGER.info("Se intentara conseguir la suma de efectivos de la caja " + caja);
|
||||
int total = 0;
|
||||
|
||||
if (Caja.EMPTY == caja) {
|
||||
LOGGER.trace("La caja entregada era Caja.EMPTY");
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -167,12 +209,20 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar conseguir la suma de efectivos con la caja " + caja);
|
||||
}
|
||||
|
||||
LOGGER.trace("La suma obtenida es " + total);
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta en la base de datos una instancia de Efectivo nueva
|
||||
* @param efectivo Efectivo a insertar, una vez que ocurra se le otorgara un id.
|
||||
*/
|
||||
@Override
|
||||
public void insert(Efectivo efectivo) {
|
||||
LOGGER.info("Se intentara insertar el efectivo " + efectivo);
|
||||
String query = "insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (?,?,?,?,?,?,?,?,?,?)";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -195,11 +245,19 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar insertar el efectivo " + efectivo, e);
|
||||
}
|
||||
LOGGER.trace("Se inserto el efectivo " + efectivo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta un efectivo por default, teniendo todos los campos en 0 exceptuando el id de la caja
|
||||
* @param efectivo Instancia de efectivo que se guardara, solo se tomara en cuenta la caja
|
||||
* que almacena para obtener su id.
|
||||
*/
|
||||
@Override
|
||||
public void insertDefault(Efectivo efectivo) {
|
||||
LOGGER.info("Se intentara insertar el efectivo por default " + efectivo);
|
||||
String query = "insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (0,0,0,0,0,0,0,0,0,?)";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -213,11 +271,18 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al insertar el efectivo por default " + efectivo, e);
|
||||
}
|
||||
LOGGER.trace("Se inserto el efectivo por default " + efectivo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualiza un Efectivo existente en la base de datos
|
||||
* @param efectivo efectivo a actualizar
|
||||
*/
|
||||
@Override
|
||||
public void update(Efectivo efectivo) {
|
||||
LOGGER.info("Se intentara actualizar el efectivo " + efectivo);
|
||||
String query = "update efectivos set veinte_mil = ?, diez_mil = ?, cinco_mil = ?, dos_mil = ?, mil = ?, quinientos = ?, cien = ?, cincuenta = ?, diez = ?, caja_id = ? where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -236,11 +301,18 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar actualizar el efectivo " + efectivo, e);
|
||||
}
|
||||
LOGGER.trace("Se actualizo el efectivo " + efectivo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina un efectivo de la base de datos
|
||||
* @param efectivo efectivo a eliminar
|
||||
*/
|
||||
@Override
|
||||
public void delete(Efectivo efectivo) {
|
||||
LOGGER.info("Se intentara eliminar el efectivo " + efectivo);
|
||||
String query = "delete from efectivos where id = ?";
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||
@@ -248,7 +320,9 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Error al intentar eliminar el efectivo " + efectivo, e);
|
||||
}
|
||||
LOGGER.trace("Se elimino el efectivo " + efectivo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
package danielcortes.xyz.utils;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
* Esta clase se dedicara a contenter los metodos
|
||||
* que guardaran distintos tipos de archivos
|
||||
*/
|
||||
public class SaveFile {
|
||||
public static void save(Workbook wb, Path saveFile){
|
||||
try (OutputStream fileOut = Files.newOutputStream(saveFile)) {
|
||||
wb.write(fileOut);
|
||||
|
||||
/**
|
||||
* Guarda un Workbook en un archivo temporal el cual sera eliminado una vez
|
||||
* que el programa sea cerrado, abre automaticamente el archivo generado
|
||||
* @param wb WorkBook a guardar
|
||||
* @param prefix prefijo para el archivo temporal.
|
||||
*/
|
||||
public static void saveToTempFileAndOpen(Workbook wb, String prefix){
|
||||
try {
|
||||
Path saveFile = Files.createTempFile(prefix, ".xls");
|
||||
saveFile.toFile().deleteOnExit();
|
||||
try (OutputStream out = Files.newOutputStream(saveFile)) {
|
||||
wb.write(out);
|
||||
}
|
||||
Desktop.getDesktop().open(saveFile.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ae41b" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="ae41b" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<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"/>
|
||||
@@ -34,12 +34,12 @@
|
||||
</component>
|
||||
<vspacer id="91971">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" 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>
|
||||
<component id="354cd" class="javax.swing.JButton" binding="estadoResultadoButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" 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>
|
||||
<properties>
|
||||
<text value="Estado Resultado"/>
|
||||
@@ -47,12 +47,20 @@
|
||||
</component>
|
||||
<component id="95688" class="javax.swing.JButton" binding="volverButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" 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>
|
||||
<properties>
|
||||
<text value="Volver"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="42dc7" class="javax.swing.JButton" binding="generarResumenArqueoButton">
|
||||
<constraints>
|
||||
<grid row="2" 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>
|
||||
<properties>
|
||||
<text value="Resumen Arqueo"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -39,6 +39,7 @@ public class InformesSideBar {
|
||||
private JPanel contentPanel;
|
||||
private JButton GenerarEgresosFacturasMateriaPrimaButton;
|
||||
private JButton estadoResultadoButton;
|
||||
private JButton generarResumenArqueoButton;
|
||||
private JButton volverButton;
|
||||
|
||||
public JPanel getContentPanel() {
|
||||
@@ -57,6 +58,10 @@ public class InformesSideBar {
|
||||
return estadoResultadoButton;
|
||||
}
|
||||
|
||||
public JButton getGenerarResumenArqueoButton() {
|
||||
return generarResumenArqueoButton;
|
||||
}
|
||||
|
||||
public JButton getVolverButton() {
|
||||
return volverButton;
|
||||
}
|
||||
@@ -78,7 +83,7 @@ public class InformesSideBar {
|
||||
contentPanel = new JPanel();
|
||||
contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(5, 1, new Insets(10, 10, 10, 10), -1, -1));
|
||||
panel1.setLayout(new GridLayoutManager(6, 1, new Insets(10, 10, 10, 10), -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,
|
||||
@@ -101,18 +106,25 @@ public class InformesSideBar {
|
||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
|
||||
panel1.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
|
||||
GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0,
|
||||
false));
|
||||
estadoResultadoButton = new JButton();
|
||||
estadoResultadoButton.setText("Estado Resultado");
|
||||
panel1.add(estadoResultadoButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
|
||||
panel1.add(estadoResultadoButton, new GridConstraints(3, 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));
|
||||
volverButton = new JButton();
|
||||
volverButton.setText("Volver");
|
||||
panel1.add(volverButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
|
||||
panel1.add(volverButton, new GridConstraints(5, 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));
|
||||
generarResumenArqueoButton = new JButton();
|
||||
generarResumenArqueoButton.setText("Resumen Arqueo");
|
||||
panel1.add(generarResumenArqueoButton,
|
||||
new GridConstraints(2, 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));
|
||||
|
||||
@@ -4,7 +4,9 @@ name = PropertiesConfig
|
||||
filters = threshold
|
||||
|
||||
filter.threshold.type = ThresholdFilter
|
||||
filter.threshold.level = debug
|
||||
filter.threshold.level = trace
|
||||
filter.threshold.onMatch = ACCEPT
|
||||
filter.threshold.onMismatch= NEUTRAL
|
||||
|
||||
appenders = console, file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user