Re: using libofx_request_statement() to get balance

"G. Paul Ziemba" <[email protected]> Thu, 12 Jul 2007 18:28:52 +0000 (UTC)
Newsgroups gmane.comp.finance.libofx.devel
Message-ID <[email protected]>
I wrote:
 
>aqbanking seems to call libofx_request_statement() with a 0 date_from
>when it doesn't want any transactions to be downloaded (i.e., when it
>wants just the balance): see the function AO_Provider_RequestStatements()
>in aqbanking/src/plugins/backends/aqofxconnect/plugin/provider.c
> 
>Should date_from==0 mean "get balance only and no transactions", i.e.,
>omit <INCTRAN> ? 
 
Now that I have dug around a little more, my understanding is better,
and it is clear my earlier proposal is flawed. (And I learned I could
control aqofxconnect recvTimeout in .banking/settings.conf)
 
I believe the current libofx API allows the caller to request a
statement with transactions included starting at a specified time:
 
    CFCT char *
    libofx_request_statement(
        const struct OfxFiLogin* fi,
        const struct OfxAccountInfo* account,
        time_t date_from );
 
I would like some additional control over the request:
 
    1. Allow to omit the transactions because they should not
       be included when the caller only wants a balance.
 
    2. Allow caller to specify an end time for transactions just
       like we can now specify start time. This would allow
       correct behavior with gnucash where user specifies both
       start and end times for the transaction period. Right now,
       if I request 1/1/06-1/31/06 I get 1/1/06-7/12/07 instead.
 
    3. Allow "unspecified" start time and end time for the
       transaction period. An unspecified time corresponds to
       omitting the corresponding <DTSTART> or <DTEND>, and the
       OFX 2.1.1 spec says it means, respectively, the earliest
       available or latest available time.
 
Proposal:
 
Additional entry point(s) to libofx to permit more control:
 
    CFCT char *
    libofx_request_balance(
        const struct OfxFiLogin* fi,
        const struct OfxAccountInfo* account);
 
    CFCT char *
    libofx_request_statement2(
        const struct OfxFiLogin* fi,
        const struct OfxAccountInfo* account,
        time_t date_from,               /* 0 means "unspecified" */
        time_t date_to );               /* 0 means "unspecified" */

(I use libofx_request_statement2() instead of libofx_request_statement()
to avoid silent library version mismatch problems)

Alternate:

    CFCT char *
    libofx_request_statement2(
        const struct OfxFiLogin* fi,
        const struct OfxAccountInfo* account,
        int include_transactions,       /* 0 means no transactions */
        time_t date_from,               /* 0 means "unspecified" */
        time_t date_to );               /* 0 means "unspecified" */

I have made prototype code against libofx-0.8.3 and it seems to
work OK.
 
Benoit, if you agree with this change, I could send a patch...

many thanks,
 
 ~!paul

-- 
G. Paul Ziemba
FreeBSD unix:
11:26AM  up 10 days,  1:49, 12 users, load averages: 0.14, 0.15, 0.15

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/