Skip to content

Commit

Permalink
Fix #163 (#167)
Browse files Browse the repository at this point in the history
* Fix #163

* Sollte von größer als bis sein

* Zwischenstand

* Final fix

* Und noch was

* Leerzeile auch bei Jahressaldo

* kleine Optimierung

* Weiterer Update

* Text ändern

* Remove ...
  • Loading branch information
JohannMaierhofer committed Mar 2, 2024
1 parent 416af37 commit 5e5d422
Show file tree
Hide file tree
Showing 13 changed files with 769 additions and 388 deletions.
77 changes: 10 additions & 67 deletions src/de/jost_net/JVerein/gui/control/BuchungsklasseSaldoControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

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;
Expand All @@ -33,81 +31,29 @@
import de.jost_net.JVerein.io.BuchungsklassesaldoPDF;
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 BuchungsklasseSaldoControl extends AbstractControl
public class BuchungsklasseSaldoControl extends SaldoControl
{

private BuchungsklasseSaldoList saldoList;

private DateInput datumvon;

private DateInput datumbis;

private Settings settings = null;

final static String AuswertungPDF = "PDF";

final static String AuswertungCSV = "CSV";

public BuchungsklasseSaldoControl(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()
Expand Down Expand Up @@ -147,29 +93,26 @@ public Part getSaldoList() throws ApplicationException
{
try
{
if (getDatumvon().getValue() != null)
if (getDatumvon().getDate() != null)
{
settings.setAttribute("von",
new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue()));
}
if (getDatumvon().getValue() != null)
{
new JVDateFormatTTMMJJJJ().format(getDatumvon().getDate()));
settings.setAttribute("bis",
new JVDateFormatTTMMJJJJ().format((Date) getDatumbis().getValue()));
new JVDateFormatTTMMJJJJ().format(getDatumbis().getDate()));
}

if (saldoList == null)
{
saldoList = new BuchungsklasseSaldoList(null,
(Date) datumvon.getValue(), (Date) datumbis.getValue());
datumvon.getDate(), datumbis.getDate());
}
else
{
settings.setAttribute("von",
new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue()));
new JVDateFormatTTMMJJJJ().format(getDatumvon().getDate()));

saldoList.setDatumvon((Date) datumvon.getValue());
saldoList.setDatumbis((Date) datumbis.getValue());
saldoList.setDatumvon(datumvon.getDate());
saldoList.setDatumbis(datumbis.getDate());
ArrayList<BuchungsklasseSaldoZeile> zeile = saldoList.getInfo();
saldoList.removeAll();
for (BuchungsklasseSaldoZeile sz : zeile)
Expand Down Expand Up @@ -217,8 +160,8 @@ private void starteAuswertung(String type) throws ApplicationException
final File file = new File(s);
settings.setAttribute("lastdir", file.getParent());

