diff --git a/cli/AccountStatement.py b/cli/AccountStatement.py index c3aa0c2..9feaf73 100644 --- a/cli/AccountStatement.py +++ b/cli/AccountStatement.py @@ -20,10 +20,6 @@ def perform(dbh, params): ) template = getParam(params, 'template', 'accountStatement.tmpl') - prefix = getParam(params, 'prefix', 'accountStatement') - suffix = getParam(params, 'suffix', 'tex') input = { 'year': year, 'entries': accountEntries } - outputFile = f"{prefix}-{year}.{suffix}" tmpl = Template(file=template, searchList=[ input ]) - with open(outputFile, 'w') as f: - f.write(str(tmpl)) + print(tmpl) diff --git a/cli/AccountStatement.sh b/cli/AccountStatement.sh new file mode 100755 index 0000000..9998ddd --- /dev/null +++ b/cli/AccountStatement.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +SHOW="0" +PRINT="0" +while getopts "y:sphP:" flag +do + case "${flag}" in + h) + echo "y ... year for statement"; + echo "s ... show output using evince"; + echo "p ... print output"; + echo "P ... printer name"; + exit 1; + ;; + y) + YEAR=${OPTARG} + ;; + s) + SHOW="1" + ;; + p) + PRINT="1" + ;; + P) + PRINTER="-P ${OPTARG}" + ;; + esac +done + +if [ "$YEAR" = "" ]; then + echo "give year for statement as argument" + exit 1 +fi + +python3.10 hv2cli.py -o AccountStatement -p '{"year":'$YEAR'}' > $YEAR.tex +pdflatex $YEAR.tex + +if [ "$SHOW" = "1" ]; then + evince $YEAR.pdf +fi + +if [ "$PRINT" = "1" ]; then + lpr $PRINTER $YEAR.pdf +fi + diff --git a/cli/accountStatement.tmpl b/cli/accountStatement.tmpl index d72b41e..1aa7d2a 100644 --- a/cli/accountStatement.tmpl +++ b/cli/accountStatement.tmpl @@ -11,26 +11,26 @@ \subsection*{Kontoauszug $year} -\begin{longtable}{rrp{5cm}rrrp{3cm}l} - \bf{id} & \bf{createdAt} & \bf{description} & \bf{amount} & \bf{documentNo} & \bf{fiscalYear} & \bf{category} & \bf{account} \\ \hline +\begin{longtable}{|r|r|p{5cm}|r|r|r|p{3cm}|r|p{5cm}|} + \hline \textcolor{blue}{\tt{id}} & \textcolor{blue}{\tt{date}} & \textcolor{blue}{\tt{description}} & \textcolor{blue}{\tt{amount}} & \textcolor{blue}{\tt{docNo}} & \textcolor{blue}{\tt{year}} & \textcolor{blue}{\tt{category}} & \textcolor{blue}{\tt{isRef}} & \textcolor{blue}{\tt{baseAccount}} \\ \hline \hline \endfirsthead - \bf{id} & \bf{createdAt} & \bf{description} & \bf{amount} & \bf{documentNo} & \bf{fiscalYear} & \bf{category} & \bf{account} \\ \hline + \hline \textcolor{blue}{\tt{id}} & \textcolor{blue}{\tt{date}} & \textcolor{blue}{\tt{description}} & \textcolor{blue}{\tt{amount}} & \textcolor{blue}{\tt{docNo}} & \textcolor{blue}{\tt{year}} & \textcolor{blue}{\tt{category}} & \textcolor{blue}{\tt{isRef}} & \textcolor{blue}{\tt{baseAccount}} \\ \hline \hline \endhead - \hline \multicolumn{8}{r}{\em{to be continued}} + \multicolumn{9}{r}{\em{to be continued}} \endfoot - \hline + \endlastfoot #for $entry in $entries \tt{$entry['id']} & \tt{$entry['created_at']} & \tt{$entry['description']} & #slurp -#if not $entry['income'] +#if $entry['amount'] <= 0 \textcolor{red}{#slurp #end if \tt{$entry['amount']}#slurp -#if not $entry['income'] +#if $entry['amount'] <= 0 }#slurp #end if -& \tt{$entry['document_no']} & \tt{$entry['fiscal_year']} & \tt{$entry['category']} & \tt{{ $entry['account'].replace('_', '\\textunderscore ') }} \\ +& \tt{$entry['document_no']} & \tt{$entry['fiscal_year']} & \tt{$entry['category']} & \tt{$entry['is_reference']} & \tt{{$entry['base_account'].replace('_', ' ') }} \\ \hline #end for \end{longtable} diff --git a/schema/account-statement.sql b/schema/account-statement.sql index fc61444..449181b 100644 --- a/schema/account-statement.sql +++ b/schema/account-statement.sql @@ -6,12 +6,15 @@ create or replace view account_statement_v as ae.document_no as document_no, ae.fiscal_year as fiscal_year, aec.description as category, - aec.income as income, - ac.description as account - from account_entry_t ae, + ac.description as account, + ae.is_reference as is_reference, + bac.description as base_account + from joined_account_entry_v ae, account_entry_category_t aec, - account_t ac + account_t ac, + account_t bac where ae.account_entry_category = aec.id and ae.account = ac.id and - aec.id not in (3, 4) + ae.base_account = bac.id and + ac.id = 1000 order by created_at; diff --git a/schema/changes02.sql b/schema/changes02.sql index 672f385..baead02 100644 --- a/schema/changes02.sql +++ b/schema/changes02.sql @@ -5,7 +5,7 @@ CREATE TABLE account_entry_reference_t ( ); -CREATE OR REPLACE VIEW joined_account_entry_t AS +CREATE OR REPLACE VIEW joined_account_entry_v AS SELECT ae.id as id, ae.description as description, ae.account as account,