Jump to content

How to realize the  Overages Billing function?


malin

Recommended Posts

I see the Overages Billing in WHMCS, there have the overage of bandwidth price configuration. 

 

If I enable the Overages Billing, and set the overage of bandwidth price configuration, where is the WHMCS to calculate the bandwidth? what it base on? 

 

Is there else other should be set for providing the bandwidth usage?

 

image.thumb.png.a0e288de7eab4f600c8b24da7366e393.png 

Link to comment
Share on other sites

3 hours ago, malin said:

If I enable the Overages Billing, and set the overage of bandwidth price configuration, where is the WHMCS to calculate the bandwidth? what it base on? 

the bandwidth values provided via the hosting panel, e.g cPanel, DirectAdmin etc, which if enabled are updated daily by the cron.

https://docs.whmcs.com/Disk_Space_and_Bandwidth_Overage_Billing

Link to comment
Share on other sites

3 hours ago, malin said:

How can I pass usage bandwidth to the WHMCS database? and which database should be insert data?

i'd watch out as triple posting the same question as it breaks the rules (4.2) here (double posting would, never mind triple!)... though I suspect our part-time community "Manager" is on holiday, so you might get away with it. 🏖️

you won't get an answer any quicker by asking it multiple times!

in any event, I think you've answered your own question - as you have found, the values for each service are stored in tblhosting - so I would assume updating these usage values *before* the cron runs, would allow the cron to generate the appropriate invoices if any clients have gone over their limits.

the three usual ways to do that would be a Capsule Update, Models Update or using the UpdateClientProduct API in a hook... and that's assuming that you can pull those values from their current location (e.g your hosting panel) and pass them to the correct customer in WHMCS.

Link to comment
Share on other sites

17 hours ago, brian! said:

i'd watch out as triple posting the same question as it breaks the rules (4.2) here (double posting would, never mind triple!)... though I suspect our part-time community "Manager" is on holiday, so you might get away with it. 🏖️

you won't get an answer any quicker by asking it multiple times!

in any event, I think you've answered your own question - as you have found, the values for each service are stored in tblhosting - so I would assume updating these usage values *before* the cron runs, would allow the cron to generate the appropriate invoices if any clients have gone over their limits.

the three usual ways to do that would be a Capsule Update, Models Update or using the UpdateClientProduct API in a hook... and that's assuming that you can pull those values from their current location (e.g your hosting panel) and pass them to the correct customer in WHMCS.

 

Thanks your response, I am very graceful. 

I have an idea to update the tblhosting table, before invoice create. 

https://developers.whmcs.com/hooks-reference/invoices-and-quotes/#invoicecreation

I have several question about it:

1.the InvoiceCreation hook describe `Executes as an invoice is being created in the admin area`,  `in the admin area` is mean contains the invoice automatically right?  or just mean create the Invoice by admin manually? 

2.there is no hook before invoice creation, right?

 

 

 

 

 

Link to comment
Share on other sites

2 hours ago, malin said:

1.the InvoiceCreation hook describe `Executes as an invoice is being created in the admin area`,  `in the admin area` is mean contains the invoice automatically right?  or just mean create the Invoice by admin manually? 

the docs imply any one of the 3 conditions would trigger it..

Quote
  Indicates where the invoice creation action originated, can be one of adminarea, api or autogen
2 hours ago, malin said:

2.there is no hook before invoice creation, right?

PreInvoicingGenerateInvoiceItems

Quote

Executes prior to invoice generation to allow for manipulation of stored data prior to aggregation of due items.

however, before you go down this road, it's worth noting one important point - the overages billing invoice generation only occurs once per month...

https://docs.whmcs.com/Crons

Quote

All routines of system cron (cron.php) are tasks. Most tasks are daily, and should only be run once a day. Some tasks benefit from running multiple times a day, such as ticket escalations or checking for WHMCS Updates.

Other tasks should only run once a month, such as calculating overage usage and generating the respective invoices.

now I suppose in theory you could run that task more frequently, but i've never tried to and i'm not sure how WHMCS would react to doing so... therefore, updating the database just before every invoice is generated seems redundant to me... it only needs to be updated once, and before the overages billing task runs... hence why I said it was a pre cron job, or I suppose any time before the overages task runs.

Link to comment
Share on other sites

16 hours ago, brian! said:

before the overages billing task runs

Thanks your response, brain. From your saying, I read [document](https://docs.whmcs.com/Disk_Space_and_Bandwidth_Overage_Billing#Invoicing

Usage charges are calculated on the last day of each month

there do not says whether is the day's last time, is the last day 's ` 23:59` calculated? 

Edited by malin
Link to comment
Share on other sites

3 hours ago, malin said:

there do not says whether is the day's last time, is the last day 's ` 23:59` calculated? 

 under usual circumstances (and if enabled), the server usage statistics are updated daily at the time specified in the automation settings Time Of Day...

Quote

This setting allows you to select the hour in which you'd like WHMCS to perform all daily automation tasks. This setting depends on your cron being configured to run at least once every hour to work properly.

... and then on the last day of the month, when the cron runs to complete it's daily tasks and after the usage stats have been updated, WHMCS then calculates the usage overages based on the values in the table (which have just been updated by the previous task -  so it's basically using current values in the calculation).

therefore, you'll know from your automation settings when the cron runs daily (and checking the activity log for those daily tasks will confirm when it's occurring), so because you're not updating the server usage stats automatically from WHMCS (e.g I assume you're not using cPanel, DA or Plesk etc for your hosting panel), your custom script will have to update the database table before the overages task runs at the end of each month.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated