Calculate conversion factor based on other fields (PO)

Hi guys,

Usually we (as jewelry manufacturer) buy by carat and the stock enters as pc, but the conversion rate always varies.

For that, I created a new field in the purchase order item table called pc quantity which will have the quantity in pc.

I need to auto calculate the conversion factor based on:
Quantity in Pc / carat = conversion factor

How to do that only if the UOM for purchase is different than stock UOM?