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

Fixes bool filters, add new bool filters, and add createdAt and updatedAt to get_transactions #41

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions monarchmoney/monarchmoney.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@ async def get_transactions(
category_ids: List[str] = [],
account_ids: List[str] = [],
tag_ids: List[str] = [],
has_attachments: bool = False,
has_notes: bool = False,
hidden_from_reports: bool = False,
is_split: bool = False,
is_recurring: bool = False,
has_attachments: Optional[bool] = None,
has_notes: Optional[bool] = None,
hidden_from_reports: Optional[bool] = None,
is_split: Optional[bool] = None,
is_recurring: Optional[bool] = None,
imported_from_mint: Optional[bool] = None,
synced_from_institution: Optional[bool] = None,
) -> Dict[str, Any]:
"""
Gets transaction data from the account.
Expand All @@ -327,6 +329,8 @@ async def get_transactions(
:param hidden_from_reports: a bool to filter for whether the transactions are hidden from reports.
:param is_split: a bool to filter for whether the transactions are split.
:param is_recurring: a bool to filter for whether the transactions are recurring.
:param imported_from_mint: a bool to filter for whether the transactions were imported from mint.
:param synced_from_institution: a bool to filter for whether the transactions were synced from an institution.
"""

query = gql(
Expand Down Expand Up @@ -363,6 +367,8 @@ async def get_transactions(
__typename
}
isSplitTransaction
createdAt
updatedAt
category {
id
name
Expand Down Expand Up @@ -401,14 +407,31 @@ async def get_transactions(
"categories": category_ids,
"accounts": account_ids,
"tags": tag_ids,
"hasAttachments": has_attachments,
"hasNotes": has_notes,
"hideFromReports": hidden_from_reports,
"isRecurring": is_recurring,
"isSplit": is_split,
},
}

# If bool filters are not defined (i.e. None), then it should not apply the filter
if has_attachments is not None:
variables["filters"]["hasAttachments"] = has_attachments

if has_notes is not None:
variables["filters"]["hasNotes"] = has_notes

if hidden_from_reports is not None:
variables["filters"]["hideFromReports"] = hidden_from_reports

if is_recurring is not None:
variables["filters"]["isRecurring"] = is_recurring

if is_split is not None:
variables["filters"]["isSplit"] = is_split

if imported_from_mint is not None:
variables["filters"]["importedFromMint"] = imported_from_mint

if synced_from_institution is not None:
variables["filters"]["syncedFromInstitution"] = synced_from_institution

if start_date and end_date:
variables["filters"]["startDate"] = start_date
variables["filters"]["endDate"] = end_date
Expand Down
Loading