Skip to content

Commit

Permalink
Support coerce types in table plugin (invoice-x#498)
Browse files Browse the repository at this point in the history
* Support coerce types in table plugin
  • Loading branch information
bosd authored Mar 30, 2023
1 parent c842025 commit 081a73d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/invoice2data/extract/plugins/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def extract(self, content, output):
if not start or not end:
logger.warning("no table body found - start %s, end %s", start, end)
continue
types = table.get("types", [])

table_body = content[start.end() : end.start()]
logger.debug("START table body content ========================")
Expand All @@ -63,6 +64,8 @@ def extract(self, content, output):
return None
elif field.startswith("amount"):
output[field] = self.parse_number(value)
elif field in types:
output[field] = self.template.coerce_type(output[field], types[value])
else:
output[field] = value
logger.debug("ignoring *%s* because it doesn't match anything", line)

0 comments on commit 081a73d

Please sign in to comment.