mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 10:28:48 +02:00
All checks were successful
Deploy to VPS / deploy (push) Successful in 24s
DEPOSITO transactions (salaries) were displaying with negative sign and red styling. Flipped logic so only COMPRA is negative; DEPOSITO and DEVOLUCION both show as positive income. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
214 lines
7.5 KiB
Python
214 lines
7.5 KiB
Python
from sqlmodel import Session, select
|
|
|
|
from app.db import engine
|
|
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"),
|
|
("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,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"),
|
|
("Electronics", "cpu", "extremetechcr,extreme tech,ticotek,ishop,gollo,radioshack"),
|
|
("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),
|
|
]
|
|
|
|
|
|
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()
|
|
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()
|
|
|
|
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()
|