Skip to content

Rule Engine

rohithkrajan edited this page Dec 26, 2017 · 6 revisions

a RuleEngine is used match the transactions for reconciliation. Following are the concepts used

  • Rule -A Rule can be defined to apply any logic between any fields of Two transactions(Client and Bank)
  • RuleSet -can contain single or multiple Rules which defines whether two transactions match.
  • RuleEvaluator - evaluates a ruleset against two transaction and return if it can be reconciled or not.
  • ReconcileEngine - will use any number of RuleEvaluators and reconcile a collection of client and bank transactions.First RuleEvaluator will go through all transactions and find match second RuleEvaluator goes through remaining unmatched transactions and it goes on like this.

A simple rule will look like

IRule rule=new PropertyRule("WalletReference", "Equal", "WalletReference")    
IRule rule2=new DateRule(3600);

There are already many types of Rules defined and you can easily build a custom rule by implementing the IRule interface

  1. PropertyRule

A property Rule can be used to define a match between two properties of Transaction. SourceProperty, Operator, TargetProperty values are required to define a PropertyRule.SourceProperty is the name of the matching field from client transaction ,TargetProperty is the name of the field from Tutuka Transaction.For Operator ,following values are allowed

  • Equal
  • NotEqual
  • GreaterThanOrEqual
  • GreaterThan
  • LessThan
  • LessThanOrEqual
  1. DateRule

A DateRule is used to match TransactionDate of two transactions where you can say the Date can only have a delta of 24 Hours maximum.

e.g. IRule rule2=new DateRule(120); will match two transaction if the transaction timestamp is within 2 minutes.

  1. PropertyFuzzyMatchRule

This is a Rule which implements approximate string matching algorithm match between any two fields of two transaction using the https://en.wikipedia.org/wiki/Bitap_algorithm

and and you can easily implement a custom rule easily by implementing any of the following classes IRule,MethodbaseRule,MethodbaseRule .

You can any number of Rule to a RuleSet

_ruleSet = new RuleSet( new PropertyRule[] {new PropertyRule("WalletReference", "Equal", "WalletReference"), new PropertyRule[] {new PropertyRule("Amount", "Equal", "Amount") });

  • any number of RuleSetEvaluator can be used to compare two transactions

          `_reconcileEvaluator = new RuleSetEvaluator(_ruleSet);`
          `_reconciledItem=_reconcileEngine.Evaluate(trans1,trans2);`
    

More Details can be found in the BDD specs http://finreconcile.azurewebsites.net/docs/Index.html?feature=Rules.feature and related