tidy up datatables api and ensure principal is paid off before interest in advance and partial payment cases.