Are there any known show-shoppers regarding "un-merging" transactions?

jgfolsom's Avatar

jgfolsom

05 Jan, 2025 08:58 AM

Hello All,

I can code in C, Java, Python. I haven't used (or really looked into) your API yet. I see some good info for beginners from Mr. Bray and Mr. Beesley.

I want to write something that will take a merged transaction, rebuild the two source transactions, then remove the merged transaction. At first look, all of the original data appears to exist in the Raw Data of the resultant (merged) transaction. I'm sure there are complex considerations, such as being able to re-merge again, handling reconciled status, etc..

I know that you can undo a merge if you catch it immediately (by Edit -> Undo). But I need to undo a bunch of merges that happened some time ago. I see in the forums that people have wanted this feature for years.

Which brings me to my question. This feature hasn't been added yet! Either it is low on the priority list, or it's a difficult problem, or both :) Should I take it on or are there good reasons for me to avoid trying?

Thanks very much,
Jon

  1. 1 Posted by Stuart Beesley ... on 05 Jan, 2025 12:14 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

  2. Support Staff 2 Posted by Sean Reilly on 05 Jan, 2025 08:46 PM

    Sean Reilly's Avatar

    Hi John,

    Ah yes, this is definitely do-able. If a transaction (AbstractTxn) has a property ol.match-type = 3 then you should be able to do something like the following to record the original downloaded transaction:

    OnlineTxn originalOnlineTxn = txn.getOriginalOnlineTxn()
    MoneydanceGUI gui = (MoneydanceGUI)extensionContext.getUI()
    OnlineTxnMerger merger = gui.getOnlineManager().getTxnMerger(txn.getAccount())
    
    // record the online version of the transaction as it's own local transaction
    ParentTxn asDownloadedTxn = merger.createDefaultNewTxn(originalOnlineTxn)
    asDownloadedTxn.syncItem(); // records the separate as-downloaded transaction
    
    // then it's a matter of removing the downloaded properties of the register transaction:
    for(propname : ["ol.match-type", "ol.orig-txn", "ol.orig-payee", "ol.orig-memo", "ol.match-status"]) {
      txn.removeParameter(propname)
    }
    txn.syncItem()
    

    The OnlineTxnMerger object does have a method called .unmergeTxn() which generally does some of this, but I don't use it internally to undo merges... IIRC it's used to handle situations in which a transaction is merged with a local transaction that was already merged with another.

    That's the high level way to do it, but I'm sure I've probably missed some details.

    Thanks,
    Sean

    --
    Sean Reilly
    Developer, The Infinite Kind
    https://infinitekind.com

  3. 3 Posted by Stuart Beesley ... on 05 Jan, 2025 10:12 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Unmerge would make a pretty cool / useful right click context menu action on selected transactions.

  4. 4 Posted by -Kevin N. on 05 Jan, 2025 11:04 PM

    -Kevin N.'s Avatar

    +1 for Unmerge.

  5. 5 Posted by jgfolsom on 05 Jan, 2025 11:18 PM

    jgfolsom's Avatar

    Thanks guys! Yes, I envisioned a right-click menu option, but I figured that might be too big of an undertaking for me. I'm going to be moving slowly whenever I can scrape together a few minutes to work on it :)

    For this to be fully fleshed out, it would be nice if there were some kind of icon to denote merged transactions (similar to the "confirmed"/"unconfirmed" circles). But I'm guessing that would be something Infinite Kind would need to add. Am I right?

    Anyway, thanks again! I'll start poking around the API...

  6. 6 Posted by Stuart Beesley ... on 05 Jan, 2025 11:32 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Yes, any new visual icon on the txn register could only be done by IK and core code really. Certainly an extension could not (should not) attempt to do this. But an extension can easily hook into the right click context menu and choose to show itself, or not, depending on the selected txns’ merge status, and then unmerge when clicked.

  7. Support Staff 7 Posted by Sean Reilly on 06 Jan, 2025 03:27 PM

    Sean Reilly's Avatar

    I've just added an icon to indicate merged transactions (attached), and will look into adding a register menu entry to unmerge merged transactions. It's likely not possible to fully unmerge, but we'll see how close we can get.

    Thanks!
    Sean

  8. Support Staff 8 Posted by Sean Reilly on 06 Jan, 2025 05:03 PM

    Sean Reilly's Avatar

    I've also added an "Undo Merge" entry to the register's popup menu and it seems to work! The "undo" support for it isn't quite right, but that should be fixable.

    --
    Sean Reilly
    Developer, The Infinite Kind
    https://infinitekind.com

  9. 9 Posted by Stuart Beesley ... on 06 Jan, 2025 08:47 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    😃 👌 👍

  10. 10 Posted by -Kevin N. on 06 Jan, 2025 09:37 PM

    -Kevin N.'s Avatar

    Thanks Sean, and what Stuart said. :)

  11. 11 Posted by jgfolsom on 07 Jan, 2025 08:54 PM

    jgfolsom's Avatar

    You guys are amazing! Thanks, Sean, for the icon and menu entry.

    I'm not sure of the process here... Is there a way for me to see/use the a version of MD with the icon/menu changes applied? Or will they be in a future release?

    Also, I had assumed this would take much longer than it has! I'm not quite ready to test/flesh out the unmerge functionality yet, but I don't want to hold anyone back who wants to keep working on it. So, feel free!

    Thanks again!

  12. 12 Posted by dwg on 07 Jan, 2025 09:00 PM

    dwg's Avatar

    It is in an Alpha release that is being tested, it should not be used for production. There are some issues still being worked so this will not be a build that is released.

    In due course it will come out in a stable release.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac