LP_CUSTOMER_RANK woes!

Hello! I have inherited a "LP_CUSTOMER_RANK" sproc that  no longer performs as desired - it is assigning rankings that give discounts to customers not entitled to said discount. It has been through many changes in developers and business practices, and seems mostly made of band-aids at this point. I want to redo it, but at this point it is hard to tell what the current sproc is even doing. Do any of you fine Tessiturians have a "clean" copy of this stored procedure that you'd be willing to share as an example? Many thanks!