Attaching one Split* to multiple Account*s

Derek Atkins warlord@MIT.EDU
19 Nov 2001 17:28:39 -0500


I'm trying to figure out the best way to attach one Split to
multiple Accounts.  What I'm really trying to do is attach
an order Entry to both an Order and an Invoice.  What I really
want is to have the following pointers:

	Entry(Split)->Order(Account)
	Entry(Split)->Invoice(Account)

	Invoice(Account)->Entry(Split)
	Order(Account)->Entry(Split)

This should look familiar to some; this is what Scheduled Transactions
do...  Unfortunately a Split only has a single Account, so I'm not
sure how to do this.  What I'd like to be able to do is lookup an
Invoice and get all the Entries, or look up an Order and get all the
Entries.  But I don't want to have to duplicate the Entries -- I'd
like to have one Entry point to both the Order and the Invoice.

Here's the problem.  Assume a SQL backend with a caching client -- you
don't load all the Invoices/Orders/Entries at load-time.  Assume the
Entry(Split) is linked to the Order(Account).  Now assume a user wants
to view the Invoice(Account) and all the Entries associated with it?

One approach I thought of is to link the Entry to the Order and then
list the Entries and Orders in the Invoice kvp data.  This way when a
user goes to view the Invoice, it can then lookup all the Orders and
then search those Orders for the particular Entries.  The cache can,
of course, keep local pointers.  But in storage purposes it's only
entered through the kvp.

Obviously being able to point to the Entry(Splits) directly from both
Invoice and Order Accounts would be better, but that would require
fundamental changes to the engine architecture.  Does anyone have any
better ideas than what I've laid out above?

-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