Prototype

Buckets

Consume
Sink for consumed service; source for refunds
Service
Current allocation for service (can go negative if customer desires, or act as access cutoff)
Balance
Current customer balance not allocated for service (can go negative as consumed, or positive if prepaid)
Invoice
Amount owed on current invoice

Ticks

Automatic Ticks

Manual Ticks

Service Consumption

  1. Generate Service tick once a day for daily consumption (disk usage)
  2. Generate Service tick once a month for monthly consumption (hosting charges)
  3. Generate Service tick for yearly charges (domain registration)
  4. Manual Service tick for one-time charges

Invoice Generation

  1. Generate Unused tick to refund unused service
  2. Generate Billing tick to fund next billing period
  3. Generate Invoice tick to account for payments and refunds
  4. Compute invoice values and lines from all relevant ticks

    • Anticipated future ticks (Service ticks)
    • All ticks between previous and current Invoice tick
    • All ticks before previous Invoice tick that are still relevant (positive/negative balance, etc)

Example flows

Sample invoice:

 $10.00   - VHOST MED: example.com 2011-Jan
 $10.00   - VHOST MED: example.com 2011-Feb
----
 $20.00   - Amount due
 $10.00   - VHOST MED: example.com 2011-Jan
 $10.00   - VHOST MED: example.com 2011-Feb
 $20.00CR - Payment received 2011-01-30, Thank you!
 $10.00   - VHOST MED: example.com 2011-Mar
----
 $10.00   - Amount due
 $10.00   - VHOST MED: example.com 2011-Mar
 $10.00   - VHOST MED: example.com 2011-Apr
----
 $20.00   - Amount due
 $10.00   - VHOST MED: example.com 2011-Mar
 $10.00   - VHOST MED: example.com 2011-Apr
 $20.00CR - Payment received 2011-03-21, Thank you!
 $40.00   - Prepay request
 $10.00   - VHOST MED: example.com 2011-May
----
 $50.00   - Amount due

(Prepay request is computed as the Prepay tick(s) minus the anticipated Service tick(s). If the Prepay ticks don't cover all of the anticipated Service ticks, then adjust Invoice tick upwards to compensate and don't bother showing the Prepay tick)

 $40.00   - Prepay request
 $10.00   - VHOST MED: example.com 2011-May
 $50.00CR - Payment received 2011-04-25, Thank you!
 $10.00   - VHOST MED: example.com 2011-Jun
----
 $30.00CR - Current balance
 $30.00CR - Current balance
 $10.00   - VHOST MED: example.org 2011-Jun
 $10.00   - VHOST MED: example.com 2011-Jul
 $10.00   - VHOST MED: example.org 2011-Jul
 $10.00CR - Unused service
----
 $10.00CR - Current balance
 $10.00CR - Current balance
 $10.00   - VHOST MED: example.com 2011-Aug
 $10.00   - VHOST MED: example.org 2011-Aug
----
 $10.00   - Amount due
 $10.00   - Amount due
 $10.00CR - Payment received 2011-08-07, Thank you!
 $12.00   - Domain registration
 $10.00   - VHOST MED: example.com 2011-Sep
 $10.00   - VHOST MED: example.com 2011-Sep
----
 $32.00   - Amount due

PHP Warning

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:"