Hard to comment not seeing the derivation.
Technically there 5 equilibria present - two for the acid, two for the base, one for water, so there are 5 equations that needs to be combined, and the final equation should be not cubic, but of 5th degree. In this case of these equilibria one for the acid and one for the base can be safely neglected if all you are interested in is a practical result, not a theoretical formula.