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

  • Service tick

    • Service -> Consume

      • Consumes a bit of Service

        • once a day for daily consumption (disk, etc)
        • once a month for monthly service (hosting)
        • once a year for registrations (domain)
        • manually, for one-time charges (setup, cleanup)
  • Billing tick

    • Balance -> Service

      • Replenish (empty or negative) Service bucket
      • Move enough to cover anticipated consumption for the next billing period
  • Unused tick

    • Service -> Balance

      • Move unconsumed Service back to Balance, in case of overprovisioning or unconfigured service
  • Invoice tick

    • Invoice -> Balance

      • Bring Balance from negative to zero to account for currently owed outstanding
      • Bring Invoice from positive to zero to account for overpayment
  • Payment tick

    • Outside -> Invoice

      • Incoming payments are placed here until they're accounted for by an invoice run

Manual Ticks

  • Prepay tick

    • Invoice -> Balance

      • Preemptively move money to indicate a customer's desire to prepay by owing more on next invoice than is actually outstanding
  • Payout tick

    • Balance -> Outside

      • Issues a physical refund to a customer
  • Refund tick

    • Consume -> Service

      • Refund for consumed but unprovided service (outage, etc)

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

  • 20-Dec: January period starts December 20th
  • 29-Dec: New customer provisioned for $10.00 VHOST MED service
  • 29-Dec: Bucket balances: C:0 S:0 B:0 I:0
  • 29-Dec: Billing tick: $10 B->S - C:0 S:10 B:-10 I:0
  • 01-Jan: Service tick: $10 S->C - C:10 S:0 B:-10 I:0
  • 20-Jan: February billing period starts
  • 20-Jan: Unused tick (none necessary)
  • 20-Jan: Billing tick: $10 B->S - C:10 S:10 B:-20 I:0
  • 20-Jan: Invoice tick: $20 I->B - C:10 S:10 B:0 I:-20

Sample invoice:

 $10.00   - VHOST MED: example.com 2011-Jan
 $10.00   - VHOST MED: example.com 2011-Feb
----
 $20.00   - Amount due
  • 30-Jan: Payment tick: $20 ?->I - C:20 S:0 B:0 I:0
  • 01-Feb: Service tick: $10 S->C - C:20 S:0 B:0 I:0
  • 20-Feb: March billing period starts
  • 20-Feb: Unused tick (none necessary)
  • 20-Feb: Billing tick: $10 B->S - C:20 S:10 B:-10 I:0
  • 20-Feb: Invoice tick: $10 I->B - C:20 S:10 B:0 I:-10
 $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
  • Customer goes delinquent!
  • 01-Mar: Service tick: $10 S->C - C:30 S:0 B:0 I:-10
  • 20-Mar: April billing period starts
  • 20-Mar: Unused tick (none necessary)
  • 20-Mar: Billing tick: $10 B->S - C:30 S:10 B:-10 I:-10
  • 20-Mar: Invoice tick: $10 I->B - C:30 S:10 B:0 I:-20
 $10.00   - VHOST MED: example.com 2011-Mar
 $10.00   - VHOST MED: example.com 2011-Apr
----
 $20.00   - Amount due
  • Customer requests prepay so they don't go delinquent again; next invoice should be $50
  • 21-Mar: Payment tick: $20 ?->I - C:30 S:10 B:0 I:0
  • 21-Mar: Prepay tick: $50 I->B - C:30 S:10 B:50 I:-50
  • 01-Apr: Service tick: $10 VHOST MED - S->C - C:40 S:0 B:50 I:-50
  • 20-Apr: May billing period starts
  • 20-Apr: Unused tick (none necessary)
  • 20-Apr: Billing tick: $10 B->S - C:40 S:10 B:40 I:-50
  • 20-Apr: Invoice tick: $0 I->B - C:40 S:10 B:40 I:-50
 $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)

  • 25-Apr: Payment tick: $50 ?->I - C:40 S:10 B:40 I:0
  • 01-May: Service tick: $10 S->C - C:50 S:0 B:40 I:0
  • 20-May: June billing period starts
  • 20-May: Unused tick (none necessary)
  • 20-May: Billing tick: $10 B->S - C:50 S:10 B:30 I:0
  • 20-May: Invoice tick: $0 I->B - C:50 S:10 B:30 I:0
 $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
  • Customer wants new service added, but doesn't get it configured before next Service tick
  • 21-May: Service added: another VHOST MED: $10.00
  • 21-May: Billing tick: $10 B->S - C:50 S:20 B:20 I:0
  • 01-Jun: Service tick: $10 S->C - C:60 S:10 B:20 I:0
  • 20-Jun: July billing period starts
  • 20-Jun: Unused tick: $10 S->B - C:60 S:0 B:30 I:0
  • 20-Jun: Billing tick: $10 B->S - C:60 S:10 B:20 I:0
  • 20-Jun: Billing tick: $10 B->S - C:60 S:20 B:10 I:0
  • 20-Jun: Invoice tick: $0 I->B - C:60 S:20 B:10 I:0
 $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
  • 01-Jul: Service tick: $10 S->C - C:70 S:10 B:10 I:0
  • 01-Jul: Service tick: $10 S->C - C:80 S:0 B:10 I:0
  • 20-Jul: August billing period starts
  • 20-Jul: Unused tick (none)
  • 20-Jul: Billing tick: $20 B->S - C:80 S:10 B:0 I:0
  • 20-Jul: Billing tick: $20 B->S - C:80 S:20 B:-10 I:0
  • 20-Jul: Invoice tick: $10 I->B - C:80 S:20 B:0 I:-10
 $10.00CR - Current balance
 $10.00   - VHOST MED: example.com 2011-Aug
 $10.00   - VHOST MED: example.org 2011-Aug
----
 $10.00   - Amount due
  • Domain registration coming up! Must be paid by end of December!
  • 01-Aug: Service tick: $10 S->C - C:90 S:10 B:0 I:-10
  • 01-Aug: Service tick: $10 S->C - C:100 S:0 B:0 I:-10
  • 07-Aug: Payment tick: $10 ?->I - C:100 S:0 B:0 I:0
  • 20-Aug: September billing period starts
  • 20-Aug: Unused tick (none)
  • 20-Aug: Billing tick: $10 B->S - C:100 S:10 B:-10 I:0
  • 20-Aug: Billing tick: $10 B->S - C:100 S:20 B:-20 I:0
  • 20-Aug: Billing tick: $12 B->S - C:100 S:32 B:-32 I:0
  • 20-Aug: Invoice tick: $32 I->B - C:100 S:32 B:0 I:-32
 $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
  • 01-Sep: Service tick: $10 S->C C:110 S:22 B:0 I:-32
  • 01-Sep: Service tick: $10 S->C C:120 S:12 B:0 I:-32
  • 01-Sep: Service tick: $12 S->C C:132 S:0 B:0 I:-32
  • 12-Sep: Payment tick: $32 ?->I C:132 S:0 B:0 I:0