Skip to content

Commit 05744e6

Browse files
committed
Add YNAB_FLAG_COLOR env
1 parent c43fb21 commit 05744e6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The configuration is done via environment variables:
6262
* `YNAB_ACCESS_TOKEN`: Go to your budget settings to create one.
6363
* `YNAB_BUDGET_ID`: On the webpage of your budget the last number in the path.
6464
* `YNAB_ACCOUNT_ID`: On the webpage of the account the last uuid in the path.
65+
* `YNAB_FLAG_COLOR`: If set, use that color for the imported transactions.
6566

6667
### FinTS
6768

ing_ynab/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def hash_transaction(transaction):
2828
return sha256(payload.encode("utf-8")).hexdigest()
2929

3030

31-
def transform_transactions(transactions, account_id=None):
31+
def transform_transactions(transactions, account_id=None, flag_color=None):
3232
"""Transform the FinTS transactions into something the YNAB API understands.
3333
"""
3434
transformed = []
@@ -43,6 +43,7 @@ def transform_transactions(transactions, account_id=None):
4343
"payee_name": data["applicant_name"],
4444
"cleared": "cleared",
4545
"memo": data["purpose"],
46+
"flag_color": flag_color,
4647
},
4748
)
4849
return transformed
@@ -96,7 +97,9 @@ def ing_to_ynab(fints_client, fints_account, debug=False):
9697

9798
# Transform FinTS transactions to YNAB transactions.
9899
ynab_transactions = transform_transactions(
99-
transactions, account_id=os.environ["YNAB_ACCOUNT_ID"]
100+
transactions,
101+
account_id=os.environ["YNAB_ACCOUNT_ID"],
102+
flag_color=os.environ.get("YNAB_FLAG_COLOR"),
100103
)
101104

102105
# Print or import the transformed transactions.

0 commit comments

Comments
 (0)