Custom sales invoice page

i will create custom sales invoice page
but problem is this …if i select customer then inventory item select via dropdown then i know what had been last rate when customer had purchase last time …if any API available or any solution ?