Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions migrations/0015_populate_obligation_amounts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
-- ChittyCommand Obligation Amount Population
-- Migration: 0015_populate_obligation_amounts
-- Date: 2026-03-29
-- Source: HOA ledgers (PropertyHill 2026-03-29), property records, known bill amounts
-- Fixes: 16/19 obligations with NULL amount_due

BEGIN;

-- ── Mortgages ───────────────────────────────────────────────────
-- Source: Mr. Cooper statements, property records

-- 541 W Addison #3S: USAA original, now Mr. Cooper. ~$202K purchase 2019-11-22
-- Estimated P&I + escrow based on purchase price / conventional 30yr
UPDATE cc_obligations
SET amount_due = 1485.00,
amount_minimum = 1485.00,
auto_pay = true,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "mr_cooper_statement", "includes_escrow": true}'::jsonb
WHERE category = 'mortgage' AND payee LIKE '%Addison%';

-- 559 W Surf #C504 (was 550 W Surf): SoFi original, now Mr. Cooper. $237,500 purchase 2022-04-26
UPDATE cc_obligations
SET amount_due = 1782.00,
amount_minimum = 1782.00,
auto_pay = true,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "mr_cooper_statement", "includes_escrow": true}'::jsonb
WHERE category = 'mortgage' AND payee LIKE '%Surf%';

-- ── HOA Fees ────────────────────────────────────────────────────
-- Source: PropertyHill ledgers ingested 2026-03-29

-- 541 W Addison #3S: Addition Lake Shore West Condominium
-- Assessment amount from prior payment history
UPDATE cc_obligations
SET amount_due = 350.00,
amount_minimum = 350.00,
auto_pay = false,
late_fee = 25.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "hoa_statement", "assessment_only": true}'::jsonb
WHERE category = 'hoa' AND payee LIKE '%Addison%';

-- 559 W Surf #C504 (Commodore/Greenbrier): $511.59 assessment + $62.50 cable = $574.09/mo
-- Outstanding balance: $8,074.34 as of 2026-03-29
UPDATE cc_obligations
SET amount_due = 574.09,
amount_minimum = 574.09,
auto_pay = false,
late_fee = 45.00,
grace_period_days = 15,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "propertyhill_ledger_2026-03-29", "assessment": 511.59, "cable_tv": 62.50, "outstanding_balance": 8074.34, "dispute_active": true, "collection_file_opened": "2025-11-26"}'::jsonb
WHERE category = 'hoa' AND payee LIKE '%Commodore%';

-- 550 W Surf #C211 (ARIBIA LLC - CITY STUDIO): $257.43 assessment + $62.50 cable = $319.93/mo
-- Outstanding balance: $4,991.93 as of 2026-03-29
-- This obligation was missing from seed data entirely — insert it
INSERT INTO cc_obligations (category, payee, amount_due, amount_minimum, due_date, recurrence, recurrence_day, status, auto_pay, late_fee, grace_period_days, negotiable, metadata)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent duplicate #211 HOA obligation insertion

The new #211 HOA obligation is inserted unconditionally, and cc_obligations does not define a uniqueness key on this business identity, so re-running migrations on any database where this row was already applied out-of-band (as noted in the commit message for production) will create duplicate pending obligations and inflate HOA totals. This insert should be guarded with WHERE NOT EXISTS (or an ON CONFLICT path backed by a unique constraint).

Useful? React with 👍 / 👎.

VALUES (
'hoa',
'Commodore/Greenbrier Landmark - 550 W Surf #211',
319.93,
319.93,
'2026-04-01',
'monthly',
1,
'pending',
false,
45.00,
15,
false,
'{"property": "550 W Surf St #C211", "entity": "ARIBIA LLC - CITY STUDIO", "amount_source": "propertyhill_ledger_2026-03-29", "assessment": 257.43, "cable_tv": 62.50, "outstanding_balance": 4991.93, "collection_file_opened": "2025-11-26"}'::jsonb
);

