Skip to content

Instantly share code, notes, and snippets.

@mtlynch
Last active June 27, 2022 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtlynch/e62a3a73476b2f36fd98fcabd4102618 to your computer and use it in GitHub Desktop.
Save mtlynch/e62a3a73476b2f36fd98fcabd4102618 to your computer and use it in GitHub Desktop.
Bash script for checking unmatched transfers in a beancount journal (https://redd.it/vlkaxp)
#!/bin/bash
set -eu
JOURNAL="myjournal.beancount" # Replace with your beancount file
RESULT="$(bean-query "${JOURNAL}" \
'SELECT account, sum(position)
WHERE account = "Assets:Transfers";')"
TRANSFERS_LINE="$(echo "${RESULT}" | grep "^Assets:Transfers")"
if echo "${TRANSFERS_LINE}" | grep --quiet "^Assets:Transfers *$"; then
echo "No outstanding transfers for ${JOURNAL}"
else
echo "ERROR: Outstanding transfers for ${JOURNAL}"
echo "${TRANSFERS_LINE}"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment