Files
WealthySmart/backend/app/seed.py
Carlos Escalante 0a8e00e227
All checks were successful
Deploy to VPS / deploy (push) Successful in 45s
Add accounts expansion, analytics, exchange rates, API tokens, PWA support, and UI overhaul
- Expand Account model with account_type (pension, savings, liability, crypto), new banks/currencies (BTC, XMR, FCL, ROP, VOL, MEMP, MPAT, MORTGAGE), and next_payment field
- Add exchange rate endpoint (BCCR integration), analytics endpoint, paste-import for transactions, and API token management
- Add PWA manifest, service worker, and app icons
- Redesign dashboard, transactions, transfers, and login pages with theme support
- Add billing cycle selector, confirm dialog, and paste import modal components
- One-time DB reset in deploy workflow for schema migration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 18:23:47 -06:00

61 lines
3.1 KiB
Python

from sqlmodel import Session, select
from app.db import engine
from app.models.models import Account, AccountType, Bank, Category, Currency
DEFAULT_CATEGORIES = [
("Groceries", "shopping-cart", "automercado,auto mercado,fresh market,macrobiotica,pricesmart,price smart,grassfedcr,pequeno mundo"),
("Food & Delivery", "utensils", "uber eats,rappi,mcdonalds,subway,pizza,restaurant,soda,cafe,coyote ugly,el rodeo,steak house"),
("Utilities", "zap", "c.n.f.l,cnfl,ice,aya,claro cr telecomunicaciones"),
("Transportation", "car", "gasolina,gasolinera,uber rides,didi,parqueo,parking,peaje,estacion de servicio,estac.de serv"),
("Shopping", "shopping-bag", "amazon,ebay,ticotek,construplaza,epa,novex,novedades chayfer,total imports,tiendalaliga,gnc live well"),
("Entertainment", "film", "netflix,disney,cine,steam,playstation,blizzard,diablo"),
("Health", "heart-pulse", "farmacia,hospital,clinica,laboratorio,optica,medicina regenerativa,neumi,doer fitness,kettlebell,lacrosse"),
("Education", "graduation-cap", "universidad,udemy,coursera,libro"),
("Housing", "home", "hipoteca,alquiler,municipalidad,condominio,bac san jose pensiones"),
("Insurance", "shield", "seguro,ins"),
("Subscriptions", "repeat", "cloudflare,github,google one,apple,icloud,spotify,openai,claude.ai,cursor,netcup"),
("Telecom", "phone", "liberty,tigo,kolbi"),
("Parking & Fees", "circle-parking", "centro comercial curridabat,debito compass,cobro administr,compass"),
("Auto", "car-front", "auto lavado,lavado"),
("Lab & Medical", "microscope", "laboratorio echandi"),
("Other", "tag", ""),
]
DEFAULT_ACCOUNTS = [
# Bank accounts
(Bank.BAC, Currency.CRC, "BAC", AccountType.BANK),
(Bank.BAC, Currency.USD, "BAC", AccountType.BANK),
(Bank.BCR, Currency.CRC, "BCR", AccountType.BANK),
(Bank.BCR, Currency.USD, "BCR", AccountType.BANK),
(Bank.DAVIVIENDA, Currency.CRC, "DAV", AccountType.BANK),
(Bank.DAVIVIENDA, Currency.USD, "DAV", AccountType.BANK),
# Pensions (CRC)
(Bank.FCL, Currency.CRC, "FCL", AccountType.PENSION),
(Bank.ROP, Currency.CRC, "ROP", AccountType.PENSION),
(Bank.VOL, Currency.CRC, "VOL", AccountType.PENSION),
# Savings (CRC)
(Bank.MEMP, Currency.CRC, "MEMP", AccountType.SAVINGS),
(Bank.MPAT, Currency.CRC, "MPAT", AccountType.SAVINGS),
# Liabilities
(Bank.MORTGAGE, Currency.USD, "Mortgage", AccountType.LIABILITY),
# Crypto
(Bank.BAC, Currency.BTC, "BTC", AccountType.CRYPTO),
(Bank.BAC, Currency.XMR, "XMR", AccountType.CRYPTO),
]
def seed_db():
with Session(engine) as session:
existing = session.exec(select(Category)).first()
if not existing:
for name, icon, patterns in DEFAULT_CATEGORIES:
session.add(Category(name=name, icon=icon, auto_match_patterns=patterns))
session.commit()
existing_acc = session.exec(select(Account)).first()
if not existing_acc:
for bank, currency, label, account_type in DEFAULT_ACCOUNTS:
session.add(Account(bank=bank, currency=currency, label=label, account_type=account_type))
session.commit()