auswertungSaldo(zeile, file, (Date) getDatumvon().getValue(),
(Date) getDatumbis().getValue(), type);
auswertungSaldo(zeile, file, getDatumvon().getDate(),
getDatumbis().getDate(), type);
}
catch (RemoteException e)
{
Expand Down
74 changes: 19 additions & 55 deletions src/de/jost_net/JVerein/gui/control/JahressaldoControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
import de.jost_net.JVerein.gui.parts.JahressaldoList;
import de.jost_net.JVerein.io.JahressaldoPDF;
import de.jost_net.JVerein.io.SaldoZeile;
import de.jost_net.JVerein.rmi.Buchung;
import de.jost_net.JVerein.util.Dateiname;
import de.jost_net.JVerein.util.Geschaeftsjahr;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.jameica.gui.AbstractControl;
import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ;
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.SelectInput;
import de.willuhn.jameica.gui.parts.Button;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.system.BackgroundTask;
Expand All @@ -47,56 +44,14 @@
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

public class JahressaldoControl extends AbstractControl
public class JahressaldoControl extends SaldoControl
{

private JahressaldoList saldoList;

private SelectInput suchjahr;

private Settings settings = null;

public JahressaldoControl(AbstractView view)
{
super(view);
settings = new Settings(this.getClass());
settings.setStoreWhenRead(true);
}

public SelectInput getSuchJahr()
throws RemoteException, ApplicationException, ParseException
{
if (suchjahr != null)
{
return suchjahr;
}
DBIterator<Buchung> list = Einstellungen.getDBService()
.createList(Buchung.class);
list.setOrder("ORDER BY datum");
Buchung b = null;
Calendar von = Calendar.getInstance();
if (list.hasNext())
{
b = list.next();
von.setTime(new Geschaeftsjahr(b.getDatum()).getBeginnGeschaeftsjahr());
}
else
{
throw new ApplicationException(
"Abbruch! Es existiert noch keine Buchung");
}
Calendar bis = Calendar.getInstance();
ArrayList<Integer> jahre = new ArrayList<>();

for (int i = von.get(Calendar.YEAR); i <= bis.get(Calendar.YEAR); i++)
{
jahre.add(i);
}

suchjahr = new SelectInput(jahre, settings.getInt("jahr", jahre.get(0)));
// suchjahr.setPleaseChoose("Bitte auswählen");
suchjahr.setPreselected(settings.getInt("jahr", bis.get(Calendar.YEAR)));
return suchjahr;
}

public Button getStartAuswertungButton()
Expand All @@ -123,17 +78,25 @@ public Part getSaldoList() throws ApplicationException
{
try
{
settings.setAttribute("jahr", (Integer) getSuchJahr().getValue());
if (getDatumvon().getDate() != null)
{
settings.setAttribute("von",
new JVDateFormatTTMMJJJJ().format(getDatumvon().getDate()));
settings.setAttribute("bis",
new JVDateFormatTTMMJJJJ().format(getDatumbis().getDate()));
}

Calendar cal = Calendar.getInstance();
cal.setTime(getDatumvon().getDate());
int jahr = cal.get(Calendar.YEAR);

if (saldoList == null)
{
saldoList = new JahressaldoList(null,
new Geschaeftsjahr((Integer) getSuchJahr().getValue()));
saldoList = new JahressaldoList(null, new Geschaeftsjahr(jahr));
}
else
{
saldoList.setGeschaeftsjahr(
new Geschaeftsjahr((Integer) getSuchJahr().getValue()));
saldoList.setGeschaeftsjahr(new Geschaeftsjahr(jahr));
ArrayList<SaldoZeile> zeile = saldoList.getInfo();
saldoList.removeAll();
for (SaldoZeile sz : zeile)
Expand Down Expand Up @@ -182,9 +145,10 @@ private void starteAuswertung() throws ApplicationException

final File file = new File(s);
settings.setAttribute("lastdir", file.getParent());
Integer jahr = (Integer) suchjahr.getValue();

Geschaeftsjahr gj = new Geschaeftsjahr(jahr.intValue());
Calendar cal = Calendar.getInstance();
cal.setTime(getDatumvon().getDate());
int jahr = cal.get(Calendar.YEAR);
Geschaeftsjahr gj = new Geschaeftsjahr(jahr);

auswertungSaldoPDF(zeile, file, gj);
}
Expand Down
79 changes: 11 additions & 68 deletions src/de/jost_net/JVerein/gui/control/ProjektSaldoControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

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;
Expand All @@ -32,77 +30,25 @@
import de.jost_net.JVerein.io.ProjektSaldoZeile;
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
public class ProjektSaldoControl extends SaldoControl
{

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()
Expand All @@ -128,29 +74,26 @@ public Part getSaldoList() throws ApplicationException
{
try
{
if (getDatumvon().getValue() != null)
if (getDatumvon().getDate() != null)
{
settings.setAttribute("von",
new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue()));
}
if (getDatumvon().getValue() != null)
{
new JVDateFormatTTMMJJJJ().format(getDatumvon().getDate()));
settings.setAttribute("bis",
new JVDateFormatTTMMJJJJ().format((Date) getDatumbis().getValue()));
new JVDateFormatTTMMJJJJ().format(getDatumbis().getDate()));
}

if (saldoList == null)
{
saldoList = new ProjektSaldoList(null, (Date) datumvon.getValue(),
(Date) datumbis.getValue());
saldoList = new ProjektSaldoList(null, datumvon.getDate(),
datumbis.getDate());
}
else
{
settings.setAttribute("von",
new JVDateFormatTTMMJJJJ().format((Date) getDatumvon().getValue()));
new JVDateFormatTTMMJJJJ().format(getDatumvon().getDate()));

saldoList.setDatumvon((Date) datumvon.getValue());
saldoList.setDatumbis((Date) datumbis.getValue());
saldoList.setDatumvon(datumvon.getDate());
saldoList.setDatumbis(datumbis.getDate());
ArrayList<ProjektSaldoZeile> zeile = saldoList.getInfo();
saldoList.removeAll();
for (ProjektSaldoZeile sz : zeile)
Expand Down Expand Up @@ -196,8 +139,8 @@ private void starteAuswertung() throws ApplicationException

final File file = new File(s);
settings.setAttribute("lastdir", file.getParent());
auswertungSaldoPDF(zeile, file, (Date) getDatumvon().getValue(),
(Date) getDatumbis().getValue());
auswertungSaldoPDF(zeile, file, getDatumvon().getDate(),
getDatumbis().getDate());
}
catch (RemoteException e)
{
Expand Down

0 comments on commit 5e5d422

Please sign in to comment.