Skip to content

Commit

Permalink
Feature Lastschrift View (#239)
Browse files Browse the repository at this point in the history
* Zwischenstand

* Endstand

* Add Table Summary

* Filter fuer Mitglied Art

* Einstellungen abprüfen
  • Loading branch information
JohannMaierhofer authored Jul 23, 2024
1 parent 6aa99c7 commit 5c22a3d
Show file tree
Hide file tree
Showing 9 changed files with 456 additions and 1 deletion.
106 changes: 106 additions & 0 deletions src/de/jost_net/JVerein/gui/action/LastschriftDeleteAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**********************************************************************
* 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.rmi.Lastschrift;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.dialogs.YesNoDialog;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

/**
* Loeschen einer Lastschrift.
*/
public class LastschriftDeleteAction implements Action
{

@Override
public void handleAction(Object context) throws ApplicationException
{
if (context == null
|| (!(context instanceof Lastschrift) && !(context instanceof Lastschrift[])))
{
throw new ApplicationException("Keine Lastschrift ausgewählt");
}
try
{
Lastschrift[] la = null;
if (context instanceof Lastschrift)
{
la = new Lastschrift[1];
la[0] = (Lastschrift) context;
}
else if (context instanceof Lastschrift[])
{
la = (Lastschrift[]) context;
}
if (la == null)
{
return;
}
if (la.length == 0)
{
return;
}
if (la[0].isNewObject())
{
return;
}
YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER);
d.setTitle("Lastschrift" + (la.length > 1 ? "en" : "") + " löschen");
d.setText("Wollen Sie diese Lastschrift" + (la.length > 1 ? "en" : "")
+ " wirklich löschen?");
try
{
Boolean choice = (Boolean) d.open();
if (!choice.booleanValue())
{
return;
}
}
catch (Exception e)
{
Logger.error("Fehler beim Löschen der Lastschrift", e);
return;
}
int count = 0;
for (Lastschrift l : la)
{
l.delete();
count++;
}
if (count > 0)
{
GUI.getStatusBar().setSuccessText(String.format(
"%d Lastschrift" + (count != 1 ? "en" : "") + " gelöscht.", count));
}
else
{
GUI.getStatusBar().setErrorText("Keine Lastschrift gelöscht");
}
}
catch (RemoteException e)
{
String fehler = "Fehler beim Löschen der Lastschrift.";
GUI.getStatusBar().setErrorText(fehler);
Logger.error(fehler, e);
}
}
}
30 changes: 30 additions & 0 deletions src/de/jost_net/JVerein/gui/action/LastschriftListAction.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import de.jost_net.JVerein.gui.view.LastschriftListeView;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;

public class LastschriftListAction implements Action
{
@Override
public void handleAction(Object context)
{
GUI.startView(LastschriftListeView.class.getName(), null);
}
}
50 changes: 50 additions & 0 deletions src/de/jost_net/JVerein/gui/control/FilterControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class FilterControl extends AbstractControl
protected SelectInput suchadresstyp = null;

protected SelectInput status = null;

protected SelectInput art = null;

protected TextInput suchexternemitgliedsnummer = null;

Expand Down Expand Up @@ -255,6 +257,39 @@ public boolean isMitgliedStatusAktiv()
return status != null;
}

public Input getMitgliedArt()
{
if (art != null)
{
return art;
}
art = new SelectInput(
new String[] { "Mitglied", "Nicht-Mitglied" },
settings.getString(settingsprefix + "status.art", ""));
try
{
if (Einstellungen.getEinstellung().getKursteilnehmer())
{
art = new SelectInput(
new String[] { "Mitglied", "Nicht-Mitglied", "Kursteilnehmer" },
settings.getString(settingsprefix + "status.art", ""));
}
}
catch (Exception e)
{
Logger.error("Fehler beim lesen der Einstellungen");
}
art.setName("Mitgliedsart");
art.setPleaseChoose("Bitte auswählen");
art.addListener(new FilterListener());
return art;
}

public boolean isMitgliedArtAktiv()
{
return art != null;
}

public TextInput getSuchExterneMitgliedsnummer()
{
if (suchexternemitgliedsnummer != null)
Expand Down Expand Up @@ -914,6 +949,8 @@ public void handleAction(Object context) throws ApplicationException
suchadresstyp.setValue(null);
if (status != null)
status.setValue("Angemeldet");
if (art != null)
art.setValue(null);
if (suchexternemitgliedsnummer != null)
suchexternemitgliedsnummer.setValue("");
if (eigenschaftenabfrage != null)
Expand Down Expand Up @@ -1154,6 +1191,19 @@ public void saveFilterSettings() throws RemoteException
}
}

if (art != null)
{
String tmp = (String) art.getValue();
if (tmp != null && !tmp.equals("Bitte auswählen"))
{
settings.setAttribute(settingsprefix + "status.art", tmp);
}
else
{
settings.setAttribute(settingsprefix + "status.art", "");
}
}

