Updated ledger to autocategorize transactions

This commit is contained in:
Random936
2026-02-03 20:45:35 -05:00
parent 7d83c328be
commit b8c01492e2

View File

@@ -1,3 +1,23 @@
# Takes in a string as the transaction description and returns the
# acconut to categorize as.
def categorize_transaction:
if test("MURNMGMT-MIRA") then "Expenses:Bills:Rent"
elif test("VERIZON\\s+DES") then "Expenses:Bills:Internet"
elif test("PEPCO\\s+PAYMENTUS|WASHINGTON\\s+GAS\\s+DES") then "Expenses:Bills:Utilities"
elif test("HEALTHEQUITY\\s+INC") then "Assets:HealthEquity"
elif test("LOCKHEED\\s+MARTIN") then "Income:Work"
elif test("CASH\\s+REWARDS") then "Income:Gifts"
elif test("Roosters") then "Expenses:Essentials:Hygiene"
elif test("ALASKA\\s+AIR") then "Expenses:Travel:Flights"
elif test("HELP\\.UBER\\.COMCA") then "Expenses:Travel:Taxi"
elif test("STEAM GAMES") then "Expenses:Entertainment:Games"
elif test("YouTubePremium|DOORDASHDASHPASS|Prime\\s+Video\\s+Channels|TIDAL\\.COM|Amazon Grocery|SIMPLEFIN BRIDGE|(APPLE\\.COM.*RECURRING$)") then "Expenses:Subscriptions"
elif test("MOMS OF|SAFEWAY\\.COM|MAYORGA") then "Expenses:Food:Groceries"
elif test("CHICK-FIL-A|GEMELLIS\\s+ITALIAN|CHIPOTLE|SHEETZ|KUNG\\s+FU\\s+TEA") then "Expenses:Food:Restaurants"
elif test("GRUBHUB|DD\\s+\\*DOORDASH") then "Expenses:Food:Delivery"
elif test("MARKET@WORK") then "Expenses:Food:Snacks"
else "UNKNOWN" end;
def format_transactions:
map(
.name as $name |
@@ -7,7 +27,7 @@ def format_transactions:
sort_by(.transacted_at) |
map(
(.transacted_at | strftime("%Y/%m/%d")) + " " +
(.description | gsub("\\s+"; " ")) + "\n UNKNOWN $" +
(.description | gsub("\\s+"; " ")) + "\n " + (.description | categorize_transaction) + " $" +
(-(.amount | tonumber) | tostring) + " ; Payee: " +
.payee + "\n " +
.account + "\n"
@@ -20,4 +40,4 @@ def rename_accounts:
elif (.| startswith("Amazon Prime Rewards Visa Signature")) then "Amazon"
end));
.accounts | rename_accounts | format_transactions[]
.accounts | rename_accounts | format_transactions[]