Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class AccountStatementImportSheetMapping(models.Model):
string="Decimals Separator",
selection=[("dot", "dot (.)"), ("comma", "comma (,)"), ("none", "none")],
default="comma",
help="When the separator is 'none', the value will be shifted according "
"to the currency decimals. For example, 12345 will be converted to "
"123.45",
)
file_encoding = fields.Selection(
string="Encoding",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2019 ForgeFlow, S.L.
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import itertools
Expand Down Expand Up @@ -506,5 +507,14 @@ def _parse_decimal(self, value, mapping):
or "0"
)
value = value.replace(thousands, "")
value = value.replace(decimal, ".")
float_separator = "."
if decimal:
value = value.replace(decimal, float_separator)
else:
journal = self.env["account.journal"].browse(
self.env.context.get("journal_id")
)
currency = journal.currency_id or journal.company_id.currency_id
decimal_places = currency.decimal_places if currency else 2
value = value[:-decimal_places] + float_separator + value[-decimal_places:]
return float(value)
1 change: 1 addition & 0 deletions account_statement_import_sheet_file/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
- [CorporateHub](https://corporatehub.eu/)
- Alexey Pelykh \<<[email protected]>\>
- Sebastiano Picchi <[email protected]>
- Jacques-Etienne Baudoux (BCIM) <[email protected]>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2019 ForgeFlow, S.L.
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from base64 import b64encode
Expand Down Expand Up @@ -53,6 +54,8 @@ def setUp(self):
self.mock_mapping_comma_dot._get_float_separators.return_value = (",", ".")
self.mock_mapping_dot_comma = Mock()
self.mock_mapping_dot_comma._get_float_separators.return_value = (".", ",")
self.mock_mapping_none_none = Mock()
self.mock_mapping_none_none._get_float_separators.return_value = ("", "")

def _data_file(self, filename, encoding=None):
mode = "rt" if encoding else "rb"
Expand Down Expand Up @@ -651,6 +654,11 @@ def test_parse_decimal(self):
1234567.89,
self.mock_mapping_dot_comma,
), # inverted separators
(
"123456",
1234.56,
self.mock_mapping_none_none,
), # no separator
]

for value, expected, mock_mapping in test_cases:
Expand Down