Skip to content

Commit

Permalink
impl, docu
Browse files Browse the repository at this point in the history
Issue #159
  • Loading branch information
rsoika committed Feb 23, 2024
1 parent bee01c2 commit 8e4f7f8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
11 changes: 9 additions & 2 deletions imixs-adapters-sepa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,15 @@ Example:

<sepa-export name="key"><itemvalue>dbtr.iban</itemvalue>-<itemvalue>invoice.currency</itemvalue></sepa-export>




To restrict the max count of invoices collected in a single SEPA Export the optional event configuration `maxcount` and `maxcount-event` can be added.

<sepa-export name="maxcount">100</sepa-export>
<sepa-export name="maxcount-event">20</sepa-export>

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*.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* <sepa-export name="modelversion">sepa-export-manual-de-3.0</sepa-export>
<sepa-export name="task">1000</sepa-export>
<sepa-export name="key">SEPA Lastschriftverfahren</sepa-export>
<sepa-export name="maxcount">100</sepa-export>
<sepa-export name="maxcount-event">20</sepa-export>
}</pre>
* <p>
* If a workitem is already been linked to a SEPA Export, nothing happens.
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -86,7 +99,6 @@ public ItemCollection execute(ItemCollection workitem, ItemCollection event)
// validate workitem
sepaWorkflowService.validateDbtrData(workitem);
}


String key = sepaWorkflowService.computeKey(workitem, event);

Expand All @@ -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) {
Expand Down

0 comments on commit 8e4f7f8

Please sign in to comment.