Update Item Rate in purchase receipt with custom script


I am trying to update item rate in Purchase Receipt Item based on a custom_field “item_mrp”.

we have a specific formula to calculate our purchase price, I need to calculate item price & fill the same into item rate field in child table.

Can anyone help with this issue of mine please?