← back to AbramsOS

scripts/seed-unclaimed-ca.js

61 lines

#!/usr/bin/env node
// Seed the California unclaimed-property records found for Steve on 2026-07-31
// via claimit.ca.gov. Idempotent: upserts on (user_id, property_id).
// Public property data only — no SSN / identity. Status defaults to 'staged'
// because these are already selected in the claimit.ca.gov claim cart
// (relationship = "Myself"), awaiting Steve's FILE CLAIM + signature.

require('dotenv').config();
const db = require('../lib/db');

const USER_ID = process.env.UCP_USER_ID || 'user_steve';

const PROPERTIES = [
  { property_id: '1024857116', holder_name: 'Grace Class Action',        owner_name: 'ABRAMS STEVE', address: '1501 S Durango Ave',       city: 'Los Angeles',  zip: '90035', amount_display: '$30.43', property_type: 'Misc Outstanding Checks' },
  { property_id: '972437075',  holder_name: 'PayPal Inc',                owner_name: 'ABRAMS STEVE', address: '1482 Shenandoah Ave #203', city: 'Los Angeles',  zip: '90035', amount_display: '$66.50', property_type: 'Misc Intangible Prop' },
  { property_id: '964119998',  holder_name: 'New Hampshire Indemnity Co', owner_name: 'STEVE ABRAMS', address: '1501 S Durango Ave',       city: 'Los Angeles',  zip: '90035', amount_display: '$5.00',  property_type: 'Premium Refunds' },
  { property_id: '1041807865', holder_name: 'Google Payment Corporation', owner_name: 'ABRAMS STEVE', address: '15442 Ventura Blvd #201',  city: 'Sherman Oaks', zip: '91403', amount_display: '$9.15',  property_type: 'Credit Bal - Accts Receivable' },
  { property_id: '961308880',  holder_name: 'UBS Financial Services',     owner_name: 'ABRAMS STEVE', address: '914 20th St Apt A',        city: 'Santa Monica', zip: '90403', amount_display: '$20.47', property_type: 'Credit Balances' },
];

function centsFrom(display) {
  const m = String(display).match(/\$?([\d,]+)\.(\d{2})/);
  if (!m) return null;
  return parseInt(m[1].replace(/,/g, ''), 10) * 100 + parseInt(m[2], 10);
}

async function main() {
  let n = 0;
  for (const p of PROPERTIES) {
    await db.query(
      `INSERT INTO unclaimed_property
         (id, user_id, jurisdiction, property_id, holder_name, owner_name, address, city, state, zip,
          amount_cents, amount_display, property_type, source, status)
       VALUES ($1,$2,'US-CA',$3,$4,$5,$6,$7,'CA',$8,$9,$10,$11,'claimit.ca.gov','staged')
       ON CONFLICT (user_id, property_id) DO UPDATE SET
         holder_name = EXCLUDED.holder_name,
         owner_name  = EXCLUDED.owner_name,
         address     = EXCLUDED.address,
         city        = EXCLUDED.city,
         zip         = EXCLUDED.zip,
         amount_cents = EXCLUDED.amount_cents,
         amount_display = EXCLUDED.amount_display,
         property_type  = EXCLUDED.property_type,
         updated_at  = now()`,
      [
        `ucp_${p.property_id}`, USER_ID, p.property_id, p.holder_name, p.owner_name,
        p.address, p.city, p.zip, centsFrom(p.amount_display), p.amount_display, p.property_type,
      ]
    );
    n++;
  }
  const tot = await db.query(
    `SELECT count(*)::int AS c, COALESCE(sum(amount_cents),0)::int AS cents
       FROM unclaimed_property WHERE user_id = $1`, [USER_ID]);
  console.log(`seeded/updated ${n} CA unclaimed-property rows`);
  console.log(`total tracked: ${tot.rows[0].c} properties, $${(tot.rows[0].cents / 100).toFixed(2)}`);
  process.exit(0);
}

main().catch((e) => { console.error(e); process.exit(1); });