Aug 17 - Update with utilities management
This commit is contained in:
+14
-2
@@ -116,6 +116,7 @@ def create_app(config_name=None):
|
||||
from app.routes.plaid import plaid_bp
|
||||
from app.routes.logs import logs_bp
|
||||
from app.routes.bank_import import bank_import_bp
|
||||
from app.routes.utilities import utilities_bp
|
||||
|
||||
app.register_blueprint(health_bp)
|
||||
app.register_blueprint(auth_bp)
|
||||
@@ -134,13 +135,14 @@ def create_app(config_name=None):
|
||||
app.register_blueprint(plaid_bp)
|
||||
app.register_blueprint(logs_bp)
|
||||
app.register_blueprint(bank_import_bp)
|
||||
app.register_blueprint(utilities_bp)
|
||||
|
||||
with app.app_context():
|
||||
from app.models import (
|
||||
User, Account, Category, Receipt, RecurringRule,
|
||||
Transaction, Budget, Goal, GoalContribution,
|
||||
Investment, InvestmentTransaction, NetWorthSnapshot,
|
||||
AiInsight, FxRate
|
||||
AiInsight, FxRate, UtilityProvider, UtilityBill
|
||||
)
|
||||
from app.models.teller_enrollment import TellerEnrollment, TellerAccount
|
||||
from app.models.schwab_connection import SchwabConnection, SchwabAccount
|
||||
@@ -152,7 +154,7 @@ def create_app(config_name=None):
|
||||
@app.context_processor
|
||||
def inject_globals():
|
||||
from flask_login import current_user as _u
|
||||
ctx = {'plaid_review_count': 0}
|
||||
ctx = {'plaid_review_count': 0, 'utility_due_count': 0}
|
||||
if _u.is_authenticated:
|
||||
try:
|
||||
from app.models.transaction import Transaction as _T
|
||||
@@ -162,6 +164,16 @@ def create_app(config_name=None):
|
||||
).count()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from app.models.utility import UtilityBill as _UB, DUE_SOON_DAYS
|
||||
from datetime import date as _d, timedelta as _td
|
||||
ctx['utility_due_count'] = _UB.query.filter(
|
||||
_UB.is_paid == False,
|
||||
_UB.due_date.isnot(None),
|
||||
_UB.due_date <= _d.today() + _td(days=DUE_SOON_DAYS),
|
||||
).count()
|
||||
except Exception:
|
||||
pass
|
||||
return ctx
|
||||
|
||||
# ── Session idle timeout ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user