Thermal and electrical transport formalism for electronic microstructures with many terminals