### Eclipse Workspace Patch 1.0 #P jverein diff --git src/de/jost_net/JVerein/gui/action/ProjektSaldoAction.java src/de/jost_net/JVerein/gui/action/ProjektSaldoAction.java new file mode 100644 index 0000000..7c17676 --- /dev/null +++ src/de/jost_net/JVerein/gui/action/ProjektSaldoAction.java @@ -0,0 +1,30 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.gui.action; + +import de.jost_net.JVerein.gui.view.ProjektSaldoView; +import de.willuhn.jameica.gui.Action; +import de.willuhn.jameica.gui.GUI; + +public class ProjektSaldoAction implements Action +{ + @Override + public void handleAction(Object context) + { + GUI.startView(ProjektSaldoView.class.getName(), null); + } +} diff --git src/de/jost_net/JVerein/gui/control/ProjektSaldoControl.java src/de/jost_net/JVerein/gui/control/ProjektSaldoControl.java new file mode 100644 index 0000000..dc3e3ed --- /dev/null +++ src/de/jost_net/JVerein/gui/control/ProjektSaldoControl.java @@ -0,0 +1,244 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.gui.control; + +import java.io.File; +import java.rmi.RemoteException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; + +import de.jost_net.JVerein.Einstellungen; +import de.jost_net.JVerein.gui.parts.ProjektSaldoList; +import de.jost_net.JVerein.io.ProjektSaldoZeile; +import de.jost_net.JVerein.io.ProjektSaldoPDF; +import de.jost_net.JVerein.util.Dateiname; +import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; +import de.willuhn.jameica.gui.AbstractControl; +import de.willuhn.jameica.gui.AbstractView; +import de.willuhn.jameica.gui.Action; +import de.willuhn.jameica.gui.GUI; +import de.willuhn.jameica.gui.Part; +import de.willuhn.jameica.gui.input.DateInput; +import de.willuhn.jameica.gui.parts.Button; +import de.willuhn.jameica.system.Application; +import de.willuhn.jameica.system.BackgroundTask; +import de.willuhn.jameica.system.Settings; +import de.willuhn.util.ApplicationException; +import de.willuhn.util.ProgressMonitor; + +public class ProjektSaldoControl extends AbstractControl +{ + + private ProjektSaldoList saldoList; + + private DateInput datumvon; + + private DateInput datumbis; + + private Settings settings = null; + + public ProjektSaldoControl(AbstractView view) + { + super(view); + settings = new Settings(this.getClass()); + settings.setStoreWhenRead(true); + } + + public DateInput getDatumvon() + { + if (datumvon != null) + { + return datumvon; + } + Calendar cal = Calendar.getInstance(); + Date d = new Date(); + try + { + d = new JVDateFormatTTMMJJJJ().parse(settings.getString("von", "01.01" + + cal.get(Calendar.YEAR))); + } + catch (ParseException e) + { + // + } + datumvon = new DateInput(d, new JVDateFormatTTMMJJJJ()); + return datumvon; + } + + public DateInput getDatumbis() + { + if (datumbis != null) + { + return datumbis; + } + Calendar cal = Calendar.getInstance(); + Date d = new Date(); + try + { + d = new JVDateFormatTTMMJJJJ().parse(settings.getString("bis", "31.12." + + cal.get(Calendar.YEAR))); + } + catch (ParseException e) + { + // + } + datumbis = new DateInput(d, new JVDateFormatTTMMJJJJ()); + return datumbis; + } + + public Button getStartAuswertungButton() + { + Button b = new Button("PDF", new Action() + { + @Override + public void handleAction(Object context) throws ApplicationException + { + starteAuswertung(); + } + }, null, true, "pdf.png"); // "true" defines this button as the default + // button + return b; + } + + public void handleStore() + { + // + } + + public Part getSaldoList() throws ApplicationException + { + try + { + if (getDatumvon().getValue() != null) + { + settings.setAttribute("von", + new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue())); + } + if (getDatumvon().getValue() != null) + { + settings.setAttribute("bis", + new JVDateFormatTTMMJJJJ().format((Date) getDatumbis().getValue())); + } + + if (saldoList == null) + { + saldoList = new ProjektSaldoList(null, + (Date) datumvon.getValue(), (Date) datumbis.getValue()); + } + else + { + settings.setAttribute("von", + new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue())); + + saldoList.setDatumvon((Date) datumvon.getValue()); + saldoList.setDatumbis((Date) datumbis.getValue()); + ArrayList zeile = saldoList.getInfo(); + saldoList.removeAll(); + for (ProjektSaldoZeile sz : zeile) + { + saldoList.addItem(sz); + } + } + } + catch (RemoteException e) + { + throw new ApplicationException(String.format("Fehler aufgetreten %s", + e.getMessage())); + } + return saldoList.getSaldoList(); + } + + private void starteAuswertung() throws ApplicationException + { + try + { + ArrayList zeile = saldoList.getInfo(); + + FileDialog fd = new FileDialog(GUI.getShell(), SWT.SAVE); + fd.setText("Ausgabedatei w�hlen."); + // + Settings settings = new Settings(this.getClass()); + // + String path = settings.getString("lastdir", + System.getProperty("user.home")); + if (path != null && path.length() > 0) + { + fd.setFilterPath(path); + } + fd.setFileName(new Dateiname("projektsaldo", "", Einstellungen + .getEinstellung().getDateinamenmuster(), "PDF").get()); + + final String s = fd.open(); + + if (s == null || s.length() == 0) + { + return; + } + + final File file = new File(s); + settings.setAttribute("lastdir", file.getParent()); + auswertungSaldoPDF(zeile, file, (Date) getDatumvon().getValue(), + (Date) getDatumbis().getValue()); + } + catch (RemoteException e) + { + throw new ApplicationException(String.format( + "Fehler beim Aufbau des Reports: %s", e.getMessage())); + } + } + + private void auswertungSaldoPDF( + final ArrayList zeile, final File file, + final Date datumvon, final Date datumbis) + { + BackgroundTask t = new BackgroundTask() + { + @Override + public void run(ProgressMonitor monitor) throws ApplicationException + { + try + { + new ProjektSaldoPDF(zeile, file, datumvon, datumbis); + GUI.getCurrentView().reload(); + } + catch (ApplicationException ae) + { + GUI.getStatusBar().setErrorText(ae.getMessage()); + throw ae; + } + } + + @Override + public void interrupt() + { + // + } + + @Override + public boolean isInterrupted() + { + return false; + } + }; + Application.getController().start(t); + } +} diff --git src/de/jost_net/JVerein/gui/navigation/MyExtension.java src/de/jost_net/JVerein/gui/navigation/MyExtension.java index 7962e19..08823d8 100644 --- src/de/jost_net/JVerein/gui/navigation/MyExtension.java +++ src/de/jost_net/JVerein/gui/navigation/MyExtension.java @@ -70,6 +70,7 @@ import de.jost_net.JVerein.gui.action.MitgliedskontoMahnungAction; import de.jost_net.JVerein.gui.action.MitgliedskontoRechnungAction; import de.jost_net.JVerein.gui.action.ProjektListAction; +import de.jost_net.JVerein.gui.action.ProjektSaldoAction; import de.jost_net.JVerein.gui.action.QIFBuchungsImportViewAction; import de.jost_net.JVerein.gui.action.SEPAKonvertierungAction; import de.jost_net.JVerein.gui.action.SpendenAction; @@ -199,6 +200,8 @@ new BuchungsListeAction(), "preferences-system-windows.png")); buchfuehrung.addChild(new MyItem(buchfuehrung, "Hibiscus-Buchungen", new BuchungsuebernahmeAction(), "hibiscus-icon-64x64.png")); + buchfuehrung.addChild(new MyItem(buchfuehrung, "Projekte", + new ProjektSaldoAction(), "summe.png")); buchfuehrung.addChild(new MyItem(buchfuehrung, "Buchungsklassen", new BuchungsklasseSaldoAction(), "summe.png")); buchfuehrung.addChild(new MyItem(buchfuehrung, "Jahressaldo", diff --git src/de/jost_net/JVerein/gui/parts/ProjektSaldoList.java src/de/jost_net/JVerein/gui/parts/ProjektSaldoList.java new file mode 100644 index 0000000..004eeec --- /dev/null +++ src/de/jost_net/JVerein/gui/parts/ProjektSaldoList.java @@ -0,0 +1,249 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.gui.parts; + +import java.rmi.RemoteException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; + +import org.eclipse.swt.widgets.Composite; + +import de.jost_net.JVerein.Einstellungen; +import de.jost_net.JVerein.io.ProjektSaldoZeile; +import de.jost_net.JVerein.rmi.Buchungsart; +import de.jost_net.JVerein.rmi.Projekt; +import de.willuhn.datasource.GenericIterator; +import de.willuhn.datasource.GenericObject; +import de.willuhn.datasource.pseudo.PseudoIterator; +import de.willuhn.datasource.rmi.DBIterator; +import de.willuhn.datasource.rmi.DBService; +import de.willuhn.datasource.rmi.ResultSetExtractor; +import de.willuhn.jameica.gui.Action; +import de.willuhn.jameica.gui.Part; +import de.willuhn.jameica.gui.formatter.CurrencyFormatter; +import de.willuhn.jameica.gui.parts.Column; +import de.willuhn.jameica.gui.parts.TablePart; +import de.willuhn.util.ApplicationException; + +public class ProjektSaldoList extends TablePart implements Part +{ + + private TablePart saldoList; + + private Date datumvon = null; + + private Date datumbis = null; + + public ProjektSaldoList(Action action, Date datumvon, Date datumbis) + { + super(action); + this.datumvon = datumvon; + this.datumbis = datumbis; + } + + public Part getSaldoList() throws ApplicationException + { + ArrayList zeile = null; + try + { + zeile = getInfo(); + + if (saldoList == null) + { + GenericIterator gi = PseudoIterator.fromArray(zeile + .toArray(new GenericObject[zeile.size()])); + + saldoList = new TablePart(gi, null); + saldoList.addColumn("Projekt", "projektbezeichnung", + null, false); + saldoList.addColumn("Buchungsart", "buchungsartbezeichnung"); + saldoList.addColumn("Einnahmen", "einnahmen", new CurrencyFormatter("", + Einstellungen.DECIMALFORMAT), false, Column.ALIGN_RIGHT); + saldoList.addColumn("Ausgaben", "ausgaben", new CurrencyFormatter("", + Einstellungen.DECIMALFORMAT), false, Column.ALIGN_RIGHT); + saldoList.addColumn("Umbuchungen", "umbuchungen", + new CurrencyFormatter("", Einstellungen.DECIMALFORMAT), false, + Column.ALIGN_RIGHT); + saldoList.setRememberColWidths(true); + saldoList.setSummary(false); + } + else + { + saldoList.removeAll(); + for (ProjektSaldoZeile sz : zeile) + { + saldoList.addItem(sz); + } + } + } + catch (RemoteException e) + { + throw new ApplicationException("Fehler aufgetreten" + e.getMessage()); + } + return saldoList; + } + + public ArrayList getInfo() throws RemoteException + { + ArrayList zeile = new ArrayList(); + Projekt projekt = null; + Buchungsart buchungsart = null; + Double einnahmen; + Double ausgaben; + Double umbuchungen; + Double suBukEinnahmen = new Double(0); + Double suBukAusgaben = new Double(0); + Double suBukUmbuchungen = new Double(0); + Double suEinnahmen = new Double(0); + Double suAusgaben = new Double(0); + Double suUmbuchungen = new Double(0); + + ResultSetExtractor rsd = new ResultSetExtractor() + { + @Override + public Object extract(ResultSet rs) throws SQLException + { + if (!rs.next()) + { + return new Double(0); + } + return new Double(rs.getDouble(1)); + } + }; + ResultSetExtractor rsi = new ResultSetExtractor() + { + @Override + public Object extract(ResultSet rs) throws SQLException + { + if (!rs.next()) + { + return Integer.valueOf(0); + } + return Integer.valueOf(rs.getInt(1)); + } + }; + + DBService service = Einstellungen.getDBService(); + DBIterator projekteIt = service.createList(Projekt.class); + projekteIt.setOrder("ORDER BY bezeichnung"); + while (projekteIt.hasNext()) + { + projekt = (Projekt) projekteIt.next(); + String sql = "select count(*) from buchung " + + "where datum >= ? and datum <= ? " + + "and projekt = ?"; + int anz = (Integer) service.execute(sql, new Object[] { datumvon, + datumbis, projekt.getID() }, rsi); + if (anz > 0) + { + zeile.add(new ProjektSaldoZeile(ProjektSaldoZeile.HEADER, projekt)); + DBIterator buchungsartenIt = service.createList(Buchungsart.class); + buchungsartenIt.setOrder("ORDER BY nummer"); + suBukEinnahmen = new Double(0); + suBukAusgaben = new Double(0); + suBukUmbuchungen = new Double(0); + + while (buchungsartenIt.hasNext()) + { + buchungsart = (Buchungsart) buchungsartenIt.next(); + sql = "select count(*) from buchung, buchungsart " + + "where datum >= ? and datum <= ? " + + "and buchung.buchungsart = buchungsart.id " + + "and buchungsart.id = ? " + + "and projekt = ?"; + anz = (Integer) service.execute(sql, new Object[] { datumvon, + datumbis, buchungsart.getID(), projekt.getID() }, rsi); + if (anz > 0) + { + sql = "select sum(betrag) from buchung, buchungsart " + + "where datum >= ? and datum <= ? " + + "and buchung.buchungsart = buchungsart.id " + + "and projekt = ?" + + "and buchungsart.id = ? and buchungsart.art = ?"; + einnahmen = (Double) service.execute(sql, new Object[] { datumvon, + datumbis, projekt.getID(), buchungsart.getID(), 0 }, rsd); + suBukEinnahmen += einnahmen; + ausgaben = (Double) service.execute(sql, new Object[] { datumvon, + datumbis, projekt.getID(), buchungsart.getID(), 1 }, rsd); + suBukAusgaben += ausgaben; + umbuchungen = (Double) service.execute(sql, new Object[] { datumvon, + datumbis, projekt.getID(), buchungsart.getID(), 2 }, rsd); + suBukUmbuchungen += umbuchungen; + zeile.add(new ProjektSaldoZeile(ProjektSaldoZeile.DETAIL, + buchungsart, einnahmen, ausgaben, umbuchungen)); + } + } + zeile.add(new ProjektSaldoZeile( + ProjektSaldoZeile.SALDOFOOTER, "Saldo" + " " + + projekt.getBezeichnung(), suBukEinnahmen, suBukAusgaben, + suBukUmbuchungen)); + zeile.add(new ProjektSaldoZeile( + ProjektSaldoZeile.SALDOGEWINNVERLUST, "Gewinn/Verlust" + " " + + projekt.getBezeichnung(), suBukEinnahmen + suBukAusgaben + + suBukUmbuchungen)); + suEinnahmen += suBukEinnahmen; + suAusgaben += suBukAusgaben; + suUmbuchungen += suBukUmbuchungen; + } + } + zeile.add(new ProjektSaldoZeile(ProjektSaldoZeile.HEADER, + "Alle Projekte")); + zeile.add(new ProjektSaldoZeile(ProjektSaldoZeile.GESAMTSALDOFOOTER, + "Saldo alle Projekte", + suEinnahmen, suAusgaben, suUmbuchungen)); + zeile.add(new ProjektSaldoZeile(ProjektSaldoZeile.GESAMTSALDOGEWINNVERLUST, + "Gewinn/Verlust alle Projekte", + suEinnahmen + suAusgaben + suUmbuchungen)); + + String sql = "select count(*) from buchung where datum >= ? and datum <= ? " + + "and buchung.buchungsart is null and not buchung.projekt is null"; + Integer anzahl = (Integer) service.execute(sql, new Object[] { datumvon, + datumbis }, rsi); + if (anzahl > 0) + { + zeile.add(new ProjektSaldoZeile( + ProjektSaldoZeile.NICHTZUGEORDNETEBUCHUNGEN, + "Anzahl Buchungen ohne Buchungsart: " + anzahl.toString())); + } + return zeile; + } + + public void setDatumvon(Date datumvon) + { + this.datumvon = datumvon; + } + + public void setDatumbis(Date datumbis) + { + this.datumbis = datumbis; + } + + @Override + public void removeAll() + { + saldoList.removeAll(); + } + + @Override + public synchronized void paint(Composite parent) throws RemoteException + { + super.paint(parent); + } + +} diff --git src/de/jost_net/JVerein/gui/view/ProjektSaldoView.java src/de/jost_net/JVerein/gui/view/ProjektSaldoView.java new file mode 100644 index 0000000..1a6e67e --- /dev/null +++ src/de/jost_net/JVerein/gui/view/ProjektSaldoView.java @@ -0,0 +1,72 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.gui.view; + +import de.jost_net.JVerein.gui.action.DokumentationAction; +import de.jost_net.JVerein.gui.control.ProjektSaldoControl; +import de.willuhn.jameica.gui.AbstractView; +import de.willuhn.jameica.gui.Action; +import de.willuhn.jameica.gui.GUI; +import de.willuhn.jameica.gui.parts.Button; +import de.willuhn.jameica.gui.parts.ButtonArea; +import de.willuhn.jameica.gui.util.LabelGroup; +import de.willuhn.util.ApplicationException; + +public class ProjektSaldoView extends AbstractView +{ + + @Override + public void bind() throws Exception + { + GUI.getView().setTitle("Projekte-Saldo"); + + final ProjektSaldoControl control = new ProjektSaldoControl( + this); + + LabelGroup group = new LabelGroup(getParent(), "Zeitraum"); + group.addLabelPair("von", control.getDatumvon()); + group.addLabelPair("bis", control.getDatumbis()); + + ButtonArea buttons = new ButtonArea(); + Button button = new Button("suchen", new Action() + { + @Override + public void handleAction(Object context) throws ApplicationException + { + control.getSaldoList(); + } + }, null, true, "system-search.png"); + buttons.addButton(button); + buttons.paint(this.getParent()); + + LabelGroup group2 = new LabelGroup(getParent(), "Saldo", true); + group2.addPart(control.getSaldoList()); + + ButtonArea buttons2 = new ButtonArea(); + buttons2.addButton("Hilfe", new DokumentationAction(), + DokumentationUtil.JAHRESSALDO, false, "help-browser.png"); + buttons2.addButton(control.getStartAuswertungButton()); + buttons2.paint(this.getParent()); + } + + @Override + public String getHelp() + { + return "

