Bug 464337 - Deleting split from the categories view deletes the ENTIRE transaction in the ledger (Appimage 5.1-360-linux-gcc-x86_64)
Summary: Deleting split from the categories view deletes the ENTIRE transaction in the...
Status: RESOLVED INTENTIONAL
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-15 19:10 UTC by lp.allard.1
Modified: 2023-01-17 10:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lp.allard.1 2023-01-15 19:10:17 UTC
SUMMARY
No stack trace available or any error messages.  Doing a cleanup and wanting to delete splits, KMM deletes the entire transaction containing the splits.

Example:  A transaction occurs each week in my chequing account with 4 splits:
1.  Split A
2.  Split B
3.  Split C
4.  Split D

Each split is in a DIFFERENT category.

If I enter the category where Split C is stored, and delete all "splits C", and go back to the chequing account ledger, ALL transactions where split C was referenced will be deleted.

STEPS TO REPRODUCE
1. See above


OBSERVED RESULT
See above

EXPECTED RESULT
See above

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Mint 20.3
KDE Frameworks 
Version 5.101.0
Qt 
Version 5.15.8 (built against 5.15.7)
ADDITIONAL INFORMATION
Using local kmy file.
Comment 1 alx.kuzza 2023-01-15 20:30:47 UTC
Reproducible using 5.1.3 and current master.

Simplified scenario.
1) create 'new category'
2) create a  transaction and use the above 'new category' (1 split is enough)
3) delete 'new category'

Expected result
- a transaction should have ***unassigned*** category

Actual result:
- a transaction deleted from the ledger
Comment 2 lp.allard.1 2023-01-15 22:05:15 UTC
Just to be clear, when I delete the split, the ENTIRE transaction disappears from the ledger.

Detailed Example

Ledger before deleting categories:

Transaction 1			$541.00
	Split 1	Category A	$98.00
	Split 2	Category B	$233.00
			
Transaction 2			$545.00
	Split 1	Category A	$150.00
	Split 2	Category B	$114.00
	Split 3	Category C	$45.00
	Split 4	Category D	$236.00
			
Transaction 3			$387.00
	Split 1	Category A	$227.00
	Split 2	Category D	$41.00
			
Transaction 4			$202.00
	Split 1	Category B	$10.00
	Split 2	Category D	$168.00

Then I delete category C and all of the splits inside....

Resulting ledger:

Transaction 1			$541.00
	Split 1	Category A	$98.00
	Split 2	Category B	$233.00
						
Transaction 3			$387.00
	Split 1	Category A	$227.00
	Split 2	Category D	$41.00
			
Transaction 4			$202.00
	Split 1	Category B	$10.00
	Split 2	Category D	$168.00
