Measuring State of Charge of a Battery
A method for determining state of charge (SOC) from a simple measurement is the Holy Grail of the battery industry, all major companies are trying to do it, and it has still not been done well. This is why 'gas gauge' ICs are integrated into battery packs.

That said, a simple voltage measurement can get you some of the way. It's fairly easy to say with confidence that a battery is fully charged, or totally discharged, it's not possible to be at all sure about figures between those extremes.

Different battery chemistries have characteristics that are more or less amenable to simple voltage measurement. Lead and Nickel have a fairly flat voltage to SOC curve, and are very difficult to assess by voltage. Lithium has a much stronger voltage to SOC curve (as do alkaline primary cells) so you can estimate somewhat better with those.

The voltage difference between a battery being on charge, idle, and discharging, can be quite profound. The problem is polarisation. Concentration gradients of different states of chemicals within the battery, set up by a charge or discharge, can take hours to settle down fully when idle, resulting in a terminal voltage that changes over that period.