30 lines
887 B
Python
30 lines
887 B
Python
|
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))
|