hammem / monarchmoney

Python API for Monarch Money
MIT License
124 stars 24 forks source link

[Feature Request] Add additional filters to "get_transactions" #106

Open DarkPhyber-hg opened 2 months ago

DarkPhyber-hg commented 2 months ago

I'd like to see the ability to search by Merchant and Amount.

I'm trying to write a script to categorize my amazon transactions based on my downloaded amazon history. Finding a transaction by date, merchant and amount should allow me to identify most transactions programmatically.

DarkPhyber-hg commented 2 months ago

I've never done a pull request before, or else i'd submit one.

I cloned the repo and played around with the code looking at the chrome dev tools (first time using the dev tools and playing around with apis), i figured out how to find transactions by amount. There are 2 values, that i assume are floats, that can be used as search filters.
absAmountGte & absAmountLte

I assigned them as floats and it works. I've never done a pull request before or else i'd submit one.

under the async def get_transactions() block at line 1412 I added the following 2 lines

        AmountGt: Optional[float] = None,
        AmountLt: Optional[float] = None,

then there are a series of if statements under the comment "# If bool filters are not defined (i.e. None), then it should not apply the filter"

so at line 1546 I added

        if AmountGt is not None:
            variables["filters"]["absAmountGte"] = AmountGt
        if AmountLt is not None:
            variables["filters"]["absAmountLte"] = AmountLt   

Merchants appears to just be a list of Merchant Id's with an api value of "merchants", but i haven't added the code for it yet.