Lawrence Posted July 8, 2009 Share Posted July 8, 2009 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. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted July 9, 2009 Author Share Posted July 9, 2009 I have confirmed a bug in this version and advise against using it until a fix is available. My apologies 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted July 9, 2009 Author Share Posted July 9, 2009 This version fixes a calculation error when the amount of credit available is greater than the balance of an invoice. whmcs_credit_invoices_addon.zip 0 Quote Link to comment Share on other sites More sharing options...
kazey Posted July 11, 2009 Share Posted July 11, 2009 How do I implement this addon? 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted July 11, 2009 Share Posted July 11, 2009 How do I implement this addon?See the first post for easy instructions. Thanks for sharing this Lars with us. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted July 12, 2009 Author Share Posted July 12, 2009 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. That is it. There is no configuration needed otherwise. 0 Quote Link to comment Share on other sites More sharing options...
cmo Posted August 2, 2009 Share Posted August 2, 2009 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? 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted August 2, 2009 Author Share Posted August 2, 2009 Yes it does. As long as the cron is set to e-mail you, you will get a short report each time it runs. 0 Quote Link to comment Share on other sites More sharing options...
cmo Posted August 2, 2009 Share Posted August 2, 2009 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"); 0 Quote Link to comment Share on other sites More sharing options...
cmo Posted August 2, 2009 Share Posted August 2, 2009 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. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted August 3, 2009 Author Share Posted August 3, 2009 Yea, that was a small error in my original post. I meant to say you should put it in your admin folder, in it's own separate folder. example: /whmcs/admin/creditinvoices/ 0 Quote Link to comment Share on other sites More sharing options...
sochart Posted October 4, 2010 Share Posted October 4, 2010 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$. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted October 14, 2010 Author Share Posted October 14, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
hireahit Posted February 7, 2012 Share Posted February 7, 2012 This version fixes a calculation error when the amount of credit available is greater than the balance of an invoice. Has anyone tested this against 5.0.3 (or anything in the 5.x series, anyway)? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted February 7, 2012 Share Posted February 7, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
hireahit Posted February 7, 2012 Share Posted February 7, 2012 Thanks! From what I can tell it does seem to work in my dev. environment, so I think I'll throw it live and see what happens. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted February 8, 2012 Author Share Posted February 8, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.