Kontoauszug
This commit is contained in:
29
cli/AccountStatement.py
Normal file
29
cli/AccountStatement.py
Normal file
@ -0,0 +1,29 @@
|
||||
from db import dbGetMany
|
||||
from loguru import logger
|
||||
import datetime
|
||||
import iso8601
|
||||
from utils import getParam
|
||||
from Cheetah.Template import Template
|
||||
|
||||
def perform(dbh, params):
|
||||
year = getParam(params, 'year', datetime.datetime.today().year)
|
||||
|
||||
accountEntries = dbGetMany(
|
||||
dbh,
|
||||
{
|
||||
"statement": "SELECT * FROM account_statement_v WHERE fiscal_year = %(year)s",
|
||||
"params": {
|
||||
'year': year
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
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))
|
Reference in New Issue
Block a user