Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Split a transaction #25

Closed
grablair opened this issue Nov 9, 2023 · 3 comments
Closed

[Feature] Split a transaction #25

grablair opened this issue Nov 9, 2023 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@grablair
Copy link
Collaborator

grablair commented Nov 9, 2023

Add the ability to split a transaction

@hammem hammem added enhancement New feature or request help wanted Extra attention is needed labels Nov 9, 2023
@jprouty
Copy link
Contributor

jprouty commented Jan 2, 2024

I was exploring the web app today to map out the relevant graphgl queries. Here's what I see:

  • GetTransactionsList - once split, the list contains only the split transactions which are denoted with isSplitTransaction: True member. There is no transaction member that indicates the parent transaction id (originalTransaction as MM likes to call it).
  • GetTransactionDrawer - for split transactions, this query returns detailed per-transaction members to populate the drawer/side bar in the web app. Once a transaction is split, I cannot find a place in the UI such that the original transaction is shown again (unless you unsplit it - see below). The hasSplitTransactions: <bool> and splitTransactions: [] members seem to indicate that if given a parent id as the query id it would return all splits; this isn't particularly useful because the UI invokes another query, described below, for getting all of the splits for a given transaction id. Importantly, this call does indicate the parent transactions by including the originalTransaction member (real example):
"data": {
    "getTransaction": {
        "id": "123childID321", <- Fake
        ...other transaction members...
        "hasSplitTransactions": false,
        "isSplitTransaction": true,
        "splitTransactions": [],
        "originalTransaction": {
            "id": "123parentID321", <- Fake
            "date": "2024-01-02",
            "amount": -100.0,
            "merchant": {
                "id": "12321", <- Fake
                "name": "Test",
                "__typename": "Merchant"
            },
            "__typename": "Transaction"
        }
    }
}
  • TransactionSplitQuery - the UI invokes this query when bringing up the split dialog (which allows for creating, adjusting, deleting splits). Given the parent transaction id, returns a list of transaction ids that are the children splits.
  • SplitTransactionMutation - query for creating, modifying, deleting splits. All operate on the parent transaction id and are given a splitData array for how to divide the transaction. From the UI, you can only provide the new amount, merchantName, and category. If the parent transaction already has a note (or I imagine also tags - to be verified), these are cloned onto each split transaction automagically.

Deleting is the simplest: given the parent transaction id and splitData=[], delete all children transactions and return the parent transaction as the only transaction.

Creating and modifying splits are the same: given the parent transaction id and splitData=[...children splits...], where sum([s.amount for split in splitData]) == parentTranasction.amount, creates len(splitData) new transactions that are displayed in the UI in place of the parentTranasction; if parentTranasction already had splitTransactions, then replace those with the new splitData.

Next step I am translating the network captures I've made into a working version and will create a PR once things look right.

@hammem
Copy link
Owner

hammem commented Jan 5, 2024

@grablair , can you confirm @jprouty 's PR addresses this issue?

@grablair
Copy link
Collaborator Author

grablair commented Jan 5, 2024

I believe it does. We can close this and open another one if someone discovers we are missing something.

@grablair grablair closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants