mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] *_online_ponto: code organisation
Check situation that should raise exception immediately, prevent ident on normal flow
This commit is contained in:
@@ -156,7 +156,11 @@ class OnlineBankStatementProviderPonto(models.Model):
|
|||||||
response = requests.get(
|
response = requests.get(
|
||||||
page_url, params=params, headers=self._ponto_header()
|
page_url, params=params, headers=self._ponto_header()
|
||||||
)
|
)
|
||||||
if response.status_code == 200:
|
if response.status_code != 200:
|
||||||
|
raise UserError(
|
||||||
|
_("Error during get transaction.\n\n%s \n\n %s")
|
||||||
|
% (response.status_code, response.text)
|
||||||
|
)
|
||||||
if params.get("before"):
|
if params.get("before"):
|
||||||
params.pop("before")
|
params.pop("before")
|
||||||
data = json.loads(response.text)
|
data = json.loads(response.text)
|
||||||
@@ -174,16 +178,10 @@ class OnlineBankStatementProviderPonto(models.Model):
|
|||||||
)
|
)
|
||||||
if date_since <= date < date_until:
|
if date_since <= date < date_until:
|
||||||
current_transactions.append(transaction)
|
current_transactions.append(transaction)
|
||||||
|
|
||||||
if current_transactions:
|
if current_transactions:
|
||||||
if not page_next or (page_next and not latest_identifier):
|
if not page_next or (page_next and not latest_identifier):
|
||||||
latest_identifier = current_transactions[0].get("id")
|
latest_identifier = current_transactions[0].get("id")
|
||||||
transaction_lines.extend(current_transactions)
|
transaction_lines.extend(current_transactions)
|
||||||
else:
|
|
||||||
raise UserError(
|
|
||||||
_("Error during get transaction.\n\n%s \n\n %s")
|
|
||||||
% (response.status_code, response.text)
|
|
||||||
)
|
|
||||||
if latest_identifier:
|
if latest_identifier:
|
||||||
self.ponto_last_identifier = latest_identifier
|
self.ponto_last_identifier = latest_identifier
|
||||||
return transaction_lines
|
return transaction_lines
|
||||||
|
|||||||
Reference in New Issue
Block a user