i
Rules
The model class contains getter and setter methods for each of the parameters defined in an advanced rule, while the service class contains the operation to be performed with the model.
The model name as well as the service name are determined by the property SDK Class Name specified when modeling the advanced rule.
For example, if the "taxCalculation" advanced rule is used when downloading the Java sources of the rule, you get a taxCalculation.java file that represents the model and another taxCalculationService.java file with the available operation of the service.
Model Class Content
An advanced rule model contains:
•Model builder.
•General getter method.
•Set of getter and setter methods of its parameters. The output parameters only have getter methods.
General getter method
Operation |
Description |
Parameter |
---|---|---|
getCdRule() |
Returns the identifier of the rule. |
Data Type
The parameters of an advanced rule have their equivalence with the data types of form fields.
Service Class Content
Service allows the following operations to be performed:
Operation |
Description |
Parameter |
---|---|---|
execute(rule) |
Executes an advanced rule. |
Rule rule: Model of the rule to be executed |
Example of Use
The example invokes the "taxCalculation" advanced rule, using the model and service classes.
Values for "amount" and "taxRate" input parameters are defined in the model using its setter methods. Next, the execute(myRule) method of the service is executed and a VAT value is obtained from the getter method of the "taxValue" parameter.
// Calculation of 21% VAT on the Amount Received
|