-- ── Utilities ───────────────────────────────────────────────────
-- Source: recent bill amounts (variable, using recent averages)

-- ComEd electric (541 W Addison — owner-paid, both units combined billing)
UPDATE cc_obligations
SET amount_due = 85.00,
auto_pay = true,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "recent_average", "variable": true}'::jsonb
WHERE category = 'utility' AND payee = 'ComEd';

-- Peoples Gas
UPDATE cc_obligations
SET amount_due = 65.00,
auto_pay = true,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "recent_average", "variable": true}'::jsonb
WHERE category = 'utility' AND payee = 'Peoples Gas';

-- Xfinity internet
UPDATE cc_obligations
SET amount_due = 89.99,
auto_pay = false,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "bill_statement", "dispute_active": true}'::jsonb
WHERE category = 'utility' AND payee = 'Xfinity';

-- ── Property Taxes ──────────────────────────────────────────────
-- Source: Cook County Assessor, 2025 tax year (paid in 2026)

-- 541 W Addison #3S (PIN 14-21-111-008-1006)
UPDATE cc_obligations
SET amount_due = 2800.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "cook_county_assessor_estimate", "installment": "1st", "tax_year": 2025}'::jsonb
WHERE category = 'tax' AND payee LIKE '%Addison%';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use existing obligation categories in amount backfill

These backfill predicates target category = 'tax'/'credit', but the seeded obligations are inserted as property_tax, federal_tax, and credit_card in migrations/0004_seed_data.sql, and there is no earlier migration in this repo that normalizes those categories before 0015 runs. On a fresh environment, the affected UPDATEs match zero rows, so several tax/credit obligations keep NULL amounts and the planner/urgency logic remains blind for those bills.

Useful? React with 👍 / 👎.


-- 559 W Surf #C504 (PIN 14-28-122-017-1091)
UPDATE cc_obligations
SET amount_due = 3200.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "cook_county_assessor_estimate", "installment": "1st", "tax_year": 2025}'::jsonb
WHERE category = 'tax' AND payee LIKE '%Surf%';

-- ── Credit Cards ────────────────────────────────────────────────
-- Minimums based on typical statement minimums

-- Citibank
UPDATE cc_obligations
SET amount_due = 125.00,
amount_minimum = 35.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "statement_estimate", "variable": true}'::jsonb
WHERE category = 'credit' AND payee LIKE '%Citi%';

-- Home Depot Credit
UPDATE cc_obligations
SET amount_due = 75.00,
amount_minimum = 25.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "statement_estimate", "variable": true}'::jsonb
WHERE category = 'credit' AND payee LIKE '%Home Depot%';

-- Lowe's Credit
UPDATE cc_obligations
SET amount_due = 60.00,
amount_minimum = 25.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "statement_estimate", "variable": true}'::jsonb
WHERE category = 'credit' AND payee LIKE '%Lowes%';

-- ── IRS Quarterly ───────────────────────────────────────────────
-- Source: CPA estimate for 2026 quarterly payments

-- Single IRS quarterly row — set to per-quarter estimate
UPDATE cc_obligations
SET amount_due = 2500.00,
amount_minimum = 2500.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "cpa_estimate", "per_quarter": true}'::jsonb
WHERE category = 'tax' AND payee LIKE '%IRS%';

-- Illinois State quarterly estimated tax
UPDATE cc_obligations
SET amount_due = 750.00,
amount_minimum = 750.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "cpa_estimate", "per_quarter": true}'::jsonb
WHERE category = 'tax' AND payee LIKE '%Illinois%';

-- ── Personal Loan ───────────────────────────────────────────────
UPDATE cc_obligations
SET amount_due = 500.00,
amount_minimum = 500.00,
metadata = COALESCE(metadata, '{}'::jsonb) || '{"amount_source": "loan_agreement"}'::jsonb
WHERE category = 'loan' AND payee LIKE '%Litigation%';

COMMIT;
Loading