On 7/20/07, snacktime <snacktime / gmail.com> wrote:
> So today I finally had the time to sit down with racc and work on a
> natural language for defining recurring billing cycles.  The racc part
> was actually pretty easy once I got a handle on how yacc works, but
> it's the wording and syntax I'm struggling with a bit.
>
> I'm trying to include most of the different billing scenario's that
> I've seen used out there.  The basic flow is that you have different
> stages of a billing cycle.  The first stage is what to do when a
> customer first signs up.  You can charge them immediately, charge them
> in a number of days, or give them a free trial.  Subsequent stages
> define a billing cycle over a period of time.  You can create several
> stages where you can for example bill someone every month for 3
> months, then bill them every 6 months for 3 years, etc..
>
> What I'm having problems with is finding a way to use a similar syntax
> to describe two different scenarios.

8<

Hi Chris,

Sorry not to be helpful at all with the "racc" issue.

Your current challenge has a business rule / process taste. You could
have different rulesets or processes for each business case.
There are some of those tools written in Ruby.


Or you could take inspiration in Rake which defines compilation rules,
and taking a similar approach, define an engine for interpreting
billing rules defined in Ruby (directly).
Let the Ruby interpreter do the grunt work and focus on providing an
abstraction level, in Ruby, for your billing issues.

---8<---
Snacktime::BillingTask.new do |t|
    t.charge = {
        :now => "$40",
        :after_one_month => :the_rest
    }
end
--->8---


Best regards,

-- 
John Mettraux   -///-   http://jmettraux.openwfe.org