If you are using the latest purchase invoice price as your 'cost', I would run a query that found the latest date for that item using Max on the date field. This will give you the relevant price.
However there is an accounting (not a programming) dilemma here. Suppose you get a bulk price on your hammers and order 100 at $5 a piece. You then buy an extra one hammer and this costs you $8. All of the hammers that cost $5 each are now being costed at $8. That's a difference of $300 on the stock. Are you happy with this?
You can't always get what you want, but if you try sometimes you may just get what you need - Rolling Stones