6.9.5 More Multiple Calculations

A sales tax calculation will be added to the previous example. A sales tax field is added to the screen, and the sales tax amount is calculated using the sales tax rate. The sales tax amount is added to the subtotal to give a final total. This example is detailed below.

Form Name ex4

Data File

Beginning form no Unique records no

Repeating form no Append form no

Freeze form no Additional form no

Required form no for one record

Next form name ex4

gifs/00000001.gif

Field name units1 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each1 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount1 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units1*each1)

Edit Data Type money

Field name units2 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each2 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount2 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units2*each2)

Edit Data Type money

Field name units3 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each3 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount3 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units3*each3)

Edit Data Type money

Field name taxrate Field length 10

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name subtotal Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation amount1+amount2+amount3

Edit Data Type money

Field name tax Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (taxrate*subtotal/100)

Edit Data Type money

Field name grandtotal Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation subtotal+tax

Edit Data Type money

Figure 4

As a further example, the total of all the items with a credit limit can be compared and information displayed about whether the total requires a credit authorization. In this example, the value of the credit limit field is initialized to $100.00, but this value could have been retrieved from a data file by making this field a Lookup field. The credit authorization example is shown in Figure 5.

Form Name ex5

Data File

Beginning form no Unique records no

Repeating form no Append form no

Freeze form no Additional form no

Required form no for one record

Next form name ex5

gifs/00000001.gif

Field name units1 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each1 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount1 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units1*each1)

Edit Data Type money

Field name units2 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each2 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount2 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units2*each2)

Edit Data Type money

Field name units3 Field length 8

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name each3 Field length 12

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type money

Field name amount3 Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (units3*each3)

Edit Data Type money

Field name taxrate Field length 10

Entry Allowed yes Input required no

In Data File no Invisible no

Edit Data Type real

Field name subtotal Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation amount1+amount2+amount3

Edit Data Type money

Field name tax Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation round (taxrate*subtotal/100)

Edit Data Type money

Field name grandtotal Field length 14

Entry Allowed no Input required no

In Data File no Invisible no

Calculation subtotal+tax

Edit Data Type money

Field name limit Field length 10

Entry Allowed no Input required no

In Data File no Invisible no

Initial value 100.00

Edit Data Type money

Field name credit Field length 3

Entry Allowed no Input required no

In Data File no Invisible no

Calculation grandtotal > limit

Edit Data Type boolean

Figure 5

If you wanted to disallow entries with a total over the credit limit rather than just flagging them, you could add an Edit/Match to the grandtotal field as follows test grandtotal > limit "Requires credit authorization".

Every time the grandtotal field is recalculated, the test is made, and if it fails, the operator cannot proceed.