Allow preparing trial balance and income statement reports at arbitrary dates
This commit is contained in:
parent
4cff4c9432
commit
ef711f1828
@ -22,6 +22,7 @@ from .plugins import account_kinds, advanced_reports, data_sources
|
|||||||
from .reports import balance_sheet_report, income_statement_report
|
from .reports import balance_sheet_report, income_statement_report
|
||||||
from .webapp import all_transactions, api_transactions, app
|
from .webapp import all_transactions, api_transactions, app
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@ -69,8 +70,10 @@ def general_ledger():
|
|||||||
|
|
||||||
@app.route('/trial-balance')
|
@app.route('/trial-balance')
|
||||||
def trial_balance():
|
def trial_balance():
|
||||||
balancer = TrialBalancer.from_cached()
|
dt = datetime.strptime(request.args['date'], '%Y-%m-%d') if 'date' in request.args else None
|
||||||
balancer.apply_transactions(api_transactions())
|
|
||||||
|
balancer = TrialBalancer.from_cached(end_date=dt)
|
||||||
|
balancer.apply_transactions(api_transactions(end_date=dt))
|
||||||
|
|
||||||
total_dr = Amount(sum(v.quantity for v in balancer.accounts.values() if v.quantity > 0), reporting_commodity())
|
total_dr = Amount(sum(v.quantity for v in balancer.accounts.values() if v.quantity > 0), reporting_commodity())
|
||||||
total_cr = Amount(sum(v.quantity for v in balancer.accounts.values() if v.quantity < 0), reporting_commodity())
|
total_cr = Amount(sum(v.quantity for v in balancer.accounts.values() if v.quantity < 0), reporting_commodity())
|
||||||
@ -126,5 +129,13 @@ def balance_sheet():
|
|||||||
|
|
||||||
@app.route('/income-statement')
|
@app.route('/income-statement')
|
||||||
def income_statement():
|
def income_statement():
|
||||||
report = income_statement_report()
|
if 'end_date' in request.args:
|
||||||
|
start_date = datetime.strptime(request.args['start_date'], '%Y-%m-%d') if 'start_date' in request.args else datetime.min
|
||||||
|
end_date = datetime.strptime(request.args['end_date'], '%Y-%m-%d')
|
||||||
|
|
||||||
|
print(end_date)
|
||||||
|
else:
|
||||||
|
start_date, end_date = None, None
|
||||||
|
|
||||||
|
report = income_statement_report(start_date=start_date, end_date=end_date)
|
||||||
return render_template('report.html', report=report)
|
return render_template('report.html', report=report)
|
||||||
|
Loading…
Reference in New Issue
Block a user