Jump to content

Deleting Invoices doesn't remove Invoice Items.


martynnorman

Recommended Posts

I have seen this issue in old threads.

 

Running the latest 5.2.8. After deleting several invoices, we've noticed that WHMCS is reusing the invoice numbers (which is fine I guess) BUT it also appears to be including invoice items from invoices that no longer exist..

 

The invoices belong to the same customer, so I don't think the problem is with invoice items from invoices of other customers where the invoice IDs are the same.

 

But it does raise the question, why isn't WHMCS deleting invoice items along with invoices ?

 

I assume it's a bug, is there a work around, like a mysql trigger ?

Link to comment
Share on other sites

I reported this a long long time ago to Matt, probably more than 4 years ago and apparently nothing was done and since then I tried to always delete the invoice items before actually deleting the invoice.

At the time WHMCS support mentioned that the table should hold enough items and that I should not be worried. Go figure.

 

That is totally leaving trash behind in the database and giving chance for future issues like the one you mentioned here.

 

"Listen to your customers" always works!

Link to comment
Share on other sites

I understand your point of view about how invoiceitems are treated when you delete the related invoice. Years ago initially i was thinking the same but now that i have customized my invoicing system, i need invoiceitems like air. In fact i'm used to delete invoices that have been paid with credit since i already invoice my clients properly when they add funds to their accounts. I need invoiceitems to keep a track of all credit-transactions in a module i have.

 

Anyway if you really want to delete invoiceitems when you delete the related invoice, it's really simple to do. You just need 2 lines of code (one single query) and run it with DailyCronJob.

Edited by Kian
Link to comment
Share on other sites

  • 8 years later...

From the thread:

https://whmcs.community/topic/222841-rows-in-tblinvoiceitems-where-invoiceid-does-not-exist-in-tblinvoices/?do=findComment&comment=1056193

"If an invoice was deleted the record in tblinvoiceitems remains by design. This is how WHMCS knows not to generate a duplicate invoice for a service on a particular next due date - even if the original invoice was deleted.

Leaving them would be totally normal, but if you wanted to delete them I don't see it causing a major problem."

I don't know that moment in which "WHMCS knows not to generate a duplicate invoice". In fact, we've had the problem that WHMCS didn't generate new invoices because the orphaned tblinvoiceitems rows exist with no related invoice.

 

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