Projekte-Saldo

" + + "
"; + } +} \ No newline at end of file diff --git src/de/jost_net/JVerein/io/ProjektSaldoPDF.java src/de/jost_net/JVerein/io/ProjektSaldoPDF.java new file mode 100644 index 0000000..1844b7d --- /dev/null +++ src/de/jost_net/JVerein/io/ProjektSaldoPDF.java @@ -0,0 +1,142 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.io; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Date; + +import com.itextpdf.text.BaseColor; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.Element; + +import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; +import de.willuhn.jameica.gui.GUI; +import de.willuhn.logging.Logger; +import de.willuhn.util.ApplicationException; + +public class ProjektSaldoPDF +{ + + public ProjektSaldoPDF(ArrayList zeile, + final File file, Date datumvon, Date datumbis) + throws ApplicationException + { + try + { + FileOutputStream fos = new FileOutputStream(file); + String subtitle = new JVDateFormatTTMMJJJJ().format(datumvon) + " - " + + new JVDateFormatTTMMJJJJ().format(datumbis); + Reporter reporter = new Reporter(fos, "Projekte-Saldo", subtitle, + zeile.size()); + makeHeader(reporter); + + for (ProjektSaldoZeile pz : zeile) + { + switch (pz.getStatus()) + { + case ProjektSaldoZeile.HEADER: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_LEFT, new BaseColor(220, 220, 220), 4); + break; + } + case ProjektSaldoZeile.DETAIL: + { + reporter.addColumn( + (String) pz.getAttribute("buchungsartbezeichnung"), + Element.ALIGN_LEFT); + reporter.addColumn((Double) pz.getAttribute("einnahmen")); + reporter.addColumn((Double) pz.getAttribute("ausgaben")); + reporter.addColumn((Double) pz.getAttribute("umbuchungen")); + break; + } + case ProjektSaldoZeile.SALDOFOOTER: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_RIGHT); + reporter.addColumn((Double) pz.getAttribute("einnahmen")); + reporter.addColumn((Double) pz.getAttribute("ausgaben")); + reporter.addColumn((Double) pz.getAttribute("umbuchungen")); + break; + } + case ProjektSaldoZeile.SALDOGEWINNVERLUST: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_RIGHT); + reporter.addColumn((Double) pz.getAttribute("einnahmen")); + reporter.addColumn("", Element.ALIGN_LEFT, 2); + break; + } + case ProjektSaldoZeile.GESAMTSALDOFOOTER: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_LEFT); + reporter.addColumn((Double) pz.getAttribute("einnahmen")); + reporter.addColumn((Double) pz.getAttribute("ausgaben")); + reporter.addColumn((Double) pz.getAttribute("umbuchungen")); + break; + } + case ProjektSaldoZeile.GESAMTSALDOGEWINNVERLUST: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_LEFT); + reporter.addColumn((Double) pz.getAttribute("einnahmen")); + reporter.addColumn("", Element.ALIGN_LEFT, 2); + break; + } + case ProjektSaldoZeile.NICHTZUGEORDNETEBUCHUNGEN: + { + reporter.addColumn( + (String) pz.getAttribute("projektbezeichnung"), + Element.ALIGN_RIGHT, 4); + break; + } + } + } + GUI.getStatusBar().setSuccessText("Auswertung fertig."); + reporter.closeTable(); + reporter.close(); + fos.close(); + FileViewer.show(file); + } + catch (Exception e) + { + Logger.error("error while creating report", e); + throw new ApplicationException("Fehler", e); + } + } + + private void makeHeader(Reporter reporter) throws DocumentException + { + reporter.addHeaderColumn("Buchungsart", Element.ALIGN_CENTER, 90, + BaseColor.LIGHT_GRAY); + reporter.addHeaderColumn("Einnahmen", Element.ALIGN_CENTER, 45, + BaseColor.LIGHT_GRAY); + reporter.addHeaderColumn("Ausgaben", Element.ALIGN_CENTER, 45, + BaseColor.LIGHT_GRAY); + reporter.addHeaderColumn("Umbuchungen", Element.ALIGN_CENTER, 45, + BaseColor.LIGHT_GRAY); + reporter.createHeader(); + } +} \ No newline at end of file diff --git src/de/jost_net/JVerein/io/ProjektSaldoZeile.java src/de/jost_net/JVerein/io/ProjektSaldoZeile.java new file mode 100644 index 0000000..7365952 --- /dev/null +++ src/de/jost_net/JVerein/io/ProjektSaldoZeile.java @@ -0,0 +1,183 @@ +/********************************************************************** + * Copyright (c) by Heiner Jostkleigrewe + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, + * see . + * + * heiner@jverein.de + * www.jverein.de + **********************************************************************/ +package de.jost_net.JVerein.io; + +import java.rmi.RemoteException; + +import de.jost_net.JVerein.rmi.Buchungsart; +import de.jost_net.JVerein.rmi.Projekt; +import de.willuhn.datasource.GenericObject; + +/** + * Hilfs-Objekt + */ +public class ProjektSaldoZeile implements GenericObject +{ + + private Projekt projekt; + + private Buchungsart buchungsart; + + private String text; + + private Double umbuchungen; + + private Double einnahmen; + + private Double ausgaben; + + public static final int UNDEFINED = 0; + + public static final int HEADER = 1; + + public static final int DETAIL = 2; + + public static final int SALDOFOOTER = 3; + + public static final int SALDOGEWINNVERLUST = 4; + + public static final int GESAMTSALDOFOOTER = 5; + + public static final int GESAMTSALDOGEWINNVERLUST = 6; + + public static final int NICHTZUGEORDNETEBUCHUNGEN = 7; + + private int status = UNDEFINED; + + public ProjektSaldoZeile(int status, Projekt projekt) + { + this.projekt = projekt; + this.status = status; + this.buchungsart = null; + this.text = null; + this.umbuchungen = null; + this.einnahmen = null; + this.ausgaben = null; + } + + public ProjektSaldoZeile(int status, Buchungsart buchungsart, + Double einnahmen, Double ausgaben, Double umbuchungen) + { + this.status = status; + this.projekt = null; + this.buchungsart = buchungsart; + this.text = null; + this.umbuchungen = new Double(umbuchungen); + this.einnahmen = new Double(einnahmen); + this.ausgaben = new Double(ausgaben); + } + + public ProjektSaldoZeile(int status, String text, Double einnahmen, + Double ausgaben, Double umbuchungen) + { + this.status = status; + this.projekt = null; + this.buchungsart = null; + this.text = text; + this.umbuchungen = new Double(umbuchungen); + this.einnahmen = new Double(einnahmen); + this.ausgaben = new Double(ausgaben); + } + + public ProjektSaldoZeile(int status, String text, Double gewinnverlust) + { + this.status = status; + this.projekt = null; + this.buchungsart = null; + this.text = text; + this.umbuchungen = null; + this.einnahmen = new Double(gewinnverlust); + this.ausgaben = null; + } + + public ProjektSaldoZeile(int status, String text) + { + this.status = status; + this.projekt = null; + this.buchungsart = null; + this.text = text; + this.umbuchungen = null; + this.einnahmen = null; + this.ausgaben = null; + } + + public int getStatus() + { + return status; + } + + @Override + public Object getAttribute(String arg0) throws RemoteException + { + if (arg0.equals("projektbezeichnung")) + { + if (projekt == null && text != null) + { + return text; + } + return projekt != null ? projekt.getBezeichnung() : ""; + } + if (arg0.equals("buchungsartbezeichnung")) + { + return buchungsart != null ? buchungsart.getBezeichnung() : ""; + } + else if (arg0.equals("einnahmen")) + { + return einnahmen; + } + else if (arg0.equals("ausgaben")) + { + return ausgaben; + } + else if (arg0.equals("umbuchungen")) + { + return umbuchungen; + } + throw new RemoteException(String.format("Ung�ltige Spaltenbezeichung: %s", + arg0)); + } + + @Override + public String[] getAttributeNames() + { + return new String[] { "projektbezeichnung", + "buchungsartbezeichnung", "einnahmen", "ausgaben", + "umbuchungen" }; + } + + @Override + public String getID() throws RemoteException + { + return projekt.getID(); + } + + @Override + public String getPrimaryAttribute() + { + return "projektbezeichnung"; + } + + @Override + public boolean equals(GenericObject arg0) throws RemoteException + { + if (arg0 == null || !(arg0 instanceof ProjektSaldoZeile)) + { + return false; + } + return this.getID().equals(arg0.getID()); + } +} \ No newline at end of file