feat: customers buy with a CPF or a CNPJ
All checks were successful
Build and deploy / Validate source (push) Successful in 1m38s
Build and deploy / Integration suite on a real stack (push) Successful in 4m57s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 2m1s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m38s
Build and deploy / Integration suite on a real stack (push) Successful in 4m57s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 2m1s
The cart and the account signup take either document, each with its own mask and check digits. Tiny gets a person (F) for a CPF, Mercado Pago the matching identification type, and only CNPJs go to the company registry. The Kanban, the account page and the alerts show which one it is. Also pins the Correios test's clock: its fake token expired today, so the suite failed from Oct 16 on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -360,12 +360,13 @@ def money(cents):
|
||||
|
||||
def contact_payload(order, company=None):
|
||||
"""A new contact, named after the company's razão social when the
|
||||
registry gave it (app/cnpj.py), else the recipient or the e-mail."""
|
||||
registry gave it (app/cnpj.py), else the recipient or the e-mail. A CPF
|
||||
(11 digits) is a person (F), a CNPJ a company (J)."""
|
||||
customer = order['customer']
|
||||
destination = order.get('destination')
|
||||
company = company or {}
|
||||
contact = {'nome': company.get('legal') or (destination or {}).get('recipient') or customer['mail'],
|
||||
'tipoPessoa': 'J', 'cpfCnpj': customer['cnpj'], 'email': customer['mail'],
|
||||
'tipoPessoa': 'F' if len(customer['cnpj']) == 11 else 'J', 'cpfCnpj': customer['cnpj'], 'email': customer['mail'],
|
||||
'celular': customer['zap'], 'situacao': 'A'}
|
||||
if company.get('trade'):
|
||||
contact['fantasia'] = company['trade']
|
||||
@@ -560,7 +561,7 @@ class TinyOrders:
|
||||
if ''.join(ch for ch in str(entry.get('cpfCnpj') or '') if ch.isdigit()) == cnpj:
|
||||
return entry['id']
|
||||
company = None
|
||||
if self.names:
|
||||
if self.names and len(cnpj) == 14:
|
||||
try:
|
||||
company = self.names(cnpj)
|
||||
except Exception: # a name is a nicety; the order must still go
|
||||
|
||||
Reference in New Issue
Block a user