fix(checkout): pull company from intake_data (compliance has no customer_company col)
compliance_orders stores company in intake_data JSON, not a column; read it from there (company/legal_name/entity_name) with graceful fallback. Fix e2e test seed accordingly.
This commit is contained in:
parent
9987b1e30d
commit
3c65dd8748
2 changed files with 15 additions and 3 deletions
|
|
@ -188,7 +188,18 @@ async function ensureCompliancePortalUser(
|
|||
if (!first) return;
|
||||
const email = ((first.customer_email as string) || "").toLowerCase().trim();
|
||||
const name = (first.customer_name as string) || email.split("@")[0] || "Customer";
|
||||
const company = (first.customer_company as string) || null;
|
||||
// Company: compliance_orders has no customer_company column; it lives in
|
||||
// intake_data. Fall back gracefully across order types.
|
||||
let company: string | null = (first.customer_company as string) || null;
|
||||
if (!company && first.intake_data) {
|
||||
try {
|
||||
const intake = typeof first.intake_data === "string"
|
||||
? JSON.parse(first.intake_data as string)
|
||||
: (first.intake_data as Record<string, unknown>);
|
||||
company = (intake.company as string) || (intake.legal_name as string)
|
||||
|| (intake.entity_name as string) || null;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
if (!email) return;
|
||||
|
||||
// Skip only the genuine FMCSA-census placeholder, never a real customer who
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ try {
|
|||
await pool.query(
|
||||
`INSERT INTO compliance_orders
|
||||
(order_number, service_slug, service_name, customer_name, customer_email,
|
||||
customer_company, payment_method, payment_status, total_cents, service_fee_cents)
|
||||
payment_method, payment_status, total_cents, service_fee_cents, intake_data)
|
||||
VALUES ($1,'dot-drug-alcohol','DOT Drug & Alcohol Compliance Program',
|
||||
'E2E Tester','${EMAIL}','E2E Co','paypal','pending_payment',14900,14900)`,
|
||||
'E2E Tester','${EMAIL}','paypal','pending_payment',14900,14900,
|
||||
'{"company":"E2E Co"}'::jsonb)`,
|
||||
[ORDER],
|
||||
);
|
||||
ok(`seeded pending compliance order ${ORDER}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue