CREATE TABLE IF NOT EXISTS CommissionTransactions
(
     id BIGINT PRIMARY KEY AUTO_INCREMENT,
     Partner BIGINT UNSIGNED NOT NULL,

     Transaction BIGINT NOT NULL,
     Reference BIGINT NOT NULL,
     Total DECIMAL( 10, 2 ), 
     Admissible DECIMAL( 10, 2 ),
     Date BIGINT UNSIGNED NOT NULL,
     ts   BIGINT UNSIGNED NOT NULL,


     CommissionRate DECIMAL( 5, 2 ),
     EffectiveRate DECIMAL( 5, 2 ),
     Payable DECIMAL( 10, 2 ),

     Type ENUM ( "Service", "Recurring" ) default 'Recurring',

     /* It would be a serious error to pay the same partner more than once for the same transaction and type. */
     UNIQUE( Partner, Transaction, Type ),
     INDEX( Partner, ts )
)
