Skip to content

Commit

Permalink
Fix issue #142 (#144)
Browse files Browse the repository at this point in the history
* Fix issue #142

* Fix Text
  • Loading branch information
JohannMaierhofer committed Feb 10, 2024
1 parent 35f1c95 commit 4458e0e
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 28 deletions.
18 changes: 18 additions & 0 deletions src/de/jost_net/JVerein/gui/control/EinstellungControl.java
Expand Up @@ -225,6 +225,8 @@ public class EinstellungControl extends AbstractControl
private SelectInput sepaland;

private SelectInput sepaversion;

private SelectInput ct1sepaversion;

private Input altersgruppen;

Expand Down Expand Up @@ -1269,6 +1271,21 @@ public SelectInput getSepaVersion() throws RemoteException
sepaversion.setPleaseChoose("Bitte auswählen");
return sepaversion;
}

public SelectInput getCt1SepaVersion() throws RemoteException
{
if (ct1sepaversion != null)
{
return ct1sepaversion;
}
List<SepaVersion> list = SepaVersion.getKnownVersions(
org.kapott.hbci.sepa.SepaVersion.Type.PAIN_001);
ct1sepaversion = new SelectInput(list,
Einstellungen.getEinstellung().getCt1SepaVersion());
ct1sepaversion.setAttribute("file");
ct1sepaversion.setPleaseChoose("Bitte auswählen");
return ct1sepaversion;
}

