Credit Expiration

Imagine the scenario where, starting on Nov 1st, your client purchases 6 credits per month which you plan to expire after 90 days. Every cron operation the system calculates total hours consumed against total credits purchased prior to Today - Expiration Term (90 days). If credits are greater, then they are expired.

Jan 1st - 6 hours added, 6 hour balance Jan - Feb - 4 hours consumed

Feb 1st - 6 hours added, 12 total, 4 consumed, 0 expired, 8 hour balance Feb - Mar - 3 hours consumed, now all of Jan consumed

Mar 1st - 6 hours added, 18 total, 7 consumed, 0 expired, 11 hour balance Mar - Apr - 5 hours consumed, now all of Feb consumed

Apr 1st - 6 hours added, 24 total, 12 consumed, 0 expired, 12 hour balance Apr - May - 2 hours consumed

May 1st - 6 hours added, 30 total, 14 consumed, 0 expired, 16 hour balance May - Jun - 1 hours consumed

Jun 1st Overrage Event - Credits purchased prior March 3rd = 18 hours - 15 Total hours consumed = 3 expired credits *** Jun 1st - 6 hours added, 36 total, 15 consumed, 3 expired, 18 hour balance

Here's how you can test it - setup a client with a condition similar to above, then run the following: https://www.yourwhmcsurl.com/modules/addons/wbtimelog/cron.php?dryrun=expire_aged_credits

It's gonna spit out something like this

Starting wbTimeLog Processing
 - Client #18: test@client.com | 18 Credits - 15 Hours = 3 Overrage
 - 3 Credit Hours Expired from 3 Clients
 - Done