I am struggling to understand the $Q$-factor for the $\beta^-$- decay process. My understanding of the $Q$-factor is that it's the difference in binding energies before and after the chemical reaction. So far, I have seen the $Q$-factor for $\beta^-$ - decay derived as follows (neglecting the binding energy of the electrons):
$$m(^A_ZX)=Zm_H + (A-Z)m_n + Zm_e \Rightarrow Zm_H + (A-Z)m_n = m(^A_ZX)-Zm_e$$
$$\Rightarrow Q=[m(^A_ZX)-Zm_e]c² - [m(^A_{Z+1}Y)-(Z+1)m_e + m_e]c²=[m(^A_ZX)-m(^A_{Z+1}Y)]c²$$
i.e. the Q-factor for $\beta^-$- decay is the difference in atomic mass of the parent and daughter atom converted into energy. I do not understand how this is correct as the binding energy of the nucleus before decay is given as (1) and after the reaction is given as (2). Substituting (2) from (1) gives a different result to the Q-factor above.
$$B_i=[Zm_H+(A-Z)m_n-m(^A_ZX)]c²\tag{1}$$ $$B_f=[(Z+1)m_H+(A-Z-1)m_n-m(^A_{Z+1}Y)+m_e]c²\tag{2}$$
$$\Rightarrow B_i - B_f=[-m_H + m_n - m(^A_ZX) + m(^A_{Z+1}Y) - m_e]c^2$$
Could someone please provide a clear definition of the $Q$-factor for radioactive decays and which of the above calculations is correct?