public Input getAltersgruppen() throws RemoteException
{
Expand Down Expand Up @@ -1871,6 +1888,7 @@ public void handleStoreAbrechnung()
SEPALandObject slo = (SEPALandObject) getDefaultSEPALand().getValue();
e.setDefaultLand(slo.getLand().getKennzeichen());
e.setSepaVersion((SepaVersion) sepaversion.getValue());
e.setCt1SepaVersion((SepaVersion) ct1sepaversion.getValue());
e.setSEPADatumOffset((Integer) sepadatumoffset.getValue());
e.setAbrlAbschliessen((Boolean) abrlabschliessen.getValue());
e.store();
Expand Down
13 changes: 9 additions & 4 deletions src/de/jost_net/JVerein/gui/control/PreNotificationControl.java
Expand Up @@ -64,6 +64,7 @@
import de.willuhn.jameica.gui.parts.Button;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.system.BackgroundTask;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.jameica.system.Settings;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;
Expand All @@ -90,13 +91,13 @@ public class PreNotificationControl extends AbstractControl

private SelectInput pdfModus = null;

public static final String NICHT_EINZELN = "eine PDF-Datei";
public static final String NICHT_EINZELN = "Eine PDF-Datei";

public static final String EINZELN_NUMMERIERT = "einzelne PDF-Dateien, nummeriert";
public static final String EINZELN_NUMMERIERT = "Einzelne PDF-Dateien, nummeriert";

public static final String EINZELN_MITGLIEDSNUMMER = "einzelne PDF-Dateien, mit Mitgliedsnummer";
public static final String EINZELN_MITGLIEDSNUMMER = "Einzelne PDF-Dateien, mit Mitgliedsnummer";

public static final String EINZELN_NUMMERIERT_UND_MNR = "einzelne PDF-Dateien, nummeriert mit Mitgliedsnummer";
public static final String EINZELN_NUMMERIERT_UND_MNR = "Einzelne PDF-Dateien, nummeriert mit Mitgliedsnummer";

private FormularInput formular = null;

Expand Down Expand Up @@ -296,6 +297,10 @@ public void handleAction(Object context)
settings.setAttribute("tab.selection", folder.getSelectionIndex());
generiere1ct(currentObject);
}
catch (OperationCanceledException oce)
{
throw oce;
}
catch (Exception e)
{
Logger.error("Fehler", e);
Expand Down
Expand Up @@ -41,7 +41,9 @@ public void bind() throws Exception
cont.addInput(control.getZahlungsweg());
cont.addInput(control.getSEPADatumOffset());
cont.addInput(control.getDefaultSEPALand());
cont.addLabelPair("SEPA XML-Version",
cont.addLabelPair("SEPA XML-Version - 1ct Überweisung",
control.getCt1SepaVersion());
cont.addLabelPair("SEPA XML-Version - Lastschrift",
control.getSepaVersion());
cont.addLabelPair("Arbeitsstunden Modell",
control.getArbeitsstundenmodel());
Expand Down
80 changes: 57 additions & 23 deletions src/de/jost_net/JVerein/io/Ct1Ueberweisung.java
Expand Up @@ -18,17 +18,28 @@

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.kapott.hbci.GV.SepaUtil;
import org.kapott.hbci.GV.generators.ISEPAGenerator;
import org.kapott.hbci.GV.generators.SEPAGeneratorFactory;
import org.kapott.hbci.sepa.SepaVersion;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.Variable.AllgemeineMap;
Expand All @@ -37,25 +48,24 @@
import de.jost_net.JVerein.keys.Ct1Ausgabe;
import de.jost_net.JVerein.rmi.Abrechnungslauf;
import de.jost_net.JVerein.rmi.Lastschrift;
import de.jost_net.JVerein.util.JVDateFormatDATETIME;
import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ;
import de.jost_net.JVerein.util.StringTool;
import de.jost_net.OBanToo.SEPA.SEPAException;
import de.jost_net.OBanToo.SEPA.Ueberweisung.Empfaenger;
import de.jost_net.OBanToo.SEPA.Ueberweisung.Ueberweisung;
import de.jost_net.OBanToo.StringLatin.Zeichen;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBService;
import de.willuhn.jameica.hbci.HBCI;
import de.willuhn.jameica.hbci.HBCIProperties;
import de.willuhn.jameica.hbci.gui.action.SepaUeberweisungMerge;
import de.willuhn.jameica.hbci.gui.dialogs.PainVersionDialog;
import de.willuhn.jameica.hbci.rmi.AuslandsUeberweisung;
import de.willuhn.jameica.hbci.rmi.HibiscusAddress;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.util.ApplicationException;

public class Ct1Ueberweisung
{
private Ueberweisung ueb;

public Ct1Ueberweisung()
{
Expand All @@ -79,30 +89,54 @@ public int write(Abrechnungslauf abrl, File file, Date faell,
private int dateiausgabe(Abrechnungslauf abrl, File file, Date faell,
Ct1Ausgabe ct1ausgabe, String verwendungszweck) throws Exception
{
ueb = new Ueberweisung();
ueb.setAusfuehrungsdatum(faell);
ueb.setBIC(Einstellungen.getEinstellung().getBic());
ueb.setIBAN(Einstellungen.getEinstellung().getIban());
ueb.setMessageID(abrl.getID() + " "
+ new JVDateFormatDATETIME().format(abrl.getDatum()));
ueb.setName(Einstellungen.getEinstellung().getName());
ueb.setSammelbuchung(false);

SepaVersion sepaVersion;
if (Einstellungen.getEinstellung().getCt1SepaVersion() != null)
{
sepaVersion = Einstellungen.getEinstellung().getCt1SepaVersion();
}
else
{
PainVersionDialog d = new PainVersionDialog(org.kapott.hbci.sepa.SepaVersion.Type.PAIN_001);
sepaVersion = (SepaVersion) d.open();
if (sepaVersion == null)
{
throw new OperationCanceledException();
}
}
Properties ls_properties = new Properties();
ls_properties.setProperty("src.bic", Einstellungen.getEinstellung().getBic());
ls_properties.setProperty("src.iban", Einstellungen.getEinstellung().getIban());
ls_properties.setProperty("src.name", Einstellungen.getEinstellung().getName().toUpperCase());
long epochtime = Calendar.getInstance().getTimeInMillis();
String epochtime_string = Long.toString(epochtime);
DateFormat ISO_DATE = new SimpleDateFormat(SepaUtil.DATE_FORMAT);
ls_properties.setProperty("sepaid", epochtime_string);
ls_properties.setProperty("pmtinfid", epochtime_string);
ls_properties.setProperty("date", ISO_DATE.format(faell) );
ls_properties.setProperty("batchbook", "false");
int counter = 0;
DBIterator<Lastschrift> it = getIterator(abrl);
while (it.hasNext())
{
Lastschrift ls = (Lastschrift) it.next();
Empfaenger e = new Empfaenger();
e.setBetrag(new BigDecimal("0.01"));
e.setBic(ls.getBIC());
e.setIban(ls.getIBAN());
e.setName(ls.getName());
e.setReferenz(ls.getMandatID());
e.setVerwendungszweck(eval(ls, verwendungszweck));
ueb.add(e);
ls_properties.setProperty(SepaUtil.insertIndex("dst.bic", counter), StringUtils.trimToEmpty(ls.getBIC()));
ls_properties.setProperty(SepaUtil.insertIndex("dst.iban", counter), StringUtils.trimToEmpty(ls.getIBAN()));
ls_properties.setProperty(SepaUtil.insertIndex("dst.name", counter), StringUtils.trimToEmpty(ls.getMitglied()
.getKontoinhaber(1).toUpperCase()));
ls_properties.setProperty(SepaUtil.insertIndex("btg.value", counter), (new BigDecimal("0.01")).toString());
ls_properties.setProperty(SepaUtil.insertIndex("btg.curr", counter), HBCIProperties.CURRENCY_DEFAULT_DE);
ls_properties.setProperty(SepaUtil.insertIndex("usage", counter), StringUtils.trimToEmpty(eval(ls, verwendungszweck)));
ls_properties.setProperty(SepaUtil.insertIndex("endtoendid", counter), "NOTPROVIDED");
ls_properties.setProperty(SepaUtil.insertIndex("mandateid", counter), StringUtils.trimToEmpty(ls.getMandatID()));
ls_properties.setProperty(SepaUtil.insertIndex("manddateofsig", counter), ISO_DATE.format(ls.getMandatDatum()));
counter += 1;
}
ueb.write(file);
return Integer.parseInt(ueb.getAnzahlBuchungen());
final OutputStream os = Files.newOutputStream(file.toPath());
System.setProperty("sepa.pain.formatted", "true");
ISEPAGenerator sepagenerator = SEPAGeneratorFactory.get("UebSEPA", sepaVersion);
sepagenerator.generate(ls_properties, os, true);
os.close();
return counter;
}

private int hibiscusausgabe(Abrechnungslauf abrl, File file, Date faell,
Expand Down
5 changes: 5 additions & 0 deletions src/de/jost_net/JVerein/rmi/Einstellung.java
Expand Up @@ -533,5 +533,10 @@ public void setSepaVersion(SepaVersion sepaversion)
throws RemoteException;

public SepaVersion getSepaVersion() throws RemoteException;

public void setCt1SepaVersion(SepaVersion sepaversion)
throws RemoteException;

public SepaVersion getCt1SepaVersion() throws RemoteException;

}
36 changes: 36 additions & 0 deletions src/de/jost_net/JVerein/server/DDLTool/Updates/Update0432.java
@@ -0,0 +1,36 @@
/**********************************************************************
* 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/>.
*
**********************************************************************/
package de.jost_net.JVerein.server.DDLTool.Updates;

import de.jost_net.JVerein.server.DDLTool.AbstractDDLUpdate;
import de.jost_net.JVerein.server.DDLTool.Column;
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

import java.sql.Connection;

public class Update0432 extends AbstractDDLUpdate
{
public Update0432(String driver, ProgressMonitor monitor, Connection conn)
{
super(driver, monitor, conn);
}

@Override
public void run() throws ApplicationException
{
execute(addColumn("einstellung",
new Column("ct1sepaversion", COLTYPE.VARCHAR, 50, null, false, false)));
}
}
24 changes: 24 additions & 0 deletions src/de/jost_net/JVerein/server/EinstellungImpl.java
Expand Up @@ -1775,5 +1775,29 @@ public void setSepaVersion(SepaVersion sepaversion) throws RemoteException
setAttribute("sepaversion", sepaversion.getFile());
}
}

@Override
public SepaVersion getCt1SepaVersion() throws RemoteException
{
String ct1sepaversion = (String) getAttribute("ct1sepaversion");
if (ct1sepaversion == null || !(ct1sepaversion.length() > 0))
{
return null;
}
return SepaVersion.byURN(ct1sepaversion);
}

@Override
public void setCt1SepaVersion(SepaVersion ct1sepaversion) throws RemoteException
{
if (ct1sepaversion == null)
{
setAttribute("ct1sepaversion", null);
}
else
{
setAttribute("ct1sepaversion", ct1sepaversion.getFile());
}
}

}

0 comments on commit 4458e0e

Please sign in to comment.