From e20c8673bbe9f313613a5e05cd5716cc6265e8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 29 Sep 2026 10:00:44 -0300 Subject: [PATCH] fix: send the Jadlog account exactly as configured 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 --- app/jadlog.py | 4 +++- tests/test_jadlog.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/jadlog.py b/app/jadlog.py index 34fab8f..db8bf99 100644 --- a/app/jadlog.py +++ b/app/jadlog.py @@ -37,7 +37,9 @@ class JadlogQuotes: modalidade=None, transport=None): self.token = (token or os.environ.get('JADLOG_TOKEN', '')).strip() 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. 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) diff --git a/tests/test_jadlog.py b/tests/test_jadlog.py index 61fd0c2..7ff844d 100644 --- a/tests/test_jadlog.py +++ b/tests/test_jadlog.py @@ -49,6 +49,13 @@ class JadlogQuoteTest(unittest.TestCase): 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): replies = [ httpx.Response(200, json={'frete': [{}], 'error': {'id': -1, 'descricao': 'frete[0].contrato Numero de contrato invalido'}}),