What's is the EHP version?
This Transaction is obsoleted and was replaced for the transaction TPM15M, which works a bit difference.
The note Explain it. https://launchpad.support.sap.com/#/notes/2230212
I would recommend that you migrate to the TPM15m, Whether migrates for the new valuation class transfer won't be an option.
The first advice is set-up exactly the way it has been provided by SAP.
See the SPRO Implementation Guide, attached in the note 1035579
https://launchpad.support.sap.com/#/notes/1035579
I had a situation where I just change the account symbol that leads to unexpectable behaviors.
About the account determination, is apart from the standard TRM functions, I believe there's no Badi for manipulate that.
Try to have a look at note 1455357 - BST Brazil: Balancing Field Not Filled might help.
Best