In section 7-1 of Cengel and Boles text, "Thermodynamics - An Engineering Approach", the authors give a demonstration of the validity of the Clausius Inequality. In their justification, the authors ask the reader to consider a compound system composed of a reversible cyclic device connected to some system (as shown in the attached figure). The cyclic device receives heat $\delta Q_R$ from a thermal reservoir at temperature $T_R$ and produces an amount of work $\delta W_{\mathrm{rev}}$. The cyclic device rejects an amount $\delta Q$ of heat to the system, whose boundary temperature is $T$. Due to this transfer of heat, the system performs an amount of work $\delta W_{\mathrm{sys}}$. Applying the First Law, the authors come up with
$$ \delta W_c = \delta Q_R - d E_c, \quad (1)$$
where the subscript "c" refers to the compound system. Now, I have no qualms with the terms $\delta W_c$ or $d E_c$, however, I find $\delta Q_R$ a bit troublesome. The authors fail to consider heat rejected by the system that does an amount $\delta W_{sys}$ of work. The way the First Law is phrased above in (1), it looks like all the heat $\delta Q_R$ that was transferred to the system is transformed into mechanical work. However, this would violate the Second Law. Am I missing something? How do I overcome this apparent inconsistency?