[IMP] account_statement_import_txt_xlsx: add tests

This commit is contained in:
Jordi Ballester Alomar
2022-12-18 14:29:39 +01:00
committed by Rocío Vega
parent 8b33c8b571
commit a9a377fe5c
3 changed files with 70 additions and 11 deletions

View File

@@ -0,0 +1 @@
"12/15/2018","Your payment","EUR","1,525.00","-1,000.00","Azure Interior","","INV0001"
1 12/15/2018 Your payment EUR 1,525.00 -1,000.00 Azure Interior INV0001

View File

@@ -226,6 +226,55 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
self.assertEqual(line.foreign_currency_id, self.currency_eur)
self.assertEqual(line.amount_currency, 1000.0)
def test_original_currency_no_header(self):
no_header_statement_map = self.AccountStatementImportSheetMapping.create(
{
"name": "Sample Statement",
"float_thousands_sep": "comma",
"float_decimal_sep": "dot",
"delimiter": "comma",
"quotechar": '"',
"timestamp_format": "%m/%d/%Y",
"no_header": True,
"timestamp_column": "0",
"amount_column": "3",
"original_currency_column": "2",
"original_amount_column": "4",
"description_column": "1,7",
"partner_name_column": "5",
"bank_account_column": "6",
}
)
journal = self.AccountJournal.create(
{
"name": "Bank",
"type": "bank",
"code": "BANK",
"currency_id": self.currency_usd.id,
"suspense_account_id": self.suspense_account.id,
}
)
data = self._data_file("fixtures/original_currency_no_header.csv", "utf-8")
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
{
"statement_filename": "fixtures/original_currency.csv",
"statement_file": data,
"sheet_mapping_id": no_header_statement_map.id,
}
)
wizard.with_context(
account_statement_import_txt_xlsx_test=True
).import_file_button()
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
self.assertEqual(len(statement), 1)
self.assertEqual(len(statement.line_ids), 1)
line = statement.line_ids
self.assertEqual(line.currency_id, self.currency_usd)
self.assertEqual(line.foreign_currency_id, self.currency_eur)
self.assertEqual(line.amount_currency, 1000.0)
self.assertEqual(line.payment_ref, "Your payment INV0001")
def test_original_currency_empty(self):
journal = self.AccountJournal.create(
{