fix: send the Jadlog account exactly as configured
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m19s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m33s

Jadlog issues the account as 000000-0 and documents a six-character field;
stripping the dash sent seven digits. The value now goes as typed, so the
accepted form can be found on the account without a new release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-09-29 10:00:44 -03:00
parent 4de2151e9a
commit e20c8673bb
2 changed files with 10 additions and 1 deletions

View File

@@ -37,7 +37,9 @@ class JadlogQuotes:
modalidade=None, transport=None): modalidade=None, transport=None):
self.token = (token or os.environ.get('JADLOG_TOKEN', '')).strip() self.token = (token or os.environ.get('JADLOG_TOKEN', '')).strip()
self.cnpj = digits(cnpj or os.environ.get('JADLOG_CNPJ')) self.cnpj = digits(cnpj or os.environ.get('JADLOG_CNPJ'))
self.conta = digits(conta if conta is not None else os.environ.get('JADLOG_CONTA')) # Sent as configured: Jadlog issues it as 000000-0 and documents six
# characters, so which form it accepts is only known on the account.
self.conta = (conta if conta is not None else os.environ.get('JADLOG_CONTA', '')).strip()
# Only when Jadlog issued one; the manual says to send null otherwise. # Only when Jadlog issued one; the manual says to send null otherwise.
self.contrato = (contrato if contrato is not None else os.environ.get('JADLOG_CONTRATO', '')).strip() or None self.contrato = (contrato if contrato is not None else os.environ.get('JADLOG_CONTRATO', '')).strip() or None
self.origin = digits(origin or os.environ.get('JADLOG_ORIGEM_CEP') or ORIGIN) self.origin = digits(origin or os.environ.get('JADLOG_ORIGEM_CEP') or ORIGIN)

View File

@@ -49,6 +49,13 @@ class JadlogQuoteTest(unittest.TestCase):
client(handler, contrato='042').quote('01310100', 1, 100) client(handler, contrato='042').quote('01310100', 1, 100)
def test_account_is_sent_as_configured(self):
def handler(request):
self.assertEqual(json.loads(request.content)['frete'][0]['conta'], '123456-7')
return httpx.Response(200, json={'frete': [{'vltotal': 10, 'prazo': 2}]})
JadlogQuotes(token='tok', cnpj=CNPJ, conta=' 123456-7 ', transport=httpx.MockTransport(handler)).quote('01310100', 1, 100)
def test_account_and_item_errors_are_raised_with_jadlog_text(self): def test_account_and_item_errors_are_raised_with_jadlog_text(self):
replies = [ replies = [
httpx.Response(200, json={'frete': [{}], 'error': {'id': -1, 'descricao': 'frete[0].contrato Numero de contrato invalido'}}), httpx.Response(200, json={'frete': [{}], 'error': {'id': -1, 'descricao': 'frete[0].contrato Numero de contrato invalido'}}),