Example: Use a Custom Function to Determine the End of Tax Year Date
In Australia, the income year for tax purposes is the 12-month period from 1 July to 30 June. You could use a custom function to determine the end of the tax year date based on the current date.
For example, on the Data tab in Policy Modeling you could define the following custom function called EndOfTaxYear:
You could then have the following rules:
The first rule shows a typical usage of the custom function. When this rule is evaluated, the engine creates an instance of an entity called "the EndOfTaxYear function", and it sets an attribute "the EndOfYaxYear function argument 1" to the value that was passed in via "the current date" attribute.
For the instance it just created, the engine evaluates all the other rules shown (all of which contain the custom function's entity text and therefore belong to the custom function entity).
One of those rules infers an attribute called "the EndOfTaxYear function result", which has been configured in Policy Modeling to be the return value for the custom function. The engine considers the function call to be complete, and it finishes evaluating the original rule by storing the result value into the attribute "the due date".
The instance that the engine created is not directly available anywhere, except that if a decision report is requested on the value of "the due date", it will trace through the internal workings of the custom function and the instance will appear there.