Search

 

Module: Editor

Version: 4.2.1 +

User: Developer

Difficulty: Medium

Introduction

In this exercise we will create multiple documents in which information is merged from Futurama.

 

Prerequisites

- The Futurama Editor must be installed.
- Completing the tutorial Generating Documents first, is recommended. 
- Completing the exercise Shares first, is recommended. 

 

 

Description

This assignment is a continuation of the assignment Shares that belongs to the previous tutorial.

You can download the basis for this tutorial (the end-result of this previous exercise, and the extra external files needed), by clicking here. These files are necessary for completing the assigment. Unzip and place the files in one develop-folder. 

In this exercise we will generate documents in which the amount of taxes are displayed that three participants are obliged to pay, based on their values of shares.

Tax-rates are as follows:

Tax BracketsRates
0 - 10000 10%
10000 - 20000 20%
20000 - more 30%

To simplify the assignment we will assume that the tax rate determined holds for the entire income amount. (Example: If your income is 15,000, then your tax rate would be 20%. This means that you would have to pay a tax of 15,000*0.2 = 3,000.) 

In the download-file a Word-document 'Letter' is given. This document should be generate for each of the participants, with the mergefields filled in appropriately. 

Assignment

Read and process both files in Futurama and calculate in the Futurama Editor who has the best total value of shares. Take the following steps to do so:

  1. Create a new Node 'Tax rate' in your Futurama document, in which you will calculate the Tax Rate and Net Income of a participant
    - Create a DataTable 'Tax Rates' type Double that contains 3 rows and 1 column. Use the index (type Double) to set the bottom boundary of the Tax Brackets. Enter the corresponding tax rates in the column next.
    - Create a formula 'Rate' that determines the tax rate that corresponds to the total value of the participants shares. Use the formula 'VlookUp'. Verify if your result is correct by evaluating your formula (change names to evaluate all three participants).
    - Create a formula 'Net Income' that gives us the Net Income: Gross income -/- Taxes.
  2. Create an XmlBuilder 'Merge' that will hold the data that is needed for the 'Letter'-document:
    - Create a formula 'Date' that returns the current date, 'Now()'.
    - Create references named 'Name', 'Gross', 'Rate' and 'Net' to the corresponding objects.
  3. Create an Action object 'Generate Documents' in which the DocConverter will be used to generate the document out of your data and Word-template. 
  4. Create a DocConverter 'Converter' within the Action object, and configure it as follows: 
    -  Create a formula 'Input' in which you define the filename of the template 'Letter'. The result of this formula should consist of the path to the template, and the full name including the extension of the file. In the property 'TemplateFileName' of the DocConverter, refer to this Input-formula.
    - Create  a formula 'Output' in which you define the filename for the resulting document. The result of this formula should consist of the path to the template, and the full name including the extension of the file. Create a folder 'Output' within your document-folder and make sure the Output-formula will generate the documents in this folder. In the property 'ResultFileName' of the DocConverter, refer to this Output-formula.
    - In the property XmlData of the DocConverter, refer to the XmlBuilder 'Merge'.
    (For help with this construction, see the Tips-section)  
  5. Verify that your Action works by rightclicking the Action-object and select Debug --> Execute.
    (If the Action does not work, see the Tips-section)  
  6. Expand the Action to a loop-function that will generate documents for all three participants as follows:
    -  Change the Fixed 'Name' into a UserVariable by rightclicking the object and select 'Change To'. Give the UserVariable a TestValue of f.i. John to be able to test your construction in the Editor.
    -  Add an XMLField 'Names' of type String to the XMLNode 'Participants' and retrieve an array with the names of the participants. (See the Tips-section for help)
    - In the Action object, edit the property RepeatData and refer to the XMLField 'Names'
    - In the Action object, edit the property RepeatTarget and refer to the UserVariable 'Name'
    - In the 'Output'-formula, include a reference to the UserVariable 'Name' in the name of the result-file, to ensure a different filename for each document generated. 
  7. Verify again if your Action works by Executing from within the Editor.
  8. Create a batch-file that generates the three documents.

Tips

  • The formulas 'Input' and 'Output' can be constructed as follows:
    - Input: Concatenate(GetPathToDataFiles(), Letter.doc)
    - Output: Concatenate(GetPathToDataFiles(), Output\, Name, .doc)
  • The XMLField 'Names' should be constructed as follows:
    - Make sure the property 'SingleRow' is set to 'False'
    - Enter the following query in the XPath-property: a:Participant/@id
  • If executing the Action doesn't work:
    - Make sure you have writer's permission on the output-folder.
    - Make sure you have closed the Letter.doc file before executing. The DocConverter won't work when your Word-file is still open! 

Solutions

Answers

  • The net income for Sara: 16,800.
  • The net income for Frank: 15,360.
  • The net income for John: 15,680.

Download

image

You can download our solution for this assignment by clicking the image at the right. (Futurama 4.2.1.2)
Please note that you can very well have a different solution that is just as good as ours.
If your browser is Google Chrome, the download might not work. There's a batch-file in the zip-folder, and Chrome is very strict in that. Please try a different browser (f.i. Firefox) instead. 

Variations

If you want some more practise on this subject, you could try the extra exercises below.
We won't provide a solution for these variations, just consider them as a way to further experiment with Futurama.
  • (Difficult): See exercise 2 for an extension on this assignment.
  • (Difficult): Improve the Tax Rate calculation into a real progressive tax system. The income part that is in a lower Tax bracket should only be taxed for the corresponding tax rate. 

Updated: 2013-01-04