blob: 32aa3007c17024e8f719fec9112a7b3632dd201e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/bash
set -eufCo pipefail
export SHELLOPTS
IFS=$'\t\n'
PORT=${PORT:-5000}
LEDGER_ROOT=${LEDGER_ROOT:-/ledger}
LEDGER2BEANCOUNT_CONFIG=${LEDGER2BEANCOUNT_CONFIG:-$(cat ~/.ledger2beancount.yaml)}
ADDITIONAL_CONFIG=${ADDITIONAL_CONFIG:-$(
cat <<EOF
option "operating_currency" "EUR"
2016-04-14 custom "fava-option" "language" "en"
2016-04-14 custom "fava-option" "invert-income-liabilities-equity" "true"
EOF
)}
echo "${LEDGER2BEANCOUNT_CONFIG}" >|~/.ledger2beancount.yaml
echo "LEDGER2BEANCOUNT_CONFIG"
cat ~/.ledger2beancount.yaml
echo
echo "ADDITIONAL_CONFIG"
echo "$ADDITIONAL_CONFIG"
echo
tmp_file=$(mktemp)
while read -r ledger_file; do
echo "Processing ${ledger_file}"
ledger2beancount -c ~/.ledger2beancount.yaml "$(realpath "${ledger_file}")" >>"${tmp_file}"
done < <(find "${LEDGER_ROOT}" -type f -name '*.ledger')
bean-check "${tmp_file}"
echo "${ADDITIONAL_CONFIG}" >>"${tmp_file}"
fava \
--host 0.0.0.0 \
--port "${PORT}" \
--read-only \
"${tmp_file}"
rm "${tmp_file}"
|