Añado los fuentes de java

This commit is contained in:
2025-06-09 13:37:06 +02:00
parent d6c990e5d5
commit a97a6350ee
226 changed files with 57246 additions and 0 deletions
@@ -0,0 +1,440 @@
package com.tarisan.control;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Vector;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.tarisan.data.TaliquimediDet;
import com.tarisan.data.Tavolin;
import com.tarisan.excepcion.ExcepcionTarisan;
import com.tarisan.log.*;
import com.tarisan.util.*;
public class PersistenciaTaliquimedidet implements Constantes
{
/**
* Devuelve los resultados correspondientes para ese medico, especialidad, mes y anio, siguiendo la paginacion
* @param med
* @param espe
* @param mes
* @param anio
* @param pag
* @return
*/
public Vector buscarDetalles(int med, int mes, int anio, int pag)
{
Vector resultado = new Vector();;
TaliquimediDet talimedet = new TaliquimediDet();
Object[] aCondiciones = new Object[3];
StringBuffer sqlSelect = new StringBuffer();
String m = (mes<10)?"0"+mes:""+mes;
try
{
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
sqlSelect.append("Select MEDICO, FACTURA, APELLIDOS, ENTIDAD, COLECTIVO, poliza, orden, fecha_gasto, FECHA_FACTURA, especialidad, descripcion, importe from taliquimedidet");
sqlSelect.append(" where medico = ?");
sqlSelect.append(" and fecha_factura = ?");
sqlSelect.append(" order by fecha_gasto desc");
aCondiciones[0] = Integer.valueOf(med);
Calendar cal = Calendar.getInstance();
cal.set(anio, mes-1, Utilidades.ultimo_dia_mes(mes,anio));
aCondiciones[1] = new Date(cal.getTimeInMillis());
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString().toUpperCase(), aCondiciones);
Paginacion pg = new Paginacion();
pg.inicializarPaginacion(rs);
pg.realizarPaginacion(rs, pag);
for(int i=0;i<pg.getFilasPorPagina();i++)
{
rs.next();
//LogTarisan.logger.log(NivelLog.DEBUG, "llega 51");
talimedet = new TaliquimediDet();
talimedet.setMedico(rs.getInt("MEDICO"));
//LogTarisan.logger.log(NivelLog.DEBUG, "llega 54");
talimedet.setFactura(rs.getInt("FACTURA"));
talimedet.setApellidos(rs.getString("APELLIDOS"));
talimedet.setEntidad(rs.getInt("ENTIDAD"));
talimedet.setColectivo(rs.getInt("COLECTIVO"));
talimedet.setPoliza(rs.getDouble("POLIZA"));
talimedet.setOrden(rs.getInt("ORDEN"));
talimedet.setFecha_gasto(rs.getDate("FECHA_GASTO"));
talimedet.setEspecialidad(rs.getInt("ESPECIALIDAD"));
talimedet.setDescripcion(rs.getString("DESCRIPCION"));
talimedet.setImporte(rs.getDouble("IMPORTE"));
talimedet.setFecha_factura(rs.getDate("FECHA_FACTURA"));
resultado.add(talimedet);
}
rs.close();
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + resultado.size() +" detalles del medico " + med);
} catch (ExcepcionTarisan e){
LogTarisan.logger.log(NivelLog.ERROR, "Error al obtener los detalles del medico: "+med);
} catch (SQLException e) {
LogTarisan.logger.log(NivelLog.ERROR, "Error al obtener los detalles del medico: "+med);
}
return resultado;
}
/**
* Devuelve todos los resultados correspondientes para ese medico, especialidad, mes y anio
* @param med
* @param espe
* @param mes
* @param anio
* @return
*/
public Vector buscarDetalles(int med, int mes, int anio)
{
Vector resultado = new Vector();;
TaliquimediDet talimedet = new TaliquimediDet();
Object[] aCondiciones = new Object[2];
StringBuffer sqlSelect = new StringBuffer();
String m = (mes<10)?"0"+mes:""+mes;
try
{
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
sqlSelect.append("Select MEDICO, FACTURA, APELLIDOS, ENTIDAD, COLECTIVO, poliza, orden, fecha_gasto, FECHA_FACTURA, especialidad, descripcion, importe from taliquimedidet");
sqlSelect.append(" where medico = ?");
sqlSelect.append(" and fecha_factura = ?");
sqlSelect.append(" order by fecha_gasto desc");
aCondiciones[0] = Integer.valueOf(med);
Calendar cal = Calendar.getInstance();
cal.set(anio, mes-1, Utilidades.ultimo_dia_mes(mes,anio));
aCondiciones[1] = new Date(cal.getTimeInMillis());
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString().toUpperCase(), aCondiciones);
while(rs.next())
{
talimedet = new TaliquimediDet();
talimedet.setMedico(rs.getInt("MEDICO"));
talimedet.setFactura(rs.getInt("FACTURA"));
talimedet.setApellidos(rs.getString("APELLIDOS"));
talimedet.setEntidad(rs.getInt("ENTIDAD"));
talimedet.setColectivo(rs.getInt("COLECTIVO"));
talimedet.setPoliza(rs.getDouble("POLIZA"));
talimedet.setOrden(rs.getInt("ORDEN"));
talimedet.setFecha_gasto(rs.getDate("FECHA_GASTO"));
talimedet.setEspecialidad(rs.getInt("ESPECIALIDAD"));
talimedet.setDescripcion(rs.getString("DESCRIPCION"));
talimedet.setImporte(rs.getDouble("IMPORTE"));
talimedet.setFecha_factura(rs.getDate("FECHA_FACTURA"));
resultado.add(talimedet);
}
rs.close();
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + resultado.size() +" detalles del medico " + med);
} catch (ExcepcionTarisan e){
LogTarisan.logger.log(NivelLog.ERROR, "Error al obtener los detalles del medico: "+med);
} catch (SQLException e) {
LogTarisan.logger.log(NivelLog.ERROR, "Error al obtener los detalles del medico: "+med);
}
return resultado;
}
/**
* Genera el pdf de los detalles de la liquidación que está consultando el médico
* @param med
* @param espe
* @param mes
* @param anio
* @return
*/
public boolean generarPdfDetalle(int med, int mes, int anio)
{
boolean resul = false;
Double importe = 0.0;
DecimalFormat df = new DecimalFormat("#.##");
String m = (String) ((mes<10)?"0"+mes:""+mes);
int ultimo_dia = Utilidades.ultimo_dia_mes(mes, anio);
String fecha_factura = ultimo_dia+"/"+m+"/"+anio;
//String file_detalle="/root/apache-tomcat-6.0.20/webapps/tarisan/liquidaciones/detalle_"+med+"_"+m+"_"+anio+".pdf";
String file_detalle=ParametrosConfiguracion.ruta_pdf_liquidaciones + "detalle_"+med+"_"+m+"_"+anio+".pdf";
LogTarisan.logger.log(NivelLog.DEBUG, "Vamos a generar el pdf del detalle de la liquidacion "+file_detalle);
LogTarisan.logger.log(NivelLog.DEBUG, "Vamos a generar el pdf del detalle de la liquidacion para el medico "+med+", del mes "+mes+" del año "+anio+"\n\n\n\n");
Font fuente= new Font(Font.getFamily("ARIAL"), 7, Font.BOLD);
String encabezado = null;
String detalles_fra = null;
String pie = null;
Document documento = new Document(PageSize.A4);
//float[] colsWidth = {1f, 1f, 2f, 1f, 3f, 2f, 1f, 1f};
float[] colsWidth = {2f, 5f, 3f, 1f, 1f};
PdfPTable tabla=new PdfPTable(colsWidth);
tabla.setWidthPercentage(100);
// entidad, colectivo, poliza, orden, asegurado, descripcion, fecha_gasto
Vector detalles = this.buscarDetalles(med, mes, anio);
if(detalles.size()>0)
{
TaliquimediDet talimedet = new TaliquimediDet();
talimedet = (TaliquimediDet)detalles.get(0);
detalles_fra="Detalle de los honorarios del: "+m+"/"+anio+"\n"+ "Fecha Factura: "+talimedet.getFecha_factura()+"\n Factura Numero: "+talimedet.getMedico()+"/"+talimedet.getFactura()+"\n"+"\n"+"\n"+"\n";
Phrase para=new Phrase(detalles_fra,FontFactory.getFont("arial",10,Font.NORMAL,BaseColor.BLACK));
try {
PdfWriter.getInstance(documento, new FileOutputStream(file_detalle));
documento.open();
documento.add(para);
//Añadimos los encabezados de la tabla
PdfPCell celda1 =new PdfPCell (new Paragraph("Póliza",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
//PdfPCell celda2 =new PdfPCell (new Paragraph("Col.",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
//PdfPCell celda3 =new PdfPCell (new Paragraph("Póliza",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
//PdfPCell celda4 =new PdfPCell (new Paragraph("Orden",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
PdfPCell celda5 =new PdfPCell (new Paragraph("Asegurado",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
PdfPCell celda6 =new PdfPCell (new Paragraph("Descripción",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
PdfPCell celda7 =new PdfPCell (new Paragraph("Fecha gasto",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
PdfPCell celda8 =new PdfPCell (new Paragraph("Importe",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED)));
//LogTarisan.logger.log(NivelLog.DEBUG, "\n\n\n\nLlega 218\n\n\n\n");
celda1.setBorder(1);
celda1.setBorderWidthTop(1);
celda1.setBorderWidthBottom(1);
celda1.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda1.setVerticalAlignment(Element.ALIGN_MIDDLE);
/*celda2.setBorder(1);
celda2.setBorderWidthTop(1);
celda2.setBorderWidthBottom(1);
celda2.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda2.setVerticalAlignment(Element.ALIGN_MIDDLE);
celda3.setBorder(1);
celda3.setBorderWidthTop(1);
celda3.setBorderWidthBottom(1);
celda3.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda3.setVerticalAlignment(Element.ALIGN_MIDDLE);
celda4.setBorder(1);
celda4.setBorderWidthTop(1);
celda4.setBorderWidthBottom(1);
celda4.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda4.setVerticalAlignment(Element.ALIGN_MIDDLE);*/
celda5.setBorder(1);
celda5.setBorderWidthTop(1);
celda5.setBorderWidthBottom(1);
celda5.setHorizontalAlignment(Element.ALIGN_LEFT);
celda5.setVerticalAlignment(Element.ALIGN_MIDDLE);
celda6.setBorder(1);
celda6.setBorderWidthTop(1);
celda6.setBorderWidthBottom(1);
celda6.setHorizontalAlignment(Element.ALIGN_LEFT);
celda6.setVerticalAlignment(Element.ALIGN_MIDDLE);
celda7.setBorder(1);
celda7.setBorderWidthTop(1);
celda7.setBorderWidthBottom(1);
celda7.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda7.setVerticalAlignment(Element.ALIGN_MIDDLE);
celda8.setBorder(1);
celda8.setBorderWidthTop(1);
celda8.setBorderWidthBottom(1);
celda8.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda8.setVerticalAlignment(Element.ALIGN_MIDDLE);
tabla.addCell(celda1);/*
tabla.addCell(celda2);
tabla.addCell(celda3);
tabla.addCell(celda4);*/
tabla.addCell(celda5);
tabla.addCell(celda6);
tabla.addCell(celda7);
tabla.addCell(celda8);
//ahora recorremos el vector con todos los detalles de la liquidacion y vamos añadiendo los campos
for(int j=0;j<detalles.size();j++)
{
//LogTarisan.logger.log(NivelLog.DEBUG, "Llega 272: detalle "+j+" de"+detalles.size());
talimedet = (TaliquimediDet)detalles.get(j);
Double aux = talimedet.getPoliza();
Long aux2 = aux.longValue();
String poliza = talimedet.getEntidad()+"-"+talimedet.getColectivo()+"-"+aux2.toString()+"-"+talimedet.getOrden();
PdfPCell celda01 =new PdfPCell (new Paragraph(poliza,FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
//PdfPCell celda02 =new PdfPCell (new Paragraph(talimedet.getColectivo()+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
//PdfPCell celda03 =new PdfPCell (new Paragraph(aux2.toString(),FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
//PdfPCell celda04 =new PdfPCell (new Paragraph(talimedet.getOrden()+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
PdfPCell celda05 =new PdfPCell (new Paragraph(talimedet.getApellidos()+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
PdfPCell celda06 =new PdfPCell (new Paragraph(talimedet.getDescripcion()+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
PdfPCell celda07 =new PdfPCell (new Paragraph(Utilidades.formatear_fecha(talimedet.getFecha_gasto())+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
PdfPCell celda08 =new PdfPCell (new Paragraph(df.format(talimedet.getImporte())+"",FontFactory.getFont("arial",7,Font.NORMAL,BaseColor.BLACK)));
celda01.setBorder(0);
celda01.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda01.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda01.setBackgroundColor(BaseColor.LIGHT_GRAY);
/*
celda02.setBorder(0);
celda02.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda02.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda02.setBackgroundColor(BaseColor.LIGHT_GRAY);
celda03.setBorder(0);
celda03.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda03.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda03.setBackgroundColor(BaseColor.LIGHT_GRAY);
celda04.setBorder(0);
celda04.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda04.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda04.setBackgroundColor(BaseColor.LIGHT_GRAY);
*/
celda05.setBorder(0);
celda05.setHorizontalAlignment(Element.ALIGN_LEFT);
celda05.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda05.setBackgroundColor(BaseColor.LIGHT_GRAY);
celda06.setBorder(0);
celda06.setHorizontalAlignment(Element.ALIGN_LEFT);
celda06.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda06.setBackgroundColor(BaseColor.LIGHT_GRAY);
celda07.setBorder(0);
celda07.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda07.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda07.setBackgroundColor(BaseColor.LIGHT_GRAY);
celda08.setBorder(0);
celda08.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda08.setVerticalAlignment(Element.ALIGN_MIDDLE);
if((j % 2) == 0)
celda08.setBackgroundColor(BaseColor.LIGHT_GRAY);
tabla.addCell(celda01);/*
tabla.addCell(celda02);
tabla.addCell(celda03);
tabla.addCell(celda04);*/
tabla.addCell(celda05);
tabla.addCell(celda06);
tabla.addCell(celda07);
tabla.addCell(celda08);
importe = importe + talimedet.getImporte();
}
documento.add(tabla);
PdfPTable resumen=new PdfPTable(2);
resumen.setWidthPercentage(40);
PdfPCell celda_pie1 =new PdfPCell (new Paragraph("Importe total:",FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie1.setBorder(0);
PdfPCell celda_pie2 =new PdfPCell (new Paragraph(df.format(importe),FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie2.setBorder(0);
celda_pie2.setHorizontalAlignment(Element.ALIGN_RIGHT);
resumen.addCell(celda_pie1);
resumen.addCell(celda_pie2);
Double irpf = 0.0;
Double total = 0.0;
irpf = importe*0.15;
total = importe - irpf;
if(tieneRetencion(med))
{
celda_pie1 =new PdfPCell (new Paragraph("I.R.P.F. ",FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie2 =new PdfPCell (new Paragraph(df.format(irpf),FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie1.setBorder(0);
celda_pie2.setBorder(0);
celda_pie2.setHorizontalAlignment(Element.ALIGN_RIGHT);
//resumen.addCell(celda_pie1);
//resumen.addCell(celda_pie2);
}
celda_pie1 =new PdfPCell (new Paragraph("Total Liquidacion:",FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie2 =new PdfPCell (new Paragraph(df.format(total),FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
celda_pie1.setBorder(0);
celda_pie2.setBorder(0);
celda_pie1.setHorizontalAlignment(Element.ALIGN_RIGHT);
celda_pie2.setHorizontalAlignment(Element.ALIGN_RIGHT);
//resumen.addCell(celda_pie1);
//resumen.addCell(celda_pie2);
Paragraph fin=new Paragraph(pie,FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK));
//documento.add(tabla);
documento.add(new Paragraph("\n\n\n",FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
documento.add(resumen);
documento.add(new Paragraph("\n\n\n",FontFactory.getFont("arial",8,Font.NORMAL,BaseColor.BLACK)));
documento.add(fin);
documento.close();
LogTarisan.logger.log(NivelLog.DEBUG, "Suma total del detalle: "+Utilidades.formatearDouble(importe, 2));
} catch (FileNotFoundException e) {
LogTarisan.logger.log(NivelLog.ERROR, "No encuentro el fichero: "+file_detalle);
} catch (DocumentException e) {
LogTarisan.logger.log(NivelLog.ERROR, "Excepcion DocumentException: "+e.toString());
}
}
return resul;
}
/**
* Devuelve si el médico pasado por parámetro tiene retención o no.
* @param med
* @return
*/
public boolean tieneRetencion(int med)
{
boolean retencion = false;
String sql = "Select cla from ttmedico where ttmedico.medico = " + med;
Connection conexion;
try {
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
ResultSet resul = ParametrosConfiguracion.dataStore.seleccionar(conexion, sql);
if(resul.next())
{
if(resul.getString("cla").contains("M"))
{
retencion = true;
}
}
} catch (ExcepcionTarisan e) {
LogTarisan.logger.log(NivelLog.ERROR, "Excepcion tarisan al obtener la retencion del medico : "+med+", "+e.toString());
} catch (SQLException e) {
LogTarisan.logger.log(NivelLog.ERROR, "Excepcion sql al obtener la retencion del medico : "+med+", "+e.toString());
}
return retencion;
}
}