Measuring battery voltage in PV scenario with MPPT charge controller with inverter
To calculate how much energy is being stored on the battery it's simple I*V*t which gives a result in Watt hour (Wh).

The problem is that it's quite difficult to know how much energy is in the battery itself as it will depend of many factors like temperature, internal serial resistance of the battery and so forth, which changes over time as well.

None the less, you can calculate how much energy is provided to it, and how much energy is drawn from it, with that data in hand, you can run some computing to analyse and estimate the state of life and the energy it has.

You should measure the battery voltage when it charges directly on the battery leads, to avoid any connection serial resistance that would create a voltage drop. Unfortunately there is no better way, as you will always have the internal resistance of the battery.