Modeling Tips - aggregating events to generate invoice

Hello people…
I been working in a process for a service company where some activities should create “events” that will be consolidated in the end of the month to create an invoice.

I’m not sure about what would be the best approach to it and I’d like to hear some tips.

I’ve considered some ideas:

  • Using signals and/or calls to start a different process for each event, but I’m not sure how I could aggregate these instances to consolidate them to a single instance for each client (to generate the invoice).
  • Collecting these events in a separate table and reading them once a month, maybe using a DataStore (but I haven’t found much documentation about how to use it).

What do you recommend ?

An event subprocess would be able to wait for events from load of sources in the same instance.
https://cawemo.com/shares/8e6314b0-0b8b-4a15-9878-30cc02fe1163

Hi,

For this type of use-case, I tend to use the following pattern. To use an analogy, consider a bank account or credit card. Each purchase on the credit card could be considered a purchase process. Hence the purchase process is Validate Card->Authorise Amount->Confirm Purchase->Debit Credit Facility->Credit Merchant Facility… or something similar. Hence the debit credit facility task effectively puts a transaction line item against the credit facility. A separate process runs at the end of the month and extracts the month’s transactions for statement purposes.

Along these lines, a few principles come to mind;
I tend to reserve process variable storage for process state data, not business object state data. Thus as per the example above, a credit transaction is a business object which should be persisted in its own repository. Given it has its own repository, I don’t need the process engine to store it for the purpose of a monthly run…

Anyway, thats how I tend to think about these patterns…

regards

Rob

The problem here is that I need to consolidate events from different instances, so the subprocess approach is not feasible.

I understand I could use delegates to save data in a database and use the same approach to read the data in a different process (monthly), but it would make the two processes really independent from each other.
This is not exactly bad but I’d like to hear some other approaches to evaluate pros and cons… I like the idea of “connecting” both processes - in the model - but maybe it’s not technically viable.

When you say “stored in its own repository” are you using any feature camunda provides or just coding it in a delegate (like connecting to a database and reading/updating data) ?

Hi,

The latter, ie the process uses a service task to write a record to a system of record or its own database table.

Im curious to understand why you want to connect both processes? To me you have two different process cadences. One is based on event cadence, the other is say monthly cadence. As an aside, you could model both these processes as independent processes in a common model/diagram…

regards

Rob