Recommended flow for ERPs integration
Here's a recommended general synchronisation algorithm for transactions. A similar approach can bet taken for balances.
We assume that the intention is to sync as fast as possible all transactions into a target system.
We assume there are business rules which impact the sync into the target system (for example: we sync transactions for yesterday until today at noon, no later).
Unfiltered
This is the fastest way to sync because it avoids unneeded requests. You receive all new or updated transactions, in any account, since the last sync.
The downisde is that the “distribution logic” for placing the recieved transactions in the correct target system, for the right company, for the right bank account needs to be handled generically, for any transaction, based on its attributes.
We recommed the existance of a buffer DB if the target ERP has an API or data model which does not match this synchronisation pattern closely.
This buffer DB allows fetching transactions fast, analysis of the data by technical integrators so that the correct design choices can be made.
This approach has the advantage that it does not necesarilly need any configuration. When a new Account (IBAN) is used by a Transaction, it can be inserted in the buffer. When a new Organisation Unit (Company) appears, it can be used.
// pseudocode
// initial state: buffer is emppty: no transactions, no accounts
// triggered by schedule: for example, every 15 minutes during 9AM - 20PM
// one execution runs for as long as needed, in a loop, until all transactions are fetched
// no Sleep is needed between iterations of the same loop
let currentRowVersion = ReadPersistedValue( "CurrentRowVersion" ) ?? 0; // get starting row version from a persisted state or user 0 if this is the first ever loop
while (true)
{
var currentPageOfTxResult = getOnePageOfTransactions(currentRowVersion);
foreach ( var tx in currentPageOfTxResult.Items )
{
var bufferTx = LookupTxInBufferDb( tx.Id );
if (bufferTx == null)
InsertTxInBufferDb( tx );
else
UpdateTxInBufferDb( tx );
//currentRowVersion = tx.RowVersion; // we can remember where we are after each tx
}
var currentRowVersion = currentPageOfTxResult.Items.Max( t ⇒ t.RowVersion ); // we can remember where we are at the end of a page
//alternate method: var currentRowVersion = currentPageOfTxResult.MaxRowVersion;
WritePeristedValue( "CurrentRowVersion", currentRowVersion ):
var thereIsMoreData = currentPageOfTxResult.TotalCount > currentPageOfTxResult.Items.Count;
if ( !thereIsMoreData )
break; // exit current loop
}
// now, the buffer is up to date with FinqTreasury
// a similar sync loop can be applied between the buffer database and the target system (ERP)
// the logic here depends a lot on specific constraints
// examples:
// ERP does not allow transaction updates ⇒ insert transactions in target ERP after certain amount of time (depends on banks being used, internal Treasury rules; this may be Bank specific, transaction type specific)
// ERP needs to close a banking day at noon in the next day ⇒ After the cuttoff date/time, transactions should no longer be inserted in the ERP; ideally, a notification or message caould be sent to users to inform there recent transactions were received for a “closed day” and they can be seen in the buffer Db ⇒ this allows a customer to understand the quality of the data feed without missing transactions
Filtered
This method allows targeted synchronisation for specific accounts or dates or organisations (companies).
The same algorithm can be used, the only difference being that the fetch itself is scoped per Account IBAN, Date or OrganisationUnitId (company).
This approach must be configured. The system will not automatically learn of new accounts, banks, organisation units.
On this page
- Recommended flow for ERPs integration