Provide for deletion of bills and vendors
I understand this isn't trivial because of the transactional nature of gnucash and dependencies would have to be undone. I also realize it breaks auditability conventions. But I use Gnucash for personal use and I want accurate, clean records. Being human I make mistakes with creating vendors and bills all the time that I want to delete, not uncheck active and have garbage data lingering in my database forever.
-
Anonymous commented
There is a way to delete it from the xml file, if you feel up to it.
Please make sure you backup your files first.
See the link: https://wiki.gnucash.org/wiki/FAQ#Q:_How_can_I_delete_an_Invoice.2C_Customer.2C_Vendor.2C_or_Employee.3F
The excerpt from the link above:
" How can I delete an Invoice, Customer, Vendor, or Employee?
A: Quick answer: you can't. Longer answer: you can mark the item as "inactive" (just uncheck the "active" button) and it will no longer show up in standard searches. There are no plans to ever allow you to delete these objects. If you really care you can just re-use them later.
A: Quick answer: you can. Longer answer: 1 - delete Invoice entries (GncEntry clause), 2 - delete Invoice of these deleted entries (GncInvoice clause), 3 - Customer of these deleted Invoices (gncCustomer), 4 - correct counters (count-data) for those deleted positions. Try to learn database file structure. It takes one hour for me.
A: Longer Answer. You can delete them, but it is going to involve editing the XML file yourself. Take a deep breath, it's going to be okay. I'd also just like to note that while this seemed to work fine on my machine, I can't promise you 100% that this will work. Please, please, please backup before you do this. Alright, now that all that is out of the way, lets do it.
I am going to suggest that you clean out all the Invoices you want to delete before you do this. So go into the invoice and delete all the entries that exist in it. That will make removing data much easier.
First we're going to need to ungzip your gnucash file (make sure you're working in a separate directory from the directry that you ususally save your data file and that you've copied the latest version of the data file to this directory). Rename the data file to something that ends in '.gz'. So if your data file is named accounts rename it to accounts.gz.
Then run gzip -d accounts.gz. This will create an unzipped file with the name of accounts
Open up accounts in your favorite text editor.
The GnuCash xml format is pretty simple, but there is probably going to be a lot of data to wade through. You're going to have to start at the top of what you want to delete and work your way down.
If you're deleting a Customer, then you start there, then move down to all its jobs and then down to all the invoices and finally to the entries (but you shouldn't have to do this if you cleared out the invoices first.
If you're deleting a Job, you start with the Job, then work down to all the Invoices.
If you're deleting an Employee, start with the Employee and then delete all the invoices.
If you're deleting an Invoice, just delete the Invoice.
I'm going to take the case of deleting an Employee for the example. The first thing to do is to find the GncEmployee line that corresponds to the employee you want to delete. Go ahead and search the document for the string GncEmployee. This should take you right to the first employee in the file. Scroll down until you find the user you want to delete. Don't just delete the user. Select all the text that represents that user, from the <gnc:GncEmployee version = "2.0.0"> to the final closing </gnc:GncEmployee> tag. Cut it and paste it into a temp file. Make sure you remove any extra line breaks (there shouldn't be any blank lines left). So you've just gotten rid of the employee.
Now you need to go find all the invoices associated with that Employee. In the temp file, find the line that starts with <employee:guid type="guid". That value if the unique ID number that gnucash uses to identify that employee in the xml file. So now copy that value, return to the data file and do a search for that guid.
Each time you seach, you should land inside a GnvInvoice block. Delete the entire block, again making sure that you aren't leaving any spaces.
The last thing you need to do is clean up the counters in two places. You only can do this if you're deleting the LAST thing that you added. So if you have an employee and it is the last employee you added, you can fix the employee counter. If it is an Invoice and it is the last invoice you added, you can fix the invoice counter. DO NOT CHANGE THE COUNTERS IF WHAT YOU'RE DELETING ISN'T THE LAST THING ADDED.
Go back to the top of document. Find the block that starts with <book:slots> Inside that there should be a section labeled <slot:key>counters</slot:key>. Under that you'll find a slot:key line for each type, for example GncEmployee. Underneath that is a slot:value. Decrease the value by one.
In SQL:
SELECT * FROM slots WHERE name="counters/gncInvoice"; ..." -
Anonymous commented
hi,
the idea, is when creating a bill with incorrect Vendor, you cannot change it to a current Vendor, or it creates same vendor twice ,how to solve this??
-
Anonymous commented
IMO, vendor slot recycling is a kludgy workaround to try to make up for lack of true deletion. It's akin to if gnucash didn't allow the deletion of transactions and the proposed remedy was recycling them, leaving bunches of blank transactions marked "***DUMMY***" lingering around. Ludicrously sloppy. Unless the number of vendors is rapidly expanding, recycling leaves faux vendors lingering in the database awaiting re-use at some future date. Sloppy, error prone, and misleading when reports are generated.
I don't see why it is considered so incredibly hard to delete vendors. I can delete transactions. I can delete entire accounts. Why not vendors.
My current solution is to bypass gnucash's vendor capabilities entirely, using expense sub-accounts with the vendor names in them. This way I can create and delete vendors with the click of a mouse. However in exchange I lose all the nice invoice management and pre-built reporting features I would have liked to have been able to use.
-
AdminGeert Janssens (Core Dev, GnuCash) commented
Besides marking bills and vendors as inactive, you can also recycle them as an alternative to deleting them.
That means: if you have a bill that's wrong, simply edit it to become right. You can change everything on an unposted bill: entries, vendor, job, date, number, whatever. So if you don't need the bill for the vendor you entered it for, simply change it to belong to a vendor for which you do need to enter a bill.
Same goes for vendors. If you entered a wrong vendor, you are free to change it and use it the next time you need to enter a new vendor. The only condition is obviously that you haven't entered any bills for the wrong vendor. Any such bills should first be assigned to the correct vendor.
I believe this greatly reduces the need for a delete option for bills and vendors. Other than that I don't know if it is feasible to implement such a feature easily.