mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 10:28:48 +02:00
Add budget module and push notifications for transactions
All checks were successful
Deploy to VPS / deploy (push) Successful in 34s
All checks were successful
Deploy to VPS / deploy (push) Successful in 34s
Budget: recurring items CRUD, yearly/monthly projections with no-double-count logic, and full UI (overview, monthly detail, recurring items manager). Push notifications: Web Push via VAPID keys, triggered on transaction creation from n8n. Includes service worker handlers, frontend subscription flow, and a test button on the Dashboard (temporary). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
from sqlmodel import Session, select
|
||||
|
||||
from app.db import engine
|
||||
from app.models.models import Account, AccountType, Bank, Category, Currency
|
||||
from app.models.models import (
|
||||
Account,
|
||||
AccountType,
|
||||
Bank,
|
||||
Category,
|
||||
Currency,
|
||||
RecurringFrequency,
|
||||
RecurringItem,
|
||||
RecurringItemType,
|
||||
)
|
||||
|
||||
DEFAULT_CATEGORIES = [
|
||||
("Groceries", "shopping-cart", "automercado,auto mercado,fresh market,macrobiotica,pricesmart,price smart,grassfedcr,pequeno mundo"),
|
||||
@@ -45,6 +54,143 @@ DEFAULT_ACCOUNTS = [
|
||||
]
|
||||
|
||||
|
||||
DEFAULT_RECURRING_ITEMS = [
|
||||
# Incomes
|
||||
{
|
||||
"name": "Alquiler Apt 1",
|
||||
"amount": 320000,
|
||||
"item_type": RecurringItemType.INCOME,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"day_of_month": 1,
|
||||
"notes": "Tenant rent - start of month",
|
||||
},
|
||||
{
|
||||
"name": "Alquiler Apt 2",
|
||||
"amount": 360000,
|
||||
"item_type": RecurringItemType.INCOME,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"day_of_month": 15,
|
||||
"notes": "Tenant rent - mid month",
|
||||
},
|
||||
{
|
||||
"name": "Salario Quincenal 1",
|
||||
"amount": 1400000,
|
||||
"item_type": RecurringItemType.INCOME,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"day_of_month": 15,
|
||||
"notes": "Net salary - mid month",
|
||||
},
|
||||
{
|
||||
"name": "Salario Quincenal 2",
|
||||
"amount": 1400000,
|
||||
"item_type": RecurringItemType.INCOME,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"day_of_month": 30,
|
||||
"notes": "Net salary - end of month",
|
||||
},
|
||||
{
|
||||
"name": "Aguinaldo",
|
||||
"amount": 3000000,
|
||||
"item_type": RecurringItemType.INCOME,
|
||||
"frequency": RecurringFrequency.YEARLY,
|
||||
"month_of_year": 12,
|
||||
"notes": "Yearly bonus",
|
||||
},
|
||||
# Fixed expenses
|
||||
{
|
||||
"name": "Hipoteca",
|
||||
"amount": 450000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Mortgage payment estimate",
|
||||
},
|
||||
{
|
||||
"name": "Comida y Gasolina",
|
||||
"amount": 300000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Food & Gas estimate",
|
||||
},
|
||||
{
|
||||
"name": "CNFL",
|
||||
"amount": 50000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Electricity",
|
||||
},
|
||||
{
|
||||
"name": "Internet",
|
||||
"amount": 50000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Internet service",
|
||||
},
|
||||
{
|
||||
"name": "Municipalidad",
|
||||
"amount": 30000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"override_amounts": {"3": 150000, "6": 150000, "9": 150000, "12": 150000},
|
||||
"notes": "Local gov fees; 150k in property tax quarters",
|
||||
},
|
||||
{
|
||||
"name": "Tennis y Limpieza",
|
||||
"amount": 150000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Tennis lessons + house cleaning",
|
||||
},
|
||||
# Cash transfers
|
||||
{
|
||||
"name": "Empleada Doméstica",
|
||||
"amount": 20000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.WEEKLY,
|
||||
"day_of_month": 0,
|
||||
"notes": "Weekly maid payment (~80k/month)",
|
||||
},
|
||||
{
|
||||
"name": "Clases de Tennis",
|
||||
"amount": 50000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Monthly tennis lessons cash transfer",
|
||||
},
|
||||
# Sporadic
|
||||
{
|
||||
"name": "CCE (Country Club)",
|
||||
"amount": 720000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.YEARLY,
|
||||
"month_of_year": 2,
|
||||
"notes": "Yearly country club fee",
|
||||
},
|
||||
{
|
||||
"name": "Seguro Vehicular",
|
||||
"amount": 150000,
|
||||
"item_type": RecurringItemType.EXPENSE,
|
||||
"frequency": RecurringFrequency.BIANNUAL,
|
||||
"month_of_year": 1,
|
||||
"notes": "Car insurance every 6 months (Jan, Jul)",
|
||||
},
|
||||
# Savings
|
||||
{
|
||||
"name": "Ahorro MEMP",
|
||||
"amount": 200000,
|
||||
"item_type": RecurringItemType.SAVINGS,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Monthly savings to MEMP account",
|
||||
},
|
||||
{
|
||||
"name": "Ahorro MPAT",
|
||||
"amount": 200000,
|
||||
"item_type": RecurringItemType.SAVINGS,
|
||||
"frequency": RecurringFrequency.MONTHLY,
|
||||
"notes": "Monthly savings to MPAT account",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def seed_db():
|
||||
with Session(engine) as session:
|
||||
existing = session.exec(select(Category)).first()
|
||||
@@ -58,3 +204,9 @@ def seed_db():
|
||||
for bank, currency, label, account_type in DEFAULT_ACCOUNTS:
|
||||
session.add(Account(bank=bank, currency=currency, label=label, account_type=account_type))
|
||||
session.commit()
|
||||
|
||||
existing_recurring = session.exec(select(RecurringItem)).first()
|
||||
if not existing_recurring:
|
||||
for item_data in DEFAULT_RECURRING_ITEMS:
|
||||
session.add(RecurringItem(**item_data))
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user