I have an entity that defines a transaction. Most of the time the transaction will simply involve an addition (e.g. receiving a shipment of 10 widgets into department A) or a subtraction (e.g. dispatching an order of 3 widgets from department B).
However, sometimes a transaction may be a little more complicated. For example department A may transfer 2 widgets to department B but as the departments are located on opposite sides of the globe department A records the subtraction transaction as having occurred on 16/07/2009 while department B has a long weekend in their country and doesn't record their addition transaction until 21/07/2009. They also give the transactions different names and descriptions.
I would like to be able to reconcile these two transactions in my application once they are completed. Obviously I could add additional information to the transaction entity to allow this (i.e. Department A creates a transaction with a "from" date, name and description but with an empty "to" date, name and description) which department B then fills in. This doesn't seem ideal though.
What I think would make sense is letting both departments create their transactions normally and then create a "transfer" entity to link the two. My question is, how do I go about this? Is it simply a matter of creating a "transfer" entity with a to-many relationship to transaction (with a min count of 2 and a max count of 2)? If so I guess I would then have to validate to make sure the transactions are compatible (i.e. count is the same, item is the same, receive date is not before send date, etc).
Alternatively, does transfer need two separate relationships to figure out who the transfer is from and to? If I create two separate relationships I then have to create two inverse-relationships in the "transaction" entity (transferFrom and transferTo) which seems to be a slippery slope towards the less than ideal solution I already mentioned.
I think I might have answered my own question while thinking through the alternatives but any input would be appreciated!
However, sometimes a transaction may be a little more complicated. For example department A may transfer 2 widgets to department B but as the departments are located on opposite sides of the globe department A records the subtraction transaction as having occurred on 16/07/2009 while department B has a long weekend in their country and doesn't record their addition transaction until 21/07/2009. They also give the transactions different names and descriptions.
I would like to be able to reconcile these two transactions in my application once they are completed. Obviously I could add additional information to the transaction entity to allow this (i.e. Department A creates a transaction with a "from" date, name and description but with an empty "to" date, name and description) which department B then fills in. This doesn't seem ideal though.
What I think would make sense is letting both departments create their transactions normally and then create a "transfer" entity to link the two. My question is, how do I go about this? Is it simply a matter of creating a "transfer" entity with a to-many relationship to transaction (with a min count of 2 and a max count of 2)? If so I guess I would then have to validate to make sure the transactions are compatible (i.e. count is the same, item is the same, receive date is not before send date, etc).
Alternatively, does transfer need two separate relationships to figure out who the transfer is from and to? If I create two separate relationships I then have to create two inverse-relationships in the "transaction" entity (transferFrom and transferTo) which seems to be a slippery slope towards the less than ideal solution I already mentioned.
I think I might have answered my own question while thinking through the alternatives but any input would be appreciated!