Transition-metal compounds pose serious challenges to first-principles calculations based on density-functional theory (DFT), due to the inability of most approximate exchange-correlation functionals to capture the localization of valence electrons on their d states, essential for a predictive modeling of their properties. In this work we focus on two representatives of a well known family of cathode materials for Li-ion batteries, namely the orthorhombic LiMPO4 olivines (M = Fe, Mn). We show that extended Hubbard functionals with on-site (U ) and inter-site (V ) interactions (so called DFT+U+V) can predict the electronic structure of the mixed-valence phases, the formation energy of the materials with intermediate Li contents, and the overall average voltage of the battery with remarkable accuracy. We find, in particular, that the inclusion of inter-site interactions in the corrective Hamiltonian improves considerably the prediction of thermodynamic quantities when electronic localization occurs in the presence of significant interatomic hybridization (as is the case for the Mn compound), and that the self-consistent evaluation of the effective interaction parameters as material-and ground-state-dependent quantities allows the prediction of energy differences between different phases and concentrations.