ofxstatement icon indicating copy to clipboard operation
ofxstatement copied to clipboard

Fails to produce ofx file due to AssertionError & ValueError under Debian

Open kirmaha opened this issue 1 year ago • 4 comments

Hello,

I'm trying to use ofxstatement for the first time. I tested it with both Debian packages (Debian testing trixie) and Python3.12 virtual environment. Plugins tested here are properly listed as installed when using ofxstatement list-plugins.

In both cases, I end up with no ofx file and the same errors, which is why I assume ofxstatement causes this rather than the plugins.

  1. Using triodosbe plugin on CSV statement from that bank :
$ ofxstatement convert -t triodosbe file.csv file.ofx
Traceback (most recent call last):
File "/usr/bin/ofxstatement", line 33, in <module>
  sys.exit(load_entry_point('ofxstatement==0.7.1', 'console_scripts', 'ofxstatement')())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ofxstatement/tool.py", line 198, in run
  return args.func(args)
         ^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ofxstatement/tool.py", line 169, in convert
  statement = parser.parse()
              ^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ofxstatement/plugins/triodosbe.py", line 38, in parse
  stmt = super(TriodosBeParser, self).parse()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ofxstatement/parser.py", line 48, in parse
  stmt_line.assert_valid()
File "/usr/lib/python3/dist-packages/ofxstatement/statement.py", line 159, in assert_valid
  assert self.id or self.check_no or self.refnum
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1. Using argenta plugin on XLSX statement from that bank :
$ ofxstatement convert -t argenta file.xlsx test.ofx
/usr/lib/python3/dist-packages/openpyxl/styles/stylesheet.py:237: UserWarning: Workbook contains no default style, apply openpyxl's default
  warn("Workbook contains no default style, apply openpyxl's default")
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ofxstatement/plugins/argenta.py", line 69, in validate
    self._validate()
  File "/usr/lib/python3/dist-packages/ofxstatement/plugins/argenta.py", line 94, in _validate
    assert self.header == statement_header_row
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/ofxstatement", line 33, in <module>
    sys.exit(load_entry_point('ofxstatement==0.7.1', 'console_scripts', 'ofxstatement')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ofxstatement/tool.py", line 198, in run
    return args.func(args)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ofxstatement/tool.py", line 167, in convert
    parser = p.get_parser(args.input)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ofxstatement/plugins/argenta.py", line 185, in get_parser
    return ArgentaStatementParser(fin)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ofxstatement/plugins/argenta.py", line 50, in __init__
    self.validate()
  File "/usr/lib/python3/dist-packages/ofxstatement/plugins/argenta.py", line 71, in validate
    raise ValueError(e)
ValueError

This is the missing piece for me to handle comptability on Linux. I sincerly hope ofxstatement can work sustainably. Note that I have very little knowledge in dev (yet I'm willing to add plugins for a few banks if ofxstatement can run on my computer). Thank you !

kirmaha avatar Aug 21 '24 07:08 kirmaha

I took a look at the triodos' plugin file and argenta's plugin file, and I figured that argenta plugin has been made with Dutch-speaking version of statements in mind, when I use French-speaking version... so I should probably fork the plugin and make a French-speaking version out of it.

Regarding Triodos, I did not find anything "meaningful for someone who does not understand Python", but one can now assume it may be more of a plugin issue than an ofxstatement issue?

kirmaha avatar Aug 21 '24 10:08 kirmaha

Hi @kirmaha , yeah, this looks like an issue with those plugins. You can try asking argenta devs to support French version as well, would be simpler to maintain than a fork.

For triodos it looks the plugin needs a small update to work. I'm not familiar with the file format that bank produces, but I expect one of the columns in that csv file would indicate a unique transaction id (or a check number or some reference number). It needs to be added to a statement object. Probably the easiest way to do this is to add the column number into this dictionary:

https://github.com/renardeau/ofxstatement-be-triodos/blob/10f4d35c95beda3211886ef02dba0a3e65c6e57b/src/ofxstatement/plugins/triodosbe.py#L20-L25

kedder avatar Aug 21 '24 16:08 kedder

Thank you @kedder ! Having such a quick reply makes me more confident about investing time in ofxstatement community plug-ins (as an active project) rather than developing bash scripts to arrange csv structures (which would suit my usecase and no-one else's).

I seen that the be-argenta plug-in has not been maintained for years, but that Nick-DT forked it two months ago and made it compatible with statements in both FR and NL languages : Nick-DT's ofxstatement-be-argenta. If it works well (which is still to be tested), should'nt it take over as the offical be-argenta plug-in ?

Edit: after a few tests on Dutch-speaking and French-speaking version of statements:

kirmaha avatar Aug 24 '24 12:08 kirmaha

@kirmaha I'm happy to update the link in the list of plugins to reference the more up-to-date fork, but there's one problem: pypi has a released package: ofxstatement-be-argenta 1.0.5 by the original author, which would be installed if someone does pip install ofxstatement-be-argenta. That could cause a bit of confusion.

Would it be possible to release the fork under some new name (e.g. ofxstatement-be-argenta-ng) or ask the original author to pull the changes and make a new release?

kedder avatar Aug 24 '24 20:08 kedder