From 8e4f7f8b6c554b12668656a56baae8e2677515fc Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Fri, 23 Feb 2024 10:02:08 +0100 Subject: [PATCH] impl, docu Issue #159 --- imixs-adapters-sepa/README.md | 11 ++++-- .../sepa/adapter/SEPARefAddAdapter.java | 35 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/imixs-adapters-sepa/README.md b/imixs-adapters-sepa/README.md index b88a139..bda0f64 100644 --- a/imixs-adapters-sepa/README.md +++ b/imixs-adapters-sepa/README.md @@ -100,8 +100,15 @@ Example: dbtr.iban-invoice.currency - - + +To restrict the max count of invoices collected in a single SEPA Export the optional event configuration `maxcount` and `maxcount-event` can be added. + + 100 + 20 + +In case and existing sepa export reaches the max count of collected invoices the max count event will be automatically executed. + + ## Scheduler Mode In the scheduler mode the invoice workflow does not link an workitem to a SEPA Export. Instead a scheduler can be configured to collect invoices periodically. The SEPA export is an implementation of the interface *org.imxis.workflow.scheduler.Scheduler*. diff --git a/imixs-adapters-sepa/src/main/java/org/imixs/workflow/sepa/adapter/SEPARefAddAdapter.java b/imixs-adapters-sepa/src/main/java/org/imixs/workflow/sepa/adapter/SEPARefAddAdapter.java index a3c6dec..3bf3c2f 100644 --- a/imixs-adapters-sepa/src/main/java/org/imixs/workflow/sepa/adapter/SEPARefAddAdapter.java +++ b/imixs-adapters-sepa/src/main/java/org/imixs/workflow/sepa/adapter/SEPARefAddAdapter.java @@ -36,6 +36,8 @@ * sepa-export-manual-de-3.0 1000 SEPA Lastschriftverfahren + 100 + 20 } *

* If a workitem is already been linked to a SEPA Export, nothing happens. @@ -55,6 +57,8 @@ public class SEPARefAddAdapter implements SignalAdapter { @Inject WorkflowService workflowService; + int invoicesMaxCount = 0; + int invoicesMaxCountEvent = 0; /** * This method finds or create the SEPA Export and adds a reference @@ -67,15 +71,24 @@ public class SEPARefAddAdapter implements SignalAdapter { public ItemCollection execute(ItemCollection workitem, ItemCollection event) throws AdapterException, PluginException { - // We test the config item "type". If it is set to OUT than a - // - + // + // test if the workitem has a dbtr.iban / dbtr.bic or a cdtr.iban / cdtr.bic ItemCollection sepaConfig = workflowService.evalWorkflowResult(event, "sepa-export", workitem, true); - String type= "OUT"; // default - if (sepaConfig!=null && !sepaConfig.isItemEmpty("type")) { - type=sepaConfig.getItemValueString("type"); + + // compute maxcount properties.... + if (sepaConfig != null) { + logger.fine("read max count configuration from event"); + if (sepaConfig.getItemValueInteger("maxcount") > 0) { + invoicesMaxCount = sepaConfig.getItemValueInteger("maxcount"); + invoicesMaxCountEvent = sepaConfig.getItemValueInteger("maxcount-event"); + } + } + + String type = "OUT"; // default + if (sepaConfig != null && !sepaConfig.isItemEmpty("type")) { + type = sepaConfig.getItemValueString("type"); } if ("OUT".equalsIgnoreCase(type)) { sepaWorkflowService.updateDbtrDefaultData(workitem); @@ -86,7 +99,6 @@ public ItemCollection execute(ItemCollection workitem, ItemCollection event) // validate workitem sepaWorkflowService.validateDbtrData(workitem); } - String key = sepaWorkflowService.computeKey(workitem, event); @@ -106,6 +118,15 @@ public ItemCollection execute(ItemCollection workitem, ItemCollection event) // set event 100 sepaExport.event(SepaWorkflowService.EVENT_ADD_REF); sepaWorkflowService.processSEPAExport(sepaExport); + + // test if the max count was reached. + if (invoicesMaxCount > 0 && sepaExport.getItemValue("$workitemref").size() >= invoicesMaxCount) { + logger.info("......Max Count of " + invoicesMaxCount + + " invoices reached, executing maxcount-event=" + invoicesMaxCountEvent); + // process the maxcoutn event on the sepa export + sepaExport.event(invoicesMaxCountEvent); + sepaWorkflowService.processSEPAExport(sepaExport); + } } } catch (QueryException | AccessDeniedException | ProcessingErrorException | ModelException e1) {