Skip to content

Commit

Permalink
Sollbuchungen manuell erstellen (#598)
Browse files Browse the repository at this point in the history
* Sollbuchungen manuell erstellen

* Code Formatter anwenden

---------

Co-authored-by: Johann Maierhofer <[email protected]>
  • Loading branch information
JohannMaierhofer and Johann Maierhofer authored Jan 23, 2025
1 parent 97c51a5 commit 43f32b7
Show file tree
Hide file tree
Showing 14 changed files with 702 additions and 66 deletions.
29 changes: 10 additions & 19 deletions src/de/jost_net/JVerein/gui/action/SollbuchungEditAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,31 @@ public class SollbuchungEditAction implements Action
@Override
public void handleAction(Object context) throws ApplicationException
{
MitgliedskontoNode mkn = null;
Mitgliedskonto mk = null;
MitgliedskontoNode mkn = null;

if (context != null && (context instanceof MitgliedskontoNode))
if (context instanceof Mitgliedskonto)
{
mk = (Mitgliedskonto) context;
}
else if (context instanceof MitgliedskontoNode)
{
mkn = (MitgliedskontoNode) context;
try
{
mk = (Mitgliedskonto) Einstellungen.getDBService().createObject(
Mitgliedskonto.class, mkn.getID());
mk = (Mitgliedskonto) Einstellungen.getDBService()
.createObject(Mitgliedskonto.class, mkn.getID());
}
catch (RemoteException e)
{
throw new ApplicationException(
"Fehler beim Editieren einer Sollbuchung");
}
}
else if (context != null && (context instanceof Mitgliedskonto))
{
mk = (Mitgliedskonto) context;
}
else
{
try
{
mk = (Mitgliedskonto) Einstellungen.getDBService().createObject(
Mitgliedskonto.class, null);
}
catch (Exception e)
{
throw new ApplicationException(
"Fehler bei der Erzeugung einer neuen Sollbuchung", e);
}
throw new ApplicationException("Keine Sollbuchung ausgewählt");
}
GUI.startView(new SollbuchungDetailView(MitgliedskontoNode.SOLL), mk);
GUI.startView(new SollbuchungDetailView(), mk);
}
}
47 changes: 30 additions & 17 deletions src/de/jost_net/JVerein/gui/action/SollbuchungNeuAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,39 @@ public void handleAction(Object context) throws ApplicationException
MitgliedskontoNode mkn = null;
Mitgliedskonto mk = null;

if (context == null || !(context instanceof MitgliedskontoNode))
if (context instanceof MitgliedskontoNode)
{
throw new ApplicationException("Keine Sollbuchung ausgewählt");
mkn = (MitgliedskontoNode) context;
try
{
Mitglied m = (Mitglied) Einstellungen.getDBService()
.createObject(Mitglied.class, mkn.getID());
mk = (Mitgliedskonto) Einstellungen.getDBService()
.createObject(Mitgliedskonto.class, null);
mk.setZahlungsweg(m.getZahlungsweg());
mk.setMitglied(m);
mk.setBetrag(0.0);
}
catch (RemoteException e)
{
throw new ApplicationException(
"Fehler bei der Erzeugung einer Sollbuchung");
}
}

mkn = (MitgliedskontoNode) context;
try
{
Mitglied m = (Mitglied) Einstellungen.getDBService().createObject(
Mitglied.class, mkn.getID());
mk = (Mitgliedskonto) Einstellungen.getDBService().createObject(
Mitgliedskonto.class, null);
mk.setZahlungsweg(m.getZahlungsweg());
mk.setMitglied(m);
}
catch (RemoteException e)
else
{
throw new ApplicationException(
"Fehler bei der Erzeugung einer Sollbuchung");
try
{
mk = (Mitgliedskonto) Einstellungen.getDBService()
.createObject(Mitgliedskonto.class, null);
mk.setBetrag(0.0);
}
catch (Exception e)
{
throw new ApplicationException(
"Fehler bei der Erzeugung einer neuen Sollbuchung", e);
}
}
GUI.startView(new SollbuchungDetailView(MitgliedskontoNode.SOLL), mk);
GUI.startView(new SollbuchungDetailView(), mk);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**********************************************************************
* 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/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

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

