Skip to content

Commit

Permalink
Korrekturen Splitbuchung (#156)
Browse files Browse the repository at this point in the history
* Korrekturen Splitbuchung

* Logger bleibt

* Lösche auch dependent neue Buchungen

* Merge
  • Loading branch information
JohannMaierhofer authored Feb 18, 2024
1 parent d85b3a7 commit 093ddce
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 12 deletions.
88 changes: 88 additions & 0 deletions src/de/jost_net/JVerein/gui/action/SplitBuchungDeleteAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**********************************************************************
* 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 <http://www.gnu.org/licenses/>.
*
* heiner@jverein.de
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import java.rmi.RemoteException;
import java.util.ArrayList;

import de.jost_net.JVerein.gui.control.BuchungsControl;
import de.jost_net.JVerein.io.SplitbuchungsContainer;
import de.jost_net.JVerein.rmi.Buchung;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

/**
* Loeschen einer Buchung.
*/
public class SplitBuchungDeleteAction implements Action
{
private BuchungsControl control;

public SplitBuchungDeleteAction(BuchungsControl control)
{
this.control = control;
}

@Override
public void handleAction(Object context) throws ApplicationException
{
if (context == null || !(context instanceof Buchung))
{
throw new ApplicationException("Keine Buchung ausgewählt");
}
try
{
Buchung bu = (Buchung) context;
if (((Buchung) context).isNewObject())
{
if (bu.getDependencyId() == -1)
{
SplitbuchungsContainer.get().remove(bu);
}
else
{
ArrayList<Buchung> container = SplitbuchungsContainer.get();
Buchung[] splitbuchungen = new Buchung[container.size()];
splitbuchungen = container.toArray(splitbuchungen);
int size = splitbuchungen.length;
int dependencyId = bu.getDependencyId();
for (int i = 0; i < size; i++)
{
if (splitbuchungen[i].getDependencyId() == dependencyId)
{
container.remove(splitbuchungen[i]);
}
}
}
}
else
{
BuchungDeleteAction action = new BuchungDeleteAction(true);
action.handleAction(context);
}
control.refreshSplitbuchungen();
}
catch (RemoteException e)
{
String fehler = "Fehler beim Löschen der Buchung.";
GUI.getStatusBar().setErrorText(fehler);
Logger.error(fehler, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void handleAction(Object context)
buch.setMitgliedskonto(master.getMitgliedskonto());
buch.setName(master.getName());
buch.setProjekt(master.getProjekt());
buch.setSplitId(new Long(master.getID()));
buch.setSplitId(Long.valueOf(master.getID()));
buch.setUmsatzid(master.getUmsatzid());
buch.setZweck(master.getZweck());
buch.setSpeicherung(false);
Expand All @@ -55,6 +55,7 @@ public void handleAction(Object context)
catch (RemoteException e)
{
Logger.error("Fehler", e);
GUI.getStatusBar().setErrorText(e.getMessage());
}
}
}
17 changes: 9 additions & 8 deletions src/de/jost_net/JVerein/gui/menu/SplitBuchungMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import de.jost_net.JVerein.Messaging.BuchungMessage;
import de.jost_net.JVerein.gui.action.BuchungAction;
import de.jost_net.JVerein.gui.action.BuchungBuchungsartZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungDeleteAction;
import de.jost_net.JVerein.gui.action.SplitBuchungDeleteAction;
/*import de.jost_net.JVerein.gui.action.BuchungBuchungsartZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungKontoauszugZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungMitgliedskontoZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungProjektZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungProjektZuordnungAction;*/
import de.jost_net.JVerein.gui.control.BuchungsControl;
import de.jost_net.JVerein.io.SplitbuchungsContainer;
import de.jost_net.JVerein.keys.SplitbuchungTyp;
Expand All @@ -48,15 +48,16 @@ public SplitBuchungMenu(BuchungsControl control)
{
addItem(new CheckedSplitBuchungItem("Bearbeiten", new BuchungAction(true),
"text-x-generic.png"));
addItem(new CheckedSplitBuchungItem("Buchungsart zuordnen",
/*addItem(new CheckedSplitBuchungItem("Buchungsart zuordnen",
new BuchungBuchungsartZuordnungAction(control), "view-refresh.png"));
addItem(new CheckedSplitBuchungItem("Mitgliedskonto zuordnen",
new BuchungMitgliedskontoZuordnungAction(control), "view-refresh.png"));
addItem(new CheckedSplitBuchungItem("Projekt zuordnen",
new BuchungProjektZuordnungAction(control), "view-refresh.png"));
addItem(new CheckedSplitBuchungItem("Kontoauszug zuordnen",
new BuchungKontoauszugZuordnungAction(control), "view-refresh.png"));
addItem(new DeleteSplitBuchungItem());
new BuchungKontoauszugZuordnungAction(control), "view-refresh.png"));*/
addItem(new DeleteSplitBuchungItem("Löschen...",
new SplitBuchungDeleteAction(control), "user-trash-full.png"));
addItem(new RestoreSplitBuchungItem());
}

Expand Down Expand Up @@ -88,9 +89,9 @@ public boolean isEnabledFor(Object o)

private static class DeleteSplitBuchungItem extends CheckedContextMenuItem
{
private DeleteSplitBuchungItem()
private DeleteSplitBuchungItem(String text, Action action, String icon)
{
super("Löschen...", new BuchungDeleteAction(true), "user-trash-full.png");
super(text, action, icon);
}

@Override
Expand Down
13 changes: 10 additions & 3 deletions src/de/jost_net/JVerein/gui/view/SplitBuchungView.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public void handleAction(Object context)
{
try
{
SplitbuchungsContainer.store();
control.refreshSplitbuchungen();
GUI.getStatusBar().setSuccessText(String.format
if (SplitbuchungsContainer.get().size() != 0)
{
SplitbuchungsContainer.store();
GUI.getStatusBar().setSuccessText(String.format
("%s Splitbuchungen gespeichert", SplitbuchungsContainer.getAnzahl()));
}
else
{
GUI.getStatusBar().setErrorText("Hauptbuchung fehlt");
}
control.refreshSplitbuchungen();
}
catch (Exception e)
{
Expand Down

0 comments on commit 093ddce

Please sign in to comment.