This is quite complex problem
BaCl2 + Na2HPO4 = BaHPO4(s) + 2NaCl
If some ammonia is present in solution (in qualitative analysis of cations NH3 is always present at this step)
3BaCl2 + 2Na2HPO4 + 2NH3 = Ba3(PO4)2(s) + 2NH4Cl + 4NaCl
Mitch, HCl cannot be formed during reaction because a very weak acid (HPO4(2-)) cannot replace the strong one (HCl)
Of course, there are some examples when even weak acid replace the strong one, but then a powerful driving force will work, ie in H2S acid solution a concentration of S(2-) is sufficient to precipitate HgS