Last active
June 27, 2022 02:12
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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