Relation Between Sale Transaction and Refund Transaction (database level)

Relation Between Sale Transaction and Refund Transaction (database level)

Environment: 

iVend 6.5 Update 6 , 6.6 with SAP B1 9.2

Problem statement:

Relation Between Sale Transaction and Refund Transaction (database level)

Symptoms:

Relation Between Sale Transaction and Refund Transaction (database level)

Resolution/Work Around:

There are two tables, one contains the data regarding sale transactions and the other contains data regarding it's items.
TrxTransaction and Trxtransactionsaleitem
Both tables have few common columns that are listed below and can be used to establish an understanding regarding the Refund transaction:
(column) =value (detail)
Type = 1 (type 1 means refund)
RefundedQuantity = (The quantity which has been refunded)
OriginalDocumentKey = (References to the original transaction key, used in case of refund, deliveries )
OriginalDetailKey = (References to the original detail key, used in case of refund, deliveries )
Other values may be : 
The sale item type of transaction made in the transaction.
Valid values are:
Sale = 0
Exchange = 2

Recommendations/Suggestion:

From TrxTransactionsaleitem , one can find out the details about individual items and the refund quantities etc