Code to query purchase pricing?

We have a scenario where we direct ship product from a supplier to a customer.  Because of this and because we want to see accurate sales margins on the sales order, we have a need to change the cost of goods on our sales order entry screen so that it pulls current active purchase price list for that product line.

We have the data available to run a purchase price inquiry sitting on the sales order entry screen, but I've not been able to figure out how to run those parameters through the purchase pricing engine using code.  Has anyone written something along those lines?  If so, could you point me in the right direction?

I could just query the purchase price list tables, but to make this modification future proof against any price list structure changes, I figure I should figure out how to pull the numbers from the pricing engine rather than querying the table.