Domain Specific Language for Invoices

Posted by Chris Tue, 03 Oct 2006 10:37:00 GMT

5th Oct 06: Updated: now with time and currency support

I’ve been playing around with DSLs recently, inspired by the dynamism you get for free with Ruby, and thought I’d try writing one.

This is my first effort: svn.edendevelopment.co.uk/public/invoice_dsl

Check out the README.txt for more details. Basically it allows you to write an invoice in fairly natural language syntax…

Here’s an example:

new_invoice do
  address 'Test Client, Street, ZIP'
  code '2006-45'
  date '3rd Oct'

  work_at 50 do
    spent 3.on('Morning meeting')
    spent 0.5.on('Making the coffee for the boss').on('3rd Sept')
  end 

end

We then end up with something like this: 2006-45.pdf

It’s work in progress, so suggestions for improvements are welcome. Feel free to adapt it for your needs, but please send me any significant patches or new templates so we can spread the love.

Eventually it would be cool to get this invoice descriptions directly from the Basecamp API…

digg this

Comments

  1. Kamal said about 14 hours later:

    I’m digging the DSL . My only suggestion would be to add more sugar to the syntax around your time, e.g. spent 3.hours.on(‘Morning meeting’) and spent 30.minutes.on(‘Making the cofee for the boss’).

    Perhaps you can also add some sugar for the rate, e.g. work_at 50.per.hour

    Just my 2.cents :D

Comments are disabled

This is the obligatory blog of Eden Development. We write here about Pin in the Map updates and other stuff we get up to.

Search

Advertisements

Powered