Rate per Qty custom Script

I wanted rate per kg in BOM

Wanted simple division between “total_cost”(currency) & “quantity”(float) and store in my custom field “rate_per_kg” (float) but my script is showing no error nor any result.

Can anyone help with this ?

Can anyone help out with this ???