Archive for March, 2010

Templating system

I knew when I started this project (which was a while ago, I kinda cheated on this one) that I didn’t want to write out all the HTML myself, I’m not THAT masochistic. What I wanted to do was basically say “make a text box to write the address in”.

So I started with a generic preprocessor. I’ve use preprocessors such as CPP, TeX and Make so figured I would take a generic preprocessor like M4 and define a few HTML macros… problem solved. Unfortunately it wasn’t that simple and as I added complexity it got harder to keep it all straight, particularly the quoting.

The basic text box wasn’t too bad.

dnl TEXT_Q(name, label, [length])
define(`TEXT_Q’, `indir(LAYOUT, `$1,
    `<label for="$1_text">$2</label>’,
    `<input id="$1_text" name="$1" ifelse($3, `’, `’, `size="$3"’)>’

But when I tried to create optional groupings it started to get messy. This is a snippit from TABULAR_OPTIONAL_ROWS and calling it.

    dnl Build the heading rows
    <tr class="tabular_optional_rows_heading_row">
    pushdef(`LAYOUT’, “TABULAR_OPTIONAL_ROWS_HEADING_LAYOUT”)
    foreach(`XXXXX’, (dquote(shift($@))), `XXXXX’)
    popdef(`LAYOUT’)
    </tr>


TABULAR_OPTIONAL_ROWS(3,
    `TEXT_Q(salary_abn, Payers Australian business number, 11), dnl TODO: Should be Payer’s
    

With TABULAR_OPTIONAL_ROWS I couldn’t figure out how to have a variable number of rows and I couldn’t figure out how to pass it’s options without quoting so I decided to throw in the towel and switch to something else.

I had experimented with Template Toolkit at work using it to inject snippits of Javascript into HTML documents. In the end I stopped using it and had a static HTML page which included a fully generated Javascript file but the short exposure I had impressed me and I tried it here. I found it much cleaner, the named parameters cut out a lot of complexity and the ability to just drop back to Perl if I wanted to do something really hairy was nice.

This is the definition of a text box followed by the calling syntax of a radio box that toggles the visibility of the text box.


<tr class="text" id="[% name %]_row" 
    [%- IF hide -%]
        style="display: none"
    [%- END -%]
>
<td class="question">
    <label for="[% name %]_id">[% text %]</label>
</td>
<td class="answer">
    <input type="text" name="[% name %]" id="[% name %]_id">
</td>
</tr>


[% INCLUDE tax/radio
    name = "surname_changed"
    text = "Has any part of your name changed since completing your last tax return?"
    modify = "previous_surname"
    options = [{name => "Yes", action => "show"}, {name => "No", action => "hide"}]
%]

[% INCLUDE tax/text
    name = "previous_surname"
    text = "Previous surname"
    hide = "true"
%]

The normal syntax for options is simply [“Yes”, “No”], the Perl fallback I mentioned earlier allows me to have more complex syntax when I need it but keeps things simple most of the time. I’ve since discovered there’s a Template Toolkit version three that’s a nice step forward but it’s listed as still in development and in a very Alpha state, it also smelt a bit like it was suffering from classic second project woes. I think I’m playing with enough new stuff not to add experimental Template Toolkit versions to the list.

Goal – Online tax returns

For my first project I am going to make a web based tax return creator for Australian tax returns.

The Australian Tax Office (ATO) produces E-Tax, a program for Windows computers that allows you to produce a tax return and submit it online. Sadly it’s very much Windows only though they suggest exploring running Windows in a virtual machine. They are currently “investigating” supporting other platforms, but they have been doing this for years now and I’ve seen third hand correspondence that suggests the investigation isn’t progressing particularly quickly.

You can also fill in the return by hand on paper, complete with explanatory booklets. In practice the procedure for both is basically the same, the advantage of doing it digitally is that it’s easier to see the calculations and make corrections.

So the goal is to produce a website to help enter tax returns. I’ll base it off the paper tax return and as output produce a PDF that can be printed and posted in directly. The ATO actually accepts printouts from E-Tax so I’m fairly confident that they will accept these.

The secondary goal is to improve my abilities with Javascript. I have toyed around with Javascript a little bit, enough to do small tasks for webpages. In doing this I saw enough to know that Javascript had some fundamental differences but not enough to really understand or work with them. By doing a substantial Javascript project I hope to get over that hurdle and start to see how to properly design with the language.

By April 4th I’ll have a prototype site complete. Not a usable solution, that will probably happen sometime after the new tax returns come out in July. The development site can be seen at http://taxreturn.projects.david.tulloh.id.au/

April 4th features

  • Templating system
  • Basic layout
  • Functional data entry
  • Javascript data checking
  • Serverside storage
  • Basic calculations
  • Independent domain name
  • Public source repository

Maybe features

  • Client side encryption
  • User login system
  • Basic personal tax pack covered
  • Client side PDF generation

Later features

  • General package refactor
  • Complete core tax pack covered
  • Complete supplementary tax pack covered
  • Retrieve prefill information from ATO
  • Electronic submission to ATO
  • Integrate with accounting software
Return top