Skip to content

Commit

Permalink
As it is not mandatory to have the exact ammount of decimals defined …
Browse files Browse the repository at this point in the history
…in currecy import fais if numbers has less decimals than those defined in the currency configuration
  • Loading branch information
Carlos Martin Ugalde committed Sep 27, 2023
1 parent c562f31 commit 475aefe
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _get_amount_total(self, parsed_inv, raw_text, partner_config, test_info):
pattern = self.regexp
else:
if decimal_places:
pattern = r"(?:\d{1,3}%s)*\d{1,3}%s\d{%d}" % (
pattern = r"(?:\d{1,3}%s)*\d{1,3}%s\d{1,%d}" % (
thousand_sep_pattern,
decimal_sep_pattern,
decimal_places,
Expand Down Expand Up @@ -375,9 +375,7 @@ def _get_amount_total(self, parsed_inv, raw_text, partner_config, test_info):
if thousand_sep_pattern:
amount_raw = regex.sub(thousand_sep_pattern, "", amount_raw)
if decimal_places:
amount_raw_list = list(amount_raw)
amount_raw_list[-decimal_places - 1] = "."
amount_raw = "".join(amount_raw_list)
amount_raw = regex.sub(decimal_sep_pattern, ".", amount_raw)
try:
valid_amounts.append(float(amount_raw))
except ValueError:
Expand Down

0 comments on commit 475aefe

Please sign in to comment.