[ Charging Rules ]

Rules #

As was mentioned above, a rule is divided into two parts: the condition and the consequence.

The condition is a set of clauses which must be true in order for the rule to be applied. For example, the condition of a rule might be true if the glider-number field is "EBZ" or if it is "FPX" or if it is "FWN". If the glider-number is not any of these then the rule is skipped.

The consequence part is the information on what value the field is to be set to. Following the example of the previous paragraph, the consequence might be that the glider-type field should be set to "K13".

Condition Part #

The condition part can contain up to three clauses. Each clause tests an individual field, e.g, glider-number is equal to the string "EBZ".

The clauses can be combined either by AND or by OR, that is the condition can be true only if all of the clauses are true (AND), or it can be true if any of the clauses are true (OR).

There is also an option to have the rule apply if the whole of the condition is false. With this option selected for AND conditions the rule is applied if any of the clauses are false, and for OR conditions when all of the clauses are false.

In other words, the Apply if condition false option and the AND/OR option can be combined to obtain the following effects:

Apply the rule if any of the clauses are true.

Apply the rule if all of the clauses are true.

Apply the rule if all of the clauses are false.

Apply the rule if any of the clauses are false.

Normally a rule will not be applied if the result field has already been set. In other words, once a rule to set a field has been applied no further rules for that field will be applied. The Override earlier rules option allows a rule to set a field even if an earlier rule for the field has already been applied.

Condition Clauses #

The examples above show clauses checking for a field being equal to a value but this is not the only test which can be done. The tests available are:

For the comparison operators ("=" through to ">=") the type (string, integer, currency, etc) of the specified value must match that of the field, otherwise the condition is assumed to be false.

Here are two examples of condition clauses:

As different tests are chosen the controls on the second line of the clause are changed as appropriate. For example, selection of the "Has Property" test implies that the second line must have a control to select the property to test for.

If the field tested by a clause is not defined then the clause is regarded as false, except, of course, when the clause is testing for a field being Not Defined.

Consequence Part #

The consequence part of a rule states what value the field should be set to if the rule is applied. The consequence can either set ("assign") the field to one particular value or to the combination of two different values.

The combinations of two values available are the normal operations of simple arithmetic, that is, add, subtract, multiply and divide and also the operation of rounding a number up to the next higher multiple of another. The last of these can be used in cases such as rounding an aerotow height up to the next multiple of 200 feet.

The operation to be performed is selected in the drop-down list box in the middle of the consequence part of the rule.

When the assign operation is selected two controls to define the value to be assigned are shown above the operation list box. For all of the other operations these two controls are also shown and, in addition, two more similar controls for the other value are shown below the operation list box.

The first of the controls for value selection is used to define the type of value. This can be one of: String, Integer, Currency, Time or Heading or it can be Field. The first types listed here mean that the other control contains the literal value to be used, e.g:

means set the field to the string "K13" and:

means set the field to the currency value for twenty pounds.

When the type control is set to Field, however, the value used is not specified directly in the rule. Instead it is taken from one of the fields already defined in the transaction. For example, the following consequence part can be used in the rule which says that by default the time used for take-off in the charging calculation is that of the actual take-off:

The type (integer, currency, heading, etc) assigned to the rule's destination field is the same as that of the source field specified.

Note: if a source field in a rule consequence is not defined then the rule is not applied, just as if the condition part of the rule was false.

Some examples of combining two values:

Subtract the charged-take-off time (which may be different from the actual take-off time because of rules such as free flying before 10AM) from the charged-landing time (which may be different from the actual landing time for similar reasons) to obtain the charged flight time.

Round the charged flight time up to the next multiple of five minutes.

Multiply the hourly rate for the flight by the time being charged to obtain the soaring fee for the flight.

Add the aerotown fee and the soaring fee to obtain the total fee for a flight.

The types of the items being combined are very important. Combinations which do not make sense are not allowed, for example, adding a currency value to a time.

Note: if the consequence part of a rule requires that two values which are incompatible are to be combined then the rule is not applied, just as if the condition part was false.

For addition, subtraction and rounding the two values must be of exactly the same type which must be one of integer, currency or time.

For multiplication the following combinations are allowed:

Value1 Value2 Result
Integer Integer Integer
Integer Currency Currency
Integer Time Time
Currency Time Currency

The order of the values does not matter, Time x Currency is also allowed and gives the same result as Currency x Time.

When Currency is multiplied by Time it is assumed that the Currency value is an hourly rate. Multiplying one and a half hours by eighteen pounds gives £27.00 as result.

For division the following combinations are allowed:

Top Value Bottom Value Result
Integer Integer Integer
Time Integer Time
Currency Integer Currency
Time Time Integer
Currency Currency Integer
Currency Time Currency

Here, of course, the order of the values does matter - both to the combinations of types allowed and to the type and value of the result. Where the result cannot be stored exactly it is rounded down (truncated towards zero) if both the input values are greater than zero.

In the case of dividing currency by time the result is an hourly rate.