[MIG] account_statement_import_online_paypal: Migration to 16.0

This commit is contained in:
Stefan
2023-10-17 16:31:33 +02:00
parent 8b299431b7
commit 5e7ff97c51
3 changed files with 4 additions and 84 deletions

View File

@@ -4,7 +4,7 @@
{
"name": "Online Bank Statements: PayPal.com",
"version": "15.0.1.1.1",
"version": "16.0.1.0.0",
"author": "CorporateHub, Odoo Community Association (OCA)",
"maintainers": ["alexey-pelykh"],
"website": "https://github.com/OCA/bank-statement-import",

View File

@@ -206,11 +206,8 @@ class OnlineBankStatementProviderPayPal(models.Model):
token, currency, date_since, date_until
)
if not transactions:
if self.allow_empty_statements:
balance = self._paypal_get_balance(token, currency, date_since)
return [], {"balance_start": balance, "balance_end_real": balance}
else:
return None
balance = self._paypal_get_balance(token, currency, date_since)
return [], {"balance_start": balance, "balance_end_real": balance}
# Normalize transactions, sort by date, and get lines
transactions = list(
@@ -416,7 +413,6 @@ class OnlineBankStatementProviderPayPal(models.Model):
interval_start.weekday() == 0
and (datetime.utcnow() - interval_start).total_seconds() < 28800,
)
data = self.with_context(
invalid_data_workaround=invalid_data_workaround,
)._paypal_retrieve(url, token)

View File

@@ -275,7 +275,7 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
self.now,
)
self.assertEqual(data, None)
self.assertEqual(data, ([], {"balance_start": 0.75, "balance_end_real": 0.75}))
def test_error_handling_1(self):
journal = self.AccountJournal.create(
@@ -331,81 +331,6 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
with self.assertRaises(UserError):
provider._paypal_retrieve("https://url", "")
def test_dont_create_empty_paypal_statements(self):
"""Test the default behavior of not creating empty PayPal
statements ('Allow empty statements' field is unchecked).
"""
journal = self.AccountJournal.create(
{
"name": "Bank",
"type": "bank",
"code": "BANK",
"currency_id": self.currency_eur.id,
"bank_statements_source": "online",
"online_bank_statement_provider": "paypal",
}
)
provider = journal.online_bank_statement_provider_id
mocked_response_1 = json.loads(
"""{
"transaction_details": [],
"account_number": "1234567890",
"start_date": "%s",
"end_date": "%s",
"last_refreshed_datetime": "%s",
"page": 1,
"total_items": 0,
"total_pages": 0
}"""
% (
self.now_isoformat,
self.now_isoformat,
self.now_isoformat,
),
parse_float=Decimal,
)
mocked_response_2 = json.loads(
"""{
"balances": [
{
"currency": "EUR",
"primary": true,
"total_balance": {
"currency_code": "EUR",
"value": "0.75"
},
"available_balance": {
"currency_code": "EUR",
"value": "0.75"
},
"withheld_balance": {
"currency_code": "EUR",
"value": "0.00"
}
}
],
"account_id": "1234567890",
"as_of_time": "%s",
"last_refresh_time": "%s"
}"""
% (
self.now_isoformat,
self.now_isoformat,
),
parse_float=Decimal,
)
with mock.patch(
_provider_class + "._paypal_retrieve",
side_effect=[mocked_response_1, mocked_response_2],
), self.mock_token():
data = provider._obtain_statement_data(
self.now - relativedelta(hours=1),
self.now,
)
self.assertEqual(data, None)
def test_create_empty_paypal_statements(self):
"""Test creating empty PayPal statements
('Allow empty statements' field is checked).
@@ -422,7 +347,6 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
)
provider = journal.online_bank_statement_provider_id
provider.allow_empty_statements = True
mocked_response_1 = json.loads(
"""{
"transaction_details": [],