Bug 408205 - Merging payees results in error and data loss if payee is in matched transaction
Summary: Merging payees results in error and data loss if payee is in matched transaction
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR major
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-02 06:42 UTC by tusvik2
Modified: 2019-06-02 09:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.0.5


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tusvik2 2019-06-02 06:42:46 UTC
SUMMARY
If a payee is used in a matched transaction, the transaction is not visible under the payee in the payee list after they are matched. If you try to merge or delete a "ghost payee", you get an error:

Unable to remove payee(s)
Cannot remove payee that is still referenced to a transaction C:\_\be855f17\kmymoney\kmymoney\mymoney\storage\mymoneystoragemgr.cpp:290

Then all matched transaction with that payee are lost.

STEPS TO REPRODUCE
1. Manually create payee-a and payee-b
2. Manually create 2 transactions, one with Pay to: payee-a and one to payee-b. Same amount on both.
3. Match the two transactions. The matched transaction will be listed with payee-b.
4. If you now look in the payee list, you see the transaction under payee-b. If you look at payee-a, the transaction list is empty.
5. Merge payee-a and payee-b to payee-b. Then you get the error above, and the the match transaction and sub transactions are deleted.
6. If you try to delete payee-a instead, then you get an error, but transaction is not deleted as with merge.


OBSERVED RESULT
Payee not merged, transaction deleted. If a payee is used in a sub transaction in a matched transaction, the transaction is not visible in under transactions on the payee in the payee list. Now it's very dangerous to use the merge payee, since if a payee is linked to a sub transaction, it will delete all related transactions to that payee without any notifications. 

EXPECTED RESULT
When merging payees, it should also handle the sub transactions in a matched transaction.
<PAIR key="kmm-matched-tx"......."SPLIT payee=&quot;P000004&quot;"

Matched transaction's sub transaction should be listed under that payee's transaction tab. Or some other way to prevent "ghost" payees that can't be deleted or merged, because they have unknown relations to matched sub transactions. The only way to locate them is to go into the XML.

SOFTWARE/OS VERSIONS
Windows: 10 Pro x64
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 5.57.0
Qt Version: 5.12.3

ADDITIONAL INFORMATION
KMyMoney Version 5.0.80-7611781f3
Comment 1 Thomas Baumgart 2019-06-02 09:56:26 UTC
Git commit 34d12e8fdc4e8a7c18f18c5aa665bebfb3323a9d by Thomas Baumgart.
Committed on 02/06/2019 at 09:56.
Pushed by tbaumgart into branch '5.0'.

Update payee in matched transaction

In case two payees are merged and one of them is referenced in a matched
transaction, it could happen that the transaction was removed from the
users data leading to incorrect data.

This change also updates the payee identifier in the matched transaction
should it exist and thus avoids data loss.

Deleting a payee that is referenced in a matched transaction still is
not possible but does not result in data loss.
FIXED-IN: 5.0.5

M  +12   -0    kmymoney/views/kpayeesview_p.h

https://commits.kde.org/kmymoney/34d12e8fdc4e8a7c18f18c5aa665bebfb3323a9d