feat: customers show by their company's name, taken from the CNPJ registry
The Site asks for e-mail, CNPJ and WhatsApp only, so the Kanban showed an e-mail where a name belongs and a new Tiny contact was named after it. The worker now looks up each customer's CNPJ in the public registry (BrasilAPI, no key) a few at a time, never while a customer waits, and keeps the razão social and trade name in dtf_local.cnpj_names; a failed lookup is retried a day later. Cards, the order panel, quotes and the search results show the trade name (else the razão social) above the e-mail, the search finds orders and quotes by either name, and a new Tiny contact gets the razão social as its name and the trade name as fantasia. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -226,3 +226,10 @@ ALTER TABLE dtf_local.orders ADD COLUMN IF NOT EXISTS cancel_reason text;
|
||||
-- An order's place in its column's queue, when an operator dragged it up or
|
||||
-- down. Empty means "by payment time"; it is cleared when the order moves on.
|
||||
ALTER TABLE dtf_local.orders ADD COLUMN IF NOT EXISTS queue_key double precision;
|
||||
|
||||
-- The company name behind each customer's CNPJ, from the public registry
|
||||
-- (app/cnpj.py). failed_at alone: the lookup failed and is retried later.
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.cnpj_names (
|
||||
cnpj text PRIMARY KEY, legal_name text, trade_name text,
|
||||
fetched_at timestamptz, failed_at timestamptz
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user