import de.jost_net.JVerein.gui.view.SollbuchungDetailView;
import de.jost_net.JVerein.rmi.Mitgliedskonto;
import de.jost_net.JVerein.rmi.SollbuchungPosition;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.dialogs.YesNoDialog;
import de.willuhn.jameica.gui.parts.TablePart;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

/**
* Löschen eines Formularfeldes
*/
public class SollbuchungPositionDeleteAction implements Action
{

@Override
public void handleAction(Object context) throws ApplicationException
{
if (context instanceof TablePart)
{
TablePart tp = (TablePart) context;
context = tp.getSelection();
}
if (context == null || !(context instanceof SollbuchungPosition))
{
throw new ApplicationException("Keine Sollbuchungsposition ausgewählt");
}
try
{
SollbuchungPosition position = (SollbuchungPosition) context;
if (position.isNewObject())
{
return;
}

YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER);
d.setTitle("Sollbuchungsposition löschen");
d.setText("Wollen Sie diese Sollbuchungsposition wirklich löschen?");

try
{
Boolean choice = (Boolean) d.open();
if (!choice.booleanValue())
{
return;
}
}
catch (Exception e)
{
Logger.error("Fehler beim Löschen der Sollbuchungsposition", e);
return;
}
position.delete();
// Betrag in Sollbuchung neu berechnen
Double betrag = 0.0;
Mitgliedskonto sollb = position.getSollbuchung();
ArrayList<SollbuchungPosition> sollbpList = sollb
.getSollbuchungPositionList();
for (SollbuchungPosition sollp : sollbpList)
{
betrag += sollp.getBetrag();
}
sollb.setBetrag(betrag);
sollb.store();
GUI.startView(SollbuchungDetailView.class.getName(), sollb);
GUI.getStatusBar().setSuccessText("Sollbuchungsposition gelöscht.");
}
catch (RemoteException e)
{
String fehler = "Fehler beim Löschen der Sollbuchungsposition";
GUI.getStatusBar().setErrorText(fehler);
Logger.error(fehler, e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**********************************************************************
* 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/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import de.jost_net.JVerein.gui.view.SollbuchungPositionView;
import de.jost_net.JVerein.rmi.SollbuchungPosition;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.util.ApplicationException;

public class SollbuchungPositionEditAction implements Action
{

@Override
public void handleAction(Object context) throws ApplicationException
{
SollbuchungPosition position = null;

if (context != null && (context instanceof SollbuchungPosition))
{
position = (SollbuchungPosition) context;
}
else
{
throw new ApplicationException("Keine Sollbuchungsposition ausgewählt");
}

GUI.startView(SollbuchungPositionView.class.getName(), position);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**********************************************************************
* 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/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import java.rmi.RemoteException;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.gui.view.SollbuchungPositionView;
import de.jost_net.JVerein.rmi.Mitgliedskonto;
import de.jost_net.JVerein.rmi.SollbuchungPosition;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

public class SollbuchungPositionNeuAction implements Action
{

@Override
public void handleAction(Object context) throws ApplicationException
{
Mitgliedskonto sollbuchung = null;
SollbuchungPosition position = null;

if (context != null && (context instanceof Mitgliedskonto))
{
sollbuchung = (Mitgliedskonto) context;
try
{
if (sollbuchung.isNewObject())
{
throw new ApplicationException(
"Vor dem Anlegen der Sollbuchungsposition muss die Sollbuchung gespeichert werden!");
}
position = (SollbuchungPosition) Einstellungen.getDBService()
.createObject(SollbuchungPosition.class, null);
position.setSollbuchung(sollbuchung.getID());
}
catch (RemoteException e)
{
Logger.error("Fehler", e);
throw new ApplicationException(
"Fehler bei der Erzeugung einer neuen Sollbuchungsposition", e);
}
}
else
{
throw new ApplicationException("Keine Sollbuchung ausgewählt");
}

GUI.startView(SollbuchungPositionView.class.getName(), position);
}
}
Loading

0 comments on commit 43f32b7

Please sign in to comment.