Jump to content

Credit Invoices Addon


Recommended Posts

One of the things I have noticed in our business is that some clients try to pay invoices using the "Add Funds" option. As it works currently, this creates a credit on their account, but it is only used for future invoices.

 

I have created this small hack to check clients (with a credit balance) for unpaid invoices. If there are any, the credit is applied to them (in order from the oldest invoice to the latest).

 

Just upload the creditinvoices.php into your WHMCS folder and set a cron to call it as frequently as you wish. Personally, I would set it to run every 30 minutes.

 

Note: this is not extensively tested. It worked fine in some test scenarios, but I take no responsibility for any damage it may cause.

Link to comment
Share on other sites

  • 3 weeks later...

I am going to try this now as we have clients using the credit system to pay for their existing invoices.

 

I downloaded and have set the cron for 30 minutes.

 

By chance, does it generate a short report on what particular invoice(s), client(s), credit(s) was/were applied?

Link to comment
Share on other sites

I placed the file in the WHMCS main folder (/clients) but I got errors:

 

<br />

<b>Warning</b>: require(../../dbconnect.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <b>/home/tahanan/public_html/clients/creditinvoices.php</b> on line <b>3</b><br />

 

Now, I transferred to the /admin folder and will try again.

 

I am not sure if it is because it is related to this commands:

 

require("../../dbconnect.php");

require("../../includes/functions.php");

require("../../includes/invoicefunctions.php");

Link to comment
Share on other sites

I fixed the issue by placing back to the file to the main folder and then edited the file for the following:

 

from:

require("../../dbconnect.php");

require("../../includes/functions.php");

require("../../includes/invoicefunctions.php");

 

to:

 

require("dbconnect.php");

require("includes/functions.php");

require("includes/invoicefunctions.php");

 

And now the script is working.

 

Looks good as I got the report on those invoices and clients that had their credits applied to their invoices.

Link to comment
Share on other sites

  • 1 year later...

Is it a bug ?.

When running the script the credit remaining is decreased but the credit available in WHMCS remains unchanged.

So If I have 1000$ in credit, I run the script I see:

Client ID 75 has 1000.00 available

Client ID 75 has unpaid invoices

Total due for invoice 12590 (Client ID: 75) is 112.88

Invoice ID 12590 has been paid in full (amount: 112.88) (credit remaining: 887.12)

 

But after that the credit remaining in WHMC is still 1000$.

Link to comment
Share on other sites

  • 2 weeks later...
Is it a bug ?.

When running the script the credit remaining is decreased but the credit available in WHMCS remains unchanged.

So If I have 1000$ in credit, I run the script I see:

Client ID 75 has 1000.00 available

Client ID 75 has unpaid invoices

Total due for invoice 12590 (Client ID: 75) is 112.88

Invoice ID 12590 has been paid in full (amount: 112.88) (credit remaining: 887.12)

 

But after that the credit remaining in WHMC is still 1000$.

 

I looked over the code and see nothing that would cause this to happen. It sounds like you may have edited the script yourself.

Link to comment
Share on other sites

  • 1 year later...
Looking through the code I do not see anything that would cause it to not work. However, there are a number of improvements that could make made to make it more efficient and flexible.

 

I will not disagree with you there. It is on my TO DO list for an overhaul. Please feel free to PM me with any suggestions.

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