Opliste als maske ergänzt und controller bereitgestellt
This commit is contained in:
parent
2ce2b3a7d7
commit
a6be684b43
10 changed files with 487 additions and 207 deletions
|
|
@ -45,7 +45,6 @@ public class CargosoftController implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
private static Logger logger = Logger.getLogger(CargosoftController.class.getName());
|
||||
|
||||
public static final String TYPE_CARGOSOFTKREDITOR = "cargosoftkreditor";
|
||||
|
||||
@Inject
|
||||
protected DocumentService documentService;
|
||||
|
|
@ -97,7 +96,7 @@ public class CargosoftController implements Serializable {
|
|||
|
||||
// die cargosoft Kreditornummer beginnt seltsamerweise mit einem K
|
||||
// und die Debitoren mit einem D.....
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND ( (name:K" + phrase + "*) OR (name:D" + phrase
|
||||
String query = "(type:" + KreditorDebitorService.TYPE_CARGOSOFTKREDITOR + ") AND ( (name:K" + phrase + "*) OR (name:D" + phrase
|
||||
+ "*) OR (" + phrase.toLowerCase() + "*) )";
|
||||
|
||||
try {
|
||||
|
|
@ -189,7 +188,7 @@ public class CargosoftController implements Serializable {
|
|||
|
||||
// die cargosoft Kreditornummer beginnt seltsamerweise mit einem K
|
||||
// und die Debitoren mit einem D.....
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND (name:D*) AND ((name:D" + phrase
|
||||
String query = "(type:" + KreditorDebitorService.TYPE_CARGOSOFTKREDITOR + ") AND (name:D*) AND ((name:D" + phrase
|
||||
+ "*) OR (" + phrase.toLowerCase() + "*) )";
|
||||
|
||||
try {
|
||||
|
|
@ -197,13 +196,12 @@ public class CargosoftController implements Serializable {
|
|||
logger.info("found " + result.size() + " debitors...");
|
||||
if (result != null) {
|
||||
for (ItemCollection dbtr : result) {
|
||||
|
||||
// Aenderugn 22. Jun wir geben das K/D direkt witer
|
||||
String dbtrNo = dbtr.getItemValueString("_VENDOR_NUM");
|
||||
String display = dbtrNo + " - " + dbtr.getItemValueString("_VENDOR_Name");
|
||||
display=display.replace("\"","");
|
||||
display=display.replace("'","");
|
||||
searchResult.add(new KreditorSearchEntry(dbtrNo, display, buildJsonData(dbtr)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
|
|
@ -217,13 +215,12 @@ public class CargosoftController implements Serializable {
|
|||
* @return
|
||||
*/
|
||||
private String buildJsonData(ItemCollection cdtr, String iban, String bic) {
|
||||
|
||||
JsonObjectBuilder objectBuilder = Json.createObjectBuilder(). //
|
||||
add("no", cdtr.getItemValueString("_VENDOR_NUM")). //
|
||||
add("no", jsonVal(cdtr.getItemValueString("_VENDOR_NUM"))). //
|
||||
add("name", cdtr.getItemValueString("_VENDOR_Name")). //
|
||||
add("creditperiod", cdtr.getItemValueString("cdtr.creditperiod")). //
|
||||
add("iban", iban). //
|
||||
add("bic", bic);
|
||||
add("creditperiod", jsonVal(cdtr.getItemValueString("cdtr.creditperiod"))). //
|
||||
add("iban", jsonVal(iban)). //
|
||||
add("bic", jsonVal(bic));
|
||||
JsonObject jsonObject = objectBuilder.build();
|
||||
|
||||
String jsonString = "{}";
|
||||
|
|
@ -245,18 +242,18 @@ public class CargosoftController implements Serializable {
|
|||
private String buildJsonData(ItemCollection cdtr) {
|
||||
|
||||
JsonObjectBuilder objectBuilder = Json.createObjectBuilder(). //
|
||||
add("no", cdtr.getItemValueString("_VENDOR_NUM")). //
|
||||
add("name", cdtr.getItemValueString("_VENDOR_Name")). //
|
||||
add("creditperiod", cdtr.getItemValueString("cdtr.creditperiod")). //
|
||||
add("iban", cdtr.getItemValueString("cdtr.iban")). //
|
||||
add("bic", cdtr.getItemValueString("cdtr.bic")). //
|
||||
add("no", jsonVal(cdtr.getItemValueString("_VENDOR_NUM"))). //
|
||||
add("name", jsonVal(cdtr.getItemValueString("_VENDOR_Name"))). //
|
||||
add("creditperiod", jsonVal(cdtr.getItemValueString("cdtr.creditperiod"))). //
|
||||
add("iban", jsonVal(cdtr.getItemValueString("cdtr.iban"))). //
|
||||
add("bic", jsonVal(cdtr.getItemValueString("cdtr.bic"))). //
|
||||
// add ibans für kreditoren verwaltung
|
||||
add("iban2", cdtr.getItemValueString("cdtr.iban2")). //
|
||||
add("iban3", cdtr.getItemValueString("cdtr.iban3")). //
|
||||
add("iban4", cdtr.getItemValueString("cdtr.iban4")). //
|
||||
add("bic2", cdtr.getItemValueString("cdtr.bic2")). //
|
||||
add("bic3", cdtr.getItemValueString("cdtr.bic3")). //
|
||||
add("bic4", cdtr.getItemValueString("cdtr.bic4")); //
|
||||
add("iban2", jsonVal(cdtr.getItemValueString("cdtr.iban2"))). //
|
||||
add("iban3", jsonVal(cdtr.getItemValueString("cdtr.iban3"))). //
|
||||
add("iban4", jsonVal(cdtr.getItemValueString("cdtr.iban4"))). //
|
||||
add("bic2", jsonVal(cdtr.getItemValueString("cdtr.bic2"))). //
|
||||
add("bic3", jsonVal(cdtr.getItemValueString("cdtr.bic3"))). //
|
||||
add("bic4", jsonVal(cdtr.getItemValueString("cdtr.bic4"))); //
|
||||
|
||||
JsonObject jsonObject = objectBuilder.build();
|
||||
|
||||
|
|
@ -270,6 +267,17 @@ public class CargosoftController implements Serializable {
|
|||
return jsonString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to remove " and ' characters - causing problems
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
public static String jsonVal(String val) {
|
||||
val=val.replace("\"", "");
|
||||
val=val.replace("'", "");
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Resultliste wird als eine Liste einen Arrays zurückgegeben. Der Erste
|
||||
* Eintrag
|
||||
|
|
@ -309,7 +317,7 @@ public class CargosoftController implements Serializable {
|
|||
logger.fine("Zahlungsziel = " + cdtrNumber);
|
||||
|
||||
// search workitem
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND (name:" + cdtrNumber + ")";
|
||||
String query = "(type:" + KreditorDebitorService.TYPE_CARGOSOFTKREDITOR + ") AND (name:" + cdtrNumber + ")";
|
||||
|
||||
List<ItemCollection> result;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class InvoicePlugin extends AbstractPlugin {
|
|||
private static Logger logger = Logger.getLogger(InvoicePlugin.class.getName());
|
||||
|
||||
@Inject
|
||||
KreditorService kreditorService;
|
||||
KreditorDebitorService kreditorService;
|
||||
|
||||
/**
|
||||
* Test childworkitems for empty lines
|
||||
|
|
@ -350,7 +350,7 @@ public class InvoicePlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
// search the kreditor
|
||||
ItemCollection cdtr = kreditorService.findCreditor(cdtrNumber);
|
||||
ItemCollection cdtr = kreditorService.findCreditorDebitor(cdtrNumber);
|
||||
if (cdtr != null) {
|
||||
// Prüfen ob wir die IBAN schon kennen
|
||||
if (iban.equals(cdtr.getItemValueString("cdtr.iban")) && bic.equals(cdtr.getItemValueString("cdtr.bic"))) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,205 @@
|
|||
/*******************************************************************************
|
||||
* Imixs Workflow
|
||||
* Copyright (C) 2001, 2011 Imixs Software Solutions GmbH,
|
||||
* http://www.imixs.com
|
||||
*
|
||||
* 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 2
|
||||
* 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 can receive a copy of the GNU General Public
|
||||
* License at http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Project:
|
||||
* http://www.imixs.org
|
||||
* http://java.net/projects/imixs-workflow
|
||||
*
|
||||
* Contributors:
|
||||
* Imixs Software Solutions GmbH - initial API and implementation
|
||||
* Ralph Soika - Software Developer
|
||||
*******************************************************************************/
|
||||
|
||||
package com.alexanderlogistics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.annotation.security.RunAs;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Singleton;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.engine.DocumentService;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
|
||||
/**
|
||||
* Der KreditorService wird verwendet um einen Kreditor zu finden oder neue
|
||||
* IBAN/BIC kombinationen aufzunehmen.
|
||||
*
|
||||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
|
||||
@DeclareRoles({ "org.imixs.ACCESSLEVEL.NOACCESS", "org.imixs.ACCESSLEVEL.READERACCESS",
|
||||
"org.imixs.ACCESSLEVEL.AUTHORACCESS", "org.imixs.ACCESSLEVEL.EDITORACCESS",
|
||||
"org.imixs.ACCESSLEVEL.MANAGERACCESS" })
|
||||
@RolesAllowed({ "org.imixs.ACCESSLEVEL.NOACCESS", "org.imixs.ACCESSLEVEL.READERACCESS",
|
||||
"org.imixs.ACCESSLEVEL.AUTHORACCESS", "org.imixs.ACCESSLEVEL.EDITORACCESS",
|
||||
"org.imixs.ACCESSLEVEL.MANAGERACCESS" })
|
||||
@Singleton
|
||||
@RunAs("org.imixs.ACCESSLEVEL.MANAGERACCESS")
|
||||
public class KreditorDebitorService {
|
||||
public static final String TYPE_CARGOSOFTKREDITOR = "cargosoftkreditor";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Logger logger = Logger.getLogger(KreditorDebitorService.class.getName());
|
||||
|
||||
@EJB
|
||||
DocumentService documentService;
|
||||
|
||||
/**
|
||||
* Diese Method sucht einen Kreditor/Debitor. Bei Cargosoft haben kreditoren und debitoren
|
||||
* die selbe nummer und haben nur ein führendes D/K (Absolutler Irrsinn)
|
||||
* <p>
|
||||
* Diese Methode erwartet das führende K oder D
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public ItemCollection findCreditorDebitor(String cdtrNumber) throws PluginException {
|
||||
|
||||
if (cdtrNumber==null || !(cdtrNumber.startsWith("K") || cdtrNumber.startsWith("D"))) {
|
||||
throw new PluginException(PluginException.class.getName(), "QUERY ERROR", "Invalid debitor/creditor number - prafix K/D expected!");
|
||||
}
|
||||
try {
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND (name:" + cdtrNumber + ")";
|
||||
List<ItemCollection> result = documentService.find(query, 1, 0, "$modified", true);
|
||||
if (result.size() > 0) {
|
||||
return result.get(0);
|
||||
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
throw new PluginException(PluginException.class.getName(), "QUERY ERROR", e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Diese Method sucht einen Kreditor.
|
||||
* <p>
|
||||
* Diese Methode erwartet das führende K
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public ItemCollection findCreditor(String cdtrNumber) throws PluginException {
|
||||
|
||||
if ((!cdtrNumber.startsWith("K"))) {
|
||||
cdtrNumber="K"+cdtrNumber;
|
||||
}
|
||||
try {
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND (name:" + cdtrNumber + ")";
|
||||
List<ItemCollection> result = documentService.find(query, 1, 0, "$modified", true);
|
||||
if (result.size() > 0) {
|
||||
return result.get(0);
|
||||
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
throw new PluginException(PluginException.class.getName(), "QUERY ERROR", e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Method sucht einen Debitor.
|
||||
* <p>
|
||||
* Diese Methode erwartet das führende D
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public ItemCollection findDebitor(String dbtrNumber) throws PluginException {
|
||||
|
||||
if ((!dbtrNumber.startsWith("D"))) {
|
||||
dbtrNumber="D"+dbtrNumber;
|
||||
}
|
||||
try {
|
||||
String query = "(type:" + TYPE_CARGOSOFTKREDITOR + ") AND (name:" + dbtrNumber + ")";
|
||||
List<ItemCollection> result = documentService.find(query, 1, 0, "$modified", true);
|
||||
if (result.size() > 0) {
|
||||
return result.get(0);
|
||||
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
throw new PluginException(PluginException.class.getName(), "QUERY ERROR", e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Diese Methode übertragt neue IBAN/BIC kombis in den kreditor
|
||||
*
|
||||
* @param cdtrNumber
|
||||
* @param iban
|
||||
* @param bic
|
||||
* @throws PluginException
|
||||
*/
|
||||
public void addNewIBANBIC(String cdtrNumber, String iban, String bic) throws PluginException {
|
||||
ItemCollection cdtr = findCreditorDebitor(cdtrNumber);
|
||||
|
||||
if (cdtr != null) {
|
||||
|
||||
// Wir rotieren die nummern nach unten
|
||||
cdtr.setItemValue("cdtr.iban4", cdtr.getItemValue("cdtr.iban3"));
|
||||
cdtr.setItemValue("cdtr.bic4", cdtr.getItemValue("cdtr.bic3"));
|
||||
cdtr.setItemValue("cdtr.iban3", cdtr.getItemValue("cdtr.iban2"));
|
||||
cdtr.setItemValue("cdtr.bic3", cdtr.getItemValue("cdtr.bic2"));
|
||||
cdtr.setItemValue("cdtr.iban2", cdtr.getItemValue("cdtr.iban"));
|
||||
cdtr.setItemValue("cdtr.bic2", cdtr.getItemValue("cdtr.bic"));
|
||||
// clear slot 0
|
||||
cdtr.setItemValue("cdtr.iban", "");
|
||||
cdtr.setItemValue("cdtr.bic", "");
|
||||
|
||||
// nun können wir die neue IBAN/BIC in die erste frei park position legen
|
||||
if (cdtr.getItemValueString("cdtr.iban").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban", iban);
|
||||
cdtr.setItemValue("cdtr.bic", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban2").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban2", iban);
|
||||
cdtr.setItemValue("cdtr.bic2", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban3").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban3", iban);
|
||||
cdtr.setItemValue("cdtr.bic3", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban4").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban4", iban);
|
||||
cdtr.setItemValue("cdtr.bic4", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Imixs Workflow
|
||||
* Copyright (C) 2001, 2011 Imixs Software Solutions GmbH,
|
||||
* http://www.imixs.com
|
||||
*
|
||||
* 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 2
|
||||
* 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 can receive a copy of the GNU General Public
|
||||
* License at http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Project:
|
||||
* http://www.imixs.org
|
||||
* http://java.net/projects/imixs-workflow
|
||||
*
|
||||
* Contributors:
|
||||
* Imixs Software Solutions GmbH - initial API and implementation
|
||||
* Ralph Soika - Software Developer
|
||||
*******************************************************************************/
|
||||
|
||||
package com.alexanderlogistics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.annotation.security.RunAs;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Singleton;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.engine.DocumentService;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
|
||||
/**
|
||||
* Der KreditorService wird verwendet um einen Kreditor zu finden oder neue
|
||||
* IBAN/BIC kombinationen aufzunehmen.
|
||||
*
|
||||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
|
||||
@DeclareRoles({ "org.imixs.ACCESSLEVEL.NOACCESS", "org.imixs.ACCESSLEVEL.READERACCESS",
|
||||
"org.imixs.ACCESSLEVEL.AUTHORACCESS", "org.imixs.ACCESSLEVEL.EDITORACCESS",
|
||||
"org.imixs.ACCESSLEVEL.MANAGERACCESS" })
|
||||
@RolesAllowed({ "org.imixs.ACCESSLEVEL.NOACCESS", "org.imixs.ACCESSLEVEL.READERACCESS",
|
||||
"org.imixs.ACCESSLEVEL.AUTHORACCESS", "org.imixs.ACCESSLEVEL.EDITORACCESS",
|
||||
"org.imixs.ACCESSLEVEL.MANAGERACCESS" })
|
||||
@Singleton
|
||||
@RunAs("org.imixs.ACCESSLEVEL.MANAGERACCESS")
|
||||
public class KreditorService {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Logger logger = Logger.getLogger(KreditorService.class.getName());
|
||||
|
||||
@EJB
|
||||
DocumentService documentService;
|
||||
|
||||
/**
|
||||
* sucht einen Kreditor
|
||||
*
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public ItemCollection findCreditor(String cdtrNumber) throws PluginException {
|
||||
|
||||
try {
|
||||
String query = "(type:" + CargosoftController.TYPE_CARGOSOFTKREDITOR + ") AND (name:" + cdtrNumber + ")";
|
||||
List<ItemCollection> result = documentService.find(query, 1, 0, "$modified", true);
|
||||
if (result.size() > 0) {
|
||||
return result.get(0);
|
||||
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
throw new PluginException(PluginException.class.getName(), "QUERY ERROR", e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode übertragt neue IBAN/BIC kombis in den kreditor
|
||||
*
|
||||
* @param cdtrNumber
|
||||
* @param iban
|
||||
* @param bic
|
||||
* @throws PluginException
|
||||
*/
|
||||
public void addNewIBANBIC(String cdtrNumber, String iban, String bic) throws PluginException {
|
||||
ItemCollection cdtr = findCreditor(cdtrNumber);
|
||||
|
||||
if (cdtr != null) {
|
||||
|
||||
// Wir rotieren die nummern nach unten
|
||||
cdtr.setItemValue("cdtr.iban4", cdtr.getItemValue("cdtr.iban3"));
|
||||
cdtr.setItemValue("cdtr.bic4", cdtr.getItemValue("cdtr.bic3"));
|
||||
cdtr.setItemValue("cdtr.iban3", cdtr.getItemValue("cdtr.iban2"));
|
||||
cdtr.setItemValue("cdtr.bic3", cdtr.getItemValue("cdtr.bic2"));
|
||||
cdtr.setItemValue("cdtr.iban2", cdtr.getItemValue("cdtr.iban"));
|
||||
cdtr.setItemValue("cdtr.bic2", cdtr.getItemValue("cdtr.bic"));
|
||||
// clear slot 0
|
||||
cdtr.setItemValue("cdtr.iban", "");
|
||||
cdtr.setItemValue("cdtr.bic", "");
|
||||
|
||||
// nun können wir die neue IBAN/BIC in die erste frei park position legen
|
||||
if (cdtr.getItemValueString("cdtr.iban").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban", iban);
|
||||
cdtr.setItemValue("cdtr.bic", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban2").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban2", iban);
|
||||
cdtr.setItemValue("cdtr.bic2", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban3").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban3", iban);
|
||||
cdtr.setItemValue("cdtr.bic3", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
if (cdtr.getItemValueString("cdtr.iban4").isEmpty()) {
|
||||
cdtr.setItemValue("cdtr.iban4", iban);
|
||||
cdtr.setItemValue("cdtr.bic4", bic);
|
||||
documentService.save(cdtr);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.enterprise.context.ConversationScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.engine.DocumentService;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
import org.imixs.workflow.faces.data.WorkflowController;
|
||||
|
||||
/**
|
||||
* Der OPListeController dient dazu eine liste aller offenen Ausgangsrechnungen
|
||||
* zu bilden
|
||||
* <p>
|
||||
* Zusätzlich bietet er die funktionen zum auszifferne..(??)
|
||||
*
|
||||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
@Named("opListController")
|
||||
@ConversationScoped
|
||||
public class OPListController implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static Logger logger = Logger.getLogger(OPListController.class.getName());
|
||||
|
||||
@Inject
|
||||
protected WorkflowController workflowController;
|
||||
|
||||
@Inject
|
||||
protected DocumentService documentService;
|
||||
|
||||
|
||||
public List<ItemCollection> getInvoices(String dbtrNumber) {
|
||||
List<ItemCollection> result=new ArrayList<ItemCollection>();
|
||||
|
||||
// Aus der dbtrNummer muss das führendde D entfernt werden
|
||||
// wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine Ausganksrechnung kennt das nicht
|
||||
// Das ganze ist ein übles Relikt aus Cargosoft und kann nicht vermieden werden
|
||||
if (dbtrNumber.startsWith("D")) {
|
||||
dbtrNumber=dbtrNumber.substring(1);
|
||||
}
|
||||
String query = "(type:workitem OR type:workitemarchive) AND ($modelversion:rechnungsausgang-*) AND (dbtr.number:" + dbtrNumber+")";
|
||||
|
||||
try {
|
||||
result= documentService.find(query, 999, 0, "$created", false);
|
||||
} catch (QueryException e) {
|
||||
logger.severe("Failed to get op liste:" + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* This method computes the sum for a given item in a list of workitems. The
|
||||
* result is rounded to 2 digits.
|
||||
* <p>
|
||||
* Gutschriften werden abgezogen
|
||||
*
|
||||
* @param refids - list of workitem uniqueIds
|
||||
* @param item - name of the item to summarize
|
||||
* @return sum rounded to 2 digits
|
||||
*/
|
||||
public double calculateSum(List<String> refids, String item) {
|
||||
double result = 0;
|
||||
for (String id : refids) {
|
||||
ItemCollection doc = documentService.load(id);
|
||||
if (doc != null) {
|
||||
if ("credit".equals(doc.getItemValueString("payment.type"))) {
|
||||
result = result + doc.getItemValueDouble(item);
|
||||
} else {
|
||||
result = result - doc.getItemValueDouble(item);
|
||||
}
|
||||
} else {
|
||||
logger.warning("invalid read access to calculate sum");
|
||||
}
|
||||
}
|
||||
// rond with 2 digits
|
||||
return Math.round(result * 100.0) / 100.0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes an uniqueid form the item $workitemref
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void removeInvoice(String id) {
|
||||
|
||||
List<String> refList = workflowController.getWorkitem().getItemValue("$workitemref");
|
||||
|
||||
refList.remove(id);
|
||||
workflowController.getWorkitem().setItemValue("$workitemref", refList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -25,9 +25,8 @@ import org.imixs.workflow.exceptions.AdapterException;
|
|||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.ProcessingErrorException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
|
||||
import com.alexanderlogistics.CargosoftController;
|
||||
import com.alexanderlogistics.KreditorDebitorService;
|
||||
|
||||
/**
|
||||
* Der DatevCargosoftImportAdapter liest eine von Cargosoft bereitgestellte
|
||||
|
|
@ -55,6 +54,9 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
@Inject
|
||||
DocumentService documentService;
|
||||
|
||||
@Inject
|
||||
KreditorDebitorService kreditorDebitorService;
|
||||
|
||||
/**
|
||||
* This method finds or create the Datev Export and adds a reference
|
||||
* ($workitemref) to the current invoice.
|
||||
|
|
@ -208,6 +210,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
invoiceWorkitem.setItemValue("invoice.text", text);
|
||||
invoiceWorkitem.setItemValue("invoice.date", dateBuchung);
|
||||
invoiceWorkitem.setItemValue("dbtr.number", gegenKonto);
|
||||
|
||||
return invoiceWorkitem;
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +260,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
implodeChildList(invoiceWorkitem, splitBuchungen);
|
||||
|
||||
// set dbtr.name
|
||||
ItemCollection dbtrItemCol=findDbtr(invoiceWorkitem.getItemValueString("dbtr.number"));
|
||||
ItemCollection dbtrItemCol=kreditorDebitorService.findDebitor(invoiceWorkitem.getItemValueString("dbtr.number"));
|
||||
if (dbtrItemCol!=null) {
|
||||
invoiceWorkitem.setItemValue("dbtr.name", dbtrItemCol.getItemValueString("_VENDOR_Name"));
|
||||
}
|
||||
|
|
@ -291,25 +294,6 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method searches a dbtr by number
|
||||
*/
|
||||
private ItemCollection findDbtr(String number) {
|
||||
// die cargosoft Kreditornummer beginnt seltsamerweise mit einem K
|
||||
// und die Debitoren mit einem D.....
|
||||
String query = "(type:" + CargosoftController.TYPE_CARGOSOFTKREDITOR + ") AND (name:D" + number+")";
|
||||
|
||||
try {
|
||||
List<ItemCollection> result = documentService.find(query, 1, 0, "$modified", true);
|
||||
logger.info("found " + result.size() + " debitors...");
|
||||
if (result != null && result.size()>0) {
|
||||
return result.get(0);
|
||||
|
||||
}
|
||||
} catch (QueryException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
# Imixs Lucene Plugin
|
||||
##############################
|
||||
lucence.indexDir=${imixs-office.IndexDir}
|
||||
index.fields=txtsearchstring,txtSubject,txtname,txtEmail,txtUserName,namCreator,txtworkflowgroup,txtworkflowstatus,txtWorkflowAbstract,txtWorkflowSummary,txtworkflowhistory,txtspacename,txtprocessname,_subject,_description,_name,_projectnumber,_projectname,_ordernumber,_contractnumber,datDueDate,txtcommentlog,htmldescription,htmldocumentation,dms,dms_names,invoice.number.stripped,_childitems,$file.names,_VENDOR_NAME
|
||||
index.fields=txtsearchstring,txtSubject,txtname,txtEmail,txtUserName,namCreator,txtworkflowgroup,txtworkflowstatus,txtWorkflowAbstract,txtWorkflowSummary,txtworkflowhistory,txtspacename,txtprocessname,_subject,_description,_name,_projectnumber,_projectname,_ordernumber,_contractnumber,datDueDate,txtcommentlog,htmldescription,htmldocumentation,dms,dms_names,invoice.number.stripped,_childitems,$file.names,_VENDOR_NAME,dbtr.number,cdtr.number
|
||||
index.fields.analyze=txtUsername
|
||||
index.fields.noanalyze=type,$UniqueIDRef,$created,$modified,$ModelVersion,$participants,namCreator,$ProcessID,datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber,dms_count,invoice.number,invoice.number.stripped,invoice.duedate,taxonomy.verteilung.stop,taxonomy.sachpruefung.stop,taxonomy.verteilung.start,taxonomy.sachpruefung.start,taxonomy.buchhaltung.start,taxonomy.buchhaltung.stop
|
||||
index.fields.noanalyze=type,$UniqueIDRef,$created,$modified,$ModelVersion,$participants,namCreator,$ProcessID,datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber,dms_count,invoice.number,invoice.number.stripped,invoice.duedate,taxonomy.verteilung.stop,taxonomy.sachpruefung.stop,taxonomy.verteilung.start,taxonomy.sachpruefung.start,taxonomy.buchhaltung.start,taxonomy.buchhaltung.stop,dbtr.number,cdtr.number
|
||||
index.fields.store=process.name,txtProcessName,txtWorkflowImageURL
|
||||
index.fields.category=space.name,space.ref,taxonomy.verteilung.stop.by,taxonomy.sachpruefung.stop.by,taxonomy.buchhaltung.stop.by
|
||||
office.search.noanalyze=invoice.number,invoice.number.stripped
|
||||
|
|
|
|||
|
|
@ -38,9 +38,10 @@
|
|||
autocompleteInitInput(this,cargosoftSearch,'autocomplete-resultlist-cargosoft',selectDbtrCallback);
|
||||
});
|
||||
// add cargsoft label if available
|
||||
var cdtrName="#{workflowController.workitem.item['dbtr.name.cargosoft']}";
|
||||
var inputElement=$("input[data-item='dbtr.number']");
|
||||
//inputElement.after( "<span id='cdtr-name-id' class='small'>" + cdtrName + "</p>" );
|
||||
var dbtrName="#{workflowController.workitem.item['dbtr.name']}";
|
||||
// append span with dbtr.name....
|
||||
creditorField.after( "<span id='dbtr-name-id' class='small'>" + dbtrName + "</p>" );
|
||||
//var inputElement=$("input[data-item='dbtr.number']");
|
||||
});
|
||||
|
||||
// Hier bekommen wir die JSON Struktur mit allen daten.
|
||||
|
|
@ -57,7 +58,12 @@
|
|||
// append span with dbtr.name....
|
||||
inputElement.after( "<span id='dbtr-name-id' class='small'>" + dbtrData.name + "</p>" );
|
||||
|
||||
var inputElementDbtrName=$("input[id$='dbtr_name']");
|
||||
if (inputElementDbtrName) {
|
||||
inputElementDbtrName.val(dbtrData.name);
|
||||
}
|
||||
var inputElementZahlungsziel=$("input[data-item='dbtr.creditperiod']");
|
||||
|
||||
var inputElementZahlungszielDbtr=$("input[id$='dbtr_creditperiod']");
|
||||
var inputElementInvoiceDate=$("input[id$='date_invoice']");
|
||||
var inputElementIban=$("input[data-item='dbtr.iban']");
|
||||
|
|
@ -74,9 +80,6 @@
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*]]>*/
|
||||
|
|
@ -84,10 +87,7 @@
|
|||
|
||||
<!-- Hier speichern das von Kreditor vorgeschlagene zahlungsziel -->
|
||||
<h:inputHidden id="dbtr_creditperiod" value="#{workflowController.workitem.item['dbtr.creditperiod']}" />
|
||||
|
||||
|
||||
|
||||
|
||||
<h:inputHidden id="dbtr_name" value="#{workflowController.workitem.item['dbtr.name']}" />
|
||||
|
||||
|
||||
</ui:composition>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:ui="http://java.sun.com/jsf/facelets"
|
||||
xmlns:f="http://java.sun.com/jsf/core"
|
||||
xmlns:c="http://java.sun.com/jsp/jstl/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:i="http://java.sun.com/jsf/composite/imixs"
|
||||
xmlns:marty="http://java.sun.com/jsf/composite/marty">
|
||||
|
||||
|
||||
<!-- Shows the op liste fo rthe current dbtr.number -->
|
||||
|
||||
<h:panelGroup styleClass="imixs-form-section" id="zahlungsavis-table" binding="#{zahlungsavislistContainer}">
|
||||
|
||||
<h3>Invoices</h3>
|
||||
|
||||
<table class="" style="width:100%">
|
||||
<tr>
|
||||
<th style="text-align: left;">#{message['form.invoicenumber']}</th>
|
||||
<th style="text-align: left;">#{message['form.date']}</th>
|
||||
<th style="text-align: left;">#{message['form.deadline']}</th>
|
||||
<th style="text-align: right;">Debit</th>
|
||||
<th style="text-align: right;">Credit</th>
|
||||
<th style=""></th>
|
||||
<th style="width:40px;"></th>
|
||||
</tr>
|
||||
<ui:param name="invoices" value="#{opListController.getInvoices(workitem.item['dbtr.number'])}"></ui:param>
|
||||
<ui:repeat value="#{invoices}" var="invoice">
|
||||
<tr>
|
||||
<td><h:link outcome="/pages/workitems/workitem">
|
||||
#{invoice.item['invoice.number']}
|
||||
<f:param name="id" value="#{invoice.item['$uniqueid']}" />
|
||||
</h:link>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<h:outputText value="#{invoice.item['invoice.date']}">
|
||||
<f:convertDateTime pattern="#{message.datePatternShort}"
|
||||
timeZone="#{message.timeZone}" />
|
||||
</h:outputText>
|
||||
|
||||
</td>
|
||||
<td><h:outputText value="#{invoice.item['invoice.duedate']}">
|
||||
<f:convertDateTime pattern="#{message.datePatternShort}"
|
||||
timeZone="#{message.timeZone}" />
|
||||
</h:outputText>
|
||||
</td>
|
||||
<!-- debit -->
|
||||
<ui:fragment rendered="#{invoice.item['payment.type'] eq 'credit'}">
|
||||
<td style="text-align: right;"><h:outputText
|
||||
value="#{invoice.item['invoice.total']}">
|
||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
||||
</h:outputText></td>
|
||||
<td />
|
||||
</ui:fragment>
|
||||
|
||||
<!-- credit -->
|
||||
<ui:fragment rendered="#{invoice.item['payment.type'] ne 'credit'}">
|
||||
<td />
|
||||
<td style="text-align: right;"><h:outputText
|
||||
value="#{invoice.item['invoice.total']}">
|
||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
||||
</h:outputText></td>
|
||||
</ui:fragment>
|
||||
|
||||
|
||||
|
||||
<td><h:commandLink
|
||||
actionListener="#{zahlungsavisController.removeInvoice(id)}">
|
||||
<span class="typcn typcn-trash imixs-state-info"></span>
|
||||
<f:ajax render="#{zahlungsavislistContainer.clientId}" />
|
||||
</h:commandLink>
|
||||
</td>
|
||||
</tr>
|
||||
</ui:repeat>
|
||||
|
||||
<tr style="border-top: 1px solid #ccc;">
|
||||
<td />
|
||||
<td />
|
||||
<td />
|
||||
<td />
|
||||
<td><strong>Summary</strong></td>
|
||||
<td style="text-align: right;"><strong><h:outputText
|
||||
value="#{zahlungsavisController.calculateSum(workitem.itemList['$workitemref'], 'invoice.total')}">
|
||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
||||
</h:outputText></strong></td>
|
||||
<td><strong>#{invoice.item['invoice.currency']}</strong></td>
|
||||
<td />
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h:inputTextarea converter="org.imixs.VectorConverter"
|
||||
style="display:none;"
|
||||
value="#{workitem.itemList['$workitemref']}">
|
||||
</h:inputTextarea>
|
||||
|
||||
|
||||
|
||||
|
||||
</h:panelGroup>
|
||||
<script type="text/javascript">
|
||||
/*<![CDATA[*/
|
||||
|
||||
|
||||
// This method refreshs the layout
|
||||
function updateItems(data) {
|
||||
if (data.status === 'success') {
|
||||
$('form').imixsLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*]]>*/
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</ui:composition>
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ result.isValid=true;
|
|||
<imixs:value><![CDATA[<itemvalue>cdtr.name.cargosoft</itemvalue> <itemvalue format="EEEE, d. MMMM yyyy" locale="de_DE">$modified</itemvalue> (<itemvalue>cdtr.number</itemvalue>)]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txteditorid" type="xs:string">
|
||||
<imixs:value><![CDATA[alexander/form_basic#zahlungsavis]]></imixs:value>
|
||||
<imixs:value><![CDATA[alexander/form_basic#opliste]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txtimageurl" type="xs:string">
|
||||
<imixs:value><![CDATA[typcn-database||||typcn-arrow-forward]]></imixs:value>
|
||||
|
|
|
|||
Loading…
Reference in a new issue