Files
bash-scripts/ledger/update.jq
2026-06-08 12:48:38 -04:00

50 lines
2.3 KiB
Plaintext

# 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("OLLAMA|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("PROJECT GLOW \\(FOOD\\)|SPICELIFE|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"
elif test("PROJECT GLOW \\(BEV\\)|NAGADI COFFEE|BLACK LION CAFE") then "Expenses:Luxuries:Drinks"
elif test("PROG SELECT INS") then "Expenses:Auto:Insurance"
elif test("AUTOZONE") then "Expenses:Auto:Maintenance"
elif test("Interest earned") then "Income:Interest"
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 (.| contains("7778")) then "Checking"
elif (.| contains("8704")) then "Assets:Sofi:Checking"
elif (.| contains("5809")) then "Credit"
elif (.| contains("3116")) then "Amazon"
elif (.| contains("3013")) then "Savings"
end));
.accounts | rename_accounts | format_transactions[]