Reynolds' transport theorem. Reynold's transport theorem reads
$$\dfrac{d}{dt} \int_{v(t)} f = \int_{v(t)} \frac{\partial f}{\partial t} + \oint_{\partial v(t)} f \, \mathbf{u}_b \cdot \hat{\mathbf{n}} \ ,$$
with $\mathbf{u}_b$ the velocity of the points of the boundary $\partial v(t)$.
If you apply it to the material volume $V(t)$, that moves with the same velocity of the continuum, and coincides with the a control volume $V$ coinciding at every timestep $t$, it's possible to write
$$\begin{aligned}
\dfrac{d}{dt} \int_{V(t)} f & = \int_{V(t)} \frac{\partial f}{\partial t} + \oint_{\partial V(t)} f \, \mathbf{u} \cdot \hat{\mathbf{n}} \\
\dfrac{d}{dt} \int_V f & = \int_V \frac{\partial f}{\partial t} \\
\rightarrow \quad\dfrac{d}{dt} \int_{V(t) \equiv V} f & = \dfrac{d}{dt} \int_V f \, + \oint_{\partial V} f \, \mathbf{u} \cdot \hat{\mathbf{n}} \ .
\end{aligned}$$
Let's deal now with the balance of total energy. First principle of thermodynamics is nothing else that the balance of total energy for a closed system, namely
$$\dfrac{d E^{t}}{dt} = P^{e} + \dot{Q}^e \ ,$$
being $E^{t}$ the total energy of the system of interest, and $P^e$ the power of external forces and moments acting on the system and $\dot{Q}^e$ the heat flow from the external environment.
Let's write it for a material volume $V(t)$, that is a closed system, of a continuous medium, with
$$E^{t} = \int_{V(t)} \rho e^t \ ,$$
with $\rho$ the mass density and $e^t$ the total energy per unit mass. The first principle of mechanics for the material volume thus reads
$$\dfrac{d}{dt} \int_{V(t)} \rho e^t = P^{e} + \dot{Q}^e \ ,$$
while for a control volume (open system), it reads
$$\dfrac{d}{dt} \int_{V} \rho e^t + \oint_{\partial V} \rho e^t \mathbf{u} \cdot \hat{\mathbf{n}} = P^{e} + \dot{Q}^e \ .$$
Now, you can write total energy as the sum of kinetic energy $k = \frac{|\mathbf{u}|^2}{2}$ and internal energy $e$,
$$e^{t} = k + e = \frac{|\mathbf{u}|^2}{2} + e \ .$$
You can explicitly write the power of external forces as the sum of power of volume and surface forces,
$$\begin{aligned}
P^e & = \int_{V} \rho \mathbf{g} \cdot \mathbf{u} + \oint_{\partial V} \mathbf{t}_n \cdot \mathbf{u} = \\
& = \int_{V} \rho \mathbf{g} \cdot \mathbf{u} + \oint_{\partial V} \hat{\mathbf{n}} \cdot \mathbb{T} \cdot \mathbf{u} \ ,
\end{aligned}$$
being $\mathbf{g}$ the volume force per unit mass, $\mathbf{t}_n = \hat{\mathbf{n}} \cdot \mathbb{T}$ the stress vector on the surface, expressed with the Cauchy relation as a function of the stress tensor $\mathbb{T}$. For an inviscid fluid, the stress tensor reads $\mathbb{T} = - p \mathbb{I}$, being $p$ the pressure and $\mathbb{I}$ the identity tensor, so that the power of external forces becomes
$$P^e = \int_V \rho \mathbf{g} \cdot \mathbf{u} - \oint_{\partial V} p \mathbf{u} \cdot \hat{\mathbf{n}} \ .$$
You can also explicitly write the heat flux as the sum of a volume heat source and heat transferred through the boundary of the volume,
$$\dot{Q}^e = \int_{V} \rho r - \oint_{\partial V} \mathbf{q} \cdot \hat{\mathbf{n}} \ ,$$
being $\mathbf{q}$ the outwards pointing heat vector flux per unit surface, that you can model as $\mathbf{q} = - k \nabla T$ using Fourier's law.
Putting everything together for an inviscid fluid, the balance equation for the control volume reads
$$\dfrac{d}{dt} \int_V \rho \left( e + \dfrac{|\mathbf{u}|^2}{2} \right) + \oint_{\partial V} \rho \left( e + \dfrac{|\mathbf{u}|^2}{2} \right) \mathbf{u} \cdot \hat{\mathbf{n}} = \int_V \rho \mathbf{g} \cdot \mathbf{u} - \oint_{\partial V} p \mathbf{u} \cdot \hat{\mathbf{n}} + \int_{V} \rho r - \oint_{\partial V} \mathbf{q} \cdot \hat{\mathbf{n}} \ , $$
or rearranging the terms,
$$\dfrac{d}{dt} \int_V \rho \left( e + \dfrac{|\mathbf{u}|^2}{2} \right) + \oint_{\partial V} \rho \left( \underbrace{e + \frac{P}{\rho}}_{h} + \dfrac{|\mathbf{u}|^2}{2} \right) \mathbf{u} \cdot \hat{\mathbf{n}} = \int_V \rho \mathbf{g} \cdot \mathbf{u} + \int_{V} \rho r - \oint_{\partial V} \mathbf{q} \cdot \hat{\mathbf{n}} \ , $$
telling that the time derivative of the total energy of a control volume equals the sum of the flux of total enthalpy across its boundary, the power of volume forces and heat flux,
$$\dfrac{d E^t}{dt} = \Phi_{\partial V}(h^t) + P^{e,vol} + \dot{Q}^e \ .$$