Phase 4 part 4: the spend log and CAC

Spend by month and channel (the funnel's channels and general), by hand
or from pasted CSV (all or nothing); origami.chat and explee.com campaign
spend added hourly as the difference since last seen. CAC per month and
over three months, and per channel over 12 months from each new
customer's first funnel step; unknown, not $0, without spend. Metrics →
Spend and CAC. Schema 21.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 12:45:49 -07:00
co-authored by Claude Opus 5.5
parent 6ba524295b
commit a9a1cb97ac
12 changed files with 686 additions and 2 deletions
+21
View File
@@ -546,6 +546,27 @@ CREATE TABLE crm_matches (
espo_id TEXT NOT NULL DEFAULT '', -- the Account; '' means "not in the CRM"
set_at TEXT NOT NULL
);
`,
// 21: the spend log, for CAC.
`
CREATE TABLE spend (
id INTEGER PRIMARY KEY,
month TEXT NOT NULL, -- YYYY-MM
channel TEXT NOT NULL, -- a funnel channel, or general
amount_cents INTEGER NOT NULL,
note TEXT NOT NULL DEFAULT '',
source TEXT NOT NULL DEFAULT 'manual', -- manual, csv, origami, explee
created_at TEXT NOT NULL
);
CREATE INDEX spend_by_month ON spend (month);
-- What each outside campaign had spent when last seen, so only the
-- difference is added.
CREATE TABLE spend_seen (
source TEXT NOT NULL,
campaign TEXT NOT NULL,
spend_cents INTEGER NOT NULL,
PRIMARY KEY (source, campaign)
);
`,
}