csingley / ofxtools

Python OFX Library
Other
301 stars 68 forks source link

Relax name length constraint? #91

Closed wburke11 closed 4 years ago

wburke11 commented 4 years ago

Apologies if this isn't the proper place to raise the question.

What is the best way to relax the constraint on length of the name field beyond 32 when using parser.convert()? My FI consistently reports transactions with names in excess of 32 characters. I am currently pre-processing the xml tree to truncate them before calling convert(), but I'd rather include the full information in my database. Is there an easy way to tell ofxtools to ignore the 32 character limit?

Thanks, Bill

csingley commented 4 years ago

Sure, this is the very reason for the existence of ofxtools.Types.NagString. As its docstring implies, I don't generally have a problem accomodating the parser to these kinds of trivial FI spec violations... sounds like you're looking at such a case.

What element is it, exactly? STMTTRN.name?

wburke11 commented 4 years ago

Yes, it is the STMTTRN.name. When I convert() the data without pre-processing it, I get the error:

ofxtools.Types.OFXSpecError: Can't set STMTTRN.name to : Value '' exceeds max length=32

I'm not sure how to configure the parser to make use of NagString. Google is not being very helpful here. Can you point me to the right documentation, please?

Thanks, Bill

csingley commented 4 years ago

Sorry, it's not really user-configurable at runtime. What's needed is to patch the model spec for ofxtools.models.bank.stmt.STMTTRN.name. It's currently given as String(32); what's wanted is NagString(32).

I'll modify it for you in master; it's an entirely reasonable request and trivial to implement.

csingley commented 4 years ago

Aaaaaandd... hey nonny nonny... SHAZAM!!

wburke11 commented 4 years ago

Very obliging of you. Thanks a lot. And now I know where to go if I need to do something similar.

Finally, thanks for a great library. I'm writing my own budgeting program, and downloading using ofxtools is going to be a major part of it.

csingley commented 4 years ago

That's why I wrote the library! Have fun with it.