06/05 Optimize app: report upgrades
This commit is contained in:
@@ -10,6 +10,9 @@ from app.services.ai_service import get_latest_daily_insight
|
||||
from app.services.account_service import get_total_assets, get_total_liabilities
|
||||
from datetime import date, datetime, timedelta
|
||||
import calendar
|
||||
import logging
|
||||
|
||||
log = logging.getLogger('app.dashboard')
|
||||
|
||||
dashboard_bp = Blueprint('dashboard', __name__)
|
||||
|
||||
@@ -250,6 +253,18 @@ def reconcile_api():
|
||||
})
|
||||
|
||||
|
||||
@dashboard_bp.route('/api/anomalies')
|
||||
@login_required
|
||||
def anomalies_api():
|
||||
from app.services.report_service import spending_anomalies
|
||||
try:
|
||||
items = spending_anomalies()
|
||||
except Exception as e:
|
||||
log.warning('[dashboard] anomalies_api failed: %s', e)
|
||||
items = []
|
||||
return jsonify({'anomalies': items})
|
||||
|
||||
|
||||
@dashboard_bp.route('/api/fx-history')
|
||||
@login_required
|
||||
def fx_history_api():
|
||||
|
||||
+12
-8
@@ -5,7 +5,7 @@ from app.models.transaction import Transaction
|
||||
from app.services.report_service import (
|
||||
monthly_report, quarterly_report, yearly_report,
|
||||
net_worth_history, category_trends, tax_year_summary,
|
||||
take_net_worth_snapshot,
|
||||
take_net_worth_snapshot, category_mom_comparison,
|
||||
)
|
||||
from app.services.export_service import (
|
||||
transactions_to_csv, transactions_to_excel,
|
||||
@@ -24,16 +24,16 @@ _CUR_MONTH = date.today().month
|
||||
@login_required
|
||||
def index():
|
||||
today = date.today()
|
||||
# Default: current month summary
|
||||
report = monthly_report(today.year, today.month)
|
||||
report = monthly_report(today.year, today.month)
|
||||
nw_history = net_worth_history()
|
||||
cat_trend = category_trends(6)
|
||||
|
||||
cat_trend = category_trends(6)
|
||||
mom_data = category_mom_comparison()
|
||||
years = list(range(_CUR_YEAR, _CUR_YEAR - 5, -1))
|
||||
return render_template('reports/index.html',
|
||||
report=report,
|
||||
nw_history=nw_history,
|
||||
cat_trend=cat_trend,
|
||||
mom_data=mom_data,
|
||||
years=years,
|
||||
current_year=_CUR_YEAR,
|
||||
current_month=_CUR_MONTH,
|
||||
@@ -46,16 +46,18 @@ def index():
|
||||
@reports_bp.route('/monthly')
|
||||
@login_required
|
||||
def monthly():
|
||||
year = request.args.get('year', _CUR_YEAR, type=int)
|
||||
year = request.args.get('year', _CUR_YEAR, type=int)
|
||||
month = request.args.get('month', _CUR_MONTH, type=int)
|
||||
report = monthly_report(year, month)
|
||||
report = monthly_report(year, month)
|
||||
nw_history = net_worth_history()
|
||||
cat_trend = category_trends(6)
|
||||
cat_trend = category_trends(6)
|
||||
mom_data = category_mom_comparison()
|
||||
years = list(range(_CUR_YEAR, _CUR_YEAR - 5, -1))
|
||||
return render_template('reports/index.html',
|
||||
report=report,
|
||||
nw_history=nw_history,
|
||||
cat_trend=cat_trend,
|
||||
mom_data=mom_data,
|
||||
years=years,
|
||||
current_year=_CUR_YEAR,
|
||||
current_month=_CUR_MONTH,
|
||||
@@ -78,6 +80,7 @@ def quarterly():
|
||||
report=report,
|
||||
nw_history=nw_history,
|
||||
cat_trend=cat_trend,
|
||||
mom_data=[],
|
||||
years=years,
|
||||
current_year=_CUR_YEAR,
|
||||
current_month=_CUR_MONTH,
|
||||
@@ -99,6 +102,7 @@ def yearly():
|
||||
report=report,
|
||||
nw_history=nw_history,
|
||||
cat_trend=cat_trend,
|
||||
mom_data=[],
|
||||
years=years,
|
||||
current_year=_CUR_YEAR,
|
||||
current_month=_CUR_MONTH,
|
||||
|
||||
Reference in New Issue
Block a user