Comment 3 Jack 2023-01-16 00:37:12 UTC
Please specify exactly how you are deleting Category C, or its splits.  Normally, if you delete a Category which still has any transaction, KMM will ask to which category you want to assign those transactions.  On the other hand, if you are looking at the ledger for that category, and delete the transaction, it will delete that transaction, not just one of the splits.  (although I don't think you can do that in 5.1)  The ledger for a category is showing all transactions which include a split for that category.  To delete the split for that category, you need to open the split editor while editing that transaction.
Is that what might have happened?
Comment 4 alx.kuzza 2023-01-16 00:47:56 UTC
Simplified example:

Ledger before deleting categories:

Transaction 1			$98.00
	Split 1	Category A	$98.00

Then I delete category A and all of the splits inside.... (that from the category view)

Resulting ledger:

contains nothing
Comment 5 lp.allard.1 2023-01-16 00:50:10 UTC
Jack,

My plan was to delete ALL the splits in the Category first, and if it worked, delete the category.  I dont want to transfer (or re-categorize) the splits, but simply get rid of them.  I understand the total amount of the transactions that contained those splits will INCREASE and this is the goal...

Please note I am using 5.1.3 (Appimage of a few days ago).

If I need to manually open each transaction in my chequing account one by one, edit the splits, delete the "offending" split then re-save the transaction, it will take me days or more... There are more than 500 transactions containing the split I want to get rid of....
Comment 6 lp.allard.1 2023-01-16 00:51:52 UTC
(In reply to alx.kuzza from comment #4)
> Simplified example:
> 
> Ledger before deleting categories:
> 
> Transaction 1			$98.00
> 	Split 1	Category A	$98.00
> 
> Then I delete category A and all of the splits inside.... (that from the
> category view)
> 
> Resulting ledger:
> 
> contains nothing

@alx.kuzza:   I believe this is normal, you deleted the ONLY split that transction has.... Your problem is that KMM doesnt ask for re-assignment of the split.  My problem is that KMM DESTROYS the entire transaction even of it still contains many other splits.....
Comment 7 alx.kuzza 2023-01-16 01:47:06 UTC
(In reply to lp.allard.1 from comment #6)
> (In reply to alx.kuzza from comment #4)
> > Simplified example:
> > 
> > Ledger before deleting categories:
> > 
> > Transaction 1			$98.00
> > 	Split 1	Category A	$98.00
> > 
> > Then I delete category A and all of the splits inside.... (that from the
> > category view)
> > 
> > Resulting ledger:
> > 
> > contains nothing
> 
> @alx.kuzza:   I believe this is normal, you deleted the ONLY split that
> transction has.... Your problem is that KMM doesnt ask for re-assignment of
> the split.  My problem is that KMM DESTROYS the entire transaction even of
> it still contains many other splits.....

Your example is the same as mine. But I just have only 1 transaction that disappears and it is not necessary to create 4 transactions and 4 categories to reproduce the problem. 

Similarly, if I create 10  transactions having that 1 category that is going to be used to delete splits after - all 10 transactions will be deleted. And a dialog even asking a confirmation to delete the transactions. That is dangerous if you want do delete some old category and have transactions dated a few years back.

I would say we should ask to re-assign the category for those deleted splits,
Setting ***unassigned*** seems to be not quite a good idea.
Comment 8 Thomas Baumgart 2023-01-16 07:50:03 UTC
(In reply to lp.allard.1 from comment #5)
> My plan was to delete ALL the splits in the Category first, and if it
> worked, delete the category.  I dont want to transfer (or re-categorize) the
> splits, but simply get rid of them.  I understand the total amount of the
> transactions that contained those splits will INCREASE and this is the
> goal...

I understand what you try to achieve. If you simply remove that one split
from your 500 transactions, your books are unbalanced at scale and the
consistency check will tell you about it on each save operation.

> If I need to manually open each transaction in my chequing account one by
> one, edit the splits, delete the "offending" split then re-save the
> transaction, it will take me days or more... There are more than 500
> transactions containing the split I want to get rid of....

Yes, you are right. There is currently no way to remove a single split from
existing transactions at scale. It has to be performed manually transaction
by transaction.

BTW: opening the ledger for a category is no different than opening it for
an account. And if you delete a transaction in a ledger, all splits will be removed.
That is by design.
Comment 9 Thomas Baumgart 2023-01-16 07:52:34 UTC
(In reply to alx.kuzza from comment #7)
> I would say we should ask to re-assign the category for those deleted splits,
That is exactly what KMyMoney does: it asks the user to specify another
category to which those splits will be assigned when you delete a category in
the category view. Don't expect this to work from the ledger view.

> Setting ***unassigned*** seems to be not quite a good idea.
Yes, absolutely!
Comment 10 lp.allard.1 2023-01-16 15:48:33 UTC
@alx:  you're right ;)  I spent the entire day in KMM and did think straight ;)  Sorry I agree they're the same "issue".

@Jack & @Thomas:  I have never had to do what I tried to do before, and didnt know this was by design .  If it is fine then, I will for now leave these dummy transactions in there and live with it.

In the end perhaps a better solution would be a feature request for some kind of mass editor but we would need to think about the logics of this and what would be the goal(s) of such feature.  Mass editing data should be possible in KMM, especially when one has been using it for a decade or so with tens of thousand of transactions....  For my part this bug ticket can be closed.  I will let "alx" weight in for his position.