diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java index 1af64dc..9434fdc 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java @@ -64,10 +64,10 @@ public class InvoicePlugin extends AbstractPlugin { } } - - + boolean isPublicEvent = !("0".equals(event.getItemValueString("keypublicresult"))); + // Payment.type muss immer eingetragne werden! - if (workitem.getTaskID() >= TASK_ERFASSUNG && workitem.getEventID()<900) { + if (isPublicEvent && workitem.getTaskID() >= TASK_ERFASSUNG && workitem.getEventID() < 900) { if (workitem.getItemValueString("payment.type").trim().isEmpty()) { // throw a plugin exception! throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA, @@ -78,6 +78,11 @@ public class InvoicePlugin extends AbstractPlugin { // Buchungsperiode auf plausi prüfen validateBuchungsperiode(workitem); + + // Cargosoft Kreditorennnummer prüfen + if (workitem.getTaskID() == TASK_ERFASSUNG || workitem.getTaskID() == TASK_SACHPRUEFUNG) { + validateCargosoftCdtrNumber(workitem); + } } // die prüfung der positionsnummern und Category erfolgt nur im Status @@ -211,6 +216,34 @@ public class InvoicePlugin extends AbstractPlugin { } } + private void validateCargosoftCdtrNumber(ItemCollection workitem) throws PluginException { + String crdtrNumber = workitem.getItemValueString("cdtr.number"); + + // wenn keine Nummer eingegeben wurde gehts weiter! + if (crdtrNumber.isEmpty()) { + return; + } + + // search creditor number in cargosoft... + // die cargosoft Kreditornummer beginnt seltsamerweise mit einem K..... + try { + String query = "(type:cargosoftkreditor) AND (name:K" + crdtrNumber + ")"; + List result = this.getWorkflowService().getDocumentService().find(query, 1, 0); + if (result == null || result.size() == 0) { + throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA, + "Die Kreditorennummer ist nicht gültig."); + + } else { + // update cargosoft crediotr name + ItemCollection cargo = result.get(0); + workitem.setItemValue("cdtr.name.cargosoft", cargo.getItemValueString("_VENDOR_Name")); + } + } catch (QueryException e) { + e.printStackTrace(); + } + + } + /** * converts the Map List of a workitem into a List of ItemCollectons */ diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml index cc4dc4d..ee1346d 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml @@ -39,6 +39,11 @@ autocompleteInitInput(this,cargosoftSearch,'autocomplete-resultlist-cargosoft',selectCdtrCallback); }); + // add cargsoft label if available + var cdtrName="#{workflowController.workitem.item['cdtr.name.cargosoft']}"; + //alert(cdtrName); + var inputElement=$("input[data-item='cdtr.number']"); + inputElement.after( "" + cdtrName + "

" ); }); // schneide die kreditornnummer aus dem selectierten Text aus (wir brauchen nur die)