1305 lines
52 KiB
Java
1305 lines
52 KiB
Java
package it.acxent.contab;
|
|
|
|
import com.lowagie.text.Cell;
|
|
import com.lowagie.text.Chunk;
|
|
import com.lowagie.text.Document;
|
|
import com.lowagie.text.Element;
|
|
import com.lowagie.text.HeaderFooter;
|
|
import com.lowagie.text.Image;
|
|
import com.lowagie.text.PageSize;
|
|
import com.lowagie.text.Phrase;
|
|
import com.lowagie.text.pdf.PdfWriter;
|
|
import it.acxent.anag.AbiCab;
|
|
import it.acxent.anag.Banca;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.DoubleOperator;
|
|
import it.acxent.util.FileWr;
|
|
import it.acxent.util.PdfFontFactory;
|
|
import it.acxent.util.SimpleDateFormat;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.Serializable;
|
|
import java.sql.Date;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
import java.text.NumberFormat;
|
|
import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class DistintaRiba extends _ContabAdapter implements Serializable {
|
|
private static final long serialVersionUID = 7363737491608872716L;
|
|
|
|
private long id_distintaRiba;
|
|
|
|
private long id_banca;
|
|
|
|
private Banca banca;
|
|
|
|
private Date dataPresentazione;
|
|
|
|
private double importoScadenza;
|
|
|
|
private long flgStatoDistinta;
|
|
|
|
private long flgAccorpaScadenze;
|
|
|
|
private long flgContabilizzata;
|
|
|
|
private long timestampElaborazione;
|
|
|
|
private double importoManuale;
|
|
|
|
private double maxDistinta;
|
|
|
|
public static final long STATO_BOZZA = 0L;
|
|
|
|
public static final long STATO_PRESENTATA = 1L;
|
|
|
|
public DistintaRiba(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public DistintaRiba() {}
|
|
|
|
public Date getDataPresentazione() {
|
|
return this.dataPresentazione;
|
|
}
|
|
|
|
public void setDataPresentazione(Date data) {
|
|
this.dataPresentazione = data;
|
|
}
|
|
|
|
public double getImportoScadenza() {
|
|
return this.importoScadenza;
|
|
}
|
|
|
|
public void setImportoScadenza(double importo) {
|
|
this.importoScadenza = importo;
|
|
}
|
|
|
|
protected void deleteCascade() {
|
|
DocumentoScadenzaCR CR = new DocumentoScadenzaCR();
|
|
CR.setId_distintaRiba(getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CR, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza ds = (DocumentoScadenza)vec.nextElement();
|
|
ds.setId_distintaRiba(0L);
|
|
ds.save();
|
|
}
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
ResParm rp = new ResParm(true);
|
|
if (getFlgContabilizzata() == 1L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("ERRORE! Impossibile eliminare, la distinta è stata contabilizzata!");
|
|
return rp;
|
|
}
|
|
if (getFlgStatoDistinta() == 1L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("ERRORE! Impossibile eliminare, la distinta è stata presentata!");
|
|
return rp;
|
|
}
|
|
return rp;
|
|
}
|
|
|
|
public ResParm delete() {
|
|
return super.delete();
|
|
}
|
|
|
|
public ResParm save() {
|
|
return super.save();
|
|
}
|
|
|
|
public long getFlgStatoDistinta() {
|
|
return this.flgStatoDistinta;
|
|
}
|
|
|
|
public void setFlgStatoDistinta(long flgTipoIncasso) {
|
|
this.flgStatoDistinta = flgTipoIncasso;
|
|
}
|
|
|
|
public String getDescrizioneFlgStatoDistinta() {
|
|
String ret = "";
|
|
if (getFlgStatoDistinta() == 0L) {
|
|
ret = "Bozza";
|
|
} else if (getFlgStatoDistinta() == 1L) {
|
|
ret = "Presentata";
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
public Vectumerator<DistintaRiba> findByCR(DistintaRibaCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "SELECT * FROM DISTINTA_RIBA AS A ";
|
|
String s_Sql_Order = " order by A.dataPresentazione desc, A.id_distintaRiba desc ";
|
|
WcString wc = new WcString();
|
|
if (CR.getDataPresentazioneDa() != null)
|
|
wc.addWc(" A.dataPresentazione >= ? ");
|
|
if (CR.getDataPresentazioneA() != null)
|
|
wc.addWc(" A.dataPresentazione <= ? ");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
int dataCount = 0;
|
|
if (CR.getDataPresentazioneDa() != null) {
|
|
dataCount++;
|
|
stmt.setDate(dataCount, CR.getDataPresentazioneDa());
|
|
}
|
|
if (CR.getDataPresentazioneA() != null) {
|
|
dataCount++;
|
|
stmt.setDate(dataCount, CR.getDataPresentazioneA());
|
|
}
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public ByteArrayOutputStream creaReportPdf(DistintaRibaCR CR) {
|
|
ByteArrayOutputStream ba = new ByteArrayOutputStream();
|
|
CR.setFilePdf(getPathTmpFull() + "ReportPagamenti.pdf");
|
|
try {
|
|
this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F);
|
|
this.writer = PdfWriter.getInstance(this.document, ba);
|
|
Calendar cal = Calendar.getInstance();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
SimpleDateFormat sdfh = new SimpleDateFormat("hh:mm");
|
|
Phrase pH = new Phrase("Data/ora stampa: " + sdf.format(getToday()) + " " + sdfh.format(Long.valueOf(cal.getTimeInMillis())) + " pag. ");
|
|
HeaderFooter footer = new HeaderFooter(pH, true);
|
|
footer.setAlignment(2);
|
|
footer.setBorder(0);
|
|
this.document.setFooter(footer);
|
|
this.document.open();
|
|
boolean accorpaScadenze = false;
|
|
if (CR.getId_distintaRiba() > 0L) {
|
|
DistintaRiba bean = new DistintaRiba(getApFull());
|
|
bean.findByPrimaryKey(CR.getId_distintaRiba());
|
|
this.document = creaReport(bean, (bean.getFlgAccorpaScadenze() == 1L));
|
|
} else if (CR.getTimestampElaborazione() > 0L) {
|
|
Vectumerator<DistintaRiba> vec = findDistinteByTimestamp(CR.getTimestampElaborazione());
|
|
while (vec.hasMoreElements()) {
|
|
DistintaRiba distintaRiba = (DistintaRiba)vec.nextElement();
|
|
CR.setId_distintaRiba(distintaRiba.getId_distintaRiba());
|
|
this.document = creaReport(distintaRiba, (distintaRiba.getFlgAccorpaScadenze() == 1L));
|
|
if (vec.hasMoreElements()) {
|
|
this.document.setPageCount(0);
|
|
this.document.newPage();
|
|
}
|
|
}
|
|
}
|
|
this.document.close();
|
|
this.document = null;
|
|
FileOutputStream fos = new FileOutputStream(new File(CR.getFilePdf()));
|
|
fos.write(ba.toByteArray());
|
|
fos.close();
|
|
System.out.println("Creato file documento " + CR.getFilePdf());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return ba;
|
|
}
|
|
|
|
private Document creaReport(DistintaRiba bean, boolean accorpaScadenze) {
|
|
try {
|
|
prepareNewPdfCorpoDocument();
|
|
int cellLeading = 10;
|
|
NumberFormat nf = NumberFormat.getInstance();
|
|
nf.setMinimumFractionDigits(2);
|
|
nf.setMaximumFractionDigits(2);
|
|
int[] col = { 5, 5, 20, 5, 5 };
|
|
DoubleOperator dp = new DoubleOperator();
|
|
SimpleDateFormat df = getDataFormat();
|
|
float imgLogoWidth = getDocLogoWidth();
|
|
Image imgLogo = Image.getInstance(getDocBase() + getDocBase());
|
|
imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth);
|
|
Cell cell = new Cell();
|
|
cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F));
|
|
cell.addElement(new Chunk(" Distinta presentazione RI.BA. n. " +
|
|
bean.getId_distintaRiba() + " del " + df.format(bean.getDataPresentazione()), PdfFontFactory.PDF_fGrandeB));
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(bean.getBanca().getDescrizione(), PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
AbiCab abiCab = new AbiCab(getApFull());
|
|
abiCab.findByAbiCab(bean.getBanca().getAbi(), bean.getBanca().getCab());
|
|
cell = new Cell(new Chunk(abiCab.getAgenzia(), PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("IBAN: " + bean.getBanca().getIban(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
long totaleRicevute = 0L;
|
|
DocumentoScadenzaCR CRds = new DocumentoScadenzaCR();
|
|
CRds.setId_distintaRiba(bean.getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CRds, 0, 0);
|
|
if (accorpaScadenze)
|
|
vec = accorpaScadenze(vec);
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza ds = (DocumentoScadenza)vec.nextElement();
|
|
totaleRicevute++;
|
|
cell = new Cell(new Chunk("Ord.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Scadenza", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("ABI", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("CAB", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Banca", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(21);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(totaleRicevute), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(nf.format(ds.getImportoScadenza()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(df.format(ds.getDataScadenza()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getAbi(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getCab(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getBancaDesc(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(21);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Debitore", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(16);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Indirizzo", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(12);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Località", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Prov.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(2);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(ds.getDocumento().getClifor().getId_clifor()) + "-" + String.valueOf(ds.getDocumento().getClifor().getId_clifor()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(16);
|
|
cell.setMaxLines(1);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getIndirizzo(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(12);
|
|
cell.setMaxLines(1);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getCapComune() + " " + ds.getDocumento().getClifor().getCapComune(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
cell.setMaxLines(1);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getProvinciaComune(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(2);
|
|
cell.setMaxLines(1);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Rif.documento del debito", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(28);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Partita I.V.A.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Cod.Fiscale", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(7);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getListaDocumentiPdf(), PdfFontFactory.PDF_fPiccolo));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(28);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getPIva(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getCodFisc(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(7);
|
|
this.pdfcorpo.addCell(cell);
|
|
dp.add(ds.getImportoScadenza());
|
|
}
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("NR° TOTALE RICEVUTE RI.BA.", PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(totaleRicevute), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("IMPORTO TOTALE RICEVUTE RI.BA.", PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(nf.format(dp.getResult()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
this.document.add((Element)this.pdfcorpo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return this.document;
|
|
}
|
|
|
|
public long getId_distintaRiba() {
|
|
return this.id_distintaRiba;
|
|
}
|
|
|
|
public void setId_distintaRiba(long id_distintaRiba) {
|
|
this.id_distintaRiba = id_distintaRiba;
|
|
}
|
|
|
|
public long getId_banca() {
|
|
return this.id_banca;
|
|
}
|
|
|
|
public void setId_banca(long id_banca) {
|
|
this.id_banca = id_banca;
|
|
setBanca(null);
|
|
}
|
|
|
|
public Banca getBanca() {
|
|
this.banca = (Banca)getSecondaryObject(this.banca, Banca.class, getId_banca());
|
|
return this.banca;
|
|
}
|
|
|
|
public void setBanca(Banca banca) {
|
|
this.banca = banca;
|
|
}
|
|
|
|
public long getFlgAccorpaScadenze() {
|
|
return this.flgAccorpaScadenze;
|
|
}
|
|
|
|
public void setFlgAccorpaScadenze(long flgAccorpaScadenze) {
|
|
this.flgAccorpaScadenze = flgAccorpaScadenze;
|
|
}
|
|
|
|
public long getFlgContabilizzata() {
|
|
return this.flgContabilizzata;
|
|
}
|
|
|
|
public void setFlgContabilizzata(long flgContabilizzata) {
|
|
this.flgContabilizzata = flgContabilizzata;
|
|
}
|
|
|
|
public double getImportoTotale() {
|
|
DoubleOperator dop = new DoubleOperator();
|
|
if (getId_distintaRiba() > 0L) {
|
|
DocumentoScadenzaCR CR = new DocumentoScadenzaCR();
|
|
CR.setId_distintaRiba(getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CR, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza ds = (DocumentoScadenza)vec.nextElement();
|
|
dop.add(ds.getImportoScadenza());
|
|
}
|
|
}
|
|
return dop.getResult();
|
|
}
|
|
|
|
public Vectumerator<DocumentoScadenza> accorpaScadenze(Vectumerator<DocumentoScadenza> vec) {
|
|
HashMap<Date, DocumentoScadenza> hm = new HashMap<>();
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza ds = (DocumentoScadenza)vec.nextElement();
|
|
if (hm.get(ds.getDataScadenza()) == null) {
|
|
ds.setListaDocumenti(ds.getDocumento().getTipoDocumento().getCodice() + " - " + ds.getDocumento().getTipoDocumento().getCodice() + " del " + ds.getDocumento().getNumeroDocumento());
|
|
hm.put(ds.getDataScadenza(), ds);
|
|
continue;
|
|
}
|
|
DoubleOperator dop = new DoubleOperator();
|
|
DocumentoScadenza dshm = hm.get(ds.getDataScadenza());
|
|
dop.add(dshm.getImportoScadenza());
|
|
dop.add(ds.getImportoScadenza());
|
|
dshm.setImportoScadenza(dop.getResult());
|
|
dshm.setFlgAccorpata(1L);
|
|
StringBuilder sb = new StringBuilder(dshm.getListaDocumenti());
|
|
sb.append("<br>");
|
|
sb.append(ds.getDocumento().getTipoDocumento().getCodice() + " - " + ds.getDocumento().getTipoDocumento().getCodice() + " del " + ds.getDocumento().getNumeroDocumento());
|
|
dshm.setListaDocumenti(sb.toString());
|
|
hm.put(ds.getDataScadenza(), dshm);
|
|
}
|
|
vec = new Vectumerator();
|
|
Map<Date, DocumentoScadenza> map = hm;
|
|
for (Map.Entry<Date, DocumentoScadenza> entry : map.entrySet())
|
|
vec.add(entry.getValue());
|
|
vec.sort((o1, o2) -> o1.getDataScadenza().compareTo(o2.getDataScadenza()));
|
|
return vec;
|
|
}
|
|
|
|
public ResParm creaFile() {
|
|
ResParm rp = new ResParm(true);
|
|
try {
|
|
System.out.println("Inizio creazione file");
|
|
SimpleDateFormat df = new SimpleDateFormat("HHmm");
|
|
String orario = df.format(getNow()).replace(":", "");
|
|
String nomeFile = getBanca().getCodiceAlt() + "-" + getBanca().getCodiceAlt() + ".TXT";
|
|
String path = getDocBase() + getDocBase() + getParm("PATH_FILE_RIBA").getTesto();
|
|
if (!new File(path).exists())
|
|
new File(path).mkdirs();
|
|
String retPath = "../../" + getParm("PATH_FILE_RIBA").getTesto() + nomeFile;
|
|
String codiceSia = getParm("AZIENDA_CODICE_SIA").getTesto();
|
|
String abi = getBanca().getAbi();
|
|
String cab = getBanca().getCab();
|
|
String conto = getBanca().getConto();
|
|
String data = getDateInline(getDataPresentazione());
|
|
String pIvaAzienda = getParm("AZIENDA_PIVA").getTesto();
|
|
if (cab.isEmpty() || abi.isEmpty() || conto.isEmpty() || pIvaAzienda.isEmpty())
|
|
return new ResParm(false, "ERRORE! mancano gli estremi della banca o la partita iva dell'azienda");
|
|
long lenNomeFile = (long)nomeFile.length();
|
|
int fillerPrimaRiga = (int)(20L - lenNomeFile + 74L);
|
|
int fillerUltimaRiga = (int)(20L - lenNomeFile + 6L);
|
|
File fileExist = new File(path);
|
|
if (fileExist.exists())
|
|
fileExist.delete();
|
|
fileExist = null;
|
|
FileWr f = new FileWr(path);
|
|
f.setAppend(false);
|
|
f.setDosNl(true);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("IB");
|
|
sb.append(spaceRight(codiceSia, 5));
|
|
sb.append(spaceRight(abi, 5));
|
|
sb.append(data);
|
|
sb.append(spaceRight(nomeFile, 20));
|
|
sb.append(spaceLeft("", 74));
|
|
sb.append("E");
|
|
sb.append(spaceLeft("", 6));
|
|
f.writeLine(sb.toString());
|
|
long progressivo = 0L;
|
|
DoubleOperator importiNegativi = new DoubleOperator();
|
|
DocumentoScadenzaCR CR = new DocumentoScadenzaCR();
|
|
CR.setId_distintaRiba(getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CR, 0, 0);
|
|
if (getFlgAccorpaScadenze() == 1L)
|
|
vec = accorpaScadenze(vec);
|
|
while (vec.hasMoreElements()) {
|
|
progressivo++;
|
|
DocumentoScadenza scad = (DocumentoScadenza)vec.nextElement();
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("14");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceLeft("", 12));
|
|
sb.append(getDateInline(scad.getDataScadenza()));
|
|
sb.append("30000");
|
|
sb.append(zeroLeft(getImportoInCentesimi(scad.getImportoScadenza()), 13));
|
|
importiNegativi.add(scad.getImportoScadenza());
|
|
sb.append("-");
|
|
sb.append(spaceRight(abi, 5));
|
|
sb.append(spaceRight(cab, 5));
|
|
sb.append(spaceRight(conto, 12));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getAbi(), 5));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCab(), 5));
|
|
sb.append(spaceLeft("", 12));
|
|
sb.append(spaceLeft(codiceSia, 5));
|
|
sb.append("4");
|
|
sb.append(spaceLeft("", 22));
|
|
sb.append("E");
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("20");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight("C.T. EXPRESS S.C.R.L. VIA G. DI VITTORIO 50052 EMPOLI FI", 96));
|
|
sb.append(spaceRight("", 14));
|
|
f.writeLine(sb.toString());
|
|
String descrizioneCliente = scad.getDocumento().getClifor().getDescrizioneCliente();
|
|
String segmentoUno = descrizioneCliente.substring(0, (descrizioneCliente.length() > 19) ? 19 : descrizioneCliente.length());
|
|
String segmentoDue = "";
|
|
if (descrizioneCliente.length() > 19)
|
|
segmentoDue = descrizioneCliente.substring(19, (descrizioneCliente.length() > 39) ? 39 : descrizioneCliente.length());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("30");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(descrizioneCliente.substring(0, (descrizioneCliente.length() > 59) ? 59 : descrizioneCliente.length()), 60));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCodFisc(), 16));
|
|
sb.append(spaceRight("", 34));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("40");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getIndirizzo(), 30));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCapComune(), 5));
|
|
sb.append(spaceRight(
|
|
scad.getDocumento().getClifor().getDescrizioneComune() + " " + scad.getDocumento().getClifor().getDescrizioneComune(), 25));
|
|
sb.append(spaceRight("", 50));
|
|
f.writeLine(sb.toString());
|
|
String fatture = scad.getListaDocumenti().isEmpty() ? scad.getDocumento().getNumeroDocumento() : scad.getListaDocumenti();
|
|
fatture = fatture.replace("<br>", " ");
|
|
segmentoUno = fatture.substring(0, (fatture.length() > 39) ? 39 : fatture.length());
|
|
segmentoDue = "";
|
|
if (fatture.length() > 39)
|
|
segmentoDue = fatture.substring(39, (fatture.length() > 79) ? 79 : fatture.length());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("50");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(segmentoUno, 40));
|
|
sb.append(spaceRight(segmentoDue, 40));
|
|
sb.append(spaceRight("", 10));
|
|
sb.append(spaceRight(pIvaAzienda, 16));
|
|
sb.append(spaceRight("", 4));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("51");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(zeroLeft(progressivo, 10));
|
|
sb.append(spaceRight("C.T. EXPRESS S.C.R.L. ", 20));
|
|
sb.append(spaceRight("", 80));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("70");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight("", 110));
|
|
f.writeLine(sb.toString());
|
|
}
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("EF");
|
|
sb.append(spaceLeft(codiceSia, 5));
|
|
sb.append(spaceLeft(abi, 5));
|
|
sb.append(spaceLeft(data, 6));
|
|
sb.append(nomeFile);
|
|
sb.append(spaceLeft("", fillerUltimaRiga));
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(zeroLeft(getImportoInCentesimi(importiNegativi.getResult()), 15));
|
|
sb.append(zeroLeft(0, 15));
|
|
long numeroRecord = progressivo * 7L + 2L;
|
|
sb.append(zeroLeft(numeroRecord, 7));
|
|
sb.append(spaceLeft("", 24));
|
|
sb.append("E");
|
|
sb.append(spaceLeft("", 6));
|
|
f.writeLine(sb.toString());
|
|
f.closeFile();
|
|
setFlgStatoDistinta(1L);
|
|
save();
|
|
System.out.println("File creato!");
|
|
rp.setMsg(retPath);
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
rp.setException(e);
|
|
rp.setStatus(false);
|
|
}
|
|
return rp;
|
|
}
|
|
|
|
public long getTimestampElaborazione() {
|
|
return this.timestampElaborazione;
|
|
}
|
|
|
|
public void setTimestampElaborazione(long timestampElaborazione) {
|
|
this.timestampElaborazione = timestampElaborazione;
|
|
}
|
|
|
|
public void findDistintaByTimestampBanca(long l_timestamp, long id_banca) {
|
|
String s_Sql_Find = "SELECT * FROM DISTINTA_RIBA AS A ";
|
|
String s_Sql_Order = " ";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.timestampElaborazione = " + l_timestamp);
|
|
wc.addWc(" A.id_banca = " + id_banca);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public Vectumerator<DistintaRiba> findDistinteByTimestamp(long l_timestamp) {
|
|
String s_Sql_Find = "SELECT * FROM DISTINTA_RIBA AS A ";
|
|
String s_Sql_Order = " ";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.timestampElaborazione = " + l_timestamp);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public double getImportoManuale() {
|
|
return this.importoManuale;
|
|
}
|
|
|
|
public void setImportoManuale(double importoManuale) {
|
|
this.importoManuale = importoManuale;
|
|
}
|
|
|
|
public Vectumerator<DistintaRiba> findDistinte() {
|
|
String s_Sql_Find = "SELECT A.timestampElaborazione, A.dataPresentazione FROM DISTINTA_RIBA AS A ";
|
|
String s_Sql_Group = " GROUP BY A.timestampElaborazione ";
|
|
String s_Sql_Order = " ORDER BY A.dataPresentazione DESC limit 10";
|
|
WcString wc = new WcString();
|
|
wc.addWc("(A.flgStatoDistinta is null or A.flgStatoDistinta=0)");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString() + s_Sql_Group);
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public double getMaxDistinta() {
|
|
return this.maxDistinta;
|
|
}
|
|
|
|
public void setMaxDistinta(double maxDistinta) {
|
|
this.maxDistinta = maxDistinta;
|
|
}
|
|
|
|
public ResParm creaFile2() {
|
|
ResParm rp = new ResParm(true);
|
|
try {
|
|
System.out.println("Inizio creazione file");
|
|
SimpleDateFormat df = new SimpleDateFormat("HHmm");
|
|
String orario = df.format(getNow()).replace(":", "");
|
|
String nomeFile = getBanca().getCodiceAlt() + "-" + getBanca().getCodiceAlt() + ".TXT";
|
|
String path = getDocBase() + getDocBase() + getParm("PATH_FILE_RIBA").getTesto();
|
|
if (!new File(path).exists())
|
|
new File(path).mkdirs();
|
|
String retPath = "../../" + getParm("PATH_FILE_RIBA").getTesto() + nomeFile;
|
|
String codiceSia = getParm("AZIENDA_CODICE_SIA").getTesto();
|
|
String abi = getBanca().getAbi();
|
|
String cab = getBanca().getCab();
|
|
String conto = getBanca().getConto();
|
|
String data = getDateInline(getDataPresentazione());
|
|
String pIvaAzienda = getParm("AZIENDA_PIVA").getTesto();
|
|
if (cab.isEmpty() || abi.isEmpty() || conto.isEmpty() || pIvaAzienda.isEmpty())
|
|
return new ResParm(false, "ERRORE! mancano gli estremi della banca o la partita iva dell'azienda");
|
|
long lenNomeFile = (long)nomeFile.length();
|
|
int fillerPrimaRiga = (int)(20L - lenNomeFile + 74L);
|
|
int fillerUltimaRiga = (int)(20L - lenNomeFile + 6L);
|
|
File fileExist = new File(path);
|
|
if (fileExist.exists())
|
|
fileExist.delete();
|
|
fileExist = null;
|
|
FileWr f = new FileWr(path);
|
|
f.setAppend(false);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("IB");
|
|
sb.append(codiceSia);
|
|
sb.append(abi);
|
|
sb.append(data);
|
|
sb.append(nomeFile);
|
|
sb.append(spaceLeft("", fillerPrimaRiga));
|
|
sb.append("E");
|
|
sb.append(spaceLeft("", 6));
|
|
f.writeLine(sb.toString());
|
|
long progressivo = 1L;
|
|
DocumentoScadenzaCR CR = new DocumentoScadenzaCR();
|
|
CR.setId_distintaRiba(getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CR, 0, 0);
|
|
if (getFlgAccorpaScadenze() == 1L)
|
|
vec = accorpaScadenze(vec);
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza scad = (DocumentoScadenza)vec.nextElement();
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("14");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceLeft("", 11));
|
|
sb.append(getDateInline(scad.getDataScadenza()));
|
|
sb.append("30000");
|
|
sb.append(zeroLeft(getImportoInCentesimi(scad.getImportoScadenza()), 13));
|
|
sb.append("-");
|
|
sb.append(abi);
|
|
sb.append(cab);
|
|
sb.append(spaceRight(conto, 12));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getAbi(), 5));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCab(), 5));
|
|
sb.append(spaceLeft("", 12));
|
|
sb.append(codiceSia);
|
|
sb.append(spaceLeft("", 22));
|
|
sb.append("E");
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("20");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight("C.T. EXPRESS S.C.R.L. VI", 24));
|
|
sb.append(spaceRight("A G. DI VITTORIO 50052 E", 24));
|
|
sb.append(spaceRight("MPOLI FI", 24));
|
|
sb.append(spaceRight("", 24));
|
|
sb.append(spaceRight("", 14));
|
|
f.writeLine(sb.toString());
|
|
String descrizioneCliente = scad.getDocumento().getClifor().getDescrizioneCliente();
|
|
String segmentoUno = descrizioneCliente.substring(0, (descrizioneCliente.length() > 19) ? 19 : descrizioneCliente.length());
|
|
String segmentoDue = "";
|
|
if (descrizioneCliente.length() > 19)
|
|
segmentoDue = descrizioneCliente.substring(19, (descrizioneCliente.length() > 39) ? 39 : descrizioneCliente.length());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("30");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(segmentoUno, 20));
|
|
sb.append(spaceRight(segmentoDue, 20));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCodFisc(), 16));
|
|
sb.append(spaceRight("", 34));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("40");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getIndirizzo(), 20));
|
|
sb.append(spaceRight(scad.getDocumento().getClifor().getCapComune(), 5));
|
|
sb.append(spaceRight(
|
|
scad.getDocumento().getClifor().getDescrizioneComune() + scad.getDocumento().getClifor().getDescrizioneComune(), 25));
|
|
sb.append(spaceRight("", 50));
|
|
f.writeLine(sb.toString());
|
|
String fatture = scad.getListaDocumenti().isEmpty() ? scad.getDocumento().getNumeroDocumento() : scad.getListaDocumenti();
|
|
fatture = fatture.replace("<br>", " ");
|
|
segmentoUno = fatture.substring(0, (fatture.length() > 39) ? 39 : fatture.length());
|
|
segmentoDue = "";
|
|
if (fatture.length() > 39)
|
|
segmentoDue = fatture.substring(39, (fatture.length() > 79) ? 79 : fatture.length());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("50");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(spaceRight(segmentoUno, 40));
|
|
sb.append(spaceRight(segmentoDue, 40));
|
|
sb.append(spaceRight("", 10));
|
|
sb.append(spaceRight(pIvaAzienda, 16));
|
|
sb.append(spaceRight("", 4));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("51");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(zeroLeft(progressivo, 10));
|
|
sb.append(spaceRight("C.T. EXPRESS S.C.R.L. ", 20));
|
|
sb.append(spaceRight("", 80));
|
|
f.writeLine(sb.toString());
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("70");
|
|
sb.append(zeroLeft(progressivo, 7));
|
|
sb.append(zeroLeft(progressivo, 10));
|
|
sb.append(spaceRight("", 110));
|
|
f.writeLine(sb.toString());
|
|
progressivo++;
|
|
}
|
|
sb = new StringBuilder();
|
|
sb.append(" ");
|
|
sb.append("EF");
|
|
sb.append(codiceSia);
|
|
sb.append(abi);
|
|
sb.append(data);
|
|
sb.append(nomeFile);
|
|
sb.append(spaceLeft("", fillerUltimaRiga));
|
|
sb.append(zeroLeft(0, 7));
|
|
sb.append(zeroLeft(0, 15));
|
|
sb.append(zeroLeft(0, 15));
|
|
sb.append(zeroLeft(0, 7));
|
|
sb.append(spaceLeft("", 24));
|
|
sb.append("E");
|
|
sb.append(spaceLeft("", 6));
|
|
f.writeLine(sb.toString());
|
|
f.closeFile();
|
|
setFlgStatoDistinta(1L);
|
|
save();
|
|
System.out.println("File creato!");
|
|
rp.setMsg(retPath);
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
rp.setException(e);
|
|
rp.setStatus(false);
|
|
}
|
|
return rp;
|
|
}
|
|
|
|
private Document creaReportOld(DistintaRibaCR CR) {
|
|
try {
|
|
prepareNewPdfCorpoDocument();
|
|
int cellLeading = 10;
|
|
NumberFormat nf = NumberFormat.getInstance();
|
|
nf.setMinimumFractionDigits(2);
|
|
nf.setMaximumFractionDigits(2);
|
|
int[] col = { 5, 5, 20, 5, 5 };
|
|
DoubleOperator dp = new DoubleOperator();
|
|
SimpleDateFormat df = getDataFormat();
|
|
float imgLogoWidth = getDocLogoWidth();
|
|
Image imgLogo = Image.getInstance(getDocBase() + getDocBase());
|
|
imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth);
|
|
Cell cell = new Cell();
|
|
cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F));
|
|
cell.addElement(new Chunk(" Distinta presentazione RI.BA. n. " +
|
|
getId_distintaRiba() + " del " + df.format(getDataPresentazione()), PdfFontFactory.PDF_fGrandeB));
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(getBanca().getDescrizione(), PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
AbiCab abiCab = new AbiCab(getApFull());
|
|
abiCab.findByAbiCab(getBanca().getAbi(), getBanca().getCab());
|
|
cell = new Cell(new Chunk(abiCab.getAgenzia(), PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("IBAN: " + getBanca().getIban(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
long totaleRicevute = 0L;
|
|
DocumentoScadenzaCR CRds = new DocumentoScadenzaCR();
|
|
CRds.setId_distintaRiba(CR.getId_distintaRiba());
|
|
Vectumerator<DocumentoScadenza> vec = new DocumentoScadenza(getApFull()).findByCR(CRds, 0, 0);
|
|
if (CR.getFlgAccorpaScadenze() == 1L || getFlgAccorpaScadenze() == 1L)
|
|
vec = accorpaScadenze(vec);
|
|
while (vec.hasMoreElements()) {
|
|
DocumentoScadenza ds = (DocumentoScadenza)vec.nextElement();
|
|
cell = new Cell(new Chunk("Ord.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Scadenza", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("ABI", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("CAB", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Banca", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(1);
|
|
cell.setColspan(21);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(totaleRicevute), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(nf.format(ds.getImportoScadenza()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(df.format(ds.getDataScadenza()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getAbi(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getCab(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(3);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getBancaDesc(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(21);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Cod.cliente", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Debitore", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Indirizzo", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Località", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(6);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Prov.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(ds.getDocumento().getClifor().getId_clifor()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(4);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getDescrizioneCliente(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getIndirizzo(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getDescrizioneComune(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(6);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getProvinciaComune(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Rif.documento del debito", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Partita totaleRicevute.V.A.", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("Cod.Fiscale", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getListaDocumentiPdf(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(20);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getPIva(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(ds.getDocumento().getClifor().getCodFisc(), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(10);
|
|
this.pdfcorpo.addCell(cell);
|
|
dp.add(ds.getImportoScadenza());
|
|
totaleRicevute++;
|
|
}
|
|
cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fMedioB));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setBorder(0);
|
|
cell.setColspan(40);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("NR° TOTALE RICEVUTE RI.BA.", PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(String.valueOf(totaleRicevute), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk("IMPORTO TOTALE RICEVUTE RI.BA.", PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(0);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(15);
|
|
this.pdfcorpo.addCell(cell);
|
|
cell = new Cell(new Chunk(nf.format(dp.getResult()), PdfFontFactory.PDF_fMedio));
|
|
cell.setVerticalAlignment(4);
|
|
cell.setHorizontalAlignment(2);
|
|
cell.setLeading((float)cellLeading);
|
|
cell.setColspan(5);
|
|
this.pdfcorpo.addCell(cell);
|
|
this.document.add((Element)this.pdfcorpo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return this.document;
|
|
}
|
|
|
|
public ByteArrayOutputStream creaReportPdfOLD____(DistintaRibaCR CR) {
|
|
ByteArrayOutputStream ba = new ByteArrayOutputStream();
|
|
try {
|
|
this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F);
|
|
this.writer = PdfWriter.getInstance(this.document, ba);
|
|
Calendar cal = Calendar.getInstance();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
SimpleDateFormat sdfh = new SimpleDateFormat("hh:mm");
|
|
Phrase pH = new Phrase("Data/ora stampa: " + sdf.format(getToday()) + " " + sdfh.format(Long.valueOf(cal.getTimeInMillis())) + " pag. ");
|
|
HeaderFooter footer = new HeaderFooter(pH, true);
|
|
footer.setAlignment(2);
|
|
footer.setBorder(0);
|
|
this.document.setFooter(footer);
|
|
this.document.open();
|
|
CR.setFilePdf(getPathTmpFull() + "ReportPagamenti.pdf");
|
|
this.document.close();
|
|
this.document = null;
|
|
FileOutputStream fos = new FileOutputStream(new File(CR.getFilePdf()));
|
|
fos.write(ba.toByteArray());
|
|
fos.close();
|
|
System.out.println("Creato file documento " + CR.getFilePdf());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return ba;
|
|
}
|
|
}
|