feat: customers see an order code, not the sequential number
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 3m2s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped

"Minha conta" lists and opens orders as "Pedido 1E867B56" (the first 8
characters of the order's id) and searches by that code, so a customer never
sees how many orders the store has. The Kanban shows the code beside the #
number, with a copy button, and its search finds an order by the code a
customer reads out. Tiny keeps its reference (DTF-<number>): it is how a
resent order is found there instead of duplicated, and the WhatsApp notices
the client sends from Tiny use Tiny's own number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-02 16:50:26 -03:00
parent c19941555e
commit d7b1eaae6d
7 changed files with 41 additions and 15 deletions

View File

@@ -301,6 +301,11 @@ def search(q: str = Query(min_length=2, max_length=100), user=Depends(operator))
if digits and len(digits) <= 9:
sql += ' OR number=%s'
params.append(int(digits))
# The code a customer reads out (the id's first characters, see order_code).
code = q.strip().lstrip('#').lower()
if 6 <= len(code) <= 12 and re.fullmatch(r'[0-9a-f]+', code):
sql += " OR replace(id::text,'-','') LIKE %s"
params.append(code + '%')
quote_match, quote_params = customer_match('q.draft', q)
with db.connect() as c:
orders = c.execute(f'''SELECT * FROM dtf_local.orders WHERE {sql}