GNOME Bugzilla – Bug 488035
Lot corruption when paying unposted invoices
Last modified: 2018-06-29 21:52:34 UTC
Please describe the problem: Working with Gnucash 2.2.1 on Mandriva 2007.1 Spring. BTW, I used the Mandriva 2008.0 src rpms for Gnucash to get this version on 2007.1. I have been using Gnucash in a particular way lately: Using the business utilities, I create customer's invoices, for which I enter payment information before they actually get posted. This happens for example when a customer makes an advance payment before I actually made a final invoice for the job. When multiple of such payments to unposted invoices are made, this seems to mess up the lots that are behind it. Steps to reproduce: Note: I keep the lot viewer open on Accounts receivable (where all lots for my customer's invoices show up), so I can follow what happens. Note 2: I'll ignore tax in these steps as they are not relevant for this bug. 1. I create a new invoice (test1) for customer test with a net worth of 100 €. Without posting the invoice, I make a payment (real world example: a customer makes an advance payment) 2. I create a second invoice (test2) for customer test, this time for 50€. Again, I pay it without posting it. 3. I now post the first invoice (test1) 4. I now proceed to post the second invoice (test2) 5. The payments for both invoices were made to the Cash account. I open this account, and remove the two payments. Actual results: I have made screenshots of the lot viewer at several points in the process. I will attach them to this bug, so you can look at the results I get. After step 1: (see attachment "Lots 1") This suggests a new lot has been created, but apparently when the invoice is not posted, the invoice doesn't get associated with this lot. I'm not sure if/how Gnucash knows which invoice this lot belongs to. After step 2: (see attachment "Lots 2") No new lot gets created for the second invoice. Instead, the lot created in step 1 now has the net worth of the two invoice payments as (im)balance. After step 3: (see attachment "Lots 3") The lot from the first step now explicitly gets linked to test1, and the balance is set to 0. Also a new lot suddenly appears which has got only an imbalance of 29 instead of 50. Note: when doing this exercise in a new book the imbalance will correctly be 50. But in my active book it is 29. I have no idea where that comes from or how to fix this. After step 4: (see attachment "Lots 4") So the 29 € imbalanced lot now gets explicitly associated with invoice test2 and has a new imbalance of 31,5€. I can't follow the math behind this. When I open the Pay Invoice dialog for this second invoice, this also tells me 31,5€ is still to pay. Note again that in a clean, new book this step still works correctly. After step 5: (see attachment "Lots 5") Invoice test1 now has an imbalance of 150€, while the imbalance for test2 hasn't changed. Trying to pay invoice test1 will ask me to pay 150€, although the invoice is actually only for 100€ Expected results: I would expect after step 5 to see an imbalance of 100 on invoice test1 and and imbalance of 50 for invoice test2. Instead, it seems the two original payments (which were made before the invoices were posted) got associated with the first invoice (or more arbitrarily, the first lot). Does this happen every time? Yes Other information: I first thought this was a problem with my book because the book I first encountered this issue in, was originally created with GnuCash 1.8.x and I have worked on it in Gnucash 2.0.1 as well. But when I perform the exact same steps in a new book, the steps up until 4 will work correctly. Step 5 also will cause both the removed payments to change the imbalance on test1. So in a new book, after step 5 to pay invoice test1 again, it will require 150€ in the payment dialog and 0€ for invoice test2. This is not correct, because invoice test1 only values 100€ and invoice test2 values 50€. I think the problem starts with the payments on unposted invoices getting linked in one and the same lot, although the actions a user (me in this case) takes in the business accounting screens suggest separate lots should be used. In my opinion, a payment made explicitly for one invoice should never be linked to the lot of another invoice.
Created attachment 97444 [details] Lots 1 Lot viewer screenshot after step 1
Created attachment 97445 [details] Lots 2 Lot viewer screenshot after step 2
Created attachment 97446 [details] Lots 3 Lot viewer screenshot after step 3
Created attachment 97447 [details] Lots 4 Lot viewer screenshot after step 4
Created attachment 97448 [details] Lots 5 Lot viewer screenshot after step 5
Things may not be as bad as it looks. I redid the test today with 2.2.9 and 2.3.8+. The problem is still reproducible, but I found the cause of the 50€ mismatch. After step 5, you will find an "Automatic payment forward" of 50 € in the Accounts Receivable register. If you remove this, the lots are correct again and the invoices can be paid properly. Still, this should not happen. I also found bug #143418. It may be about the same issue, but explained from the inside out, while this bug describes the issue from a user's perspective.
This issue is no longer relevant in 2.6. The payment code has been reworked and this can no longer happen.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=488035. Please update any external references or bookmarks.