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

Sepa Check temporär deaktivieren #585

Merged
merged 7 commits into from
Jan 22, 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
79 changes: 8 additions & 71 deletions src/de/jost_net/JVerein/gui/action/MitgliedLastschriftAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,22 @@
package de.jost_net.JVerein.gui.action;

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

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.gui.control.AbrechnungSEPAControl;
import de.jost_net.JVerein.io.Adressbuch.Adressaufbereitung;
import de.jost_net.JVerein.keys.Zahlungsweg;
import de.jost_net.JVerein.rmi.Mitglied;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.dialogs.SimpleDialog;
import de.willuhn.jameica.gui.dialogs.YesNoDialog;
import de.willuhn.jameica.hbci.Settings;
import de.willuhn.jameica.hbci.rmi.SepaLastSequenceType;
import de.willuhn.jameica.hbci.rmi.SepaLastschrift;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

public class MitgliedLastschriftAction implements Action
{
private static String CONFIRM_TITLE = "SEPA-Check Fehler";

@Override
public void handleAction(Object context) throws ApplicationException
Expand All @@ -60,7 +57,7 @@ public void handleAction(Object context) throws ApplicationException
mZ = (Mitglied) Einstellungen.getDBService().createObject(
Mitglied.class, m.getZahlerID() + "");

if (!confirmDialog("Familienangehöriger",
if (!AbrechnungSEPAControl.confirmDialog("Familienangehöriger",
"Dieses Mitglied ist ein Familienangehöriger.\n\n"
+ "Als Konto wird das Konto des Zahlers belastet:\n"
+ "Zahler: " + mZ.getName() + "," + mZ.getVorname() + "\n"
Expand Down Expand Up @@ -117,79 +114,19 @@ public void handleAction(Object context) throws ApplicationException

private boolean checkSEPA(Mitglied m) throws RemoteException
{

// pruefe Zahlungsweg
if (m.getZahlungsweg() == null
|| m.getZahlungsweg() != Zahlungsweg.BASISLASTSCHRIFT)
{
abortDialog("Fehler", "Zahlungsweg ist nicht Basislastschrift");
return false;
}

// pruefe Mandatsdatum
if (m.getMandatDatum() == Einstellungen.NODATE)
{
if (!confirmDialog("Mandat-Datum fehlt", "Kein Mandat-Datum vorhanden"))
{
return false;
}
}

// Pruefe Sepa Gueltigkeit:
// Bei Mandaten älter als 3 Jahre muss es eine Lastschrift
// innerhalb der letzten 3 Jahre geben
Calendar sepagueltigkeit = Calendar.getInstance();
sepagueltigkeit.add(Calendar.MONTH, -36);
if (m.getMandatDatum().before(sepagueltigkeit.getTime()))
try
{
Date letzte_lastschrift = m.getLetzteLastschrift();
if (letzte_lastschrift == null
|| letzte_lastschrift.before(sepagueltigkeit.getTime()))
{
if (!confirmDialog("Mandat abgelaufen",
"Das Mandat-Datum ist älter als 36 Monate und es erfolgte keine Lastschrift in den letzten 36 Monaten."))
{
return false;
}
}
return m.checkSEPA();
}
return true;
}

private boolean confirmDialog(String title, String text)
{
YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER);
d.setTitle(title);
d.setText(text + "\nWeiter?");
try
catch (ApplicationException ae)
{
Boolean choice = (Boolean) d.open();
if (!choice.booleanValue())
if (!AbrechnungSEPAControl.confirmDialog(CONFIRM_TITLE,
ae.getLocalizedMessage() + "\nWeiter?"))
{
return false;
}
}
catch (Exception e)
{
Logger.error("Fehler bei Erstellen einer manuellen SEPA-Lastschrift", e);
return false;
}
return true;
}

private void abortDialog(String title, String text)
{
SimpleDialog d = new SimpleDialog(SimpleDialog.POSITION_CENTER);
d.setTitle(title);
d.setText(text);
try
{
d.open();
}
catch (Exception e)
{
Logger.error("Fehler bei Erstellen einer manuellen SEPA-Lastschrift", e);
}
}

}
57 changes: 57 additions & 0 deletions src/de/jost_net/JVerein/gui/control/AbrechnungSEPAControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.dialogs.YesNoDialog;
import de.willuhn.jameica.gui.input.CheckboxInput;
import de.willuhn.jameica.gui.input.DateInput;
import de.willuhn.jameica.gui.input.SelectInput;
Expand All @@ -60,6 +61,14 @@
public class AbrechnungSEPAControl extends AbstractControl
{

private static String CONFIRM_TITEL = "SEPA-Check temporär deaktivieren";

private static String CONFIRM_TEXT = "Bei einer SEPA-Lastschrift muß ein gültiges SEPA-Mandat vorliegen.\n"
+ "Wenn das Mandat älter als 3 Jahre ist, müssen in den letzten 3 Jahren Lastschriften durchgeführt worden sein.\n"
+ "Wählen Sie \"Ja\" nur, wenn diese Bedingungen für alle Mitglieder erfüllt sind.";

private static String CONFIRM_FEHLER = "Fehler beim Setzen der Checkbox";

private AbbuchungsmodusInput modus;

private DateInput stichtag = null;
Expand All @@ -82,6 +91,8 @@ public class AbrechnungSEPAControl extends AbstractControl

private CheckboxInput sepaprint;

private CheckboxInput sepacheck;

private SelectInput ausgabe;

private Settings settings = null;
Expand Down Expand Up @@ -311,6 +322,52 @@ public CheckboxInput getSEPAPrint()
return sepaprint;
}

public CheckboxInput getSEPACheck()
{
if (sepacheck != null)
{
return sepacheck;
}
sepacheck = new CheckboxInput(false);
sepacheck.addListener(new Listener()
{
@Override
public void handleEvent(Event event)
{
// Bei temporär deaktivieren den User fragen
if ((Boolean) sepacheck.getValue())
{
if (!confirmDialog(CONFIRM_TITEL, CONFIRM_TEXT))
{
sepacheck.setValue(false);
}
}
}
});
return sepacheck;
}

public static boolean confirmDialog(String title, String text)
{
YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER);
d.setTitle(title);
d.setText(text);
try
{
Boolean choice = (Boolean) d.open();
if (!choice.booleanValue())
{
return false;
}
}
catch (Exception e)
{
Logger.error(CONFIRM_FEHLER, e);
return false;
}
return true;
}

public SelectInput getAbbuchungsausgabe()
{
if (ausgabe != null)
Expand Down
1 change: 1 addition & 0 deletions src/de/jost_net/JVerein/gui/view/AbrechnungSEPAView.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void bind() throws Exception
group.addLabelPair("Rechnung Formular", control.getRechnungFormular());
group.addLabelPair("Rechnung Text", control.getRechnungstext());
group.addLabelPair("SEPA-Datei drucken", control.getSEPAPrint());
group.addLabelPair("SEPA-Check temporär deaktivieren", control.getSEPACheck());

if (!Einstellungen.getEinstellung().getKursteilnehmer())
{
Expand Down
36 changes: 13 additions & 23 deletions src/de/jost_net/JVerein/io/AbrechnungSEPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ private JVereinZahler abrechnungMitgliederSub(AbrechnungSEPAParam param,
{
return null;
}
checkSEPA(mZahler, monitor);
checkSEPA(param, mZahler, monitor);

counter++;

Expand Down Expand Up @@ -659,7 +659,7 @@ private void abbuchenZusatzbetraege(AbrechnungSEPAParam param,

if (zahlungsweg == Zahlungsweg.BASISLASTSCHRIFT)
{
checkSEPA(mZahler, monitor);
checkSEPA(param, mZahler, monitor);
}

counter++;
Expand Down Expand Up @@ -1257,35 +1257,25 @@ private Konto getKonto() throws RemoteException, ApplicationException
return k;
}

private void checkSEPA(Mitglied m, ProgressMonitor monitor)
throws RemoteException, ApplicationException
private void checkSEPA(AbrechnungSEPAParam param, Mitglied m,
ProgressMonitor monitor) throws RemoteException, ApplicationException
{
// Wenn nicht Basislastschrift, dann kein Check nötig
if (m.getZahlungsweg() == null
|| m.getZahlungsweg() != Zahlungsweg.BASISLASTSCHRIFT)
{
return;
}
// Ohne Mandat keine Lastschrift
if (m.getMandatDatum() == Einstellungen.NODATE)
{
monitor.log(Adressaufbereitung.getNameVorname(m)
+ ": Kein Mandat-Datum vorhanden.");
throw new ApplicationException(Adressaufbereitung.getNameVorname(m)
+ ": Kein Mandat-Datum vorhanden.");
}
// Bei Mandaten älter als 3 Jahre muss es eine Lastschrift
// innerhalb der letzten 3 Jahre geben
Calendar sepagueltigkeit = Calendar.getInstance();
sepagueltigkeit.add(Calendar.MONTH, -36);
if (m.getMandatDatum().before(sepagueltigkeit.getTime()))
// Check SEPA wenn nicht deaktiviert
if (!param.sepacheckdisable)
{
Date letzte_lastschrift = m.getLetzteLastschrift();
if (letzte_lastschrift == null
|| letzte_lastschrift.before(sepagueltigkeit.getTime()))
try
{
m.checkSEPA();
}
catch (ApplicationException ae)
{
String errortext = Adressaufbereitung.getNameVorname(m)
+ ": Das Mandat-Datum ist älter als 36 Monate und es"
+ " erfolgte keine Lastschrift in den letzten 36 Monaten.";
String errortext = ae.getLocalizedMessage();
monitor.log(errortext);
throw new ApplicationException(errortext);
}
Expand Down
3 changes: 3 additions & 0 deletions src/de/jost_net/JVerein/io/AbrechnungSEPAParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class AbrechnungSEPAParam

public final Boolean sepaprint;

public final Boolean sepacheckdisable;

public final File sepafileRCUR;

public final SepaVersion sepaVersion;
Expand Down Expand Up @@ -103,6 +105,7 @@ public AbrechnungSEPAParam(AbrechnungSEPAControl ac, File sepafileRCUR, SepaVers
rechnungsformular = (Formular) ac.getRechnungFormular().getValue();
rechnungstext = (String) ac.getRechnungstext().getValue();
sepaprint = (Boolean) ac.getSEPAPrint().getValue();
sepacheckdisable = (Boolean) ac.getSEPACheck().getValue();
this.pdffileRCUR = pdffileRCUR;
this.sepafileRCUR = sepafileRCUR;
this.sepaVersion = sepaVersion;
Expand Down
2 changes: 2 additions & 0 deletions src/de/jost_net/JVerein/rmi/Mitglied.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,6 @@ public void setIndividuellerBeitrag(Double individuellerbeitrag)

public void setLeitwegID(String leitwegid) throws RemoteException;

public boolean checkSEPA() throws RemoteException, ApplicationException;

}
37 changes: 37 additions & 0 deletions src/de/jost_net/JVerein/server/MitgliedImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
public class MitgliedImpl extends AbstractDBObject implements Mitglied
{

private static String FEHLER_ZAHLUNGSWEG = ": Der Zahlungsweg ist nicht Basislastschrift.";

private static String FEHLER_MANDAT = ": Es ist kein Mandat-Datum vorhanden.";

private static String FEHLER_ALTER = ": Das Mandat-Datum ist älter als 36 Monate und es sind in JVerein keine Lastschriften für die letzten 3 Jahre vorhanden.";

private transient Map<String, String> variable;

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -2022,4 +2028,35 @@ private static Beitragsgruppe beitragsgruppe()
}
}

public boolean checkSEPA() throws RemoteException, ApplicationException
{
if (getZahlungsweg() == null
|| getZahlungsweg() != Zahlungsweg.BASISLASTSCHRIFT)
{
tolot27 marked this conversation as resolved.
Show resolved Hide resolved
throw new ApplicationException(Adressaufbereitung.getNameVorname(this)
+ FEHLER_ZAHLUNGSWEG);
}
// Ohne Mandat keine Lastschrift
if (getMandatDatum() == Einstellungen.NODATE)
{
throw new ApplicationException(Adressaufbereitung.getNameVorname(this)
+ FEHLER_MANDAT);
}
// Bei Mandaten älter als 3 Jahre muss es eine Lastschrift
// innerhalb der letzten 3 Jahre geben
Calendar sepagueltigkeit = Calendar.getInstance();
sepagueltigkeit.add(Calendar.MONTH, -36);
if (getMandatDatum().before(sepagueltigkeit.getTime()))
{
Date letzte_lastschrift = getLetzteLastschrift();
if (letzte_lastschrift == null
|| letzte_lastschrift.before(sepagueltigkeit.getTime()))
{
throw new ApplicationException(Adressaufbereitung.getNameVorname(this)
+ FEHLER_ALTER);
}
}
return true;
}

}
Loading