# 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 | .transactions | map(.account = $name)[] ) | sort_by(.transacted_at) | map( (.transacted_at | strftime("%Y/%m/%d")) + " " + (.description | gsub("\\s+"; " ")) + "\n " + (.description | categorize_transaction) + " $" + (-(.amount | tonumber) | tostring) + " ; Payee: " + .payee + "\n " + .account + "\n" ); def rename_accounts: map(.name |= ( if (.| startswith("Adv Plus Banking")) then "Checking" elif (.| startswith("Unlimited Cash Rewards Visa Signature")) then "Credit" elif (.| startswith("Amazon Prime Rewards Visa Signature")) then "Amazon" end)); .accounts | rename_accounts | format_transactions[]