GoCanvas Apps can do the math for you. We have two key features available within the App Builder that allow you to do complex mathematical functions as well as pull forward summary numbers from previous screens. These two features are called Calculation and Summary.
Let's build a simple sales order application, where a sales person could sell a product and have GoCanvas break out the sub totals, calculate the tax, and provide the bottom line price.
- Go to your Apps page.
- Click to Edit an existing app or Create New App.
- Name your app and add a new screen.
- Hover over the screen in the App Outline and click to Loop the screen. Let's call this screen "Materials."
Add a Calculation field
- On the Materials screen, add a Short Text field and label it "Product Description."
- Drag a Number field from the palette into the middle of the screen. You can label this "Cost." Open the Field Settings for Cost and select Currency in the Style drop down.
- Add another Number field to your app. You can label this "Quantity."
- Now add a Calculation field and label it "Subtotal." Open the Field Settings and look for the Calculation section.
- Select the Cost field then the Add Field option. Select Multiplication and then the Quantity field in the final drop down.
NOTE: You will use Add Field when creating mathematical functions with fields in your app. Use Add Constant to calculate a function with a constant (static) number. You can use multiple fields and constants in a single calculation field.
Add a Summary Field
You can either use a Summary field when pulling values from one screen to another OR summarizing values in a looped screen, or use another Calculation field. This is how you would use a Summary field:
- Add a new screen to your app and name it "Order Summary."
- Drag a Summary field from the palette into the app. You can label this "Product Total."
- Open the Field Settings for the Summary field. Select the Summary Screen. This is the screen that contains the information you are pulling from. Next select the Summary Entry. This is the field that you are pulling information from. In this example, the Summary Screen is "Materials" and the Summary Entry is "Subtotal."
Add Tax to the Total
- On the "Order Summary" screen add a new Calculation field and label it "Tax."
- In the Field Settings for the calculation, select "Product Total" then "Add Constant." Select *(Multiplication). As the constant value, add your tax percentage in decimal format. In this example, we will use 7.5% or .075.
- Add a final Calculation field to your app and label it "Order Total."
- Select "Product Total" in the calculation settings then Add Field to add "Tax."
Here is an example of calculations and summary fields on a mobile device. On the Materials screen below, the item total is calculated by multiplying Qty by Price.
On the next screen, the Materials Total and Labor Total are summarized, and the Tax and Grand Total are calculated.
In a number field, users have the option to set the number of decimal places available in the field. If the style is set to currency, the decimal will automatically be set to 2 decimal places. If the style is set to number, however, you can choose how many decimal places will be allowed by opening the More tab in the palette and changing the decimal places field. Your options are no limit, or from 0-6.