Generic Account Mapper

Derek Atkins warlord@MIT.EDU
11 Nov 2002 14:02:36 -0500


Christian and I were discussing the generic (target) account mapper
on #gnucash earlier today.  This email is a summary of the results
and a proposed API for the _engine_ portion of the mapper.  The
UI portion is still undefined.

The basic design is that each import protocol could define the
types of matches to map, and the precedence of the map.  The core
infrastructure has no particular tie to any match category.

The API is based around a GncImportMatchMap object, which is a map
database for a particular import object.  There could be an ImportMap
for each import account, or it could be per-book:

 typedef struct _GncImportMatchMap GncImportMatchMap;

 GncImportMatchMap* gnc_imap_map_from_account (Account*);
 GncImportMatchMap* gnc_imap_map_from_book (GNCBook*);

Within an import map there is a "map category" (or a map-type) and a
key that will map to an account.  There is an API to lookup an Account
based on the category and key, and another API to _set_ the map to an
Account based on the category and key:

 void gnc_imap_set_account (GncImportMatchMap*, const char* category,
                            const char* key, Account*);
 Account* gnc_imap_get_account (GncImportMatchMap*, const char* category,
                                const char* key);

We could also define some "well known" match categories:

 #define GNC_IMAP_DESC	"desc"
 #define GNC_IMAP_MEMO	"memo"
 #define GNC_IMAP_PAYEE	"payee"

The UI will need some way to prioritize the various categories and
provide getter functions for each category type in order to read the
data from the to-be-imported transactions.  However, that discussion
is for another email.

Any comments on this API?

-derek

--
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available