XForms-Tiny Testbed - expense claim form

This is part of a series of cross-platform experiments in incremental extensions to HTML4 forms that provide a stepping stone towards the much richer capabilities in XForms. This experiment provides an example of an expenses claim form for different currencies. Use your browser to view the source for a look at the underlying markup.

  


Expenses incurred in other currencies

  

Comments

This is something most commonly encountered as a spreadsheet. An online web-based version would help to reduce the errors often encountered in submitting paper copies of spreadsheets. In principle, a web-based editing tool should also be cheaper to use than conventional spreadsheets which rapidly become complex and costly to maintain.

This form assumes 1.0 if the exchange rate is left blank. This is expressed as follows using the JavaScript conditional operator to test if the rate is defined and provide the appropriate value:

<input id="total" name="total" datatype="number"
 readonly="readonly"
 calculate="sumover(expenses, amount/(rate?rate:1))"/>

This is convenient for entries in your own currency. That might for instance be the case when claiming for hotel bills where your credit card statement tells you exactly what you were charged in your own currency. For cash payments in another currency, it would be helpful if you could enter the exchange rate once. This suggests that the default rate should depend on the currency code, and that that there needs to be separate fields to set the default exchange rates for different currencies.

Accountants may want to see the amount charged in the original currency as well as the amount claimed in your own currency. This necessitates adding a new column. If you choose to enter the own currency amount, this should override the value computed from the default exchange rate. This necessitates distinguishing computed values from manually entered ones. Having done this, it should also be possible for the default exchange rates to appear and be overrideable in exactly the same manner.

At first glance, this appears to introduce cyclic dependences. The exchange rate depends on the amounts in the local and non-local currency, whilst the local amount depends on the non-local amount and the exchange rate. This cycle is broken if we treat the manually entered value and the computed values as being different fields. Quite how to do this elegantly will be an interesting challenge!

For additional comments please see the own currency expense claim example

Dave Raggett <dsr@w3.org>