Skip to content

Commit

Permalink
Added ability to ignore transactions and fixed some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacharrisholt committed Jan 21, 2021
1 parent acecec4 commit 16c33f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse_category(transaction, categories, currency_symbol):
return category_map[vendor]
else:
# Create a string of categories to display to the user
categories = ", ".join(category_options)
categories = "{RESET}, {BLUE}".join(category_options)

# Display transaction info to user and have user classify the transaction. If user input is not valid, ask again
while True:
Expand All @@ -45,17 +45,22 @@ def parse_category(transaction, categories, currency_symbol):
f"Amount: {{GREEN}}{currency_symbol}{amount}{{RESET}}\n"
f"Vendor: {{BLUE}}{vendor.title()}{{RESET}}\n"
f"Reference: {{BLUE}}{reference}{{RESET}}\n"
f"Category options are: {categories}\n\n").lower().strip()
f"Category options are: {{BLUE}}{categories}{{RESET}}\n"
f"Alternatively type {{BLUE}}ignore{{RESET}} to ignore this transaction.\n\n").lower().strip()
else:
category = pinput(
f"\nWhat category does the following {{RED}}{transaction_type}{{RESET}} transaction come under?\n\n"
f"Month: {{BLUE}}{month}{{RESET}}\n"
f"Amount: {{RED}}{currency_symbol}{amount}{{RESET}}\n"
f"Vendor: {{BLUE}}{vendor.title()}{{RESET}}\n"
f"Reference: {{BLUE}}{reference}{{RESET}}\n"
f"Category options are: {categories}\n\n").lower().strip()
f"Category options are: {{BLUE}}{categories}{{RESET}}\n"
f"Alternatively type {{BLUE}}ignore{{RESET}} to ignore this transaction.\n\n").lower().strip()

if category not in category_options:
if category == "ignore":
cls()
return ""
elif category not in category_options:
pprint("\n{RED}Invalid category.{RESET}")
continue
else:
Expand Down
Binary file modified test_spreadsheet.xlsx
Binary file not shown.
5 changes: 4 additions & 1 deletion vorn_finance_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
transaction_history = json.load(transaction_history_file)
transaction_history_file.close()

# Creates a copy of transaction history that won't be edited for totalling later in the program
transaction_history_for_totals = transaction_history.copy()

# Iterates through transactions. Uses height of transaction_data DataFrame as number of iterations
for i in range(0, transaction_df.shape[0]):

Expand All @@ -174,7 +177,7 @@


# Two variables to store total amount spent and received across all transactions
can_use = ~transaction_df["Transaction IDs"].isin(transaction_history)
can_use = ~transaction_df["Transaction IDs"].isin(transaction_history_for_totals)
total_in = round(transaction_df.where(can_use).loc[transaction_df["Amounts"] > 0, "Amounts"].sum(), 2)
total_out = round(abs(transaction_df.where(can_use).loc[transaction_df["Amounts"] < 0, "Amounts"].sum()), 2)

Expand Down

0 comments on commit 16c33f5

Please sign in to comment.