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

Buchungen nach Syntax Importieren #578

Merged
merged 3 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
101 changes: 101 additions & 0 deletions src/de/jost_net/JVerein/gui/action/SyntaxExportAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**********************************************************************
* 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 java.util.Arrays;
import java.util.HashMap;

import de.jost_net.JVerein.keys.SplitbuchungTyp;
import de.jost_net.JVerein.rmi.Buchung;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.messaging.QueryMessage;
import de.willuhn.jameica.system.Application;
import de.willuhn.util.ApplicationException;

public class SyntaxExportAction implements Action
{

@Override
public void handleAction(Object context) throws ApplicationException
{
if (context instanceof Buchung)
{
context = new Buchung[] { (Buchung) context };
}
if (!(context instanceof Buchung[]))
{
throw new ApplicationException("Ungültiger context");
}
Buchung[] buchungen = (Buchung[]) context;
Arrays.sort(buchungen, (b, b2) -> {
try
{
return b.getID().compareTo(b2.getID());
}
catch (RemoteException e)
{
return 0;
}
});

ArrayList<HashMap<String, Object>> buchunglist = new ArrayList<>();
for (Buchung u : buchungen)
{
HashMap<String, Object> buchungMap = new HashMap<>();

try
{
// Wenn keine Buchungsart vorhanden ist können wir auch nicht
// exportieren
// Split-Gegenbuchungen kennt Syntax nicht
if (u.getBuchungsart() == null
|| (u.getSplitTyp() != null
&& u.getSplitTyp() == SplitbuchungTyp.GEGEN))
{
continue;
}
buchungMap.put("buchungsartkonto", u.getBuchungsart().getNummer());
buchungMap.put("kommentar", u.getKommentar());
buchungMap.put("zweck", u.getZweck() + ", " + u.getName());
buchungMap.put("betrag", u.getBetrag());
buchungMap.put("datum", u.getDatum());
buchungMap.put("id", u.getID());
buchungMap.put("splitid", u.getSplitId());
if (u.getKonto().getKommentar().trim().matches("^[0-9]{3,10}$"))
{
buchungMap.put("gegenkonto", u.getKonto().getKommentar());
}
else
{
buchungMap.put("gegenkonto", u.getKonto().getNummer());
}
}
catch (RemoteException e)
{
throw new ApplicationException("Fehler beim Lesen der Buchung.");
}
buchunglist.add(buchungMap);
}

QueryMessage msg = new QueryMessage(buchunglist);
Application.getMessagingFactory().getMessagingQueue("syntax.buchung.import")
.sendSyncMessage(msg);
}

}
28 changes: 20 additions & 8 deletions src/de/jost_net/JVerein/gui/menu/BuchungMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@

import java.rmi.RemoteException;

import de.jost_net.JVerein.gui.action.AnlagenkontoNeuAction;
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.BuchungDuplizierenAction;
import de.jost_net.JVerein.gui.action.BuchungGegenbuchungAction;
import de.jost_net.JVerein.gui.action.SplitBuchungAction;
import de.jost_net.JVerein.gui.action.SplitbuchungBulkAufloesenAction;
import de.jost_net.JVerein.gui.action.AnlagenkontoNeuAction;
import de.jost_net.JVerein.gui.action.BuchungBuchungsartZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungKontoauszugZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungProjektZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungSollbuchungZuordnungAction;
import de.jost_net.JVerein.gui.action.MitgliedDetailAction;
import de.jost_net.JVerein.gui.action.BuchungProjektZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungKontoauszugZuordnungAction;
import de.jost_net.JVerein.gui.action.BuchungDeleteAction;
import de.jost_net.JVerein.gui.action.SplitBuchungAction;
import de.jost_net.JVerein.gui.action.SplitbuchungBulkAufloesenAction;
import de.jost_net.JVerein.gui.action.SyntaxExportAction;
import de.jost_net.JVerein.gui.control.BuchungsControl;
import de.jost_net.JVerein.rmi.Buchung;
import de.jost_net.JVerein.keys.ArtBuchungsart;
import de.jost_net.JVerein.keys.SplitbuchungTyp;
import de.jost_net.JVerein.rmi.Buchung;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.parts.CheckedContextMenuItem;
import de.willuhn.jameica.gui.parts.CheckedSingleContextMenuItem;
import de.willuhn.jameica.gui.parts.ContextMenu;
import de.willuhn.jameica.gui.parts.ContextMenuItem;
import de.willuhn.jameica.plugin.Plugin;
import de.willuhn.jameica.system.Application;
import de.willuhn.logging.Logger;

/**
Expand Down Expand Up @@ -87,6 +90,15 @@ public BuchungMenu(BuchungsControl control)
if (geldkonto)
addItem(new CheckedContextMenuItem("Kontoauszug zuordnen",
new BuchungKontoauszugZuordnungAction(control), "view-refresh.png"));
Plugin syntax = Application.getPluginLoader()
.getPlugin("de.willuhn.jameica.fibu.Fibu");
if (syntax != null
&& syntax.getManifest().getVersion().compliesTo("2.10.5+"))
{
addItem(ContextMenuItem.SEPARATOR);
addItem(new CheckedContextMenuItem("In SynTAX übernehmen",
JohannMaierhofer marked this conversation as resolved.
Show resolved Hide resolved
new SyntaxExportAction(), "document-save.png"));
}
}

private static class SingleBuchungItem extends CheckedSingleContextMenuItem
Expand Down
Loading