csingley / ofxtools

Python OFX Library
Other
301 stars 68 forks source link

Generating OFX how to create `BANKTRANLIST` element #132

Closed dturanski closed 3 years ago

dturanski commented 3 years ago

I see banktranlist is a kwarg for STMTRS. How do you create a sub-element like below?

<BANKTRANLIST>
            <DTSTART>20210628040000.000</DTSTART>
            <DTEND>20210719040000.000</DTEND>
            <STMTTRN>
                ...
            </STMTTRN>
                         <STMTTRN>
                ...
            </STMTTRN>
                      ...
</BANKTRANLIST>
dturanski commented 3 years ago

I figured it out so closing. It would help to include this in the generation docs. Thanks, this library is very useful.

PrplHaz4 commented 3 years ago

I figured it out so closing. It would help to include this in the generation docs. Thanks, this library is very useful.

Maybe post how you did it here and/or create a PR to address the gap?

csingley commented 3 years ago

Glad you got it figured out. I suppose the documentation is a bit subpar in this respect... I was trying to explain it over here in this section:

Contained aggregates that are allowed to appear more than once are instead defined with a validator of type ListAggregate, and accessed via the Python list API. Unique children are defined in the usual manner, and accessed as instance attributes.

So the lists are constructed accordingly.... list contents are passed as args, and the other children are passed as kwargs, something like:

stmttrn1 = STMTTRN(...)
stmttrn2 = STMTTRN(...)
dtend = datetime.now()
dtstart = dtend - timedelta(days=30)
banktranlist = BANKTRANLIST(stmttrn1, stmttrn2, dtstart=dtstart, dtend=dtend)

It all seems obvious to me, naturally, since I wrote it.... Suggestions for improvement or clarification are of course welcome.

dturanski commented 3 years ago

In my case, I append the STMTTRNs to a transaction-list, the list must be prefixed with * to unpack it before calling BANKTRANLIST.

 bank_tran_list = BANKTRANLIST(*statement_transactions, dtstart=statement_start_date, dtend=statement_end_date)