if (suchexternemitgliedsnummer != null)
{
String tmp = (String) suchexternemitgliedsnummer.getValue();
Expand Down
158 changes: 158 additions & 0 deletions src/de/jost_net/JVerein/gui/control/LastschriftControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/**********************************************************************
* 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.control;

import java.rmi.RemoteException;
import java.util.Date;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.gui.menu.LastschriftMenu;
import de.jost_net.JVerein.rmi.Lastschrift;
import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBService;
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.Part;
import de.willuhn.jameica.gui.formatter.CurrencyFormatter;
import de.willuhn.jameica.gui.formatter.DateFormatter;
import de.willuhn.jameica.gui.parts.TablePart;
import de.willuhn.jameica.gui.parts.table.FeatureSummary;
import de.willuhn.logging.Logger;

public class LastschriftControl extends FilterControl
{


private TablePart lastschriftList;

public LastschriftControl(AbstractView view)
{
super(view);
settings = new de.willuhn.jameica.system.Settings(this.getClass());
settings.setStoreWhenRead(true);
}

public Part getLastschriftList() throws RemoteException
{
if (lastschriftList != null)
{
return lastschriftList;
}
lastschriftList = new TablePart(getLastschriften(), null);
lastschriftList.addColumn("Name", "name");
lastschriftList.addColumn("Vorname", "vorname");
lastschriftList.addColumn("Zweck", "verwendungszweck");
lastschriftList.addColumn("Betrag", "betrag",
new CurrencyFormatter("", Einstellungen.DECIMALFORMAT));
lastschriftList.addColumn("Fälligkeit", "faelligkeit",
new DateFormatter(new JVDateFormatTTMMJJJJ()));
lastschriftList.addColumn("IBAN", "iban");
lastschriftList.addColumn("Mandat", "mandatid");
lastschriftList.addColumn("Mandatdatum", "mandatdatum",
new DateFormatter(new JVDateFormatTTMMJJJJ()));
lastschriftList.setRememberColWidths(true);
lastschriftList.setContextMenu(new LastschriftMenu());
lastschriftList.setRememberOrder(true);
lastschriftList.addFeature(new FeatureSummary());
lastschriftList.setMulti(true);
return lastschriftList;
}

public void TabRefresh()
{
if (lastschriftList == null)
{
return;
}
try
{
lastschriftList.removeAll();
DBIterator<Lastschrift> lastschriften = getLastschriften();
while (lastschriften.hasNext())
{
lastschriftList.addItem(lastschriften.next());
}
}
catch (RemoteException e1)
{
Logger.error("Fehler", e1);
}
}

private DBIterator<Lastschrift> getLastschriften() throws RemoteException
{
DBService service = Einstellungen.getDBService();
DBIterator<Lastschrift> lastschriften = service
.createList(Lastschrift.class);
lastschriften.join("abrechnungslauf");
lastschriften.addFilter("abrechnungslauf.id = lastschrift.abrechnungslauf");
if (isMitgliedArtAktiv() && getMitgliedArt().getValue() != null)
{
String tmpArt = (String) getMitgliedArt().getValue();
if (tmpArt.equalsIgnoreCase("Kursteilnehmer"))
{
lastschriften.addFilter("(lastschrift.kursteilnehmer IS NOT NULL)");
}
else
{
lastschriften.join("mitglied");
lastschriften.addFilter("mitglied.id = lastschrift.mitglied");
if (tmpArt.equalsIgnoreCase("Mitglied"))
{
lastschriften.addFilter("(adresstyp = 1)");
}
else if (tmpArt.equalsIgnoreCase("Nicht-Mitglied"))
{
lastschriften.addFilter("(adresstyp > 1)");
}
}
}
if (isSuchnameAktiv() && getSuchname().getValue() != null)
{
String tmpSuchname = (String) getSuchname().getValue();
if (tmpSuchname.length() > 0)
{
lastschriften.addFilter("(lower(lastschrift.name) like ?)",
new Object[] { tmpSuchname.toLowerCase() + "%"});
}
}
if (isSuchtextAktiv() && getSuchtext().getValue() != null)
{
String tmpSuchtext = (String) getSuchtext().getValue();
if (tmpSuchtext.length() > 0)
{
lastschriften.addFilter("(lower(verwendungszweck) like ?)",
new Object[] { "%" + tmpSuchtext.toLowerCase() + "%"});
}
}
if (isDatumvonAktiv() && getDatumvon().getValue() != null)
{
lastschriften.addFilter("faelligkeit >= ?",
new Object[] { (Date) getDatumvon().getValue() });
}
if (isDatumbisAktiv() && getDatumbis().getValue() != null)
{
lastschriften.addFilter("faelligkeit <= ?",
new Object[] { (Date) getDatumbis().getValue() });
}

lastschriften.setOrder("ORDER BY name");

return lastschriften;
}

}
Loading

0 comments on commit 5c22a3d

Please sign in to comment.