Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kontensaldo in Buchungsliste #590

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/de/jost_net/JVerein/gui/action/BuchungDeleteAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.rmi.RemoteException;

import de.jost_net.JVerein.Messaging.BuchungMessage;
import de.jost_net.JVerein.gui.control.BuchungsControl;
import de.jost_net.JVerein.io.SplitbuchungsContainer;
import de.jost_net.JVerein.rmi.Buchung;
import de.jost_net.JVerein.rmi.Jahresabschluss;
Expand All @@ -38,9 +39,12 @@ public class BuchungDeleteAction implements Action
{
private boolean splitbuchung;

public BuchungDeleteAction(boolean splitbuchung)
private BuchungsControl control;

public BuchungDeleteAction(BuchungsControl control, boolean splitbuchung)
{
this.splitbuchung = splitbuchung;
this.control = control;
}

@Override
Expand Down Expand Up @@ -149,6 +153,7 @@ else if (context instanceof Buchung[])
bu.getSpendenbescheinigung().delete();
bu.delete();
count++;
control.getBuchungsList();
}
else if (splitbuchung)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void handleAction(Object context) throws ApplicationException
}
else
{
BuchungDeleteAction action = new BuchungDeleteAction(true);
BuchungDeleteAction action = new BuchungDeleteAction(control, true);
action.handleAction(context);
}
control.refreshSplitbuchungen();
Expand Down
7 changes: 5 additions & 2 deletions src/de/jost_net/JVerein/gui/control/BuchungsControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class BuchungsControl extends AbstractControl

private de.willuhn.jameica.system.Settings settings;

private TablePart buchungsList;
private BuchungListTablePart buchungsList;

/* Split-Buchnungen */
private TablePart splitbuchungsList;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ private Long getSelectedBuchungsKlasseId() throws ApplicationException
}
}

public Part getBuchungsList() throws RemoteException
public BuchungListTablePart getBuchungsList() throws RemoteException
{
// Werte speichern
Date dv = (Date) getVondatum().getValue();
Expand Down Expand Up @@ -1346,9 +1346,11 @@ public String format(Object value)
buchungsList.addFeature(new FeatureSummary());
Application.getMessagingFactory()
.registerMessageConsumer(new BuchungMessageConsumer());
buchungsList.updateSaldo((Konto) getSuchKonto().getValue());
}
else
{
buchungsList.updateSaldo((Konto) getSuchKonto().getValue());
buchungsList.removeAll();

for (Buchung bu : query.get())
Expand Down Expand Up @@ -2347,4 +2349,5 @@ private void checkDate() throws ApplicationException
throw new ApplicationException("Von Datum ist nach Bis Datum!");
}
}

}
2 changes: 1 addition & 1 deletion src/de/jost_net/JVerein/gui/menu/BuchungMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public BuchungMenu(BuchungsControl control)
"edit-copy.png"));
addItem(new AufloesenItem("Auflösen", new SplitbuchungBulkAufloesenAction(),
"unlocked.png"));
addItem(new BuchungItem("Löschen", new BuchungDeleteAction(false),
addItem(new BuchungItem("Löschen", new BuchungDeleteAction(control, false),
"user-trash-full.png"));
addItem(ContextMenuItem.SEPARATOR);
if (geldkonto)
Expand Down
20 changes: 20 additions & 0 deletions src/de/jost_net/JVerein/gui/parts/BuchungListTablePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.rmi.Buchung;
import de.jost_net.JVerein.rmi.Konto;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.parts.TablePart;
import de.willuhn.jameica.gui.parts.table.Feature;
Expand All @@ -31,6 +32,8 @@
public class BuchungListTablePart extends TablePart
{

private Double saldo = null;

public BuchungListTablePart(Action action)
{
super(action);
Expand Down Expand Up @@ -67,6 +70,12 @@ protected Context createFeatureEventContext(Feature.Event e, Object data)
summary += " / " + "Gesamtbetrag:" + " "
+ Einstellungen.DECIMALFORMAT.format(sumBetrag) + " "
+ Einstellungen.CURRENCY;
if (saldo != null)
{
summary += " / " + "Kontosaldo:" + " "
+ Einstellungen.DECIMALFORMAT.format(saldo) + " "
+ Einstellungen.CURRENCY;
}
}
catch (RemoteException re)
{
Expand All @@ -77,4 +86,15 @@ protected Context createFeatureEventContext(Feature.Event e, Object data)
return ctx;
}

public void updateSaldo(Konto konto) throws RemoteException
{
if (konto != null)
{
saldo = konto.getSaldo();
}
else
{
saldo = null;
}
}
}
2 changes: 2 additions & 0 deletions src/de/jost_net/JVerein/rmi/Konto.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public interface Konto extends DBObject

public void setAfaMode(Integer afamode) throws RemoteException;

public Double getSaldo() throws RemoteException;

public DBIterator<Konto> getKontenEinesJahres(Geschaeftsjahr gj)
throws RemoteException;

Expand Down
51 changes: 50 additions & 1 deletion src/de/jost_net/JVerein/server/KontoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@
package de.jost_net.JVerein.server;

import java.rmi.RemoteException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.keys.AfaMode;
import de.jost_net.JVerein.keys.Kontoart;
import de.jost_net.JVerein.rmi.Anfangsbestand;
import de.jost_net.JVerein.rmi.Buchungsart;
import de.jost_net.JVerein.rmi.Buchungsklasse;
import de.jost_net.JVerein.rmi.Konto;
import de.jost_net.JVerein.util.Geschaeftsjahr;
import de.willuhn.datasource.db.AbstractDBObject;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBService;
import de.willuhn.datasource.rmi.ResultSetExtractor;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

Expand Down Expand Up @@ -474,7 +479,51 @@ public void setAfaMode(Integer afamode) throws RemoteException
{
setAttribute("afamode", afamode);
}


@Override
public Double getSaldo() throws RemoteException
{
ResultSetExtractor rsd = new ResultSetExtractor()
{
@Override
public Object extract(ResultSet rs) throws SQLException
{
if (!rs.next())
{
return Double.valueOf(0);
}
return Double.valueOf(rs.getDouble(1));
}
};
Double saldo = 0.0;
Date datum = null;
// Suchen ob Anfangsstand im Suchbereich enthalten ist
DBService service = Einstellungen.getDBService();
DBIterator<Anfangsbestand> anf = service.createList(Anfangsbestand.class);
anf.addFilter("konto = ? ", new Object[] { getID() });
anf.setOrder("ORDER BY datum desc");
if (anf != null && anf.hasNext())
{
Anfangsbestand anfang = anf.next();
saldo = anfang.getBetrag();
datum = anfang.getDatum();
}
if (datum != null)
{
String sql = "SELECT sum(buchung.betrag) FROM buchung"
+ " WHERE buchung.konto = ?" + " AND buchung.datum >= ?";
saldo += (Double) service.execute(sql, new Object[] { getID(), datum },
rsd);
}
else
{
String sql = "SELECT sum(buchung.betrag) FROM buchung"
+ " WHERE buchung.konto = ?";
saldo += (Double) service.execute(sql, new Object[] { getID() }, rsd);
}
return saldo;
}

@Override
public Object getAttribute(String fieldName) throws RemoteException
{
Expand Down
Loading