Fetch total allocated amount from payment entry into custom doctype field

I need to get total alllocated amount from payment entry for individual customer (party)
into another custom doctype field
what is the right way to do this?