List of usage examples for com.lowagie.text Document Document
public Document(Rectangle pageSize)
Document
-object. From source file:jm.Reporte.java
License:GNU General Public License
public void sumLista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/*from www .jav a2 s. c om*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; //int num2 = 1; float suma_total = 0; float consumo = 0; int alineacion = Element.ALIGN_LEFT; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); //tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 1; i <= numCols; i++) { alineacion = (i == numCols) ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT; tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, alineacion, 1)); } consumo = (registros.getString(numCols) != null) ? registros.getFloat(numCols) : 0; suma_total = Float.parseFloat(this.formatoNumero.format(suma_total)) + consumo; num++; //num2++; } tbl_det.addCell(Addons.setCeldaPDF("TOTAL: " + Addons.truncar(suma_total), Font.TIMES_ROMAN, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, numCols + 2)); registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void listaAgrupada(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros) {/* w w w .j av a 2 s. c o m*/ /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String columna1 = ""; try { while (registros.next()) { columna1 = (registros.getString(1) != null) ? registros.getString(1) : ""; if (aux.compareTo(columna1) != 0) { tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 1)); aux = columna1; num2 = 1; } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= numCols; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } num++; num2++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void activosCustorios(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from ww w . j av a 2 s.c o m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String columna1 = ""; String persona_recibe = ""; String fecha = ""; String id_activo = ""; try { while (registros.next()) { columna1 = (registros.getString(1) != null) ? registros.getString(1) : ""; if (aux.compareTo(columna1) != 0) { tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 2)); aux = columna1; num2 = 1; } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i < numCols; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } id_activo = (registros.getString("id_activo") != null) ? registros.getString("id_activo") : ""; try { ResultSet rsCustodio = objDB.consulta( "select persona_recibe, toDateSQL(max(fecha)) as fecha from tbl_activo_custodio as AC inner join tbl_activo_personalizacion as AP " + "on AC.id_activo_personalizacion=AP.id_activo_personalizacion where AC.eliminado=false and AC.id_activo=" + id_activo + " group by persona_recibe,AP.id_activo_personalizacion order by AP.id_activo_personalizacion desc"); if (rsCustodio.next()) { persona_recibe = (rsCustodio.getString("persona_recibe") != null) ? rsCustodio.getString("persona_recibe") : ""; fecha = (rsCustodio.getString("fecha") != null) ? rsCustodio.getString("fecha") : ""; rsCustodio.close(); } } catch (Exception ex) { ex.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(persona_recibe, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_det.addCell( Addons.setCeldaPDF(fecha, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); num++; num2++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void ventas(HttpServletResponse response, ResultSet registros, DataBase objDB, String iva_vigente) { String[] cabTabla = new String[] { "Nro.", "RUC", "RAZON SOCIAL", "Nro. FAC.", "F. EMI.", "F. PAGO", "IP", "SUBTOTAL", "DESC.", "SUB. 0", "IVA " + iva_vigente, "TOTAL", "DEUDA", "RETENCION" }; float[] anchoTabla = new float[] { 20f, 55f, 90f, 60f, 45f, 40f, 60f, 35f, 30f, 35f, 35f, 35f, 35f, 35f }; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w w w. jav a 2 s . c om PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String id_factura_venta = "-1"; String columna2 = ""; float suma_parcial[] = { 0, 0, 0, 0, 0, 0, 0 }; float suma_total[] = { 0, 0, 0, 0, 0, 0, 0 }; float valor[] = { 0, 0, 0, 0, 0, 0, 0 }; int pos = 0; ResultSet retencion = null; try { while (registros.next()) { id_factura_venta = (registros.getString("id_factura_venta") != null) ? registros.getString("id_factura_venta") : "-1"; columna2 = (registros.getString(2) != null) ? registros.getString(2) : ""; pos = 0; if (aux.compareTo(columna2) != 0) { if (num > 1) { tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_parcial.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_parcial[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); suma_parcial[j] = 0; } } tbl_det.addCell(Addons.setCeldaPDF(columna2, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 1)); aux = columna2; num2 = 1; } //tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); String ax_anulada = ""; for (int i = 3; i <= numCols; i++) { if (i <= 8) { tbl_det.addCell(Addons.setCeldaPDF( ((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } else { ax_anulada = (registros.getString("anulada") != null) ? registros.getString("anulada") : ""; valor[pos] = (registros.getString(i) != null) ? registros.getFloat(i) : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor[pos]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); if (ax_anulada.compareTo("ANULADA") != 0) { suma_parcial[pos] = Float.parseFloat(this.formatoNumero.format(suma_parcial[pos])) + valor[pos]; suma_total[pos] = Float.parseFloat(this.formatoNumero.format(suma_total[pos])) + valor[pos]; } pos++; } } valor[6] = 0; try { retencion = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_venta where anulado=false and id_factura_venta=" + id_factura_venta + ";"); if (retencion.next()) { valor[6] = (retencion.getString("ret_impuesto_retenido") != null) ? retencion.getFloat("ret_impuesto_retenido") : 0; retencion.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor[6]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); suma_parcial[6] = Float.parseFloat(this.formatoNumero.format(suma_parcial[6])) + valor[6]; suma_total[6] = Float.parseFloat(this.formatoNumero.format(suma_total[6])) + valor[6]; num++; num2++; } tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_parcial.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_parcial[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 9, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_total.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_total[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void compras(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) {/*from ww w . j a v a 2s. c om*/ //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[6]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_factura_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } valor = (registros.getString("subtotal") != null) ? registros.getFloat("subtotal") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("descuento") != null) ? registros.getFloat("descuento") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; valor = (registros.getString("subtotal_0") != null) ? registros.getFloat("subtotal_0") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[2] = Float.parseFloat(this.formatoNumero.format(sumas[2])) + valor; valor = (registros.getString("iva_2") != null) ? registros.getFloat("iva_2") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[3] = Float.parseFloat(this.formatoNumero.format(sumas[3])) + valor; id_factura_compra = (registros.getString("id_factura_compra") != null) ? registros.getString("id_factura_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_factura_compra + " and documento='f'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[4] = Float.parseFloat(this.formatoNumero.format(sumas[4])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[5] = Float.parseFloat(this.formatoNumero.format(sumas[5])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void liquidaciones(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) { //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[5]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/*from w w w .ja v a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_liquidacion_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } valor = (registros.getString("subtotal") != null) ? registros.getFloat("subtotal") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("subtotal_0") != null) ? registros.getFloat("subtotal_0") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; valor = (registros.getString("iva_2") != null) ? registros.getFloat("iva_2") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[2] = Float.parseFloat(this.formatoNumero.format(sumas[2])) + valor; id_liquidacion_compra = (registros.getString("id_liquidacion_compra") != null) ? registros.getString("id_liquidacion_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_liquidacion_compra + " and documento='l'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[3] = Float.parseFloat(this.formatoNumero.format(sumas[3])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[4] = Float.parseFloat(this.formatoNumero.format(sumas[4])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void notasVenta(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) {/*from w ww . j ava2s . com*/ //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[2]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_nota_venta_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } id_nota_venta_compra = (registros.getString("id_nota_venta_compra") != null) ? registros.getString("id_nota_venta_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_nota_venta_compra + " and documento='v'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void cierreCaja(HttpServletResponse response, int id_sucursal_sesion, String fecha, DataBase objDB) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/* w w w. ja v a 2 s. co m*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); ResultSet ventas = objDB.consulta( "select vendedor,txt_forma_pago,sum(total) as total from vta_factura_venta where id_sucursal=" + id_sucursal_sesion + " and anulado=false and fecha_emision='" + fecha + "' group by vendedor,txt_forma_pago order by vendedor"); ResultSet retencion = null; PdfPTable tbl_det = new PdfPTable(new float[] { 70f, 40f, 120f }); try { String aux = ""; float ingresos = 0; float total_ingresos = 0; float efectivo = 0; float total_efectivo = 0; float ret = 0; float total_ret = 0; String vendedor = ""; String forma_pago = ""; float total = 0; tbl_det.addCell(Addons.setCeldaPDF("VENTAS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); while (ventas.next()) { vendedor = ventas.getString("vendedor") != null ? ventas.getString("vendedor") : ""; forma_pago = ventas.getString("txt_forma_pago") != null ? ventas.getString("txt_forma_pago") : ""; total = ventas.getString("total") != null ? ventas.getFloat("total") : 0; if (aux.compareTo(vendedor) != 0) { if (aux.compareTo("") != 0) { tbl_det.addCell(Addons.setCeldaPDF(" TOTAL ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(efectivo - ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF( "___________________________________________________________________________________________________________", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 3)); } tbl_det.addCell(Addons.setCeldaPDF(vendedor, Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 4, 3)); /* retenciones */ try { retencion = objDB.consulta( "select sum(R.ret_impuesto_retenido) as total from tbl_factura_venta as F inner join tbl_retencion_venta as R " + "on R.id_factura_venta=F.id_factura_venta where id_sucursal=" + id_sucursal_sesion + " and F.anulado=false and R.anulado=false and F.vendedor='" + vendedor + "' and ret_fecha_emision='" + fecha + "'"); if (retencion.next()) { ret = retencion.getString("total") != null ? retencion.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" RETENCIONES ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); ingresos += ret; total_ret += ret; } } catch (Exception ex) { } aux = vendedor; ingresos = 0; efectivo = 0; } ingresos += total; total_ingresos += total; if (forma_pago.compareTo("EFECTIVO") == 0) { efectivo += total; total_efectivo += total; //total_caja += total; } tbl_det.addCell(Addons.setCeldaPDF(" " + forma_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); } tbl_det.addCell(Addons.setCeldaPDF(" TOTAL ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(efectivo - ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setFilaBlanco(3, 10)); /* gastos */ tbl_det.addCell(Addons.setCeldaPDF("PAGOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); String tipo_pago = ""; float total_efectivo_pago = 0; float total_egreso = 0; try { ResultSet pagos = objDB.consulta( "select txt_tipo_pago,sum(abono) as total from vta_factura_compra_pago as f inner join tbl_comprobante_egreso as C on F.id_comprobante_egreso=C.id_comprobante_egreso where C.id_sucursal=" + id_sucursal_sesion + " and fecha_pago='" + fecha + "' group by txt_tipo_pago"); while (pagos.next()) { tipo_pago = pagos.getString("txt_tipo_pago") != null ? pagos.getString("txt_tipo_pago") : ""; float pago = pagos.getString("total") != null ? pagos.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" " + tipo_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(pago), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); total_egreso += pago; if (tipo_pago.compareTo("EFECTIVO") == 0) { total_efectivo_pago += pago; //total_caja -= total; } } pagos.close(); } catch (Exception e) { } tbl_det.addCell(Addons.setFilaBlanco(3, 10)); tbl_det.addCell(Addons.setCeldaPDF("TOTALES", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL VENTAS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL PAGOS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_egreso), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_efectivo - total_ret - total_efectivo_pago), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); ventas.close(); retencion.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void ingresosPeriodos(HttpServletResponse response, ResultSet emisiones, ResultSet recaudos, ResultSet xcobrar, ResultSet instalaciones, ResultSet otros) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w w w. ja v a 2 s . co m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ float[] anchoTabla = new float[] { 25f, 15f, 15f, 15f, 15f, 15f, 20f }; document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); /*PdfPTable tbl_tit = new PdfPTable(1); tbl_tit.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_tit.addCell(Addons.setCeldaPDF("SERVIVIO DE INTERNET", Font.TIMES_ROMAN, 10, Font.NORMAL, Element.ALIGN_LEFT, 0)); document.add(tbl_tit);*/ document.add(Addons.setCabeceraTabla(new String[] { "PERIODO", "INSTALACIONES", "OTROS INGRESOS", "PRE-FACTURADO", "EMITIDO", "POR COBRAR", "SUMATORIA" }, anchoTabla)); String[][] mat_emisiones = DatosDinamicos.ResultSetToMatriz(emisiones); String[][] mat_recaudos = DatosDinamicos.ResultSetToMatriz(recaudos); String[][] mat_xcobrar = DatosDinamicos.ResultSetToMatriz(xcobrar); String[][] mat_instalaciones = DatosDinamicos.ResultSetToMatriz(instalaciones); String[][] mat_otros = DatosDinamicos.ResultSetToMatriz(otros); PdfPTable tbl_det = new PdfPTable(anchoTabla); int pos = -1; float suma = 0; String matriz = ""; for (int i = 0; i < mat_emisiones.length; i++) { if (matriz.compareTo(mat_emisiones[i][0]) != 0) { tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][0], Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1, 4, 7)); matriz = mat_emisiones[i][0]; } tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][1], Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_instalaciones, mat_emisiones[i][1], 1, mat_emisiones[i][0]); suma = Float.valueOf(pos != -1 ? mat_instalaciones[pos][2] : "0"); tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_instalaciones[pos][2] : "0", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_otros, mat_emisiones[i][1], 1, mat_emisiones[i][0]); suma += Float.valueOf(pos != -1 ? mat_otros[pos][2] : "0"); tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_otros[pos][2] : "0", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][2], Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_recaudos, mat_emisiones[i][1], 1, mat_emisiones[i][0]); suma += Float.valueOf(pos != -1 ? mat_recaudos[pos][2] : "0"); tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_recaudos[pos][2] : "0", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_xcobrar, mat_emisiones[i][1], 1, mat_emisiones[i][0]); tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_xcobrar[pos][2] : "0", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_det.addCell(Addons.setCeldaPDF(Addons.redondear(String.valueOf(suma)), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void ingresosEgresos(HttpServletResponse response, int id_sucursal, String fecha, DataBase objDB, String banco, String caja) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w ww. j av a 2 s .c o m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); ResultSet ventas = objDB.consulta( "select CASE tipo_cobro WHEN 'e' THEN 'EFECTIVO' WHEN 'c' THEN 'CHEQUE' ELSE '' END AS txt_tipo_cobro," + "sum(total) as total from vta_comprobante_ingreso where id_sucursal=" + id_sucursal + " and anulado=false and fecha_actual='" + fecha + "' group by txt_tipo_cobro"); ResultSet retencion = null; PdfPTable tbl_det = new PdfPTable(new float[] { 130f, 40f, 60f }); try { float total_ingresos = 0; float total_efectivo = 0; float ret = 0; float total_ret = 0; String forma_pago = ""; float total = 0; tbl_det.addCell(Addons.setCeldaPDF("INGRESOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); while (ventas.next()) { forma_pago = ventas.getString("txt_tipo_cobro") != null ? ventas.getString("txt_tipo_cobro") : ""; total = ventas.getString("total") != null ? ventas.getFloat("total") : 0; total_ingresos += total; if (forma_pago.compareTo("EFECTIVO") == 0) { total_efectivo += total; } tbl_det.addCell(Addons.setCeldaPDF(" " + forma_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); } /* retenciones */ try { retencion = objDB.consulta( "select sum(R.ret_impuesto_retenido) as total from tbl_factura_venta as F inner join tbl_retencion_venta as R " + "on R.id_factura_venta=F.id_factura_venta where id_sucursal=" + id_sucursal + " and F.anulado=false and R.anulado=false and ret_fecha_emision='" + fecha + "'"); if (retencion.next()) { ret = retencion.getString("total") != null ? retencion.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" RETENCIONES ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); total_ret += ret; } } catch (Exception ex) { } /*tbl_det.addCell(Addons.setCeldaPDF(" TOTAL ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));*/ tbl_det.addCell(Addons.setFilaBlanco(3, 10)); /* gastos */ tbl_det.addCell(Addons.setCeldaPDF("EGRESOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); String tipo_pago = ""; float total_efectivo_pago = 0; float total_egreso = 0; try { ResultSet pagos = objDB.consulta( "select CASE tipo_pago WHEN 'e' THEN 'EFECTIVO' WHEN 'c' THEN 'CHEQUE' ELSE '' END AS txt_tipo_pago,sum(total) as total " + "from tbl_comprobante_egreso where id_sucursal=" + id_sucursal + " and anulado=false and fecha_actual='" + fecha + "' group by txt_tipo_pago"); while (pagos.next()) { tipo_pago = pagos.getString("txt_tipo_pago") != null ? pagos.getString("txt_tipo_pago") : ""; float pago = pagos.getString("total") != null ? pagos.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" " + tipo_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(pago), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); total_egreso += pago; if (tipo_pago.compareTo("EFECTIVO") == 0) { total_efectivo_pago += pago; } } pagos.close(); } catch (Exception e) { } tbl_det.addCell(Addons.setFilaBlanco(3, 10)); tbl_det.addCell(Addons.setCeldaPDF("TOTALES", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL INGRESOS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL EGRESOS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_egreso), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" INGRESOS - EGRESOS - RETENCIONES ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_ingresos - total_egreso - total_ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" INGRESOS (EFECTIVO) - EGRESOS (EFECTIVO) - RETENCIONES ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_efectivo - total_efectivo_pago - total_ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); ventas.close(); retencion.close(); /* transferencias al banco */ try { tbl_det.addCell(Addons.setFilaBlanco(3, 10)); tbl_det.addCell(Addons.setCeldaPDF("COMPROBANTES DE DIARIO CON BANCOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); ResultSet diarios = objDB.consulta( "select distinct C.detalle, C.total from tbl_comprobante_diario as C inner join tbl_comprobante_diario_detalle as D " + "on C.id_comprobante_diario=D.id_comprobante_diario where C.id_sucursal=" + id_sucursal + " and C.anulado=false and fecha_actual='" + fecha + "' " + "and D.id_plan_cuenta in (" + banco + "," + caja + ")"); while (diarios.next()) { ret = diarios.getString("total") != null ? diarios.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF( (diarios.getString("detalle") != null ? diarios.getString("detalle") : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); } diarios.close(); } catch (Exception ex) { } } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }