How to calculate remaining battery capacity from charge discharge data?
Each battery has a charge/discharge curve. It is specific to the battery chemistry and capacity. It is also dependent on how long the battery is charged for and the age of the battery. 

If you have the charge/discharge curve, the battery capacity can reasonably be calculated from the battery voltage. Sometimes the charge/discharge curve can be found from manufacturers or by looking at similar battery chemistries.