From d1174938fa6feb0e1798fe33b231d32c6ead9575 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sun, 11 Feb 2024 14:35:54 +0100 Subject: bootstrap project --- src/.ledger2beancount.yaml | 6 ++++++ src/init.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/.ledger2beancount.yaml create mode 100644 src/init.sh (limited to 'src') diff --git a/src/.ledger2beancount.yaml b/src/.ledger2beancount.yaml new file mode 100644 index 0000000..853809b --- /dev/null +++ b/src/.ledger2beancount.yaml @@ -0,0 +1,6 @@ +--- +date_format: "%d/%m/%Y" +decimal_comma: true +automatic_declarations: false +convert_virtual: false +ignore_marker: NoL2B diff --git a/src/init.sh b/src/init.sh new file mode 100644 index 0000000..32aa300 --- /dev/null +++ b/src/init.sh @@ -0,0 +1,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 <|~/.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}" -- cgit v1.2.3