i

Please enable JavaScript to view this site.

The model class contains getters and setters 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 constructor.

General getter.

Getters and setters of its parameters. The output parameters only have getters.

 

General getter

 

 

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 setters. Next, the execute(myRule) method of the service is executed and a VAT value is obtained from the getter of the "taxValue" parameter.

 

 

// Calculation of 21% VAT on the Amount Received
taxCalculationService myService =
        new taxCalculationService (getApiClient());
taxCalculation myRule = new taxCalculation() ;
myRule.setAmount(new Double(100.12));
myRule.setTaxRate(new Double(21.00));
 
myRule = myService.execute(myRule);
// Gets the Amount of VAT Applied
Double doubleResult = myRule.getTaxValue();
log("The result of the tax value is:"
 + doubleResult);
 

 

Send us your comment
Share on Twitter Share on Linkedin Send by Email Print