Files
bash-scripts/ledger/update.jq
T

54 lines
2.7 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("FANDANGO") then "Expenses:Entertainment:Movies"
elif test("OLLAMA|AAA CLUB ALLIANCE|YouTubePremium|YouTube Member|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|ATLASCOFFEECLUB|WHOLEFDS") then "Expenses:Food:Groceries"
elif test("PROJECT GLOW \\(FOOD\\)|SPICELIFE|CHICK-FIL-A|GEMELLIS\\s+ITALIAN|CHIPOTLE|SHEETZ|KUNG\\s+FU\\s+TEA|&SHAWARMA|&PIZZA|KOREAN BBQ") 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|NEIGHBORS) COFFEE|BLACK LION CAFE|COFFEE REPUBLIC") then "Expenses:Luxuries:Drinks"
elif test("PROG SELECT INS") then "Expenses:Auto:Insurance"
elif test("AUTOZONE|KING FARM AUTO|CAR WASH") then "Expenses:Auto:Maintenance"
elif test("Interest earned") then "Income:Interest"
elif test("IONNA") then "Expenses:Travel:Fuel"
elif test("66EXPRESSLANES|DRIVEEZMD") then "Expenses:Travel:Tolls"
elif test("LIME\\*PASS") then "Expenses:Travel:Rental"
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[]