Jump to content

Invalid Unit, please specify either ‘hours’ or ‘quantity’


ezyweb

Recommended Posts

Hi everyone,

We've just upgraded to the latest version of WHMCS and that's presented a couple of issues with some of our custom modules.

After the module in question queries the server for reporting and billing data, we then ask it to add "Next Invoice" billable items with that data. However, we're now getting the following error, and I wondered if someone might be able to point in the right direction to quickly fix this issue. ...

 

Invalid Unit, please specify either ‘hours’ or ‘quantity’

 

I can see that our module has been using "period", but if we change all of those to, eg, "hours", the module errors again saying that we're calling an incorrect database table.

Could someone point in the right direction to get this fixed?

Kerry

Link to comment
Share on other sites

I presume you are using the addbillingitem api call and that you are using hours.  If so, the variables should be:

$postData = array(
    'clientid' => 1,
    'description' => "Coffee",
    'amount' => 500,
    'invoiceaction' =>  "nextinvoice",
    'quantity'=>1,
    'unit'=>'hours'
);

If you're not using hours, then just get rid of "unit" completely so the variables look like:

$postData = array(
    'clientid' => 1,
    'description' => "pizza",
    'amount' => 100,
    'invoiceaction' => "nextinvoice",
    'quantity'=>5,
);
Link to comment
Share on other sites

That's excellent, Steven. Thank you.

We found it was necessary to add a column to the table dealing with this data for our module, but that was an easy fix once we understood where to place the additional variable.

However, because that variable is now considered "required" by the addbillingitem API, leaving it out altogether would have left our code the way it was .. broken. Adding it fixed the issue straight away.

Thanks so much for your help.

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